fix(系统设置): 修复切换项目缺陷

This commit is contained in:
shiziyuan9527 2020-12-17 16:59:37 +08:00
parent e05657fe11
commit cfdbdb7fa3
2 changed files with 16 additions and 9 deletions

View File

@ -108,9 +108,9 @@ import {
if (response.data.workspaceId) {
localStorage.setItem("workspace_id", response.data.workspaceId);
}
localStorage.removeItem(PROJECT_ID)
this.$router.push('/');
window.location.reload();
this.$router.push('/').then(() => {
window.location.reload();
}).catch(err => err);
});
},
changeWs(data) {
@ -121,9 +121,9 @@ import {
this.$post("/user/switch/source/ws/" + workspaceId, {}, response => {
saveLocalStorage(response);
localStorage.setItem("workspace_id", workspaceId);
localStorage.removeItem(PROJECT_ID)
this.$router.push('/');
window.location.reload();
this.$router.push('/').then(() => {
window.location.reload();
}).catch(err => err);
})
}
}

View File

@ -68,10 +68,17 @@ export default {
this.result = this.$get("/project/listAll", response => {
this.items = response.data;
this.searchArray = response.data;
if (!getCurrentProjectID() && this.items.length > 0) {
this.change(this.items[0].id);
}
let projectId = getCurrentProjectID();
if (projectId) {
// projectId ;
if (this.searchArray.length > 0 && this.searchArray.map(p => p.id).indexOf(projectId) === -1) {
this.change(this.items[0].id);
}
} else {
if (this.items.length > 0) {
this.change(this.items[0].id);
}
}
this.changeProjectName(projectId);
})
}