bill 8 달 전
부모
커밋
1079a404c1
3개의 변경된 파일12개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 0
      src/components/path/list.vue
  2. 0 1
      src/components/path/sign.vue
  3. 11 2
      src/store/path.ts

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

@@ -32,5 +32,6 @@ const updatePosition = (ndx: number, data: Path["points"]) => {
 const updateLinePosition = (ndx: number, linePosition: Path["linePosition"]) => {
   props.paths[ndx].linePosition = linePosition;
 };
+
 defineExpose(nodes);
 </script>

+ 0 - 1
src/components/path/sign.vue

@@ -35,7 +35,6 @@ const getLineProps = () => ({
   modelId: props.path.linePosition?.modelId || props.path.points[0]?.modelId,
 });
 
-console.log("create", sdk.createPath);
 const path = sdk.createPath({
   name: props.path.name,
   showName: props.path.showName,

+ 11 - 2
src/store/path.ts

@@ -13,7 +13,8 @@ import {
   updateStoreItem, 
   fetchStoreItems,
   saveStoreItems,
-  recoverStoreItems
+  recoverStoreItems,
+  asyncTimeout
 } from '@/utils'
 
 
@@ -67,7 +68,15 @@ export const backupPaths = () => {
 }
 
 export const initialPaths = fetchStoreItems(paths, fetchPaths, backupPaths)
-export const recoverPaths = recoverStoreItems(paths, () => bcPaths)
+export const recoverPaths = async () => {
+  const backupItems = bcPaths;
+  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;
+  });
+}
 export const addPath = addStoreItem(paths, postAddPath)
 export const deletePath = deleteStoreItem(paths, path => postDeletePath(path.id))
 export const updatePath = updateStoreItem(paths, postUpdatePath)