Quellcode durchsuchen

feat: 江门定制化制作

bill vor 3 Monaten
Ursprung
Commit
062e2cae02
7 geänderte Dateien mit 76 neuen und 50 gelöschten Zeilen
  1. 9 8
      .env.jm
  2. 7 5
      .env.jmdev
  3. 11 8
      .env.jmtest
  4. 16 5
      src/example/fuse/enter.ts
  5. 1 0
      src/example/fuse/store.ts
  6. 1 1
      src/example/fuse/views/overview/header.vue
  7. 31 23
      vite.config.ts

+ 9 - 8
.env.jm

@@ -2,11 +2,12 @@ VITE_PRIMARY='#109BE0'
 VITE_TITLE='绘图'
 VITE_ENTRY='./example/fuse/enter.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
-VITE_MESH_OSS='https://4dkk.4dage.com/'
-VITE_MESH_API='https://www.4dkankan.com/'
-VITE_CLOUD_API='https://laser.4dkankan.com/backend/'
-VITE_FUSE_API='https://mix3d.4dkankan.com/'
-VITE_MESH_VIEW='https://www.4dkankan.com/spg.html?m={m}&lang=zh'
-VITE_CLOUD_VIEW='https://laser.4dkankan.com/index.html?m={m}&lang=zh'
-VITE_FUSE_VIEW='https://mix3d.4dkankan.com/'
-VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+VITE_MESH_OSS='/oss/'
+VITE_MESH_API='/'
+VITE_CLOUD_API='/'
+VITE_FUSE_API='/'
+
+VITE_MESH_VIEW='/spg.html?m={m}&lang=zh'
+VITE_CLOUD_VIEW='/swss/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='/code/'
+VITE_LOGIN_VIEW='/admin/index.html#/login?redirect={redirect}'

+ 7 - 5
.env.jmdev

@@ -2,13 +2,15 @@ VITE_PRIMARY='#109BE0'
 VITE_TITLE='绘图'
 VITE_ENTRY='./example/fuse/enter.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
-VITE_MOCK_ENV=fusetest
+VITE_MOCK_ENV=jmtest
+
+VITE_OSS='/oss/'
 VITE_MESH_OSS='/meshOSS/'
 VITE_MESH_API='/meshAPI/'
 VITE_CLOUD_API='/cloudAPI/'
 VITE_FUSE_API='/fuseAPI/'
 
-VITE_MESH_VIEW='https://test.4dkankan.com/spg.html?m={m}&lang=zh'
-VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
-VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
-VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+VITE_MESH_VIEW='http://192.168.0.25/spg.html?m={m}&lang=zh&token={token}'
+VITE_CLOUD_VIEW='http://192.168.0.25/swss/index.html?m={m}&lang=zh&token={token}'
+VITE_FUSE_VIEW='http://192.168.0.25/code/'
+VITE_LOGIN_VIEW='http://192.168.0.25/admin/index.html#/login?redirect={redirect}'

+ 11 - 8
.env.jmtest

@@ -2,11 +2,14 @@ VITE_PRIMARY='#109BE0'
 VITE_TITLE='绘图'
 VITE_ENTRY='./example/fuse/enter.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
-VITE_MESH_OSS='https://4dkk.4dage.com/'
-VITE_MESH_API='https://test.4dkankan.com/'
-VITE_CLOUD_API='https://uat-laser.4dkankan.com/uat/'
-VITE_FUSE_API='https://test-mix3d.4dkankan.com/'
-VITE_MESH_VIEW='https://test.4dkankan.com/spg.html?m={m}&lang=zh'
-VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
-VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
-VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+
+VITE_OSS='http://192.168.0.25/oss/'
+VITE_MESH_OSS='http://192.168.0.25/oss/'
+VITE_MESH_API='http://192.168.0.25/'
+VITE_CLOUD_API='http://192.168.0.25/'
+VITE_FUSE_API='http://192.168.0.25/'
+
+VITE_MESH_VIEW='http://192.168.0.25/spg.html?m={m}&lang=zh'
+VITE_CLOUD_VIEW='http://192.168.0.25/swss/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='http://192.168.0.25/code/'
+VITE_LOGIN_VIEW='http://192.168.0.25/admin/#/statistics/scene?redirect={redirect}'

+ 16 - 5
src/example/fuse/enter.ts

@@ -24,20 +24,22 @@ const viewURLS = {
   [SCENE_TYPE.fuse]: import.meta.env.VITE_FUSE_VIEW,
 };
 
+const token = (params.token || localStorage.getItem("token")) as string;
+const headers = { token, caseId: params.caseId, 'page-type': 'edit' } 
 const get = (url: string, params: Record<string, any>) => {
   const p = new URLSearchParams();
   for (const key in params) {
     p.append(key, params[key]);
   }
   const l = `${resourceURLS[SCENE_TYPE.fuse]}${url}?${p.toString()}`;
-  return after(fetch(l, { method: "get", headers: { token } }));
+  return after(fetch(l, { method: "get", headers} ));
 };
 
 const post = (url: string, data: Record<string, any>) => {
   const l = `${resourceURLS[SCENE_TYPE.fuse]}${url}`;
   return after(
     fetch(l, {
-      headers: { token, "Content-Type": "application/json;charset=UTF-8" },
+      headers: { "Content-Type": "application/json;charset=UTF-8", ...headers },
       method: "post",
       body: JSON.stringify(data),
     })
@@ -53,7 +55,7 @@ const postFile = (url: string, data: Record<string, any>) => {
   const l = `${resourceURLS[SCENE_TYPE.fuse]}${url}`;
   return after(
     fetch(l, {
-      headers: { token },
+      headers,
       method: "post",
       body: formData,
     })
@@ -89,7 +91,6 @@ const after = async (fet: Promise<Response>) => {
   }
 };
 
-const token = (params.token || localStorage.getItem("token")) as string;
 if (!params.caseId || !token) {
   login(!!params.caseId);
 }
@@ -105,6 +106,7 @@ const getSceneList = genLoading(async (keyword: string): Promise<Scene[]> => {
     m: item.num,
     title: item.name,
     id: item.id.toString(),
+    token
   }));
 });
 
@@ -144,6 +146,7 @@ const getTabulationId = async (id: string) => {
   const list = await get("fusion/caseTabulation/getByOverviewId", {
     overviewId: id,
   });
+  console.log(list)
   return list[0]?.id;
 };
 
@@ -194,7 +197,15 @@ const saveTabulationData = genLoading(
 );
 
 const uploadResourse = genLoading(async (file: File) => {
-  return postFile(`fusion/upload/file`, { file });
+  const url = await postFile(`fusion/upload/file`, { file });
+  if (url.includes('//')) {
+    return url
+  }
+  if (import.meta.env.DEV && import.meta.env.VITE_MOCK_PROXY) {
+    return `${import.meta.env.VITE_MOCK_PROXY}${url}` 
+  } else {
+    return url
+  }
 });
 
 window.platform = {

+ 1 - 0
src/example/fuse/store.ts

@@ -3,6 +3,7 @@ import { StoreData } from "@/core/store/store";
 import { PaperKey } from "../components/slide/actions";
 import { tabulationId, overviewId } from './router'
 
+
 export const tableCoverKey = '__tableCoverKey'
 export const tableCoverScaleKey = '__tableCoverScaleKey'
 export const tableTableKey = '__tableTableKey'

+ 1 - 1
src/example/fuse/views/overview/header.vue

@@ -134,6 +134,7 @@ const saveHandler = async () => {
   const url = await window.platform.uploadResourse(
     new File([blob], `tabulation-cover.png`)
   );
+
   const cover = {
     url,
     width: rect.width,
@@ -142,7 +143,6 @@ const saveHandler = async () => {
   };
 
   tabulationId.value = await window.platform.getTabulationId(overviewId.value);
-  console.error(tabulationId.value);
   await refreshTabulationData();
   const tabStore = await repTabulationStore(
     tabulationData.value.paperKey,

+ 31 - 23
vite.config.ts

@@ -1,33 +1,41 @@
 import { defineConfig, loadEnv } from "vite";
 import vue from "@vitejs/plugin-vue";
 import path from "node:path";
-import { createHtmlPlugin } from 'vite-plugin-html';  
-import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
-import { version } from './package.json'
+import { createHtmlPlugin } from "vite-plugin-html";
+import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
+import { version } from "./package.json";
 
 // https://vite.dev/config/
 export default ({ mode }: any) => {
-	const env = loadEnv(mode, process.cwd())
+  const env = loadEnv(mode, process.cwd());
 
-  let proxy: any = {}
+  let proxy: any = {};
   if (env.VITE_MOCK_ENV) {
-	  const mockEnv = loadEnv(env.VITE_MOCK_ENV, process.cwd())
+    const mockEnv = loadEnv(env.VITE_MOCK_ENV, process.cwd());
+
     const getProxy = (prev: string, api: string) => ({
       target: api,
       changeOrigin: true,
-      rewrite: (path: any) => path.replace(prev, '')
-    })
+      rewrite: (path: any) => path.replace(prev, ""),
+    });
 
-    for (const key in env) {
-      if (env[key].includes('/') && env[key] !== mockEnv[key]) {
-        proxy[env[key]]= getProxy(env[key], mockEnv[key])
+    if (env.VITE_MOCK_PROXY) {
+      proxy[env.VITE_MOCK_PROXY] = getProxy(
+        env.VITE_MOCK_PROXY,
+        mockEnv.VITE_MOCK_PROXY
+      );
+    } else {
+      for (const key in env) {
+        if (env[key].includes("/") && env[key] !== mockEnv[key]) {
+          proxy[env[key]] = getProxy(env[key], mockEnv[key]);
+        }
       }
     }
   }
-  console.log(proxy)
+  console.log(proxy);
 
   return defineConfig({
-    base: './',
+    base: "./",
     resolve: {
       alias: {
         "@/": `${path.resolve(__dirname, "src")}/`,
@@ -57,22 +65,22 @@ export default ({ mode }: any) => {
     },
     plugins: [
       createSvgIconsPlugin({
-        iconDirs: [path.resolve(process.cwd(), 'public/icons')],
-        symbolId: 'icon-[dir]-[name]'
+        iconDirs: [path.resolve(process.cwd(), "public/icons")],
+        symbolId: "icon-[dir]-[name]",
       }),
-      createHtmlPlugin({  
-        template: 'index.html',
-        entry: path.resolve('src', env.VITE_ENTRY),
+      createHtmlPlugin({
+        template: "index.html",
+        entry: path.resolve("src", env.VITE_ENTRY),
         inject: {
           data: {
             title: env.VITE_TITLE,
           },
-        }
-      }),  
-      vue()
+        },
+      }),
+      vue(),
     ],
     define: {
-      __VERSION__: JSON.stringify(version)
-    }
+      __VERSION__: JSON.stringify(version),
+    },
   });
 };