From 78fa1f005a9ec2581611e53d7eba8efeacb4df6e Mon Sep 17 00:00:00 2001 From: 田源 <tianyuan@vci-tech.com> Date: 星期三, 15 一月 2025 18:35:48 +0800 Subject: [PATCH] 调试头像接口 --- Source/plt-web/plt-web-ui/src/store/modules/user.js | 41 +++++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 10 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 8e1fbc3..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,7 +16,7 @@ const propsDefault = { label: propsConfig.label || 'name', path: propsConfig.path || 'path', - icon: propsConfig.icon || 'icon', + icon: propsConfig.icon || 'source', children: propsConfig.children || 'children', } const icon = ele[propsDefault.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) @@ -244,7 +244,6 @@ return new Promise((resolve) => { getButtons().then(res => { const data = res.data.data; - console.log('getButton',data) commit('SET_PERMISSION', data); resolve(); }) @@ -287,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; @@ -303,7 +317,14 @@ 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.id, children); -- Gitblit v1.9.3