提交 928f7bcf 编写于 作者: S shiziyuan9527

fix: 登录后未保存当前项目值

上级 a3cfeaca
......@@ -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();
......
......@@ -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);
// 保存角色
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册