浏览代码

feat: 提供本地版配置引入

bill 1 周之前
父节点
当前提交
0a48213834

+ 2 - 0
package.json

@@ -4,6 +4,8 @@
   "version": "1.1.0",
   "type": "module",
   "scripts": {
+    "dev:exe": "vite --mode=exedev",
+    "build:exe": "vite build --mode=exe",
     "dev:fuse": "vite --mode=firedev",
     "build:fusetest": "vite build --mode=firetest && vite build --mode=criminaltest && vite build --mode=cjzfiretest && vite build --mode=xmfiretest",
     "build:fuse": "vite build --mode=fire && vite build --mode=criminal && vite build --mode=cjzfire && vite build --mode=xmfire",

+ 10 - 0
profile/.env.exe

@@ -0,0 +1,10 @@
+VITE_PRIMARY='#109BE0'
+VITE_TITLE='绘图'
+VITE_ENTRY='/example/fuse/enter-exe.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'
+
+VITE_ORIGIN='params'
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&env=dev'
+VITE_CLOUD_VIEW='http://192.168.0.125:1804/swss/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='http://192.168.0.125:1804/code/'
+VITE_LOGIN_VIEW='http://192.168.0.125:1804/admin/#/statistics/scene?redirect={redirect}'

+ 20 - 0
profile/.env.exedev

@@ -0,0 +1,20 @@
+VITE_PRIMARY='#109BE0'
+VITE_TITLE='绘图'
+VITE_ENTRY='/example/fuse/enter-exe.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'
+VITE_MOCK_ENV=exetest
+
+
+# VITE_ORIGIN='params'
+VITE_STATIC='http://192.168.0.125:1804/'
+VITE_OSS='/oss/'
+VITE_OSS_ROOT="/rootOss/"
+VITE_MESH_OSS='/meshOSS/'
+VITE_MESH_API='/meshAPI/'
+VITE_CLOUD_API='/cloudAPI/'
+VITE_FUSE_API='/fuseAPI/'
+
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&env=dev'
+VITE_CLOUD_VIEW='http://192.168.0.125:1804/swss/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='http://192.168.0.125:1804/code/'
+VITE_LOGIN_VIEW='http://192.168.0.125:1804/admin/#/statistics/scene?redirect={redirect}'

+ 18 - 0
profile/.env.exetest

@@ -0,0 +1,18 @@
+VITE_PRIMARY='#109BE0'
+VITE_TITLE='绘图'
+VITE_ENTRY='/example/fuse/enter-exe.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'
+
+
+# VITE_ORIGIN='params'
+VITE_OSS_ROOT="http://192.168.0.125:1804/"
+VITE_OSS='http://192.168.0.125:1804/oss/'
+VITE_MESH_OSS='http://192.168.0.125:1804/oss/'
+VITE_MESH_API='http://192.168.0.125:1804/'
+VITE_CLOUD_API='http://192.168.0.125:1804/'
+VITE_FUSE_API='http://192.168.0.125:1804/'
+
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&env=dev'
+VITE_CLOUD_VIEW='http://192.168.0.125:1804/swss/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='http://192.168.0.125:1804/code/'
+VITE_LOGIN_VIEW='http://192.168.0.125:1804/admin/#/statistics/scene?redirect={redirect}'

+ 18 - 0
src/example/fuse/enter-exe.ts

@@ -0,0 +1,18 @@
+
+import { params } from "../env";
+import { resourceURLS, SCENE_TYPE } from "./enter-shared";
+
+let load: Promise<any>
+if (import.meta.env.VITE_ORIGIN === 'params') {
+  resourceURLS.oss = params.value.app_resource
+  resourceURLS.ossRoot = params.value.app_resource
+  resourceURLS[SCENE_TYPE.cloud] = params.value.laser_server
+  resourceURLS[SCENE_TYPE.mesh] = params.value.mesh_server
+  resourceURLS[SCENE_TYPE.fuse] = params.value.fuse_server
+  load = import('./enter')
+} else {
+  load = import('./enter')
+}
+load.then(() => {
+  window.platform.preventLogin = true
+})

+ 1 - 0
src/example/fuse/enter-shared.ts

@@ -173,6 +173,7 @@ export const getSceneList = (keyword: string) => {
           m: item.num,
           title: item.sceneName,
           id: item.id.toString(),
+          mapping: item.mapping,
           token,
         } as Scene)
     );

+ 12 - 12
src/example/fuse/enter.ts

@@ -74,7 +74,6 @@ if (window.platform.sceneDraw) {
   import(import.meta.env.VITE_ENTRY_EXAMPLE);
 }
 
-
 window.platform.getTabulationData = async (...args: any[]) => {
   const result = await platform.getTabulationData.apply(this, args as any);
   if (!result.title && platform.getTableTemp().title) {
@@ -88,7 +87,7 @@ window.platform.getTabulationData = async (...args: any[]) => {
   if (result.title) {
     let texts = result.store.layers[defaultLayer].text;
     if (!texts) {
-      texts = result.store.layers[defaultLayer].text = []
+      texts = result.store.layers[defaultLayer].text = [];
     }
     let title = texts.find((title: any) => title.key === tableTitleKey);
     if (title) {
@@ -117,7 +116,7 @@ window.platform.getTabulationData = async (...args: any[]) => {
       };
       title.mat[4] = pos.x;
       title.mat[5] = pos.y;
-      texts.push(title)
+      texts.push(title);
     }
   }
   return result;
@@ -126,18 +125,19 @@ window.platform.getTabulationData = async (...args: any[]) => {
 window.platform.saveTabulationData = (id: any, data: any) => {
   const texts = data.store.layers[defaultLayer].text;
   let title = texts.find((title: any) => title.key === tableTitleKey);
-  let content = title ? title.content : ''
+  let content = title ? title.content : "";
 
-  return platform.saveTabulationData(id, {...data, title: content})
-}
+  return platform.saveTabulationData(id, { ...data, title: content });
+};
 
 // 登录检测
 setTimeout(() => {
-  if (!platform.getHeaders().token) {
-    ElMessage.error("当前用户未登录");
-    window.platform.login();
-  } else {
-    console.log("0.0");
-    platform.getSceneList("").next();
+  if (!window.platform.preventLogin) {
+    if (!platform.getHeaders().token) {
+      ElMessage.error("当前用户未登录");
+      window.platform.login();
+    } else {
+      platform.getSceneList("").next();
+    }
   }
 }, 500);

+ 1 - 0
src/example/platform/platform-resource.ts

@@ -14,6 +14,7 @@ export type Scene = {
   m: string;
   title: string;
   id: string;
+  mapping?: string
 };
 
 export type CoverLine = {

+ 1 - 1
src/example/platform/resource-swkk.ts

@@ -24,7 +24,7 @@ import { extractConnectedSegments } from "@/utils/polygon";
 const fetchResource = genCache(
   (scene: Scene) => scene.m,
   async (scene: Scene) => {
-    const prev = `/scene_view_data/${scene.m}`;
+    const prev = `${scene.mapping ? '/' + scene.mapping : ''}/scene_view_data/${scene.m}`;
     let version = Date.now();
     const get = (url: string, def?: any) =>
       getSceneApi("oss", `${prev}${url}?_=${version}`)