3d27d359 by yangwei

修改用户名显示及系统名称显示

1 parent f587b9a9
......@@ -5,7 +5,7 @@
{{ dicData["sysCode"] && dicData["sysCode"][0].DNAME }}
</div>
<div class="user">
欢迎进入系统 {{ name }}
欢迎进入系统 {{ userInfo.name }}
<span @click="onCancel">
<svg-icon icon-class="close" class="closeStyle" />退出系统</span
>
......@@ -30,13 +30,14 @@ export default {
sidebarRight,
},
computed: {
...mapGetters(["sidebar", "dicData", "name"]),
...mapGetters(["sidebar", "dicData", "userInfo"]),
},
methods: {
onCancel() {
logout()
.then((res) => {
sessionStorage.removeItem("token");
this.$store.dispatch("user/resetState");
this.$router.replace({
path: "/login",
query: {
......
......@@ -37,8 +37,6 @@ router.beforeEach(async (to, from, next) => {
"permission/generateRoutes",
getMenuData
);
// 获取用户信息
await store.dispatch("user/getUserInfo");
router.addRoutes([
...accessRoutes,
{ path: "*", redirect: "/404", hidden: true },
......
import { getUserInfo } from "@/api/user";
const state = {
hasUser: false,
name: "",
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png",
userInfo: null,
};
const mutations = {
SET_USERINFO: (state, data) => {
state.hasUser = true;
state.userInfo = data;
state.name = data.loginName;
},
RESET_USER: (state) => {
state.hasUser = false;
state.userInfo = null;
},
};
const actions = {
getUserInfo({ commit }) {
if (!state.hasUser) {
return new Promise(async (resolve) => {
let { result: res } = await getUserInfo();
commit("SET_USERINFO", res);
resolve(true);
});
}else{
return
}
},
resetdict({ commit }) {
resetState({ commit }) {
commit("RESET_USER");
},
};
......
......@@ -9,7 +9,7 @@
<div class="d-flex">
<dv-decoration-8 class="dv-dec-8" :color="decorationColor" />
<div class="title">
<span class="title-text">汉中市不动产监管大屏</span>
<span class="title-text">{{ products.name }}}</span>
<dv-decoration-5
:dur="1"
class="dv-dec-5"
......@@ -60,6 +60,9 @@ export default {
}, 500);
},
},
computed: {
...mapGetters(["products"]),
},
};
</script>
......