perf: 清除缓存
This commit is contained in:
parent
75c83e4117
commit
c120686fae
@ -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);
|
||||
|
@ -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({
|
||||
|
30
resources/assets/js/store/actions.js
vendored
30
resources/assets/js/store/actions.js
vendored
@ -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)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** *****************************************************************************************/
|
||||
|
8
resources/assets/js/store/state.js
vendored
8
resources/assets/js/store/state.js
vendored
@ -197,14 +197,6 @@ const method = {
|
||||
}
|
||||
},
|
||||
|
||||
clearLocal() {
|
||||
try {
|
||||
window.localStorage.clear();
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
},
|
||||
|
||||
runNum(str, fixed) {
|
||||
let _s = Number(str);
|
||||
if (_s + "" === "NaN") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user