| | |
| | | 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' |
| | |
| | | items.forEach(item => { |
| | | item.pathValue = item.path; |
| | | item.path = '/' + item.code; |
| | | item.query = {}; // 初始化 item.query |
| | | item.query = queryStringToObject(item.pathValue) |
| | | if (item.children && item.children.length > 0) { |
| | | updateCode(item.children); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | const user = { |
| | | state: { |
| | |
| | | //根据用户名登录 |
| | | LoginByUsername({commit}, userInfo) { |
| | | return new Promise((resolve, reject) => { |
| | | loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key, ).then(res => { |
| | | 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; |
| | | if (data.success) { |
| | | commit('SET_TOKEN', data.obj.sessionInfo.token); |
| | | commit('SET_REFRESH_TOKEN', data.obj.sessionInfo.token); |
| | | commit('SET_TENANT_ID', data.tenant_id); |
| | | commit('SET_USER_INFO', data.obj.sessionInfo); |
| | | commit('DEL_ALL_TAG'); |
| | | commit('CLEAR_LOCK'); |
| | | }else { |
| | | } else { |
| | | Message({ |
| | | message: data.msg, |
| | | type: 'error' |
| | |
| | | //根据第三方信息登录 |
| | | LoginBySocial({commit}, userInfo) { |
| | | return new Promise((resolve) => { |
| | | loginBySocial(userInfo.tenantId, userInfo.source, userInfo.state).then(res => { |
| | | loginBySocial(userInfo.tenantId, userInfo.source, userInfo.state).then(res => { |
| | | const data = res.data; |
| | | if (data.error_description) { |
| | | Message({ |
| | |
| | | }, |
| | | mutations: { |
| | | SET_TOKEN: (state, token) => { |
| | | debugger; |
| | | setToken(token); |
| | | state.token = token; |
| | | setStore({name: 'token', content: state.token}) |
| | |
| | | } |
| | | }) |
| | | state.menuAll = menu |
| | | setStore({ name: 'menuAll', content: state.menuAll }) |
| | | setStore({name: 'menuAll', content: state.menuAll}) |
| | | }, |
| | | SET_MENU_ALL_NULL: (state) => { |
| | | state.menuAll = [] |
| | | setStore({ name: 'menuAll', content: state.menuAll }) |
| | | setStore({name: 'menuAll', content: state.menuAll}) |
| | | }, |
| | | SET_MENU: (state, menu) => { |
| | | state.menu = menu |
| | | setStore({ name: 'menu', content: state.menu }) |
| | | setStore({name: 'menu', content: state.menu}) |
| | | }, |
| | | SET_REFRESH_TOKEN: (state, refreshToken) => { |
| | | setRefreshToken(refreshToken) |