| | |
| | | import { useConnectWebSocket } from '@/utils/websocket/connect-websocket' |
| | | import { getWebsocketUrl } from '@/websocket/util/config' |
| | | import { EBizCode, ELocalStorageKey, ERouterName } from '@/types' |
| | | import VConsole from 'vconsole'; |
| | | // import VConsole from 'vconsole'; |
| | | import { analyzeKmzFile, XMLToJSON } from '@/utils/cesium/kmz.js' |
| | | import { initPointWayLine } from './hooks/initPointWayline' |
| | | import { initPlanarWayline } from './hooks/initPlanarWayline' |
| | | import { droneFly } from './hooks/droneFly' |
| | | import ClipboardJS from 'clipboard'; |
| | | |
| | | const { pointWayline } = initPointWayLine() |
| | | const { planarWayline } = initPlanarWayline() |
| | | const { initDock, getPhoneLocation, clickPhoneLocation } = droneFly() |
| | |
| | | loadLAYER, |
| | | } = cesiumOperation() |
| | | |
| | | const vConsole = new VConsole(); |
| | | // const vConsole = new VConsole(); |
| | | |
| | | const showShare = ref(false) |
| | | |
| | |
| | | const onSelectShare = () => { |
| | | saveToken({ token: localStorage.getItem(ELocalStorageKey.Token), sbInfo: window.localStorage.getItem('sbInfo') }).then((res) => { |
| | | // if (res.code !==0) return |
| | | const shareUrl = `https://wrj.shuixiongit.com/pilot-h5/#/dronePilotShare?code=${Number(res.data)}` |
| | | navigator.clipboard.writeText(shareUrl).then(() => { |
| | | showNotify({ type: 'success', message: '复制成功' }) |
| | | }).catch(() => { |
| | | showNotify({ type: 'warning', message: '复制失败' }) |
| | | }); |
| | | let shareUrl = `https://wrj.shuixiongit.com/pilot-h5/#/dronePilotShare?code=${Number(res.data)}` |
| | | if (navigator.clipboard && navigator.clipboard.writeText) { |
| | | navigator.clipboard.writeText(shareUrl).then(() => { |
| | | showNotify({ type: 'success', message: '复制成功' }) |
| | | }).catch(err => { |
| | | showNotify({ type: 'warning', message: '复制失败' }) |
| | | }); |
| | | } else { |
| | | const input = document.createElement('input'); |
| | | input.value = shareUrl; |
| | | document.body.appendChild(input); |
| | | input.select(); |
| | | try { |
| | | const success = document.execCommand('copy'); |
| | | if (success) { |
| | | showNotify({ type: 'success', message: '复制成功' }) |
| | | } else { |
| | | showNotify({ type: 'warning', message: '复制失败' }) |
| | | } |
| | | } catch (err) { |
| | | showNotify({ type: 'warning', message: '请手动选择并复制地址' }) |
| | | } finally { |
| | | document.body.removeChild(input); |
| | | } |
| | | } |
| | | |
| | | // 创建临时按钮用于复制 |
| | | // const tempButton = document.createElement('button') |
| | | // tempButton.setAttribute('data-clipboard-text', shareUrl) |
| | | |
| | | // // 初始化 Clipboard |
| | | // const clipboard = new ClipboardJS(tempButton) |
| | | |
| | | // // 复制成功回调 |
| | | // clipboard.on('success', () => { |
| | | // showNotify({ type: 'success', message: '复制成功' }) |
| | | // clipboard.destroy() // 销毁实例 |
| | | // }) |
| | | |
| | | // // 复制失败回调 |
| | | // clipboard.on('error', () => { |
| | | // showNotify({ type: 'warning', message: '复制失败' }) |
| | | // clipboard.destroy() // 销毁实例 |
| | | // }) |
| | | |
| | | // // 触发复制 |
| | | // tempButton.click() |
| | | showShare.value = false |
| | | }); |
| | | } |