CN-484 交互优化:登录拦截后,在登录成功后跳转原url
This commit is contained in:
@@ -77,7 +77,7 @@ export default {
|
||||
if (!this.$_.isEmpty(res.data.theme)) {
|
||||
localStorage.setItem(storageKey.theme, res.data.theme)
|
||||
}
|
||||
res.loginSuccessPath = this.loginSuccessPath ? this.loginSuccessPath : localStorage.getItem(storageKey.tokenExpireCurrentPath)
|
||||
res.loginSuccessPath = this.loginSuccessPath
|
||||
this.loginSuccess(res)
|
||||
localStorage.setItem(storageKey.username, this.username)
|
||||
} else if (res.code === 518005) {
|
||||
|
||||
@@ -181,6 +181,7 @@ export default {
|
||||
this.showChangePin = true
|
||||
},
|
||||
logout () {
|
||||
sessionStorage.removeItem(storageKey.tokenExpireCurrentPath)
|
||||
localStorage.removeItem(storageKey.token)
|
||||
get(api.logout)
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ const permissionWhiteList = [...loginWhiteList, '/entityDetail'] // 权限白名
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.path.indexOf('/login') == -1) {
|
||||
localStorage.setItem(storageKey.tokenExpireCurrentPath, to.fullPath)
|
||||
sessionStorage.setItem(storageKey.tokenExpireCurrentPath, to.fullPath)
|
||||
}
|
||||
// 加载iso-3166-2资源
|
||||
loadGeoData()
|
||||
@@ -46,7 +46,16 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
} else {
|
||||
if (loginWhiteList.indexOf(to.path) !== -1) {
|
||||
const tokenExpireCurrentPath = sessionStorage.getItem(storageKey.tokenExpireCurrentPath)
|
||||
if (to.path === '/login' && tokenExpireCurrentPath) {
|
||||
if (hasParam(to.fullPath, 'redirect')) {
|
||||
next()
|
||||
} else {
|
||||
next({ path: '/login', query: { redirect: tokenExpireCurrentPath } })
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
} else {
|
||||
next({ path: '/login', query: { redirect: to.fullPath } })
|
||||
}
|
||||
@@ -69,6 +78,22 @@ export function hasMenu (menuList, route) {
|
||||
})
|
||||
}
|
||||
|
||||
export function hasParam (url, param) {
|
||||
let hasParam = false
|
||||
let tempArr = url.split('?')
|
||||
const query = {}
|
||||
if (tempArr[1]) {
|
||||
tempArr = tempArr[1].split('&')
|
||||
tempArr.forEach(t => {
|
||||
const kv = t.split('=')
|
||||
if (kv[0] === param) {
|
||||
hasParam = true
|
||||
}
|
||||
})
|
||||
}
|
||||
return hasParam
|
||||
}
|
||||
|
||||
export function hasButton (buttonList, code) {
|
||||
return buttonList.some(button => button === code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user