Koishi 3 mesiacov pred
rodič
commit
5aba99d06e
5 zmenil súbory, kde vykonal 27 pridanie a 14 odobranie
  1. 2 1
      package.json
  2. 0 2
      src/main.js
  3. 7 3
      src/router/index.js
  4. 8 8
      src/views/cesium.vue
  5. 10 0
      vite.config.js

+ 2 - 1
package.json

@@ -28,6 +28,7 @@
     "less": "^4.4.0",
     "less-loader": "^12.3.0",
     "prettier": "^3.0.3",
-    "vite": "^5.0.10"
+    "vite": "^5.0.10",
+    "vite-plugin-cesium": "^1.2.23"
   }
 }

+ 0 - 2
src/main.js

@@ -11,8 +11,6 @@ import 'element-plus/dist/index.css'
 
 import * as ElementPlusIconsVue from '@element-plus/icons-vue'
 
-
-
 const app = createApp(App)
 
 app.use(ElementPlus)

+ 7 - 3
src/router/index.js

@@ -8,17 +8,17 @@ const router = createRouter({
     //   path: '/',
     //   name: 'home',
     //   component: HomeView
-      // },
+    // },
     {
       path: '/',
       name: 'CesiumMap',
       component: () => import('../views/cesium.vue')
-      },
+    },
     {
       path: '/mapview',
       name: 'mapview',
       component: () => import('../views/mapview.vue')
-      },
+    },
     {
       path: '/satellitecloudchart',
       name: 'satellitecloudchart',
@@ -31,6 +31,10 @@ const router = createRouter({
       // this generates a separate chunk (About.[hash].js) for this route
       // which is lazy-loaded when the route is visited.
       component: () => import('../views/AboutView.vue')
+    },
+    {
+      path: "/:catchAll(.*)",
+      redirect: "/"
     }
   ]
 })

+ 8 - 8
src/views/cesium.vue

@@ -60,7 +60,7 @@ export default {
       windLayer: null, // 风场图
       windLayerTimmer: null, // 风场图计时器
       cloudLayer: null, // 卫星云图
-      rainLayer: null //
+      rainLayer: null, //
     };
   },
 
@@ -70,9 +70,9 @@ export default {
 
   unmounted() {
     if (this.windLayer !== null) {
-        clearInterval(this.windLayerTimmer);
-        this.windLayer.removeLines();
-        this.windLayer = null;
+      clearInterval(this.windLayerTimmer);
+      this.windLayer.removeLines();
+      this.windLayer = null;
     }
   },
 
@@ -333,10 +333,10 @@ export default {
     },
 
     switchRainLayer() {
-        this.$router.push({
-            path: '/satellitecloudchart'
-        })
-    }
+      this.$router.push({
+        path: "/satellitecloudchart",
+      });
+    },
   },
 };
 </script>

+ 10 - 0
vite.config.js

@@ -2,12 +2,22 @@ import { fileURLToPath, URL } from 'node:url'
 
 import { defineConfig } from 'vite'
 import vue from '@vitejs/plugin-vue'
+import cesium from 'vite-plugin-cesium'
 
 // https://vitejs.dev/config/
 export default defineConfig({
+  base: './', // 确保与部署路径匹配
   plugins: [
     vue(),
+    cesium({
+      // 关键配置:强制插件处理资源路径
+      rebuildCesium: true
+    })
   ],
+  build: {
+    // 确保资源文件不被重命名
+    assetsInlineLimit: 0
+  },
   resolve: {
     alias: {
       '@': fileURLToPath(new URL('./src', import.meta.url)),