bill 8 months ago
parent
commit
93cc6e0dc7
7 changed files with 36 additions and 14 deletions
  1. 4 0
      .offline.env
  2. 2 2
      src/api/offline.ts
  3. 1 2
      src/api/setup.ts
  4. 7 6
      src/model/app.vue
  5. 4 3
      src/model/platform.ts
  6. 1 0
      src/sdk/sdk.ts
  7. 17 1
      src/views/guide/path/edit-path.vue

+ 4 - 0
.offline.env

@@ -0,0 +1,4 @@
+VITE_LASER_HOST=
+VITE_LASER_OSS=/laser-data
+VITE_PANO_OSS=/laser-data
+

+ 2 - 2
src/api/offline.ts

@@ -4,10 +4,10 @@ import { AxiosInstance } from "axios";
 import {namespace} from '@/env'
 import Axios from 'axios'
 
+export const offlinePrev = import.meta.env.DEV ? '__offline/' : ''
 export const setOfflineAxios = (axios: AxiosInstance) => {
   const data: {[key in string]: any} = {}
-  const prev = import.meta.env.DEV ? '__offline/' : ''
-  Axios.get(`./${prev}package/data.json`, {headers: { Accept: "application/json"}}).then(res => {
+  Axios.get(`./${offlinePrev}package/data.json`, {headers: { Accept: "application/json"}}).then(res => {
     Object.assign(data, res.data)
     ;(window as any).offlineData = data
   })

+ 1 - 2
src/api/setup.ts

@@ -133,8 +133,7 @@ export const axiosFactory = () => {
 
       if (!matchURL(axiosConfig.unTokenSet, config)) {
         if (!axiosConfig.token) {
-          if (!matchURL(axiosConfig.unReqErrorSet, config)) {
-            console.log(config.url)
+          if (!offline && !matchURL(axiosConfig.unReqErrorSet, config)) {
             const error = new Error('缺少token')
             callErrorHandler('req', error, config)
             throw error

+ 7 - 6
src/model/app.vue

@@ -14,6 +14,7 @@ import { params } from "@/env";
 import { fuseModel, modelProps } from "./index";
 import { modelSDKFactory } from "./platform";
 import { getToken } from "@/api";
+import { offlinePrev } from "@/api/offline";
 
 const typeChange = () => {
   const oldType = modelProps.type;
@@ -61,13 +62,13 @@ export const Model = defineComponent({
       const type = scene.value.type;
       const urls = offline
         ? {
-            [SceneType.SWKK]: `/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
-            [SceneType.SWKJ]: `/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
-            [SceneType.SWSS]: `/swss/${scene.value.num}/www/offline.html?m=${scene.value.num}&lang=zh`,
-            [SceneType.SWSSMX]: `/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
+            [SceneType.SWKK]: `${offlinePrev}/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
+            [SceneType.SWKJ]: `${offlinePrev}/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
+            [SceneType.SWSS]: `${offlinePrev}/swss/${scene.value.num}/www/offline.html?m=${scene.value.num}&lang=zh`,
+            [SceneType.SWSSMX]: `${offlinePrev}/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
             [SceneType.SWMX]: `offline.html?caseId=${params.caseId}&modelId=${scene.value.num}&share=1#sign-model`,
-            [SceneType.SWYDSS]: `/swss/${scene.value.num}/www/offline.html?m=${scene.value.num}&lang=zh`,
-            [SceneType.SWYDMX]: `/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
+            [SceneType.SWYDSS]: `${offlinePrev}/swss/${scene.value.num}/www/offline.html?m=${scene.value.num}&lang=zh`,
+            [SceneType.SWYDMX]: `${offlinePrev}/swkk/${scene.value.num}/wwwroot/spg.html?m=${scene.value.num}&lang=zh`,
           }
         : {
             [SceneType.SWKK]: `/swkk/spg.html?m=${scene.value.num}`,

+ 4 - 3
src/model/platform.ts

@@ -19,6 +19,7 @@ import { asyncTimeout } from "@/utils";
 import { aMapToWgs84 } from "@/utils/coord";
 
 import type { ModelType } from "./";
+import { offlinePrev } from "@/api/offline";
 
 export async function modelSDKFactory(
   type: ModelType,
@@ -38,9 +39,9 @@ export async function modelSDKFactory(
   if (type === fuseModel) {
     if (!fuseInitialed) {
       await initialSDK({
-        laserRoot: import.meta.env.VITE_LASER_HOST,
-        panoOSSRoot: import.meta.env.VITE_PANO_OSS,
-        laserOSSRoot: import.meta.env.VITE_LASER_OSS,
+        laserRoot: offline ? offlinePrev : import.meta.env.VITE_LASER_HOST,
+        panoOSSRoot: offline ? offlinePrev : import.meta.env.VITE_PANO_OSS,
+        laserOSSRoot: offline ? offlinePrev : import.meta.env.VITE_LASER_OSS,
         layout: dom,
         scenes: scenes.value,
         lonlat: center,

+ 1 - 0
src/sdk/sdk.ts

@@ -257,6 +257,7 @@ export type Path = {
   pause: () => void
   // 是否可编辑
   changeCanEdit: (canMove: boolean) => void
+  deletePoint: (index: number) => void
   changeEditMode: (editMode: boolean) => void
   // 可见性
   visibility: (visibility: boolean) => void

+ 17 - 1
src/views/guide/path/edit-path.vue

@@ -14,7 +14,9 @@
             <ui-input
               width="100%"
               type="text"
+              ref="nameInput"
               placeholder="路径名称"
+              @keydown="keydownHandler"
               v-model="data.name"
               :maxlength="60"
             />
@@ -185,6 +187,20 @@ onUnmounted(() => {
   console.error("unmounte");
   unKeepAdding.value && unKeepAdding.value();
 });
+const nameInput = ref();
+watchEffect((onCleanup) => {
+  document.documentElement.addEventListener("keydown", keydownHandler);
+  onCleanup(() =>
+    document.documentElement.removeEventListener("keydown", keydownHandler)
+  );
+});
+const keydownHandler = (event: KeyboardEvent) => {
+  if (event.key === "z" && (event.ctrlKey || event.composed)) {
+    console.log("组织");
+    // 阻止默认的撤销行为
+    event.preventDefault();
+  }
+};
 
 const node = computed(() => getPathNode(props.data.id));
 watch(
@@ -214,7 +230,7 @@ watchEffect((onCleanup) => {
 });
 
 const deletePoint = () => {
-  props.data.points.splice(activePointNdx.value, 1);
+  node.value?.deletePoint(activePointNdx.value);
   activePointNdx.value = -1;
 };