bill пре 8 месеци
родитељ
комит
4fdfd1d09e
3 измењених фајлова са 17 додато и 20 уклоњено
  1. 4 1
      src/components/path/list.vue
  2. 13 18
      src/sdk/association/path.ts
  3. 0 1
      src/views/guide/path/sign.vue

+ 4 - 1
src/components/path/list.vue

@@ -5,7 +5,7 @@
       @delete="deletePath(path)"
       @updatePoints="(data) => updatePosition(index, data)"
       @updateLinePosition="(data) => updateLinePosition(index, data)"
-      :ref="(node: any) => nodes[index] = ({ node, id: path.id })"
+      :ref="(node: any) => nodeHandler(index, node)"
       :path="path"
       :key="path.id"
     />
@@ -36,6 +36,9 @@ const updateLinePosition = (ndx: number, linePosition: Path["linePosition"]) =>
     props.paths[ndx].linePosition = linePosition;
   }
 };
+const nodeHandler = (index: number, node: any) => {
+  nodes[index] = { node, id: props.paths[index].id };
+};
 
 defineExpose(nodes);
 </script>

+ 13 - 18
src/sdk/association/path.ts

@@ -2,7 +2,7 @@ import { diffArrayChange, mount, shallowWatchArray } from "@/utils";
 import TaggingComponent from "@/components/path/list.vue";
 import { Path as PathData, paths } from "@/store/path";
 import { sdk, Path, SDK } from "../sdk";
-import { reactive, ref, watch, watchEffect } from "vue";
+import { nextTick, reactive, ref, watch, watchEffect } from "vue";
 import { groupProxy } from "@/store/group";
 import { isScenePlayRun, pauseScene, playScene } from "@/utils/full";
 import { analysisPose, setPose } from ".";
@@ -50,7 +50,10 @@ export const playScenePath = async (
   forceFull = false,
 ) => {
   const node = getPathNode(path)
-  if (!node) return Message.error('路径所在模型被删除,无法播放');;
+  if (!node) {
+    console.error('un', path.id)
+    return Message.error('路径所在模型被删除,无法播放');
+  }
 
   showPathsStack.push(ref(false))
   showPathStack.push(ref(path.id))
@@ -87,22 +90,14 @@ export const associationPaths = (sdk: SDK, el: HTMLDivElement) => {
         return pathsNode
       },
       (nodes, oldNodes = []) => {
-        const { added, deleted } = diffArrayChange<PathsNode>(
-          nodes,
-          oldNodes as PathsNode
-        );
-        for (const add of added) {
-          if (add) {
-            const path = paths.value.find((item) => item.id === add.id)!;
-            pathNodes.set(path, add.node);
-          }
-        }
-        for (const del of deleted) {
-          if (del) {
-            const path = paths.value.find((item) => item.id === del.id)!;
-            pathNodes.delete(path);
-          }
-        }
+        watchEffect(() => {
+          pathNodes.clear()
+          nodes.forEach(node => {
+            const path = paths.value.find((item) => item.id === node.id)!;
+            pathNodes.set(path, node.node);
+          })
+        })
+        console.error(pathNodes)
       },
       {immediate: true}
     );

+ 0 - 1
src/views/guide/path/sign.vue

@@ -86,7 +86,6 @@ const leaveHandler = () => {
 
 const enterHandler = () => {
   hover.value = true;
-  console.log("enter");
   node.value?.highlight && node.value?.highlight(true);
 };