fix(系统设置): 修复切换项目缺陷
This commit is contained in:
parent
d7b4c140b7
commit
d7f2494f84
|
@ -108,6 +108,7 @@ import {
|
||||||
if (response.data.workspaceId) {
|
if (response.data.workspaceId) {
|
||||||
localStorage.setItem("workspace_id", response.data.workspaceId);
|
localStorage.setItem("workspace_id", response.data.workspaceId);
|
||||||
}
|
}
|
||||||
|
localStorage.removeItem(PROJECT_ID);
|
||||||
this.$router.push('/').then(() => {
|
this.$router.push('/').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}).catch(err => err);
|
}).catch(err => err);
|
||||||
|
@ -121,6 +122,7 @@ import {
|
||||||
this.$post("/user/switch/source/ws/" + workspaceId, {}, response => {
|
this.$post("/user/switch/source/ws/" + workspaceId, {}, response => {
|
||||||
saveLocalStorage(response);
|
saveLocalStorage(response);
|
||||||
localStorage.setItem("workspace_id", workspaceId);
|
localStorage.setItem("workspace_id", workspaceId);
|
||||||
|
localStorage.removeItem(PROJECT_ID);
|
||||||
this.$router.push('/').then(() => {
|
this.$router.push('/').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}).catch(err => err);
|
}).catch(err => err);
|
||||||
|
|
|
@ -36,11 +36,6 @@ export default {
|
||||||
currentProject: String
|
currentProject: String
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (getCurrentUser().lastProjectId) {
|
|
||||||
localStorage.setItem(PROJECT_ID, getCurrentUser().lastProjectId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -68,9 +63,16 @@ export default {
|
||||||
this.result = this.$get("/project/listAll", response => {
|
this.result = this.$get("/project/listAll", response => {
|
||||||
this.items = response.data;
|
this.items = response.data;
|
||||||
this.searchArray = response.data;
|
this.searchArray = response.data;
|
||||||
|
let userLastProjectId = getCurrentUser().lastProjectId;
|
||||||
|
if (userLastProjectId) {
|
||||||
|
// id 是否存在
|
||||||
|
if (this.searchArray.length > 0 && this.searchArray.map(p => p.id).indexOf(userLastProjectId) !== -1) {
|
||||||
|
localStorage.setItem(PROJECT_ID, userLastProjectId);
|
||||||
|
}
|
||||||
|
}
|
||||||
let projectId = getCurrentProjectID();
|
let projectId = getCurrentProjectID();
|
||||||
if (projectId) {
|
if (projectId) {
|
||||||
// 保存的 projectId 是否存在; 切换工作空间后
|
// 保存的 projectId 在当前项目列表是否存在; 切换工作空间后
|
||||||
if (this.searchArray.length > 0 && this.searchArray.map(p => p.id).indexOf(projectId) === -1) {
|
if (this.searchArray.length > 0 && this.searchArray.map(p => p.id).indexOf(projectId) === -1) {
|
||||||
this.change(this.items[0].id);
|
this.change(this.items[0].id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue