| | |
| | | import {Message} from 'element-ui' |
| | | import {setStore, getStore} from '@/util/store' |
| | | import {isURL, validatenull} from '@/util/validate' |
| | | import {deepClone} from '@/util/util' |
| | | import {deepClone,queryStringToObject} from '@/util/util' |
| | | import website from '@/config/website' |
| | | import {loginByUsername, loginBySocial, loginBySso, getUserInfo, logout, refreshToken, getButtons} from '@/api/user' |
| | | import {getTopMenu, getRoutes} from '@/api/system/menu' |
| | |
| | | item.path = '/' + item.code; |
| | | item.query = {}; // 初始化 item.query |
| | | item.query = queryStringToObject(item.pathValue) |
| | | console.log('item', item); |
| | | if (item.children && item.children.length > 0) { |
| | | updateCode(item.children); |
| | | } |
| | | }); |
| | | } |
| | | function queryStringToObject(queryString) { |
| | | const index = queryString.indexOf('?'); |
| | | if (index !== -1) { |
| | | queryString = queryString.substring(index + 1); |
| | | } |
| | | const params = new URLSearchParams(queryString); |
| | | const obj = {}; |
| | | for (const [key, value] of params.entries()) { |
| | | obj[key] = value; |
| | | } |
| | | return obj; |
| | | } |
| | | |
| | | |
| | | const user = { |
| | | state: { |
| | |
| | | loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key,).then(res => { |
| | | const data = res.data; |
| | | if (data.success) { |
| | | debugger; |
| | | commit('SET_TOKEN', data.obj.sessionInfo.token); |
| | | commit('SET_REFRESH_TOKEN', data.obj.sessionInfo.token); |
| | | commit('SET_TENANT_ID', data.tenant_id); |
| | |
| | | }, |
| | | mutations: { |
| | | SET_TOKEN: (state, token) => { |
| | | debugger; |
| | | setToken(token); |
| | | state.token = token; |
| | | setStore({name: 'token', content: state.token}) |