Merge remote-tracking branch 'origin/master'
6 files modified
1 files added
| | |
| | | "@dcloudio/uni-quickapp-webview": "3.0.0-4070520250711001", |
| | | "@dcloudio/uni-ui": "^1.5.11", |
| | | "dayjs": "^1.11.18", |
| | | "js-audio-recorder": "^1.0.7", |
| | | "js-base64": "^3.7.4", |
| | | "js-md5": "^0.7.3", |
| | | "leaflet": "^1.9.4", |
| New file |
| | |
| | | import {request} from "@/utils/request" |
| | | |
| | | export const startVoice = data => { |
| | | return request({ |
| | | url: `/drone-device-core/speak/api/v1/startVoice`, |
| | | method: 'post', |
| | | data, |
| | | }) |
| | | } |
| | | |
| | | // 上传音频文件 |
| | | export const uploadSpeak = data => { |
| | | return request({ |
| | | url:'/drone-device-core/speak/api/v1/uploadSpeak', |
| | | method: 'post', |
| | | headers: { |
| | | 'Content-Type': 'multipart/form-data', |
| | | }, |
| | | data, |
| | | }) |
| | | } |
| | |
| | | <template> |
| | | <web-view :src="src" @message="viewMessage" /> |
| | | <web-view :src="src" @message="viewMessage" :allow="allow"/> |
| | | </template> |
| | | |
| | | <script setup> |
| | | |
| | | const allow = "accelerometer;ambient-light-sensor;autoplay;battery;camera;clipboard-read;clipboard-write;cross-origin-isolated;display-capture;document-domain;encrypted-media;execution-while-not-rendered;execution-while-out-of-viewport;fullscreen;gamepad;geolocation;gyroscope;hid;idle-detection;local-fonts;magnetometer;microphone;midi;payment;picture-in-picture;publickey-credentials-get;screen-wake-lock;serial;speaker-selection;storage-access;sync-xhr;usb;web-share;xr-spatial-tracking" |
| | | const src = defineModel("src"); |
| | | const emit = defineEmits(["webMessage"]); |
| | | |
| | | function viewMessage(event) { |
| | | messageFun({ |
| | | data: { |
| | |
| | | }, |
| | | }); |
| | | } |
| | | |
| | | // WEB_INVOKE_APPSERVICE |
| | | function messageFun(e) { |
| | | if (e.data.type === "WEB_INVOKE_APPSERVICE") { |
| | |
| | | const development = { |
| | | VITE_APP_ENV:'development', |
| | | // 开发环境这里改为自己的 |
| | | VITE_APP_WEBVIEW_URL: 'https://wrj.shuixiongit.com/drone-app-web-view/#/webViewWrapper', |
| | | // VITE_APP_WEBVIEW_URL: 'https://wrj.shuixiongit.com/drone-app-web-view/#/webViewWrapper', |
| | | VITE_APP_WEBVIEW_URL: 'http://localhost:5173/drone-app-web-view/#/webViewWrapper', |
| | | VITE_API_BASE_URL: 'https://wrj.shuixiongit.com/api', |
| | | // VITE_API_BASE_URL: 'https://aisky.org.cn/api', |
| | | } |
| | | |
| | | const test = { |
| | |
| | | |
| | | const production = { |
| | | VITE_APP_ENV:'production', |
| | | VITE_APP_WEBVIEW_URL: 'https://aisky.org.cn/drone-app-web-view/#/webViewWrapper', |
| | | VITE_API_BASE_URL: 'https://aisky.org.cn/api', |
| | | } |
| | | |
| | | export default { |
| | |
| | | "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", |
| | | "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", |
| | | "<uses-feature android:name=\"android.hardware.camera\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" |
| | | "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>", |
| | | "<uses-permission android:name=\"android.permission.RECORD_AUDIO\" />" |
| | | ] |
| | | }, |
| | | /* ios打包配置 */ |
| | |
| | | <template> |
| | | <WebViewPlus :src="`${viewUrl}`" @webMessage="onPostMessage"/> |
| | | <up-toast ref="uNotifyRef"></up-toast> |
| | | </template> |
| | | <script setup> |
| | | import {onHide, onLoad, onShow} from "@dcloudio/uni-app"; |
| | | import WebViewPlus from "@/components/WebViewPlus.vue"; |
| | | import {getWebViewUrl} from "@/utils/index.js"; |
| | | import {getEnvObj, getWebViewUrl} from "@/utils/index.js"; |
| | | import Recorder from "js-audio-recorder"; |
| | | import dayjs from "dayjs"; |
| | | import {useUserStore} from "@/store/index.js"; |
| | | |
| | | const viewUrl = ref('') |
| | | const wayLineJodInfoId = ref(null) |
| | | function onPostMessage(event) { |
| | | |
| | | const viewUrl = computed(() => { |
| | | return getWebViewUrl('/DroneConsole', { |
| | | wayLineJodInfoId: wayLineJodInfoId.value, |
| | | }) |
| | | }) |
| | | |
| | | |
| | | // 文件上传demo |
| | | const {VITE_API_BASE_URL} = getEnvObj() |
| | | function uploadUtil(options) { |
| | | const {formData, file, url} = options |
| | | return new Promise((resolve, reject) => { |
| | | let accessToken = useUserStore()?.$state?.userInfo?.access_token; |
| | | const file = new File([recorder.getWAVBlob()], '.wav') |
| | | uni.uploadFile({ |
| | | url: `${VITE_API_BASE_URL}${url}`, |
| | | name: 'file', |
| | | header: {'Blade-Auth': 'bearer ' + accessToken}, |
| | | file, |
| | | formData, |
| | | success: (res) => { |
| | | const resData = JSON.parse(res.data) |
| | | if (resData.code === 200 || resData.code === 0) { |
| | | resolve(res) |
| | | } else { |
| | | showToast(resData.message) |
| | | reject(res) |
| | | } |
| | | }, |
| | | fail: (err) => { |
| | | reject(err) |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | |
| | | function showToast(message) { |
| | | uNotifyRef.value.show({ |
| | | type: 'default', |
| | | message, |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 保存喊话至广播列表内 |
| | | function saveSound(data) { |
| | | const recorder = 'xxx' |
| | | const file = new File([recorder?.getWAVBlob()], '.wav') |
| | | uploadUtil({ |
| | | file, |
| | | formData: { |
| | | fileName: 'xxx', |
| | | sn: 'xxx', |
| | | }, |
| | | url: '/drone-device-core/speak/api/v1/uploadSpeak' |
| | | }).then(res => { |
| | | showToast('保存成功') |
| | | }) |
| | | } |
| | | |
| | | onLoad((options) => { |
| | | wayLineJodInfoId.value = options.wayLineJodInfoId |
| | | viewUrl.value = getWebViewUrl('/DroneConsole', {wayLineJodInfoId: wayLineJodInfoId.value}) |
| | | }) |
| | | |
| | | |
| | |
| | | const { UNI_PLATFORM,UNI_CUSTOM_DEFINE } = process.env |
| | | const ENV_NAME = UNI_CUSTOM_DEFINE && JSON.parse(UNI_CUSTOM_DEFINE)?.ENV_NAME |
| | | console.log("平台 -> ", UNI_PLATFORM) // 得到 mp-weixin, h5, app 等 |
| | | console.log("环境 -> ", ENV_NAME) // 得到 development,test 等 |
| | | console.log("环境 -> ", ENV_NAME || 'development') // 得到 development,test 等 |
| | | |
| | | const env = loadEnv(mode, fileURLToPath(new URL("./env", import.meta.url))) |
| | | // console.log("环境变量 env -> ", env) |