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