3d27d359 by yangwei

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

1 parent f587b9a9
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
5 {{ dicData["sysCode"] && dicData["sysCode"][0].DNAME }} 5 {{ dicData["sysCode"] && dicData["sysCode"][0].DNAME }}
6 </div> 6 </div>
7 <div class="user"> 7 <div class="user">
8 欢迎进入系统 {{ name }} 8 欢迎进入系统 {{ userInfo.name }}
9 <span @click="onCancel"> 9 <span @click="onCancel">
10 <svg-icon icon-class="close" class="closeStyle" />退出系统</span 10 <svg-icon icon-class="close" class="closeStyle" />退出系统</span
11 > 11 >
...@@ -30,13 +30,14 @@ export default { ...@@ -30,13 +30,14 @@ export default {
30 sidebarRight, 30 sidebarRight,
31 }, 31 },
32 computed: { 32 computed: {
33 ...mapGetters(["sidebar", "dicData", "name"]), 33 ...mapGetters(["sidebar", "dicData", "userInfo"]),
34 }, 34 },
35 methods: { 35 methods: {
36 onCancel() { 36 onCancel() {
37 logout() 37 logout()
38 .then((res) => { 38 .then((res) => {
39 sessionStorage.removeItem("token"); 39 sessionStorage.removeItem("token");
40 this.$store.dispatch("user/resetState");
40 this.$router.replace({ 41 this.$router.replace({
41 path: "/login", 42 path: "/login",
42 query: { 43 query: {
......
...@@ -37,8 +37,6 @@ router.beforeEach(async (to, from, next) => { ...@@ -37,8 +37,6 @@ router.beforeEach(async (to, from, next) => {
37 "permission/generateRoutes", 37 "permission/generateRoutes",
38 getMenuData 38 getMenuData
39 ); 39 );
40 // 获取用户信息
41 await store.dispatch("user/getUserInfo");
42 router.addRoutes([ 40 router.addRoutes([
43 ...accessRoutes, 41 ...accessRoutes,
44 { path: "*", redirect: "/404", hidden: true }, 42 { path: "*", redirect: "/404", hidden: true },
......
1 import { getUserInfo } from "@/api/user"; 1 import { getUserInfo } from "@/api/user";
2 const state = { 2 const state = {
3 hasUser: false, 3 hasUser: false,
4 name: "",
5 avatar: "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png",
6 userInfo: null, 4 userInfo: null,
7 }; 5 };
8 const mutations = { 6 const mutations = {
9 SET_USERINFO: (state, data) => { 7 SET_USERINFO: (state, data) => {
10 state.hasUser = true; 8 state.hasUser = true;
11 state.userInfo = data; 9 state.userInfo = data;
12 state.name = data.loginName;
13 }, 10 },
14 RESET_USER: (state) => { 11 RESET_USER: (state) => {
15 state.hasUser = false; 12 state.hasUser = false;
13 state.userInfo = null;
16 }, 14 },
17 }; 15 };
18 16
19 const actions = { 17 const actions = {
20 getUserInfo({ commit }) { 18 getUserInfo({ commit }) {
21 if (!state.hasUser) { 19 return new Promise(async (resolve) => {
22 return new Promise(async (resolve) => { 20 let { result: res } = await getUserInfo();
23 let { result: res } = await getUserInfo(); 21 commit("SET_USERINFO", res);
24 commit("SET_USERINFO", res); 22 resolve(true);
25 resolve(true); 23 });
26 });
27 }else{
28 return
29 }
30 }, 24 },
31 resetdict({ commit }) { 25 resetState({ commit }) {
32 commit("RESET_USER"); 26 commit("RESET_USER");
33 }, 27 },
34 }; 28 };
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
9 <div class="d-flex"> 9 <div class="d-flex">
10 <dv-decoration-8 class="dv-dec-8" :color="decorationColor" /> 10 <dv-decoration-8 class="dv-dec-8" :color="decorationColor" />
11 <div class="title"> 11 <div class="title">
12 <span class="title-text">汉中市不动产监管大屏</span> 12 <span class="title-text">{{ products.name }}}</span>
13 <dv-decoration-5 13 <dv-decoration-5
14 :dur="1" 14 :dur="1"
15 class="dv-dec-5" 15 class="dv-dec-5"
...@@ -60,6 +60,9 @@ export default { ...@@ -60,6 +60,9 @@ export default {
60 }, 500); 60 }, 500);
61 }, 61 },
62 }, 62 },
63 computed: {
64 ...mapGetters(["products"]),
65 },
63 }; 66 };
64 </script> 67 </script>
65 68
......