mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-02 03:57:37 +08:00
修改拦截器token获取失败
This commit is contained in:
parent
4d5ebdb4ce
commit
616ebc600a
@ -27,17 +27,17 @@ api.interceptors.request.use(
|
||||
*/
|
||||
if (request.method == 'post') {
|
||||
if (request.data instanceof FormData) {
|
||||
if (store.getters['token/isLogin']) {
|
||||
if (store.getters['user/isLogin']) {
|
||||
// 如果是 FormData 类型(上传图片)
|
||||
request.data.append('token', store.state.token.token)
|
||||
request.data.append('token', store.state.user.token)
|
||||
}
|
||||
} else {
|
||||
// 带上 token
|
||||
if (request.data == undefined) {
|
||||
request.data = {}
|
||||
}
|
||||
if (store.getters['token/isLogin']) {
|
||||
request.data.token = store.state.token.token
|
||||
if (store.getters['user/isLogin']) {
|
||||
request.data.token = store.state.user.token
|
||||
}
|
||||
// request.data = Qs.stringify(request.data)
|
||||
}
|
||||
@ -46,8 +46,8 @@ api.interceptors.request.use(
|
||||
if (request.params == undefined) {
|
||||
request.params = {}
|
||||
}
|
||||
if (store.getters['token/isLogin']) {
|
||||
request.params.token = store.state.token.token
|
||||
if (store.getters['user/isLogin']) {
|
||||
request.params.token = store.state.user.token
|
||||
}
|
||||
}
|
||||
return request
|
||||
|
@ -127,7 +127,7 @@ const getters = {
|
||||
routes: (state, getters, rootState) => {
|
||||
let routes
|
||||
if (rootState.settings.menuMode === 'single') {
|
||||
routes = [{children: []}]
|
||||
routes = [{ children: [] }]
|
||||
state.routes.map(item => {
|
||||
routes[0].children.push(...item.children)
|
||||
})
|
||||
@ -143,7 +143,7 @@ const getters = {
|
||||
|
||||
const actions = {
|
||||
// 根据权限动态生成路由(前端生成)
|
||||
generateRoutesAtFront({rootState, dispatch, commit}, data) {
|
||||
generateRoutesAtFront({ rootState, dispatch, commit }, data) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async resolve => {
|
||||
let accessedRoutes
|
||||
|
@ -21,7 +21,7 @@ const getters = {
|
||||
}
|
||||
|
||||
const actions = {
|
||||
login({commit}, data) {
|
||||
login({ commit }, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 通过 mock 进行登录
|
||||
api.post('member/login', data, {
|
||||
@ -34,14 +34,14 @@ const actions = {
|
||||
})
|
||||
})
|
||||
},
|
||||
logout({commit}) {
|
||||
logout({ commit }) {
|
||||
commit('removeUserData')
|
||||
commit('menu/invalidRoutes', null, {root: true})
|
||||
commit('tabbar/clean', null, {root: true})
|
||||
commit('menu/removeRoutes', null, {root: true})
|
||||
commit('menu/invalidRoutes', null, { root: true })
|
||||
commit('tabbar/clean', null, { root: true })
|
||||
commit('menu/removeRoutes', null, { root: true })
|
||||
},
|
||||
// 获取我的权限
|
||||
getPermissions({state, commit}) {
|
||||
getPermissions({ state, commit }) {
|
||||
return new Promise(resolve => {
|
||||
// 通过 mock 获取权限
|
||||
api.get('member/permission', {
|
||||
|
Loading…
Reference in New Issue
Block a user