瀏覽代碼

fix: 导览支持配置

bill 5 月之前
父節點
當前提交
7afb5d2c1d
共有 4 個文件被更改,包括 46 次插入20 次删除
  1. 4 2
      src/components/drawing/hook.ts
  2. 10 4
      src/sdk/association/guide.ts
  3. 30 12
      src/views/guide/guide/edit-paths.vue
  4. 2 2
      src/views/guide/guide/sign.vue

+ 4 - 2
src/components/drawing/hook.ts

@@ -47,7 +47,8 @@ export const installGlobalVar = <T>(
     if (!(key in instance)) {
       let val = create() as any;
       if (typeof val === "object" && "var" in val && "onDestroy" in val) {
-        val.onDestory && unmounteds.push(val.onDestory);
+        console.error('val.onDestory', val, key, val.onDestroy)
+        val.onDestroy && unmounteds.push(val.onDestroy);
         if (import.meta.env.DEV) {
           unmounteds.push(() => {
             console.log("销毁变量", key);
@@ -217,7 +218,8 @@ export const useGlobalResize = installGlobalVar(() => {
       fix,
     },
     onDestroy: () => {
-      fix || unResize();
+      console.error('size onDest')
+      unResize();
       unWatch && unWatch();
     },
   };

+ 10 - 4
src/sdk/association/guide.ts

@@ -1,6 +1,6 @@
 import { SceneGuide, sdk } from "../sdk";
-import { toRaw, ref, watch, watchEffect } from "vue";
-import { viewModeStack, showLeftPanoStack, custom } from "@/env";
+import { toRaw, ref, watch, watchEffect, computed } from "vue";
+import { viewModeStack, showLeftPanoStack, custom, showTaggingsStack, showPathsStack, showMeasuresStack } from "@/env";
 import { togetherCallback, asyncTimeout } from "@/utils";
 import { fuseModels, isEdit, sysBus, fuseModelsLoaded } from "@/store";
 import type { FuseModel, FuseModels, Guide, GuidePath } from "@/store";
@@ -84,10 +84,16 @@ export const recovery = async (guide: Guide) => {
 export const playSceneGuide = (
   paths: GuidePath[],
   changeIndexCallback?: (index: number) => void,
-  forceFull = false
+  forceFull = false,
+  guide?: Guide
 ) => {
   let sceneGuide: SceneGuide;
   currentTime.value = 0
+  const pop = togetherCallback([
+    showTaggingsStack.push(computed(() => guide ? guide.showTagging : true)),
+    showPathsStack.push(computed(() => guide ? guide.showPath : true)),
+    showMeasuresStack.push(computed(() => guide ? guide.showMeasure : true)),
+  ])
   return playScene(
     {
       create: () => {
@@ -109,13 +115,13 @@ export const playSceneGuide = (
         );
       },
       pause: () => {
-        console.error("pause??");
         sceneGuide.pause();
         animationGroup && animationGroup.pause()
       },
       clear: () => {
         currentTime.value = 0
         sceneGuide.clear();
+        pop()
         sceneGuide.bus.off("changePoint");
       },
     },

+ 30 - 12
src/views/guide/guide/edit-paths.vue

@@ -18,7 +18,10 @@
     </div>
 
     <Dropdown placement="top">
-      <div class="show-setting strengthen"><span>显示设置</span> <DownOutlined /></div>
+      <div class="show-setting strengthen">
+        <span>显示设置</span>
+        <DownOutlined />
+      </div>
       <template #overlay>
         <Menu>
           <menu-item v-for="option in showOptions">
@@ -121,7 +124,7 @@ import {
 } from "@/store";
 import { Dialog } from "bill/index";
 import { useViewStack } from "@/hook";
-import { computed, nextTick, onUnmounted, ref, watch, watchEffect } from "vue";
+import { computed, nextTick, onUnmounted, Ref, ref, watch, watchEffect } from "vue";
 import {
   showRightPanoStack,
   showLeftCtrlPanoStack,
@@ -145,14 +148,24 @@ const paths = ref<GuidePaths>(getGuidePaths(props.data));
 const current = ref<GuidePath>(paths.value[0]);
 
 const showOptions = [
-  { text: "标签", key: "tagging" },
-  { text: "监控", key: "video" },
-  { text: "路径", key: "path" },
-  { text: "测量", key: "measure" },
+  { text: "标签", key: "showTagging" },
+  { text: "监控", key: "showVideo" },
+  { text: "路径", key: "showPath" },
+  { text: "测量", key: "showMeasure" },
 ];
 const show = useSelects(ref(showOptions.map((item) => ({ id: item.key }))));
+const showAttrib = showOptions.reduce((t, c) => {
+  t[c.key] = computed(() => show.include(c.key));
+  return t;
+}, {} as Record<string, Ref<boolean>>);
 show.all.value = true;
 
+watchEffect(() => {
+  for (const key in showAttrib) {
+    (props.data as any)[key] = showAttrib[key].value;
+  }
+});
+
 const updatePathInfo = (index: number, calcInfo: CalcPathProps[1]) => {
   const info = sdk.calcPathInfo(paths.value.slice(index, index + 2) as any, calcInfo);
   Object.assign(paths.value[index], info);
@@ -164,9 +177,9 @@ useViewStack(() => {
     showLeftCtrlPanoStack.push(ref(false)),
     showLeftPanoStack.push(ref(false)),
     showRightCtrlPanoStack.push(ref(false)),
-    showTaggingsStack.push(computed(() => show.include("tagging"))),
-    showPathsStack.push(computed(() => show.include("path"))),
-    showMeasuresStack.push(computed(() => show.include("measure"))),
+    showTaggingsStack.push(showAttrib.showTagging),
+    showPathsStack.push(showAttrib.showPath),
+    showMeasuresStack.push(showAttrib.showMeasure),
   ]);
 });
 
@@ -243,9 +256,14 @@ const play = async () => {
   } else {
     changeCurrent(paths.value[0]);
     await asyncTimeout(400);
-    playSceneGuide(paths.value, (index) => {
-      current.value = paths.value[index - 1];
-    });
+    playSceneGuide(
+      paths.value,
+      (index) => {
+        current.value = paths.value[index - 1];
+      },
+      false,
+      props.data
+    );
   }
 };
 

+ 2 - 2
src/views/guide/guide/sign.vue

@@ -7,7 +7,7 @@
           type="preview"
           class="icon"
           ctrl
-          @click="playSceneGuide(paths, undefined, true)"
+          @click="playSceneGuide(paths, undefined, true, guide)"
           v-if="paths.length"
         />
       </div>
@@ -114,7 +114,7 @@ const actions = {
 
     videoRecorder.off("*");
     videoRecorder.on("startRecord", () => {
-      playSceneGuide(paths.value, undefined, true);
+      playSceneGuide(paths.value, undefined, true, props.guide);
       stopWatch = watchEffect(() => {
         if (!isScenePlayIng.value) {
           videoRecorder.endRecord();