Browse Source

fix: 更改登录环境,请求流程优化

bill 3 tháng trước cách đây
mục cha
commit
423f831501

+ 2 - 2
.env.development

@@ -1,4 +1,4 @@
 VITE_PRIMARY='#109BE0'
 VITE_TITLE='绘图'
-VITE_ENTRY='./mock.ts'
-VITE_ENTRY_EXAMPLE='./example/fuse/main.ts'
+VITE_ENTRY='./example/fuse/enter.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'

+ 12 - 0
.env.fuse

@@ -0,0 +1,12 @@
+VITE_PRIMARY='#D8000A'
+VITE_TITLE='绘图'
+VITE_ENTRY='./mock.ts'
+VITE_ENTRY_EXAMPLE='./example/fuse/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'

+ 13 - 0
.env.fusedev

@@ -0,0 +1,13 @@
+VITE_PRIMARY='#109BE0'
+VITE_TITLE='绘图'
+VITE_ENTRY='./example/fuse/enter.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'
+VITE_MOCK_ENV=fusetest
+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'

+ 12 - 0
.env.fusetest

@@ -0,0 +1,12 @@
+VITE_PRIMARY='#D8000A'
+VITE_TITLE='绘图'
+VITE_ENTRY='./mock.ts'
+VITE_ENTRY_EXAMPLE='./example/fuse/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'

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
   "version": "0.0.0",
   "type": "module",
   "scripts": {
-    "dev": "vite",
+    "dev:fuse": "vite --mode=fusedev",
     "build": "vue-tsc -b && vite build",
     "preview": "vite preview"
   },

+ 1 - 0
src/core/components/line/single-line.vue

@@ -110,6 +110,7 @@ const points = computed(() => [
 ]);
 const lineData = computed(() => props.line);
 const describes = mergeDescribes(lineData, {}, ["stroke", "strokeWidth"]);
+(describes.strokeWidth.props as any).proportion = true;
 const delHandler = () => {
   emit("updateBefore");
   emit("delLine");

+ 0 - 1
src/core/components/line/temp-line.vue

@@ -47,7 +47,6 @@ let ctx: NLineDataCtx;
 const updateBeforeHandler = () => {
   track = true;
   ctx = getInitCtx();
-  console.log("??");
 };
 
 const delPointHandler = (p: LineData["points"][0]) => {

+ 1 - 1
src/example/env.ts

@@ -1,6 +1,6 @@
 const urlParams = new URLSearchParams(location.search);
 
-export const params = {} as { id: string };
+export const params: Record<string, string> = {};
 
 for (const [name, value] of urlParams.entries()) {
   (params as any)[name] = value

+ 167 - 107
src/example/fuse/enter.ts

@@ -1,5 +1,9 @@
 import type { TabCover } from "./store";
-import type { Scene } from "../platform/platform-resource";
+import type { Scene } from "../../example/platform/platform-resource";
+import type { StoreData } from "@/core/store/store";
+import { params } from "../env";
+import { genLoading } from "../loadding";
+import { tempStrFill } from "@/utils/shared";
 
 const SCENE_TYPE = {
   fuse: "fuse",
@@ -7,127 +11,182 @@ const SCENE_TYPE = {
   cloud: "cloud",
 } as const;
 
-const getSceneList = async (): Promise<Scene[]> => [
-  {
-    m: 'SG-t-KclpWad2dW5',
-    title: "有AI",
-    id: onlyId(),
-    type: SCENE_TYPE.mesh,
-
-  },
-  {
-    m: "SG-t-jvab1SlVA1r",
-    title: "多楼层",
-    id: onlyId(),
-    type: SCENE_TYPE.mesh,
-  },
-  {
-    m: "SG-t-N6no657Kuze",
-    title: "单楼层",
-    id: onlyId(),
-    type: SCENE_TYPE.mesh,
-  },
-  {
-    m: "SS-t-hiNBZjf5EK8",
-    title: "庙堂火灾",
-    id: onlyId(),
-    type: SCENE_TYPE.mesh,
-  },
-  {
-    m: "SS-t-2tWYj9q5whZ",
-    title: "车行",
-    id: onlyId(),
-    type: SCENE_TYPE.mesh,
-  },
-  {
-    m: "SS-t-qnGLxHvngli",
-    title: "商品房",
-    id: onlyId(),
-    type: SCENE_TYPE.mesh,
-  },
-  {
-    m: "SG-t-lDhbbylq4sf",
-    title: "多楼层17.30",
-    id: onlyId(),
-    type: SCENE_TYPE.mesh,
-  },
-] as Scene[]
+const resourceURLS = {
+  oss: import.meta.env.VITE_MESH_OSS,
+  [SCENE_TYPE.mesh]: import.meta.env.VITE_MESH_API,
+  [SCENE_TYPE.cloud]: import.meta.env.VITE_CLOUD_API,
+  [SCENE_TYPE.fuse]: import.meta.env.VITE_FUSE_API,
+};
 
 const viewURLS = {
-  [SCENE_TYPE.mesh]: "https://test.4dkankan.com/spg.html?m={m}&lang=zh",
-  [SCENE_TYPE.cloud]:
-    "https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh",
-  [SCENE_TYPE.fuse]:
-    "https://test-mix3d.4dkankan.com/code/index.html?caseId={m}&app=1&share=1#/show/summary",
+  [SCENE_TYPE.mesh]: import.meta.env.VITE_MESH_VIEW,
+  [SCENE_TYPE.cloud]: import.meta.env.VITE_CLOUD_VIEW,
+  [SCENE_TYPE.fuse]: import.meta.env.VITE_FUSE_VIEW,
 };
 
-const resourceURLS = {
-  oss: "/meshOSS",
-  [SCENE_TYPE.mesh]: "/meshAPI",
-  [SCENE_TYPE.cloud]: "/cloudAPI",
-  [SCENE_TYPE.fuse]: "/fuseAPI",
+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 } }));
 };
 
-import type { StoreData } from "@/core/store/store";
-import { onlyId } from "../../utils/shared";
-
-const getOverviewData = async () => {
-  const storeStr = localStorage.getItem("draw-data");
-  const store = (storeStr ? JSON.parse(storeStr) : {}) as StoreData;
-
-  const vportStr = localStorage.getItem("view-port");
-  const vport = (vportStr ? JSON.parse(vportStr) : null) as number[] | null;
-
-  return {
-    store,
-    viewport: vport,
-  };
+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" },
+      method: "post",
+      body: JSON.stringify(data),
+    })
+  );
 };
 
-const saveOverviewData = async (data: {
-  store: StoreData;
-  viewport: number[] | null;
-}) => {
-  localStorage.setItem("draw-data", JSON.stringify(data.store));
-  localStorage.setItem("view-port", JSON.stringify(data.viewport));
+const postFile = (url: string, data: Record<string, any>) => {
+  const formData = new FormData();
+  for (const key in data) {
+    formData.append(key, data[key]);
+  }
+
+  const l = `${resourceURLS[SCENE_TYPE.fuse]}${url}`;
+  return after(
+    fetch(l, {
+      headers: { token },
+      method: "post",
+      body: formData,
+    })
+  );
 };
 
-const getTabulationData = async () => {
-  const storeStr = localStorage.getItem("tab-draw-data");
-  const store = (storeStr ? JSON.parse(storeStr) : {}) as StoreData;
-
-  const vportStr = localStorage.getItem("tab-view-port");
-  const vport = (vportStr ? JSON.parse(vportStr) : null) as number[] | null;
-
-  const paperKeyStr = localStorage.getItem("tab-paper-key");
-  const paperKey = paperKeyStr ? JSON.parse(paperKeyStr) : "a4";
-
-  return {
-    store,
-    cover: tabCover,
-    paperKey,
-    viewport: vport,
-  };
+const login = () => {
+  if (import.meta.env.VITE_LOGIN_VIEW) {
+    setTimeout(() => {
+      location.replace(
+        tempStrFill(import.meta.env.VITE_LOGIN_VIEW, {
+          redirect: escape(location.href),
+        })
+      );
+    }, 3000);
+  }
 };
 
-const saveTabulationData = async (data: {
-  store: StoreData;
-  viewport: number[] | null;
-  paperKey?: string;
-}) => {
-  localStorage.setItem("tab-draw-data", JSON.stringify(data.store));
-  localStorage.setItem("tab-view-port", JSON.stringify(data.viewport));
-  localStorage.setItem("tab-paper-key", JSON.stringify(data.paperKey));
+const after = async (fet: Promise<Response>) => {
+  const res = await fet.then((res) => res.json());
+  if (res.code === 4008) {
+    login();
+    throw res.message;
+  } else if (res.code !== 0) {
+    throw res.message;
+  } else {
+    return res.data;
+  }
 };
 
-let tabCover: TabCover | null = null;
-const saveTabulationCover = async (data: TabCover) => {
-  tabCover = data;
+const token = params.token;
+const getSceneList = genLoading(async (keyword: string): Promise<Scene[]> => {
+  const list = await post(`fusion/case/sceneListPost`, {
+    caseId: params.caseId,
+    isMesh: 1,
+    sceneName: keyword,
+  });
+  return list.map((item: any) => ({
+    type: SCENE_TYPE.mesh,
+    m: item.num,
+    title: item.name,
+    id: item.id.toString(),
+  }));
+});
+
+const getOverviewData = genLoading(async (id: string) => {
+  if (!id) {
+    return {
+      store: {},
+      viewport: null,
+    };
+  }
+  const data = await get("fusion/caseOverview/info", { overviewId: id });
+  return {
+    store: JSON.parse(data.store),
+    viewport: JSON.parse(data.viewport),
+  };
+});
+
+const saveOverviewData = genLoading(
+  async (
+    id: string,
+    data: {
+      store: StoreData;
+      viewport: number[] | null;
+    }
+  ) => {
+    const item = await post(`fusion/caseOverview/addOrUpdate`, {
+      ...params,
+      id,
+      store: JSON.stringify(data.store),
+      viewport: JSON.stringify(data.viewport),
+    });
+    return item.id;
+  }
+);
+
+const getTabulationId = async (id: string) => {
+  const list = await get("fusion/caseTabulation/getByOverviewId", {
+    overviewId: id,
+  });
+  return list[0]?.id;
 };
 
-const uploadResourse = async (file: File) => {
-  return URL.createObjectURL(file);
-};
+const getTabulationData = genLoading(async (id: string) => {
+  if (!id) {
+    return {
+      store: {},
+      cover: null,
+      isAutoGen: true,
+      viewport: null,
+      paperKey: "a4",
+    };
+  }
+  const data = await get(`fusion/caseTabulation/info`, { tabulationId: id });
+  return {
+    store: JSON.parse(data.store),
+    viewport: JSON.parse(data.viewport),
+    cover: JSON.parse(data.cover),
+    isAutoGen: Number(data.isAutoGen),
+    paperKey: data.paperKey,
+  };
+});
+
+const saveTabulationData = genLoading(
+  async (
+    id: string,
+    data: {
+      store: StoreData;
+      viewport: number[] | null;
+      isAutoGen: boolean;
+      cover: TabCover | null;
+      paperKey?: string;
+      overviewId: string;
+    }
+  ) => {
+    const item = await post("fusion/caseTabulation/addOrUpdate", {
+      ...params,
+      id,
+      store: JSON.stringify(data.store),
+      viewport: JSON.stringify(data.viewport),
+      cover: JSON.stringify(data.cover),
+      isAutoGen: Number(data.isAutoGen),
+      paperKey: data.paperKey,
+      overviewId: data.overviewId,
+    });
+    return item.id;
+  }
+);
+
+const uploadResourse = genLoading(async (file: File) => {
+  return postFile(`fusion/upload/file`, { file });
+});
 
 window.platform = {
   resourceURLS,
@@ -137,8 +196,9 @@ window.platform = {
   saveOverviewData,
   getTabulationData,
   saveTabulationData,
-  saveTabulationCover,
   uploadResourse,
+  getTabulationId,
 };
+
 /* @vite-ignore */
 import(import.meta.env.VITE_ENTRY_EXAMPLE);

+ 49 - 3
src/example/fuse/router.ts

@@ -1,18 +1,64 @@
 import { createRouter, createWebHashHistory } from "vue-router";
 
+
 import Overview from "./views/overview/index.vue";
 import OverviewQuery from "./views/overview/query.vue";
 import Tabulation from "./views/tabulation/index.vue";
 import QueryTabulation from "./views/tabulation/query.vue";
+import { computed, ref, watch, watchEffect } from "vue";
+import { inRevise } from "@/utils/shared";
 
 export const history = createWebHashHistory();
 export const router = createRouter({
   history,
   routes: [
     { path: "/overview", name: "overview", component: Overview },
-    { path: "/query/overview", name: "query-overview", component: OverviewQuery },
+    // { path: "/query/overview", name: "query-overview", component: OverviewQuery },
     { path: "/tabulation", name: "tabulation", component: Tabulation },
-    { path: "/query/tabulation", name: "query-tabulation", component: QueryTabulation },
-    { path: '/:pathMatch(.*)*',  redirect: '/query/overview' } 
+    // { path: "/query/tabulation", name: "query-tabulation", component: QueryTabulation },
+    { path: '/:pathMatch(.*)*',  redirect: '/overview' } 
   ],
 });
+
+const params = ref<Record<string, string | undefined>>({})
+const updateParams = () => {
+  const hash = location.hash
+  const ndx = hash.indexOf('?')
+  const sParams = new URLSearchParams(hash.substring(ndx));
+  const rParams: Record<string, string | undefined> = {};
+  [...sParams.entries()].forEach(item => {
+    rParams[item[0]] = item[1]
+  })
+  if (inRevise(rParams, params.value)) {
+    params.value = rParams
+  }
+}
+watch(params, () => {
+  const sParams = new URLSearchParams();
+  for (const key in params.value) {
+    params.value[key] && sParams.append(key, params.value[key])
+  }
+  const ndx = location.hash.indexOf('?')
+  location.replace(location.hash.substring(0, ~ndx ? ndx : undefined) + '?' + sParams.toString())
+}, {deep: true})
+
+updateParams()
+window.addEventListener('hashchange', updateParams)
+
+export const tabulationId = computed({
+  get() {
+    return params.value.tabulationId
+  },
+  set(tabulationId: string) {
+    params.value.tabulationId = tabulationId
+  }
+})
+
+export const overviewId = computed({
+  get() {
+    return params.value.overviewId
+  },
+  set(overviewId: string) {
+    params.value.overviewId = overviewId
+  }
+})

+ 4 - 2
src/example/fuse/store.ts

@@ -1,6 +1,7 @@
 import { Ref, ref } from "vue";
 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'
@@ -24,15 +25,16 @@ export const overviewData = ref() as Ref<{
   viewport: number[] | null;
 }>
 export const refreshOverviewData = () => {
-  return window.platform.getOverviewData().then((data: any) => overviewData.value = data)
+  return window.platform.getOverviewData(overviewId.value).then((data: any) => overviewData.value = data)
 }
 
 export const tabulationData = ref() as Ref<{
   store: StoreData;
   cover: TabCover | null;
   paperKey: PaperKey;
+  isAutoGen: boolean
   viewport: number[] | null;
 }>
 export const refreshTabulationData = () => {
-  return window.platform.getTabulationData().then((data: any) => tabulationData.value = data)
+  return window.platform.getTabulationData(tabulationId.value).then((data: any) => tabulationData.value = data)
 }

+ 13 - 10
src/example/fuse/views/overview/header.vue

@@ -18,8 +18,6 @@ import { useDraw } from "../../../components/container/use-draw.ts";
 import { selectScene } from "../../../dialog/vr/index.ts";
 import { Scene } from "../../../platform/platform-resource.ts";
 import { getHeaderActions, getImage } from "../../../components/header/actions.ts";
-import { router } from "../../router.ts";
-import { params } from "@/example/env.ts";
 import {
   tabulationData,
   refreshTabulationData,
@@ -32,6 +30,7 @@ import { Group } from "konva/lib/Group";
 import { Mode } from "@/constant/mode.ts";
 import { lineLen } from "@/utils/math.ts";
 import { repTabulationStore } from "../tabulation/gen-tab.ts";
+import { overviewId, router, tabulationId } from "../../router.ts";
 
 const draw = useDraw();
 
@@ -120,19 +119,20 @@ const saveHandler = async () => {
     const scale =
       lineLen(mat.point({ x: 1, y: 0 }), mat.point({ x: 0, y: 0 })) *
       draw.store.config.proportion.scale;
-    console.log(scale);
+
     const blob = await getImage(draw, "image/png");
     recover();
     await nextTick();
     return [blob, scale, rect] as const;
   });
 
-  await window.platform.saveOverviewData({
+  overviewId.value = await window.platform.saveOverviewData(overviewId.value, {
     store: storeData,
     viewport: draw!.viewer.transform.m,
   });
+
   const url = await window.platform.uploadResourse(
-    new File([blob], `tabulation-cover-${params.id}.png`)
+    new File([blob], `tabulation-cover.png`)
   );
   const cover = {
     url,
@@ -141,23 +141,26 @@ const saveHandler = async () => {
     proportion: { ...draw.store.config.proportion, scale },
   };
 
-  await window.platform.saveTabulationCover(cover);
+  tabulationId.value = await window.platform.getTabulationId(overviewId.value);
+  console.error(tabulationId.value);
   await refreshTabulationData();
-
   const tabStore = await repTabulationStore(
     tabulationData.value.paperKey,
     cover,
-    tabulationData.value.store
+    tabulationData.value.isAutoGen ? undefined : tabulationData.value.store
   );
+
   tabStore.config.compass = storeData.config.compass;
-  await window.platform.saveTabulationData({
+  tabulationId.value = await window.platform.saveTabulationData(tabulationId.value, {
     ...tabulationData.value,
+    cover,
     store: tabStore,
+    overviewId: overviewId.value,
   });
 };
 
 const gotoTabulation = async () => {
   await saveHandler();
-  router.push({ name: "tabulation" });
+  router.push({ ...router.currentRoute.value, name: "tabulation" } as any);
 };
 </script>

+ 1 - 0
src/example/fuse/views/tabulation/header.vue

@@ -106,6 +106,7 @@ const saveHandler = () => {
     store: draw!.getData(),
     viewport: draw!.viewer.transform.m,
     paperKey: tabulationData.value.paperKey,
+    isAutoGen: tabulationData.value.isAutoGen && !draw.history.hasUndo.value,
   });
 };
 </script>

+ 47 - 0
src/example/loadding.ts

@@ -0,0 +1,47 @@
+import { onlyId } from "@/utils/shared";
+import { ElLoading, ElMessage } from "element-plus";
+import { ref, watchEffect } from "vue";
+
+type PFN<T> = (...args: any) => Promise<T>;
+type Options = Parameters<typeof ElLoading.service>[0];
+
+export const genLoading = <T, K extends PFN<T>>(fn: K, options?: Options): K =>
+  ((...args) => loading(() => fn(...args), options)) as K;
+
+const loadingStack = ref<Array<Options | undefined>>([])
+const tokens: string[] = []
+let instance: ReturnType<typeof ElLoading.service> | null = null;
+watchEffect(() => {
+  console.log(loadingStack.value)
+  if (!loadingStack.value.length && instance) {
+    instance.close()
+    instance = null
+  }
+  if (loadingStack.value.length && !instance) {
+    instance = ElLoading.service(loadingStack.value[0])
+  }
+})
+
+export const loading = <T, K extends PFN<T>>(
+  fn: K | Promise<T>,
+  options?: Options
+): Promise<T> => {
+  loadingStack.value.push(options as any)
+  const token = onlyId()
+  tokens.push(token)
+
+  const ret = typeof fn === "function" ? fn() : fn;
+  ret
+    .catch((e) => {
+      ElMessage({ type: "error", message: e });
+      throw e;
+    })
+    .finally(() => {
+      setTimeout(() => {
+        const ndx = tokens.indexOf(token)
+        loadingStack.value.splice(ndx, 1)
+        tokens.splice(ndx, 1)
+      }, 50)
+    });
+  return ret;
+};

+ 9 - 1
src/mock.ts

@@ -52,7 +52,6 @@ const getSceneList = async (): Promise<Scene[]> => [
     type: SCENE_TYPE.mesh,
   },
 ] as Scene[]
-
 const viewURLS = {
   [SCENE_TYPE.mesh]: "https://test.4dkankan.com/spg.html?m={m}&lang=zh",
   [SCENE_TYPE.cloud]:
@@ -102,10 +101,16 @@ const getTabulationData = async () => {
   const paperKeyStr = localStorage.getItem("tab-paper-key");
   const paperKey = paperKeyStr ? JSON.parse(paperKeyStr) : "a4";
 
+  const isAutoGenStr = localStorage.getItem("tab-auto-gen");
+  const isAutoGen = isAutoGenStr ? JSON.parse(isAutoGenStr) : true;
+
+  
+
   return {
     store,
     cover: tabCover,
     paperKey,
+    isAutoGen,
     viewport: vport,
   };
 };
@@ -113,11 +118,14 @@ const getTabulationData = async () => {
 const saveTabulationData = async (data: {
   store: StoreData;
   viewport: number[] | null;
+  isAutoGen: boolean,
   paperKey?: string;
 }) => {
+  console.error('???', data)
   localStorage.setItem("tab-draw-data", JSON.stringify(data.store));
   localStorage.setItem("tab-view-port", JSON.stringify(data.viewport));
   localStorage.setItem("tab-paper-key", JSON.stringify(data.paperKey));
+  localStorage.setItem("tab-auto-gen", JSON.stringify(data.isAutoGen));
 };
 
 let tabCover: TabCover | null = null;

+ 8 - 7
vite.config.ts

@@ -9,21 +9,22 @@ import { version } from './package.json'
 export default ({ mode }: any) => {
 	const env = loadEnv(mode, process.cwd())
 
-  let proxy
-  if (mode === 'development') {
+  let proxy: any = {}
+  if (env.VITE_MOCK_ENV) {
+	  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, '')
     })
 
-    proxy = {
-      ['/meshOSS']: getProxy('/meshOSS', 'https://4dkk.4dage.com/'),
-      ['/meshAPI']: getProxy('/meshAPI', 'https://test.4dkankan.com/'),
-      ['/cloudAPI']: getProxy('/cloudAPI', 'https://uat-laser.4dkankan.com/'),
-      ['/fuseAPI']: getProxy('/fuseAPI', 'https://test-mix3d.4dkankan.com/'),
+    for (const key in env) {
+      if (env[key].includes('/') && env[key] !== mockEnv[key]) {
+        proxy[env[key]]= getProxy(env[key], mockEnv[key])
+      }
     }
   }
+  console.log(proxy)
 
   return defineConfig({
     resolve: {