| | |
| | | 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"; |
| | |
| | | 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]; |
| | |
| | | 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) |
| | |
| | | return new Promise((resolve) => { |
| | | getButtons().then(res => { |
| | | const data = res.data.data; |
| | | console.log('getButton',data) |
| | | commit('SET_PERMISSION', data); |
| | | resolve(); |
| | | }) |
| | |
| | | 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; |
| | |
| | | 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); |