From 36496957ffdc22851d57e6b7a2fc73ae4490f537 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期二, 18 六月 2024 17:55:50 +0800 Subject: [PATCH] 完善退出登录-实现登录后获取用户信息存储到本地 --- Source/plt-web/plt-web-ui/src/page/login/userlogin.vue | 2 +- Source/plt-web/plt-web-ui/src/store/modules/user.js | 39 +++++++++++++++++++++++++-------------- Source/plt-web/plt-web-ui/src/page/login/index.vue | 4 ++-- Source/plt-web/plt-web-ui/src/api/user.js | 4 ++-- Source/plt-web/plt-web-ui/src/page/index/top/index.vue | 4 ++-- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/api/user.js b/Source/plt-web/plt-web-ui/src/api/user.js index ba082a8..3e9891a 100644 --- a/Source/plt-web/plt-web-ui/src/api/user.js +++ b/Source/plt-web/plt-web-ui/src/api/user.js @@ -94,8 +94,8 @@ }); export const getUserInfo = () => request({ - url: '/api/blade-auth/oauth/user-info', - method: 'get' + url: '/api/framework/loginController/getSessionInfo', + method: 'post' }); export const sendLogs = (list) => request({ diff --git a/Source/plt-web/plt-web-ui/src/page/index/top/index.vue b/Source/plt-web/plt-web-ui/src/page/index/top/index.vue index 8430d37..6b99b79 100644 --- a/Source/plt-web/plt-web-ui/src/page/index/top/index.vue +++ b/Source/plt-web/plt-web-ui/src/page/index/top/index.vue @@ -242,10 +242,10 @@ cancelButtonText: this.$t("cancelText"), type: "warning" }).then(() => { - //this.$store.dispatch("LogOut").then(() => { + this.$store.dispatch("LogOut").then(() => { resetRouter(); this.$router.push({path: "/login"}); - //}); + }); }); } } diff --git a/Source/plt-web/plt-web-ui/src/page/login/index.vue b/Source/plt-web/plt-web-ui/src/page/login/index.vue index 2307ee0..da42a45 100644 --- a/Source/plt-web/plt-web-ui/src/page/login/index.vue +++ b/Source/plt-web/plt-web-ui/src/page/login/index.vue @@ -122,11 +122,11 @@ <style lang="scss" scoped> .login-container { background: #fff url('../../../public/img/login-background.png')no-repeat center; - background-size: 100% 100%; /* 鎴栬�� background-size: 100% 100%; */ + background-size: 100% 100%; } .login-bg-image{ position: fixed; - left: 10%; + left: 7%; top: 35%; } diff --git a/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue b/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue index a3ff8b0..344f9f0 100644 --- a/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue +++ b/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue @@ -186,7 +186,7 @@ }); return false; } - } + }; this.$router.push({path: this.tagWel.value}); loading.close(); }).catch((err) => { diff --git a/Source/plt-web/plt-web-ui/src/store/modules/user.js b/Source/plt-web/plt-web-ui/src/store/modules/user.js index c34bb5c..6f14ce8 100644 --- a/Source/plt-web/plt-web-ui/src/store/modules/user.js +++ b/Source/plt-web/plt-web-ui/src/store/modules/user.js @@ -67,10 +67,16 @@ if (data.code === 200) { commit('SET_TOKEN', data.obj.tokenVO.accessToken); commit('SET_REFRESH_TOKEN', data.obj.tokenVO.accessToken); - // commit('SET_TENANT_ID', data.tenant_id); - // commit('SET_USER_INFO', data.obj.sessionInfo); 鐢ㄦ埛淇℃伅 commit('DEL_ALL_TAG'); commit('CLEAR_LOCK'); + + getUserInfo().then((res) => { + const data = res.data.data; + commit('SET_USER_INFO', data.obj); + }).catch(err => { + console.log(err) + }) + } else { Message({ message: data.msg, @@ -140,18 +146,6 @@ }) }) }, - //鑾峰彇鐢ㄦ埛淇℃伅 - GetUserInfo({commit}) { - return new Promise((resolve, reject) => { - getUserInfo().then((res) => { - const data = res.data.data; - commit('SET_ROLES', data.roles); - resolve(data); - }).catch(err => { - reject(err); - }) - }) - }, //鍒锋柊token refreshToken({state, commit}, userInfo) { window.console.log('handle refresh token'); @@ -213,6 +207,21 @@ }) }) }, + + //鑾峰彇鐢ㄦ埛淇℃伅 + GetUserInfo({commit}) { + return new Promise((resolve, reject) => { + getUserInfo().then((res) => { + const data = res.data.data; + console.log('user',res) + // commit('SET_USER_INFO', data.roles); + resolve(data); + }).catch(err => { + reject(err); + }) + }) + }, + //鑾峰彇绯荤粺鑿滃崟 GetMenu({commit, dispatch}, topMenuId) { return new Promise(resolve => { @@ -231,6 +240,8 @@ }) }) }, + + //鑾峰彇绯荤粺鎸夐挳 GetButtons({commit}) { return new Promise((resolve) => { -- Gitblit v1.9.3