From 391eec3114a17e68652434c6eae610799d80290e Mon Sep 17 00:00:00 2001 From: ludc <ludc@vci-tech.com> Date: 星期四, 16 一月 2025 11:13:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/plt-web/plt-web-ui/src/store/modules/user.js | 48 +++++++++++++++++++++++++++++++++++------------- 1 files changed, 35 insertions(+), 13 deletions(-) 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 e6e7fba..5f3aab8 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 @@ -4,7 +4,7 @@ import {isURL, validatenull} from '@/util/validate' import {deepClone, queryStringToObject} from '@/util/util' import website from '@/config/website' -import {loginByUsername, loginBySocial, loginBySso, getUserInfo, logout, refreshToken, getButtons} from '@/api/user' +import {loginByUsername, loginBySocial, loginBySso, getUserInfo, logout, refreshToken, getButtons,getUserPhoto} from '@/api/user' import {getTopMenu, getRoutes} from '@/api/system/menu' import md5 from 'js-md5' import func from "@/util/func"; @@ -16,8 +16,8 @@ const propsDefault = { label: propsConfig.label || 'name', path: propsConfig.path || 'path', - icon: propsConfig.icon || 'icon', - children: propsConfig.children || 'children' + icon: propsConfig.icon || 'source', + children: propsConfig.children || 'children', } const icon = ele[propsDefault.icon]; ele[propsDefault.icon] = validatenull(icon) ? menu.iconDefault : icon; @@ -36,7 +36,7 @@ function updateCode(items) { items.forEach(item => { item.pathValue = item.path; - item.path = '/' + item.code; + item.path = '/' + item.id; item.query = {}; // 鍒濆鍖� item.query if (item.pathValue.indexOf('?') != -1) { item.query = queryStringToObject(item.pathValue) @@ -66,7 +66,7 @@ let passwordDes = func.encryptData(userInfo.password, 'daliantan0v0vcip') loginByUsername(userInfo.deptId, userInfo.roleId, userInfo.username, passwordDes, userInfo.type, userInfo.key,).then(res => { const data = res.data; - if (data.obj.failCode === 'loginSuccess') { + if (data.obj.failCode === 'loginSuccess' || data.obj.failCode === 'passwordRemainDay') { commit('SET_TOKEN', data.obj.tokenVO.accessToken); commit('SET_REFRESH_TOKEN', data.obj.tokenVO.accessToken); commit('DEL_ALL_TAG'); @@ -232,7 +232,7 @@ commit('SET_MENU_ALL', menu) commit('SET_MENU', menu) - //dispatch('GetButtons');s + dispatch('GetButtons'); resolve(menu) }) }) @@ -286,12 +286,27 @@ state.tenantId = tenantId; setStore({name: 'tenantId', content: state.tenantId}) }, + // SET_USER_INFO: (state, userInfo) => { + // getUserPhoto().then(res => { + // userInfo.avatar = URL.createObjectURL(res.data); + // console.log('userInfo',userInfo) + // }) + // state.userInfo = userInfo; + // setStore({name: 'userInfo', content: state.userInfo}) + // }, SET_USER_INFO: (state, userInfo) => { - if (validatenull(userInfo.avatar)) { - userInfo.avatar = "/img/bg/img-logo.png"; - } - state.userInfo = userInfo; - setStore({name: 'userInfo', content: state.userInfo}) + getUserPhoto().then(res => { + // 灏� Blob 杞崲涓� Base64 + const reader = new FileReader(); + reader.onloadend = (result) => { + userInfo.avatar = reader.result; // 瀛樺偍 Base64 瀛楃涓� + + // 鏇存柊鐘舵�佸苟瀛樺偍鍒� localStorage + state.userInfo = userInfo; + setStore({ name: 'userInfo', content: state.userInfo }); + }; + reader.readAsDataURL(res.data); // 璋冪敤reader鏂规硶 + }); }, SET_ROLES: (state, roles) => { state.roles = roles; @@ -302,10 +317,17 @@ let children = {}; if (item.children && item.children.length > 0) { item.children.forEach(child => { - Vue.set(children, child.code, true); + // const childObject = { + // [child.code]: true, + // source: child.source + // }; + // Object.assign(children, childObject); + children[child.code] = { + source: child.source + } }); } - Vue.set(permission_new, item.code, children); + Vue.set(permission_new, item.id, children); }); state.permission = permission_new; setStore({name: "permission", content: permission_new}); -- Gitblit v1.9.3