| | |
| | | items.forEach(item => { |
| | | item.pathValue = item.path; |
| | | 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 = { |
| | |
| | | //根据用户名登录 |
| | | 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){ |
| | | if (data.success) { |
| | | debugger; |
| | | commit('SET_TOKEN', data.obj.sessionInfo.token); |
| | | commit('SET_REFRESH_TOKEN', data.obj.sessionInfo.token); |
| | |
| | | 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({ |
| | |
| | | } |
| | | }) |
| | | 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) |