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