From b8440d9a6b1671cdf0c8f06cdaba2f80a8dac1e6 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Wed, 13 Nov 2024 14:17:15 +0800
Subject: [PATCH] 退出图标按钮修复

---
 src/hooks/initMap.js |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/hooks/initMap.js b/src/hooks/initMap.js
index 5569c85..09a24c7 100644
--- a/src/hooks/initMap.js
+++ b/src/hooks/initMap.js
@@ -2,7 +2,7 @@
  * @Author: shuishen 1109946754@qq.com
  * @Date: 2024-10-25 15:09:55
  * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2024-11-07 16:15:48
+ * @LastEditTime: 2024-11-09 19:55:21
  * @FilePath: \bigScreen\src\hooks\initMap.js
  * @Description: 
  * 
@@ -11,10 +11,12 @@
 let viewer = null
 const { VITE_APP_BASE } = import.meta.env
 import { useMap } from 'store/map'
-import { nextTick } from 'vue'
+import { nextTick, onMounted, onUnmounted } from 'vue'
+import * as turf from '@turf/turf'
+import * as Cesium from 'cesium'
+import 'cesium/Build/Cesium/Widgets/widgets.css'
 
 export function readyViewer () {
-  const Cesium = DC.getLib('Cesium')
   const store = useMap()
 
   function initMap () {
@@ -22,7 +24,9 @@
 
     nextTick(() => {
       DC.ready({
-        baseUrl: `${VITE_APP_BASE}libs/dc-sdk/resources/`
+        // Cesium: Cesium,
+        baseUrl: `${VITE_APP_BASE}libs/dc-sdk/resources/`,
+        turf,
       }).then(() => {
 
         viewer = new DC.Viewer('viewer-container')
@@ -43,7 +47,16 @@
     })
   }
 
-  initMap()
+  onMounted(() => {
+    initMap()
+  })
+
+  onUnmounted(() => {
+    viewer.destroy()
+    viewer = null
+    delete window.$viewer
+    store.setLoadMap(false)
+  })
 
   return {
 

--
Gitblit v1.9.3