zhongrj
2025-03-28 4ff3eee77b41466d08117970970d01be6e48ffe1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
<template>
  <div class="drone-pilot-details" :style="{ width: screenWidth,height: screenHeight}">
    <van-nav-bar
      title="详情"
      right-text="分享"
      left-arrow
      @click-left="onClickLogin"
      @click-right="onClickShare"
    />
    <div id="landscapeBox" class="landscape-box" :style="{ width: boxWidth + 'px', height: boxHeight + 'px'}">
      <div id="videoModule" class="l-video" :style="{ width: screenWidthVideo + 'px', height: (screenHeightVideo) + 'px'}">
        <video v-show="videoUrl" ref="videoPlayerBig" :style="{ width: screenWidthVideo + 'px', height: screenHeightVideo + 'px'}" controls autoplay muted playsinline style="text-align: left; object-fit: fill">
          Your browser is too old which doesn't support HTML5 video.
        </video>
        <el-empty v-show="videoUrl == ''" description="当前设备已关机,无法进行直播" :image="imageUrl"></el-empty>
        <div v-if="videoUrl" class="center-point"></div>
        <div class="right-box">
          <ptzControl :sn="sn" :osdVisible="sbInfo"/>
          <controlConsole :sn="sn" :osdVisible="sbInfo" :cesiumViewe="globalViewer" />
        </div>
      </div>
      <div class="l-map" :style="{ width: screenWidthVideo + 'px', height: (screenHeightVideo) + 'px'}">
        <div id="cesiumContainerBigMap"></div>
        <div class="l-zp" id="lZp">
          <comPass :cesiumViewe="globalViewer"/>
        </div>
        <div class="l-zoom" id="lZoom">
          <div class="zoom">
            <img src="@/assets/images/me.png" @touchstart="clickPhoneLocation" />
          </div>
          <div class="zoom" @touchstart="onChangeD">
            <img v-if="is2d" src="@/assets/images/stand.png" />
            <img v-else src="@/assets/images/satellite.png" />
          </div>
          <div class="zoom">
            <img v-if="!isBigMap" src="@/assets/images/fang.png" @touchstart="changeModelMap" />
            <img v-else src="@/assets/images/suo.png" @touchstart="changeModelMap" />
          </div>
        </div>
      </div>
    </div>
    <van-share-sheet
    v-model:show="showShare"
    title="立即分享"
    :options="shareOptions"
    @select="onSelectShare"
  />
  </div>
</template>
 
<script lang="ts" setup>
import { ref, onMounted, onBeforeUnmount, nextTick, reactive, computed, watch } from 'vue';
import { showNotify } from 'vant';
import { EDeviceTypeName, EHmsLevel } from '@/types/enums'
import { getRoot } from '../../root'
import { getWaylineFile, getLiveVideoUrl, saveToken } from '@/api/manage'
import { CURRENT_CONFIG as config } from '@/api/http/config';
import { getLnglatDist, cartesian3Convert, getLnglatAltitude, createCircleBillboard } from '@/utils/cesium/mapUtil';
import cesiumOperation from '@/utils/cesium-tsa.js';
const { _init, viewerDestory } = cesiumOperation();
import { useMyStore } from '@/store'
import comPass from './components/comPass.vue'
import ptzControl from './components/ptzControl.vue'
import controlConsole from './components/controlConsole.vue'
import { useConnectWebSocket } from '@/utils/websocket/connect-websocket'
import { getWebsocketUrl } from '@/websocket/util/config'
import { EBizCode, ELocalStorageKey, ERouterName } from '@/types'
// 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()
 
const {
  removeAllPoint,
  removeAllDataSource,
  globalCesium,
  getEntityById,
  removeById,
  loadLAYER,
} = cesiumOperation()
 
// const vConsole = new VConsole();
 
const showShare = ref(false)
 
const shareOptions = [ { name: '复制链接', icon: 'link' }]
 
let globalViewer = null
 
// 使用 ref 来存储屏幕宽度和高度
const screenWidth = ref(window.innerWidth);
const screenHeight = ref(window.innerHeight);
// 加了头部
const boxWidth = ref(window.innerWidth);
const boxHeight = ref(window.innerHeight - 46);
// 地图切换
const screenWidthMap = ref(boxWidth.value)// ref(((boxHeight.value)/2)*2)
const screenHeightMap = ref(((boxHeight.value)/2));
// 视频切换
const screenWidthVideo = ref(boxWidth.value);
const screenHeightVideo = ref(boxHeight.value/2);
const isBigMap = ref(false)
 
// 显示高德地图矢量还是影像(2D/3D)
let is2d = ref(true)
 
const onChangeD = () => {
  is2d.value = !is2d.value
  store.commit('SET_MAP_SETTING_MODE', is2d.value?2:3);
  loadLAYER();
}
 
const store = useMyStore()
// 获取路由
const root = getRoot()
 
interface deviceInfo {
  dockSn: string;
  latitude?:number;// 机场经纬度
  longitude?:number;
  height?:number; // 机场高度
  isOnline: boolean;
  name: string; // 可选字段
  sn: string;
  workspaceId:string;
  children?: {  };
}
// 获取机场/遥控器sn
let localData = ref<any>(window.localStorage.getItem('sbInfo'))
const sbInfo: deviceInfo = JSON.parse(localData.value) as deviceInfo;
 
// 无人机sn 
const sn = ref<String>(sbInfo.sn)
// 机场sn 
const dockSn = ref<String>(sbInfo.dockSn)
 
// 记录横竖屏模式
const isLandscape = ref(false);
 
// 记录视频地址
const videoUrl = ref<String>('');
 
// 设置图片地址
const imageUrl = new URL('@/assets/images/norecord.png', import.meta.url).href
 
const imageMapSrc = new URL('@/assets/images/mapdock.png', import.meta.url).href
 
const jgbMapSrc = new URL('@/assets/images/jgb.png', import.meta.url).href
 
const mapswitching = new URL('@/assets/images/mapswitching.png', import.meta.url).href
 
const videoWH = ref<any>(null)
 
// 视频宽高
const drawCanvasWidth = ref<Number>(0)
const drawCanvasHeight = ref<Number>(0)
 
const videoPlayerBig = ref<any>(null); // 视频播放器实例
let webrtcPlayerBig = null
 
let player = null; // video.js 播放器
 
// 无人机实时飞行链接
let ssLinePath = ref<String>(null)
 
// 实时定位
let viewDroneInfo = {}
// 机场高度
let droneHeight = ref(0)
 
// 监听
let connectWs = ref<any>(null)
 
let workspaceId = ref<String>(sbInfo.workspaceId)
localStorage.setItem('bs_workspace_id', workspaceId.value)
 
// RTCWEB 加载视频
const playBig = () => {
  webrtcPlayerBig = new window.ZLMRTCClient.Endpoint({
    element: videoPlayerBig.value, // video 标签
    debug: true, // 是否打印日志
    zlmsdpUrl: videoUrl.value, //流地址
    simulecast: false,
    useCamera: false,
    audioEnable: true,
    videoEnable: true,
    recvOnly: true,
    usedatachannel: false,
  })
  webrtcPlayerBig.on(
    window.ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,
    (e) => {
      // ICE 协商出错
      console.error('ICE 协商出错')
      // this.eventcallbacK('ICE ERROR', 'ICE 协商出错')
    },
  )
 
  webrtcPlayerBig.on(
    window.ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,
    (e) => {
      //获取到了远端流,可以播放
      console.log('播放成功', e.streams)
      // this.eventcallbacK('playing', '播放成功')
    },
  )
 
  webrtcPlayerBig.on(
    window.ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,
    (e) => {
      // offer anwser 交换失败
      console.error('offer anwser 交换失败', e)
      // this.eventcallbacK('OFFER ANSWER ERROR ', 'offer anwser 交换失败')
      if (e.code == -400 && e.msg == '流不存在') {
        console.log('流不存在')
        timerBig = setTimeout(() => {
          webrtcPlayerBig.close()
          playBig()
        }, 100)
      }
    },
  )
 
  webrtcPlayerBig.on(
    window.ZLMRTCClient.Events.WEBRTC_ON_LOCAL_STREAM,
    (s) => {
      // 获取到了本地流
 
      // document.getElementById('selfVideo').srcObject=s;
      // this.eventcallbacK('LOCAL STREAM', '获取到了本地流')
    },
  )
}
 
 
// 加载该设备的视频信息
const loadVideo = async () => {
  await getLiveVideoUrl(sn.value).then((res) => {
    if (res.data.code != 0) return
    // 获取高度
    if (videoWH.value) {
      drawCanvasWidth.value = videoWH.value.offsetWidth;
      drawCanvasHeight.value = videoWH.value.offsetHeight;
    }
    videoUrl.value =  res.data.data.rtcs_url
    // 播放
    playBig()
  })
}
 
//===============================
// 获取实时航线
const getWrjSsLx = () => {
  if (window.cesiumViewer== null) return 
  getWaylineFile(sbInfo.sn).then((res:any) => {
    if (res.code != 200) return
    ssLinePath.value = res.data
    // globalViewer = window.cesiumViewer
    // 先有航线,再飞行
    generateCourse()
  })
}
 
// 生成航线轨迹
const generateCourse = async () => {
  if (!ssLinePath.value) return
  const { fileInfoObj } = await analyzeKmzFile(`${ssLinePath.value}?_t=${new Date().getTime()}`)
  const xmlStr = await fileInfoObj['wpmz/template.kml']
  const xmlJson = XMLToJSON(xmlStr)?.['Document']
  const placemark = xmlJson.Folder.Placemark
  if (placemark?.Polygon) {
    // return 'planar'
    planarWayline(ssLinePath.value, sbInfo.longitude, sbInfo.latitude)
  } else {
    // return 'point'
    pointWayline(ssLinePath.value, sbInfo.longitude, sbInfo.latitude)
  }
}
 
// 无人机相关信息
// const droneInfo = ref({})
 
// 监听ws
const messageHandler = async (payload: any) => {
  // if (!payload) {
  //   return
  // }
  switch (payload.biz_code) {
    case EBizCode.GatewayOsd: { // 遥控器
      store.commit('SET_GATEWAY_INFO', payload.data)
      break
    }
    case EBizCode.DeviceOsd: { // 无人机的
      store.commit('SET_DEVICE_INFO', payload.data)
      store.commit('SET_WS_MESSAGE', payload)
      getviewDrone(payload)
      break
    }
    case EBizCode.DockOsd: { // 机场
      store.commit('SET_DOCK_INFO', payload.data)
      break
    }
    case EBizCode.DeviceOffline: {
      store.commit('SET_DEVICE_OFFLINE', payload.data)
      if (!payload.data.online_status) {
        videoUrl.value = ''
      }
      break
    }
    case EBizCode.FlightTaskProgress: { // 获取进度
      // 如果点击列表进入没有获取到航线文件,那么这里重新请求一次
      if (!ssLinePath || !ssLinePath.value) {
        getWrjSsLx()
      }
      break
    }
  }
  
}
 
const webSorketUrl = getWebsocketUrl() + '&workspace-id=' + workspaceId.value
// 监听ws 消息
useConnectWebSocket(messageHandler, webSorketUrl)
 
// 定义方法直接监听机场消息
const getviewDrone = (newValue) => {
  if (newValue.data.host) {
    viewDroneInfo.longitude = newValue.data.host?.longitude
    viewDroneInfo.latitude = newValue.data.host?.latitude
    viewDroneInfo.elevation = Number(newValue.data.host?.elevation.toFixed(2)) + droneHeight.value
  }
}
 
 
// let savedMapState = null; // 保存地图状态
// // 销毁之前先保存状态
// const destroyViewer = () => {
//   if ( window.cesiumViewer) {
//     // 保存当前地图状态(如相机位置)
//     // savedMapState = window.cesiumViewer.camera.view;
//     window.cesiumViewer.destroy();
//     window.cesiumViewer = null;
//   }
// }
 
// 视频全屏切换
 
// const changeModelVideo = (value:Boolean) => {
//   const videoModule = document.getElementById('videoModule');
//   // 不管是否竖/横屏都一样
//   if (value) { // 全屏
//     videoModule.style.width = `${screenWidth.value}px`
//     videoModule.style.height = `${screenHeight.value}px`
//   } else {
//     if (isLandscape.value) {
//       videoModule.style.width = `${screenWidth.value/2}px`
//       videoModule.style.height = `${screenHeight.value}px`
//     } else {
//       videoModule.style.height = `${screenHeight.value/2}px`
//       videoModule.style.width = `${screenWidth.value}px`
//     }
//   }
// }
 
// 地图全屏切换
const changeModelMap = () => {
  isBigMap.value = !isBigMap.value
  const cesiumContainer = document.getElementById('cesiumContainerBigMap');
  const lZp = document.getElementById('lZp');
  // const lZoom = document.getElementById('lZoom');
  if (isLandscape.value) { // 横屏
    if (isBigMap.value) { // 全屏
      cesiumContainer.style.position = 'fixed';
      cesiumContainer.style.top = '46px';
      cesiumContainer.style.left = '0';
      cesiumContainer.style.width = `${boxWidth.value}px`
      // cesiumContainer.style.height = `${screenHeightMap.value}px`
      lZp.style.right = '40%';
      // lZoom.style.left = '0';
    } else { // 缩放
      cesiumContainer.style.width = `${boxWidth.value/2}px`
      // cesiumContainer.style.height = `${screenHeightMap.value}px`
      cesiumContainer.style.position = 'static';
      lZp.style.right = '16%';
      // lZoom.style.left = '50%';
      
    }
  } else {
    if (isBigMap.value) { // 竖-全屏
      cesiumContainer.style.position = 'fixed';
      cesiumContainer.style.top = '46px';
      cesiumContainer.style.left = '0';
      // cesiumContainer.style.width = `${boxHeight.value}px`
      cesiumContainer.style.height = `${boxHeight.value}px`
      lZp.style.right = '30%';
      // lZoom.style.right = '0';
    } else { // 缩放
      cesiumContainer.style.width = `${boxHeight.value}px`
      cesiumContainer.style.height = `${boxHeight.value/2}px`
      cesiumContainer.style.position = 'static';
      lZp.style.right = '30%';
      // lZoom.style.right = '0';
      
    }
  }
}
 
// 更新屏幕尺寸的函数
// const updateScreenSize = () => {
//   const cesiumContainer = document.getElementById('cesiumContainerBigMap');
//   screenWidth.value = window.innerWidth;
//   screenHeight.value = window.innerHeight;
//   console.log('屏幕自身宽度',window.innerWidth)
//   console.log('屏幕自身高度',window.innerHeight)
//   if (isLandscape.value) { //横屏
//     screenWidthMap.value = window.innerWidth/2
//     screenHeightMap.value = window.innerHeight
//     screenWidthVideo.value = window.innerWidth/2
//     screenHeightVideo.value = window.innerHeight
//     cesiumContainer.style.width = `${screenWidthMap.value}px`
//     cesiumContainer.style.height = `${screenHeightMap.value}px`
//   } else {//竖屏
//     screenWidthMap.value = window.innerHeight
//     screenHeightMap.value = (window.innerHeight/2)
//     screenWidthVideo.value = window.innerWidth
//     screenHeightVideo.value = (window.innerHeight/2)
//     // 重新给赋值宽高
//     cesiumContainer.style.width = `${screenWidthMap.value}px`
//     cesiumContainer.style.height = `${screenHeightMap.value}px`
//     console.log('切换竖屏宽度',screenWidthMap.value)
//     console.log('切换竖屏高度度',screenHeightMap.value)
//   }
  
// };
 
const checkOrientation = async () => {
    boxWidth.value = window.innerWidth;
    boxHeight.value = window.innerHeight - 46;
    const landscapeBox = document.getElementById('landscapeBox');
    let cesiumContainer = document.getElementById('cesiumContainerBigMap');
    const lZp = document.getElementById('lZp');
    const lZoom = document.getElementById('lZoom');
  
    if (window.innerWidth > window.innerHeight) {//横屏
      screenWidthVideo.value = boxWidth.value/2
      screenHeightVideo.value = boxHeight.value
      isLandscape.value = true;
      // updateScreenSize()
      landscapeBox.style.display = 'flex';
      lZp.style.right = '16%';
      lZoom.style.position = 'fixed';
      cesiumContainer.style.width = `${boxWidth.value/2}px`
      cesiumContainer.style.height = `${boxHeight.value}px`
      cesiumContainer.style.position = 'static'
      cesiumContainer.style.right = '0'
      cesiumContainer.style.marginLeft = '0%'
    } else { //竖屏
      isLandscape.value = false;
      screenWidthVideo.value = boxWidth.value
      screenHeightVideo.value = boxHeight.value/2
      // updateScreenSize()
      landscapeBox.style.display = 'inherit';
      landscapeBox.style.overflow = 'hidden';
      lZp.style.right = '32%';
      cesiumContainer.style.width = `${boxHeight.value}px`
      cesiumContainer.style.height = `${boxHeight.value/2}px`
      // cesiumContainer.style.position = 'absolute'
      cesiumContainer.style.marginLeft = '-32%'
    }
  };
 
// 切换航线轨迹
const courseTrack = (data:any) => {
  if (window.cesiumViewer== null) return 
  const currentSn = dockSn.value
  const longitude = data.dockInfo[currentSn]?.basic_osd?.longitude || null
  const latitude = data.dockInfo[currentSn]?.basic_osd?.latitude || null
  const height = data.dockInfo[currentSn]?.basic_osd?.height || null
  let getLongOk = ref(0)
  if (!getEntityById('drone_dock')) {
    getLnglatAltitude(longitude, latitude,  window.cesiumViewer).then(res => {
      removeById('drone_dock')
       window.cesiumViewer.entities.add({
        position: globalCesium.Cartesian3.fromDegrees(
          longitude,
          latitude,
          res.height,
        ),
        id: 'drone_dock',
        billboard: {
          image: imageMapSrc,
          outlineWidth: 0,
          width: 36,
          height: 36,
          scale: 1.0,
        }
      })
      window.cesiumViewer.scene.camera.setView({
        destination: globalCesium.Cartesian3.fromDegrees(
          Number(longitude),
          Number(latitude),
          10000.0,
        ),
      })
      droneHeight.value = res.height
    })
  } else {
    // 当机场坐标存在时,判断获取的位置与机场坐标位置是否一致,若不是,重新更新位置
    let dornePoint = cartesian3Convert(getEntityById('drone_dock')._position._value, window.cesiumViewer,)
    getLongOk = getLnglatDist(
      dornePoint.longitude,
      dornePoint.latitude,
      longitude,
      latitude,
    )
    if (getLongOk.value > 100) {
      removeById('drone_dock')
    }
  }
  if (getLongOk.value > 100) return
  initDock(data, sn.value, dockSn.value, workspaceId.value, ssLinePath.value, viewDroneInfo)
}
 
// 监听
watch(() => store.state.deviceState, (newValue, oldValue) => {
  if (newValue) {
    nextTick()
    courseTrack(newValue)
  }
}, {deep: true})
 
// watch(() => store.state.wsMessage, (newValue, oldValue) => {
//   // 控制台报 Expected longitude to be typeof number, actual typeof was undefined 是因为这里没有及时拿到longitude数据
//   if (newValue) {
//     viewDroneInfo.longitude = newValue?.longitude
//     viewDroneInfo.latitude = newValue?.latitude
//     viewDroneInfo.elevation = Number(newValue?.elevation.toFixed(2)) + droneHeight.value
//   }
// }, {deep: true})
 
 
let intervalId = null;
 
const onClickLogin = () => {
  history.back();
}
 
const onClickShare = () => {
  showShare.value = true
 
  // root.$router.push({
  //   path:ERouterName.DRONEPILOTSHARE,
  //   query: { workspaceId:workspaceId.value, token: localStorage.getItem(ELocalStorageKey.Token),sbInfo:window.localStorage.getItem('sbInfo') } });
}
// 复制链接
const onSelectShare = () => {
  saveToken({ token: localStorage.getItem(ELocalStorageKey.Token), sbInfo: window.localStorage.getItem('sbInfo') }).then((res) => {
    // if (res.code !==0) return
    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
  });
}
 
// 为组件赋值
const getGlobalViewer = () => {
  globalViewer = window.cesiumViewer;
}
 
onMounted(async () => {
  window.addEventListener('orientationchange', checkOrientation);
  window.addEventListener('resize', checkOrientation); // 兼容某些设备
  checkOrientation(); // 初始化时检查一次
  loadVideo()
  await nextTick();
  await _init('cesiumContainerBigMap');
  await getGlobalViewer()
  await getWrjSsLx();
  // 判断是遥控器还是机场
  let domain = sessionStorage.getItem('domain')
  if (domain !== '0') {
    // await getPhoneLocation(workspaceId.value)
  // // // 设置定时器,每隔 5 秒刷新一次数据
    // intervalId = setInterval(()=> {
    //   getPhoneLocation(workspaceId.value)
    // }, 5000);
  }
});
 
onBeforeUnmount(() => {
  window.removeEventListener('orientationchange', checkOrientation);
  window.removeEventListener('resize', checkOrientation);
 
  // removeAllPoint()
  // removeAllDataSource()
  // 销毁地图实例
  if (window.cesiumViewer && !window.cesiumViewer.isDestroyed()) {
    window.cesiumViewer.destroy();
  }
  if (globalViewer && !globalViewer.isDestroyed()) {
    globalViewer.destroy();
  }
  if (player) {
    player.dispose();
  }
  // 组件卸载时清除定时器
  if (intervalId) {
    clearInterval(intervalId);
  }
});
 
 
 
</script>
 
<style lang="scss" scoped>
.drone-pilot-details {
  .landscape-box {
    overflow: hidden;
    // position: relative;
    // display: flex;
    .l-map {
      .l-zp {
        position: fixed;
        right: 16%;
        bottom: 0;
      }
      .l-zoom {
        position: fixed;
        bottom: 0;
        right: 0;
        .zoom {
          width: 2rem;
          height: 2rem;
          margin: 0.2rem 0.4rem;
          border-radius: 3px;
          background-color: rgba(0, 0, 0, 0.8);
          display: flex;
          align-items: center;
          justify-content: center;
          overflow: hidden;
          cursor: pointer;
          pointer-events: all;
          img {
            width: 1.6rem;
            height: 1.6rem;
          }
        }
      }
    }
  }
  .l-video {
    position: relative;
    .el-empty {
      width: 100%;
      height: 100%;
      padding: 0;
      ::v-deep(.el-empty__image) {
        width: 50%;
        height: 50%;
      }
      ::v-deep(.el-empty__description) {
        margin: 0;
      }
    }
    .center-point {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 0.4rem;
      height: 0.4rem;
      opacity: 0.5;
      border-radius: 50%;
      background-color: yellow;
      transform: translate(-50%, -50%);
      justify-content: center;
    }
    .right-box {}
  }
  #cesiumContainerBigMap {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transform-origin: top left;
    transition: none; // 防止切换时的动画效果
    backface-visibility: hidden; // 提高性能
    -webkit-backface-visibility: hidden; // 提高性能  
 
    :deep() {
      .cesium-viewer {
        width: 100%;
        height: 100%;
 
        .cesium-viewer-cesiumWidgetContainer {
          width: 100%;
          height: 100%;
 
          .cesium-widget {
            width: 100%;
            height: 100%;
 
            canvas {
              width: 100%;
              height: 100%;
            }
          }
        }
      }
    }
  }
  
}
</style>