This commit is contained in:
2024-03-29 19:03:35 +08:00
parent 84a2eab9ad
commit 8cdcb7a073
15 changed files with 485 additions and 146 deletions

View File

@@ -6,14 +6,15 @@ const useTreeDataStore = defineStore("treeDataStore", {
return {
treeData: [],
originTreeData: [],
currentNode: undefined
currentNode: undefined,
isInit: false
}
},
actions: {
// 不能使用箭头函数无法绑定this
async initTreeData(projectId) {
// 获取localStorage的treeData数据
if(localStorage.getItem("tree_local_data")){
if (localStorage.getItem("tree_local_data")) {
this.treeData = JSON.parse(localStorage.getItem("tree_local_data"))
}
if (this.treeData.length === 0) {
@@ -23,8 +24,8 @@ const useTreeDataStore = defineStore("treeDataStore", {
}
// 将用户关闭页面数据储存于localStorage中 -> 注意用户打开其他项目 -> 务必清除localStorage的tree_local_data数据
// 暂定在点击进入工作台时清除!!!
window.addEventListener("beforeunload",()=>{
localStorage.setItem("tree_local_data",JSON.stringify(this.treeData))
window.addEventListener("beforeunload", () => {
localStorage.setItem("tree_local_data", JSON.stringify(this.treeData))
})
},
// 用于新增轮次后显示