This commit is contained in:
2023-08-25 13:28:24 +08:00
parent 9bd55a0ab0
commit 2ed1d96074
9 changed files with 72 additions and 31 deletions

View File

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