bill пре 4 месеци
родитељ
комит
ce5e45ca25

+ 13 - 9
src/hook/ids.ts

@@ -1,22 +1,24 @@
-import { diffArrayChange } from "@/utils";
+import { debounce, diffArrayChange } from "@/utils";
 import { computed, ref, Ref, watch } from "vue";
 
 export const useSelects = <T extends { id: any }>(items: Ref<T[]>, test = false) => {
   const selects = ref<T[]>([]);
 
   const updateSelect = (item: T, select: boolean) => {
-    console.error('select', item.id, select)
     const ndx = selects.value.findIndex((s) => s.id === item.id);
+    test && console.log('updateSelect', item.id, select)
     if (select) {
-      ~ndx || selects.value.push(item as any);
+      if (~ndx) {
+        selects.value[ndx] = item as any
+      } else {
+        selects.value.push(item as any);
+      } 
     } else {
       ~ndx && selects.value.splice(ndx, 1);
     }
   };
   const updateSelectId = (id: any, select: boolean) => {
-    console.log('===>', [...items.value], id, select)
     const item = items.value.find((s) => s.id === id);
-    console.log('===>', item)
     if (item) {
       updateSelect(item, select);
     } else {
@@ -35,22 +37,24 @@ export const useSelects = <T extends { id: any }>(items: Ref<T[]>, test = false)
         items.map((item) => item.id),
         oldItems.map((item) => item.id)
       );
-      console.error([...items], 'itemChange', added, deleted)
+      test && console.error('added', added)
+      test && console.error('deleted', deleted)
+      
       added.forEach((id) => updateSelectId(id, true));
       deleted.forEach((id) => updateSelectId(id, false));
       oldItems.length = 0;
       oldItems.push(...items);
     },
-    { deep: true }
+    { deep: true, flush: 'post' }
   );
 
   return {
     selects,
-    unSelects: computed(() => items.value.filter(item => !selects.value.includes(item as any))),
+    unSelects: computed(() => items.value.filter(item => !selects.value.find(s => s.id === item.id))),
     all: computed({
       get: () => items.value.length === selects.value.length,
       set: (select: boolean) => {
-        console.error('select', select)
+        test && console.error('select', select)
         items.value.forEach(item => updateSelect(item, select))
       } 
     }),

+ 1 - 1
src/router/index.ts

@@ -59,7 +59,7 @@ let timeout: any
 watch(currentLayout, () => {
   clearTimeout(timeout)
   timeout = setTimeout(() => {
-    if (!currentLayout.value) {
+    if (!currentLayout.value || router.currentRoute.value.name === RoutesName.show) {
       router.replace({ name: RoutesName.fireInfo })
     }
   }, 100)

+ 3 - 1
src/sdk/association/path.ts

@@ -110,7 +110,9 @@ export const associationPaths = (sdk: SDK, el: HTMLDivElement) => {
   });
 
   watchEffect(() => {
-    selectPaths.selects.value.forEach(item => pathNodes.get(item)?.visibility(true))
+    selectPaths.selects.value.forEach(item => {
+      pathNodes.get(item)?.visibility(true)
+    })
     selectPaths.unSelects.value.forEach(item => {
       pathNodes.get(item)?.visibility(false)
     })

+ 3 - 3
src/store/path.ts

@@ -27,7 +27,7 @@ export  type { Path } from '@/api'
 export type Paths = Path[]
 
 export const paths = ref<Paths>([])
-export const selectPaths = useSelects(paths)
+export const selectPaths = useSelects(paths, true)
 export const getPath = (id: Path['id']) => paths.value.find(path => path.id === id)
 
 export const getPathIsShow = (path: Path) => {
@@ -79,8 +79,8 @@ export const initialPaths = fetchStoreItems(paths, async () => {
 })
 export const recoverPaths = async () => {
   const backupItems = bcPaths;
-  paths.value.length = 0
-  await asyncTimeout(16)
+  // paths.value.length = 0
+  // await asyncTimeout(16)
   paths.value = backupItems.map((oldItem) => {
     const model = paths.value.find((item) => item.id === oldItem.id);
     return model ? Object.assign(model, oldItem) : oldItem;

+ 5 - 5
src/views/guide/path/edit.vue

@@ -59,9 +59,9 @@ watchEffect(() => emit("update:current", currentPath.value));
 
 const leaveEdit = () => {
   currentPath.value = null;
-  pathsGroup.visibility(true);
-  showPathsStack.pop();
-  showPathStack.pop();
+  // pathsGroup.visibility(true);
+  // showPathsStack.pop();
+  // showPathStack.pop();
 };
 const edit = async (path?: Path) => {
   await save();
@@ -73,8 +73,8 @@ const edit = async (path?: Path) => {
   currentPath.value = path;
   enterEdit();
   sysBus.on("leave", leaveEdit);
-  showPathsStack.push(ref(false));
-  showPathStack.push(computed(() => path.id));
+  // showPathsStack.push(ref(false));
+  // showPathStack.push(computed(() => path.id));
 };
 
 const deletePath = (path: Path) => {

+ 1 - 1
src/views/setting/select-back.vue

@@ -4,7 +4,7 @@
       <div v-if="back.children" class="child-layout-parent">
         <Dropdown placement="bottom">
           <div class="child-layout" :class="{ active: activeParent === back.value }">
-            <ui-icon type="rectification" />
+            <ui-icon type="menu" />
             <BackItem
               :type="back.type"
               :label="back.label"

+ 1 - 1
src/views/summary/index.vue

@@ -41,7 +41,7 @@ enum TabKey {
 }
 const tabs = [
   { comp: Taggings, key: TabKey.tagging, text: "标签" },
-  { comp: Monitor, key: TabKey.monitor, text: "监控" },
+  // { comp: Monitor, key: TabKey.monitor, text: "监控" },
   { comp: Paths, key: TabKey.path, text: "路径" },
   { comp: Measures, key: TabKey.measure, text: "测量" },
   { comp: Guides, key: TabKey.guide, text: "导览" },

+ 1 - 1
src/views/tagging-position/sign.vue

@@ -54,7 +54,7 @@
         class="item"
         @apply-global="$emit('applyGlobal', 'lineHeight')"
       >
-        <Slider v-model:value="position.lineHeight" :min="0.5" :max="5" :step="0.1" />
+        <Slider v-model:value="position.lineHeight" :min="0" :max="5" :step="0.1" />
       </SignItem>
       <SignItem
         label="可见范围"