This commit is contained in:
chenjianxing 2020-12-11 14:42:34 +08:00
commit d97bcef1a3
2 changed files with 7 additions and 4 deletions

View File

@ -16,7 +16,7 @@
<template slot="title">
<div class="title">
{{ i.name }}
<i class="el-icon-check" v-if="i.id === projectId"></i>
<i class="el-icon-check" v-if="i.id === currentProjectId"></i>
</div>
</template>
</el-menu-item>
@ -26,7 +26,7 @@
</template>
<script>
import {getCurrentUser, hasRoles} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentUser, hasRoles} from "@/common/js/utils";
import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "@/common/js/constants";
export default {
@ -43,7 +43,7 @@ export default {
items: [],
search_text: '',
userId: getCurrentUser().id,
projectId: localStorage.getItem(PROJECT_ID)
currentProjectId: localStorage.getItem(PROJECT_ID)
}
},
watch: {
@ -61,6 +61,9 @@ export default {
this.result = this.$get(this.options.url, (response) => {
this.items = response.data;
this.items = this.items.splice(0, 3);
if (!getCurrentProjectID() && this.items.length > 0) {
this.change(this.items[0].id);
}
});
}
},
@ -72,7 +75,6 @@ export default {
}
},
change(projectId) {
// todo
this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => {
localStorage.setItem(PROJECT_ID, projectId);
window.location.reload();

View File

@ -96,6 +96,7 @@ export function getCurrentProjectID() {
export function saveLocalStorage(response) {
// 登录信息保存 cookie
localStorage.setItem(TokenKey, JSON.stringify(response.data));
localStorage.setItem(PROJECT_ID, response.data.lastProjectId);
let rolesArray = response.data.roles;
let roles = rolesArray.map(r => r.id);
// 保存角色