fix: 切换工作空间后有其它工作空间的数据

This commit is contained in:
shiziyuan9527 2021-04-20 11:28:06 +08:00 committed by 刘瑞斌
parent f9326c7b43
commit 8d6a551500
1 changed files with 6 additions and 0 deletions

View File

@ -67,6 +67,12 @@ export default {
}
if (localStorage.getItem("store")) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(localStorage.getItem("store"))))
this.$get("/project/listAll", response => {
let projectIds = response.data;
if (projectIds && projectIds.length <= 0) {
this.$store.commit('setProjectId', undefined);
}
})
}
window.addEventListener("beforeunload", () => {
localStorage.setItem("store", JSON.stringify(this.$store.state))