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}) => {
this.loadIng--;
this.$store.state.method.clearLocal();
this.$store.dispatch("saveUserInfo", data);
this.goNext();
this.$store.dispatch("handleClearCache", data).then(() => {
this.goNext();
}).catch(() => {
this.goNext();
});
}).catch(({data, msg}) => {
this.loadIng--;
$A.noticeError(msg);

View File

@ -425,7 +425,12 @@ export default {
this.archivedProjectShow = true;
return;
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;
case 'signout':
$A.modalConfirm({

View File

@ -1,4 +1,5 @@
import {Store} from 'le5le-store';
import state from "./state";
export default {
/**
@ -371,8 +372,7 @@ export default {
* @param dispatch
*/
logout({state, dispatch}) {
state.method.clearLocal();
dispatch("saveUserInfo", {}).then(() => {
dispatch("handleClearCache", {}).then(() => {
const from = ["/", "/login"].includes(window.location.pathname) ? "" : encodeURIComponent(window.location.href);
$A.goForward({name: 'login', query: from ? {from: from} : {}}, true);
});
@ -382,12 +382,28 @@ export default {
* 清除缓存
* @param state
* @param dispatch
* @param userInfo
* @returns {Promise<unknown>}
*/
clearCache({state, dispatch}) {
state.method.clearLocal();
state.method.setStorage("clearCache", $A.randomString(6))
dispatch("saveUserInfo", state.userInfo);
window.location.reload()
handleClearCache({state, dispatch}, userInfo) {
return new Promise(function (resolve, reject) {
try {
window.localStorage.clear();
//
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) {
let _s = Number(str);
if (_s + "" === "NaN") {