bill 1 месяц назад
Родитель
Сommit
85b37a82d8
3 измененных файлов с 44 добавлено и 31 удалено
  1. 1 1
      src/example/fuse/enter-mix.ts
  2. 32 30
      src/example/fuse/enter.ts
  3. 11 0
      vite.config.ts

+ 1 - 1
src/example/fuse/enter-mix.ts

@@ -46,7 +46,7 @@ const login = (isBack = true) => {
       delete query["redirect"];
       link = urlUpdateQuery(url.toString(), query, true);
     }
-    // location.replace(link);
+    location.replace(link);
     isLoging = false;
   }
 };

+ 32 - 30
src/example/fuse/enter.ts

@@ -70,12 +70,12 @@ const postFile = (url: string, data: Record<string, any>) => {
   );
 };
 
-let isLoging = false
+let isLoging = false;
 const login = (isBack = true) => {
   if (isLoging) {
-    throw '登录中'
+    throw "登录中";
   }
-  isLoging = true
+  isLoging = true;
   if (import.meta.env.DEV && params.value.caseId) {
     post("/service/manage/login", {
       password: "JwiuK95dExMjM0NTY=7nHGf5ySQWSuC4G1An",
@@ -83,10 +83,10 @@ const login = (isBack = true) => {
       userName: "super-admin",
     }).then((res) => {
       params.value.token = res.token;
-      console.error(res.token)
+      console.error(res.token);
       // console.log(res.token, {...params.value})
-      setTimeout(() => location.reload(), 1000)
-      isLoging = false
+      setTimeout(() => location.reload(), 1000);
+      isLoging = false;
     });
     return;
   }
@@ -113,8 +113,8 @@ const login = (isBack = true) => {
       delete query["redirect"];
       link = urlUpdateQuery(url.toString(), query, true);
     }
-    // location.replace(link);
-    isLoging = false
+    location.replace(link);
+    isLoging = false;
   }
 };
 
@@ -177,7 +177,7 @@ const saveOverviewData = genLoading(
       store: StoreData;
       viewport: number[] | null;
       caseTabulation: {
-        id: string,
+        id: string;
         store: StoreData;
         viewport: number[] | null;
         isAutoGen: boolean;
@@ -201,7 +201,7 @@ const saveOverviewData = genLoading(
         isAutoGen: Number(data.caseTabulation.isAutoGen),
         paperKey: data.caseTabulation.paperKey,
         overviewId: data.caseTabulation.overviewId,
-      }
+      },
     });
     return item.id;
   }
@@ -243,12 +243,14 @@ const getTabulationData = genLoading(async (id: string) => {
   };
 });
 
-if (!params.value.caseId || !token) {
-  ElMessage.error("当前项目号不存在!");
-  window.platform.login(!!params.value.caseId);
-} else {
-  setTimeout(() => getSceneList(""), 500);
-}
+setTimeout(() => {
+  if (!params.value.caseId || !token) {
+    ElMessage.error("当前项目号不存在!");
+    window.platform.login(!!params.value.caseId);
+  } else {
+    getSceneList("");
+  }
+}, 500);
 
 const saveTabulationData = genLoading(
   async (
@@ -290,27 +292,27 @@ const uploadResourse = genLoading(async (file: File) => {
 });
 
 const getTableTemp = () => {
-  let table: Record<string, string>
-  let title: string = params.value.title
+  let table: Record<string, string>;
+  let title: string = params.value.title;
   if (params.value.table) {
     try {
-      table = JSON.parse(params.value.table)
+      table = JSON.parse(params.value.table);
     } catch (e) {
-      console.log('tableTemp模板解析失败')
+      console.log("tableTemp模板解析失败");
     }
   }
   if (!table!) {
     table = {
-      案发时间: '',
-      案发地点: '',
-      绘图单位: '',
-      绘图人: '',
-      绘图时间: '',
-    }
-    title = '默认标题'
+      案发时间: "",
+      案发地点: "",
+      绘图单位: "",
+      绘图人: "",
+      绘图时间: "",
+    };
+    title = "默认标题";
   }
-  return { table, title }
-}
+  return { table, title };
+};
 
 window.platform = {
   login,
@@ -323,7 +325,7 @@ window.platform = {
   saveTabulationData,
   uploadResourse,
   getTabulationId,
-  getTableTemp
+  getTableTemp,
 };
 
 /* @vite-ignore */

+ 11 - 0
vite.config.ts

@@ -4,6 +4,7 @@ import path from "node:path";
 import { createHtmlPlugin } from "vite-plugin-html";
 import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
 import { version } from "./package.json";
+import fs from 'fs'
 
 // https://vite.dev/config/
 export default ({ mode }: any) => {
@@ -74,6 +75,16 @@ export default ({ mode }: any) => {
       proxy: proxy,
     },
     plugins: [
+      {
+        name: "remove-static-models",
+        closeBundle() {
+          const dir = path.resolve(__dirname, "dist/static/models");
+          if (fs.existsSync(dir)) {
+            fs.rmSync(dir, { recursive: true, force: true });
+            console.log("Removed dist/static/models directory after build.");
+          }
+        },
+      },
       createSvgIconsPlugin({
         iconDirs: [path.resolve(process.cwd(), "public/icons")],
         symbolId: "icon-[dir]-[name]",