bill il y a 4 mois
Parent
commit
43f3732a5e

+ 52 - 44
src/components/actions/index.vue

@@ -1,9 +1,9 @@
 <template>
   <div class="actions">
-    <span 
-      v-for="(action, i) in items" 
-      :class="{active: equal(selected, action)}"
-      :key="action.key || i" 
+    <span
+      v-for="(action, i) in items"
+      :class="{ active: equal(selected, action) }"
+      :key="action.key || i"
       @click="clickHandler(action)"
     >
       <ui-icon :type="action.icon" class="icon" />
@@ -13,79 +13,87 @@
 </template>
 
 <script lang="ts" setup>
-import { useActive } from '@/hook';
-import { ref, toRaw, watchEffect, onBeforeUnmount, nextTick, watch } from 'vue'
+import { useActive } from "@/hook";
+import { ref, toRaw, watchEffect, onBeforeUnmount, nextTick, watch } from "vue";
 
-export type ActionsItem<T = any> = { 
-  icon: string, 
-  key?: T, 
-  text: string,
-  action?: () => (() => void) | void
-}
-export type ActionsProps = { items: ActionsItem[], current?: ActionsItem | null, single?: boolean, }
+export type ActionsItem<T = any> = {
+  icon: string;
+  key?: T;
+  text: string;
+  action?: () => (() => void) | void;
+};
+export type ActionsProps = {
+  items: ActionsItem[];
+  current?: ActionsItem | null;
+  single?: boolean;
+};
 
-const props = defineProps<ActionsProps>()
-const emit = defineEmits<{ (e: 'update:current', data: ActionsItem | null): void }>()
-const equal = (a: ActionsItem | null, b: ActionsItem | null) => toRaw(a) === toRaw(b)
-const selected = ref<ActionsItem | null>(null)
+const props = defineProps<ActionsProps>();
+const emit = defineEmits<{ (e: "update:current", data: ActionsItem | null): void }>();
+const equal = (a: ActionsItem | null, b: ActionsItem | null) => toRaw(a) === toRaw(b);
+const selected = ref<ActionsItem | null>(null);
 const clickHandler = (select: ActionsItem) => {
-  selected.value = equal(selected.value, select) ? null : select
-  emit('update:current', selected.value)
+  selected.value = equal(selected.value, select) ? null : select;
+  emit("update:current", selected.value);
+  console.log("update:current", selected.value);
   if (props.single) {
-    nextTick(() => selected.value && clickHandler(selected.value))
+    setTimeout(() => selected.value && clickHandler(selected.value), 16);
   }
-}
+};
+
+// watch(
+//   () => props.current,
+//   () => {
+//     if (!props.current && selected.value) {
+//       clickHandler(selected.value)
+//     }
+//   }
+// )
 
 watch(
-  () => props.current, 
-  () => {
-    if (!props.current && selected.value) {
-      clickHandler(selected.value)
+  selected,
+  (_n, _o, onCleanup) => {
+    if (selected.value?.action) {
+      const cleanup = selected.value.action();
+      cleanup && onCleanup(cleanup);
     }
-  }
-)
-
-watch(selected, (_n, _o, onCleanup) => {
-  if (selected.value?.action) {
-    const cleanup = selected.value.action()
-    cleanup && onCleanup(cleanup)
-  }
-}, { flush: 'sync' })
+  },
+  { flush: "sync" }
+);
 
 onBeforeUnmount(() => {
-  selected.value = null
-})
+  selected.value = null;
+});
 </script>
 
 <style lang="scss" scoped>
 .actions {
   display: flex;
   gap: 10px;
-  
+
   span {
     flex: 1;
     height: 34px;
-    background: rgba(255,255,255,0.1);
+    background: rgba(255, 255, 255, 0.1);
     border-radius: 4px 4px 4px 4px;
     opacity: 1;
     display: flex;
     align-items: center;
     justify-content: center;
-    color: rgba(255,255,255,0.6);
+    color: rgba(255, 255, 255, 0.6);
     font-size: 14px;
     cursor: pointer;
-    transition: all .3s ease;
+    transition: all 0.3s ease;
 
     .icon {
       margin-right: 4px;
     }
 
-
     &:hover,
     &.active {
-      background: rgba(0,200,175,0.16);
-      color: #00C8AF;
+      background: rgba(0, 200, 175, 0.16);
+      color: #00c8af;
     }
   }
 }
-</style>
+</style>

+ 1 - 1
src/hook/use-fly.ts

@@ -64,7 +64,7 @@ export const flyTaggingPosition = (position: TaggingPosition) => {
       isFlyToTag: true,
       focusPos: getTaggingPosNode(position)!.getImageCenter(),
       ...position.pose
-    } as any);
+    } as any, sdk, false);
   } else {
     sdk.comeTo({
       position: getTaggingPosNode(position)!.getImageCenter(),

+ 6 - 0
src/layout/model-list/index.vue

@@ -55,6 +55,12 @@ import { currentModel, fuseModel, loadModel } from "@/model";
 import { flyModel } from "@/hook/use-fly";
 import { sdk } from "@/sdk/sdk";
 
+watchEffect(
+  () => {
+    console.error("modeChange", custom.showMode);
+  },
+  { flush: "sync" }
+);
 export type ModelListProps = {
   title?: string;
   canChange?: boolean;

+ 1 - 0
src/sdk/association/fuseMode.ts

@@ -214,6 +214,7 @@ export const associationModels = (sdk: SDK) => {
     if (data.active) {
       custom.currentModel = getFuseModel(data.active)!;
     }
+    console.log('modeChange', data, custom.showMode)
   });
   sdk.sceneBus.on("panoModelChange", (data) => {
     custom.showMode = "pano";

+ 14 - 12
src/sdk/association/index.ts

@@ -93,21 +93,23 @@ export const analysisPoseInfo = (info: ReturnType<typeof analysisPose>) => {
   return pose;
 };
 
-export const setPose = (info: ReturnType<typeof analysisPose>, _sdk = sdk) => {
+export const setPose = (info: ReturnType<typeof analysisPose>, _sdk = sdk, modeChange = true) => {
   const pose = analysisPoseInfo(info);
-  if ("model" in pose) {
-    setTimeout(() => {
-      for (const [k, v] of Array.from(sceneModelMap.entries())) {
-        if (toRaw(v) === toRaw(pose.model)) {
-          activeModel({ showMode: "pano", active: k });
-          return;
+  if (modeChange) {
+    if ("model" in pose) {
+      setTimeout(() => {
+        for (const [k, v] of Array.from(sceneModelMap.entries())) {
+          if (toRaw(v) === toRaw(pose.model)) {
+            activeModel({ showMode: "pano", active: k });
+            return;
+          }
         }
-      }
-    }, 300);
-  } else {
-    activeModel({ showMode: "fuse" });
+      }, 300);
+    } else {
+      activeModel({ showMode: "fuse" });
+    }
+    console.error('pose', pose)
   }
-  console.error('pose', pose)
   setTimeout(() => {
     sdk.comeTo({ ...pose, dur: 300 });
   });

+ 7 - 1
src/views/measure/index.vue

@@ -3,7 +3,12 @@
     <template #header>
       <ui-group borderBottom>
         <template #header>
-          <Actions class="edit-header" :items="options" single />
+          <Actions
+            class="edit-header"
+            :items="options"
+            single
+            v-model:current="currentAction"
+          />
         </template>
       </ui-group>
     </template>
@@ -65,6 +70,7 @@ const keyword = ref("");
 const filterMeasures = computed(() =>
   measures.value.filter((measure) => measure.desc.includes(keyword.value))
 );
+const currentAction = ref<any>();
 
 const editMeasures = ref<Measure[]>([]);
 const enterCreateMeasure = (type: MeasureType) => {

+ 7 - 1
src/views/merge/index.vue

@@ -5,7 +5,12 @@
   >
     <div class="actions-group">
       <Actions :items="actionItems" v-model:current="currentItem" />
-      <Actions class="merge-action" :items="othActions" single />
+      <Actions
+        class="merge-action"
+        v-model:current="currentAction"
+        :items="othActions"
+        single
+      />
     </div>
     <ui-group>
       <ui-group-option label="等比缩放">
@@ -98,6 +103,7 @@ const othActions = reactive([
     },
   },
 ]);
+const currentAction = ref<any>();
 
 watchEffect(() => {
   if (!custom.currentModel) {