perf: 清除缓存

This commit is contained in:
kuaifan 2021-12-22 21:13:25 +08:00
parent 75c83e4117
commit c120686fae
4 changed files with 34 additions and 19 deletions

View File

@ -143,9 +143,11 @@ export default {
}, },
}).then(({data}) => { }).then(({data}) => {
this.loadIng--; this.loadIng--;
this.$store.state.method.clearLocal(); this.$store.dispatch("handleClearCache", data).then(() => {
this.$store.dispatch("saveUserInfo", data); this.goNext();
this.goNext(); }).catch(() => {
this.goNext();
});
}).catch(({data, msg}) => { }).catch(({data, msg}) => {
this.loadIng--; this.loadIng--;
$A.noticeError(msg); $A.noticeError(msg);

View File

@ -425,7 +425,12 @@ export default {
this.archivedProjectShow = true; this.archivedProjectShow = true;
return; return;
case 'clearCache': case 'clearCache':
this.$store.dispatch("clearCache"); this.$store.dispatch("handleClearCache", null).then(() => {
this.$store.state.method.setStorage("clearCache", $A.randomString(6))
window.location.reload()
}).catch(() => {
window.location.reload()
});
return; return;
case 'signout': case 'signout':
$A.modalConfirm({ $A.modalConfirm({

View File

@ -1,4 +1,5 @@
import {Store} from 'le5le-store'; import {Store} from 'le5le-store';
import state from "./state";
export default { export default {
/** /**
@ -371,8 +372,7 @@ export default {
* @param dispatch * @param dispatch
*/ */
logout({state, dispatch}) { logout({state, dispatch}) {
state.method.clearLocal(); dispatch("handleClearCache", {}).then(() => {
dispatch("saveUserInfo", {}).then(() => {
const from = ["/", "/login"].includes(window.location.pathname) ? "" : encodeURIComponent(window.location.href); const from = ["/", "/login"].includes(window.location.pathname) ? "" : encodeURIComponent(window.location.href);
$A.goForward({name: 'login', query: from ? {from: from} : {}}, true); $A.goForward({name: 'login', query: from ? {from: from} : {}}, true);
}); });
@ -382,12 +382,28 @@ export default {
* 清除缓存 * 清除缓存
* @param state * @param state
* @param dispatch * @param dispatch
* @param userInfo
* @returns {Promise<unknown>}
*/ */
clearCache({state, dispatch}) { handleClearCache({state, dispatch}, userInfo) {
state.method.clearLocal(); return new Promise(function (resolve, reject) {
state.method.setStorage("clearCache", $A.randomString(6)) try {
dispatch("saveUserInfo", state.userInfo); window.localStorage.clear();
window.location.reload() //
state.cacheUserBasic = [];
state.cacheDialogs = state.dialogs = [];
state.cacheProjects = state.projects = [];
state.cacheColumns = state.columns = [];
state.cacheTasks = state.tasks = state.taskSubs = [];
//
state.method.setStorage("cacheTablePanel", state.cacheTablePanel);
dispatch("saveUserInfo", state.method.isJson(userInfo) ? userInfo : state.userInfo);
//
resolve()
} catch (e) {
reject(e)
}
});
}, },
/** *****************************************************************************************/ /** *****************************************************************************************/

View File

@ -197,14 +197,6 @@ const method = {
} }
}, },
clearLocal() {
try {
window.localStorage.clear();
} catch (e) {
//
}
},
runNum(str, fixed) { runNum(str, fixed) {
let _s = Number(str); let _s = Number(str);
if (_s + "" === "NaN") { if (_s + "" === "NaN") {