Skip to content

Commit

Permalink
优化缓存机制
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 12, 2021
1 parent 678af5f commit 66b5e5d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
29 changes: 29 additions & 0 deletions resources/assets/js/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ export default {
}
state.cacheUserActive = Object.assign(data, {__:Math.random()});
Store.set('cacheUserActive', data);
setTimeout(() => {
state.method.setStorage("cacheUserBasic", state.cacheUserBasic);
})
},

/**
Expand Down Expand Up @@ -405,6 +408,9 @@ export default {
} else {
state.projects.push(data);
}
setTimeout(() => {
state.method.setStorage("cacheProjects", state.cacheProjects = state.projects);
})
}
},

Expand All @@ -426,6 +432,9 @@ export default {
$A.goForward({path: '/manage/dashboard'});
}
}
setTimeout(() => {
state.method.setStorage("cacheProjects", state.cacheProjects = state.projects);
})
},

/**
Expand Down Expand Up @@ -609,6 +618,9 @@ export default {
} else {
state.columns.push(data);
}
setTimeout(() => {
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
})
}
},

Expand All @@ -624,6 +636,9 @@ export default {
dispatch('getProjectOne', state.columns[index].project_id)
state.columns.splice(index, 1);
}
setTimeout(() => {
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
})
},

/**
Expand Down Expand Up @@ -719,6 +734,12 @@ export default {
if (data.is_update_content) {
dispatch("getTaskContent", data.id);
}
//
if (key == 'tasks') {
setTimeout(() => {
state.method.setStorage("cacheTasks", state.cacheTasks = state[key]);
})
}
}
},

Expand Down Expand Up @@ -747,6 +768,11 @@ export default {
if (state.taskId == task_id) {
state.taskId = 0;
}
if (key == 'tasks') {
setTimeout(() => {
state.method.setStorage("cacheTasks", state.cacheTasks = state[key]);
})
}
},

/**
Expand Down Expand Up @@ -1146,6 +1172,9 @@ export default {
} else {
state.dialogs.push(data);
}
setTimeout(() => {
state.method.setStorage("cacheDialogs", state.cacheDialogs = state.dialogs);
})
}
},

Expand Down
12 changes: 5 additions & 7 deletions resources/assets/js/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,13 @@ state.cacheLoading = {};
// User
state.cacheUserActive = {};
state.cacheUserWait = [];
state.cacheUserBasic = [];
state.cacheUserBasic = state.method.getStorageArray("cacheUserBasic");
// Dialog
state.cacheDialogs = [];
state.cacheDialogMsgs = [];
state.cacheDialogs = state.method.getStorageArray("cacheDialogs");
// Project
state.cacheProjects = [];
state.cacheColumns = [];
state.cacheTasks = [];
state.cacheTaskSubs = [];
state.cacheProjects = state.method.getStorageArray("cacheProjects");
state.cacheColumns = state.method.getStorageArray("cacheColumns");
state.cacheTasks = state.method.getStorageArray("cacheTasks");
// TablePanel
state.cacheTablePanel = state.method.getStorageArray("cacheTablePanel");

Expand Down

0 comments on commit 66b5e5d

Please sign in to comment.