sc
This commit is contained in:
@@ -20,54 +20,45 @@ const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/regis
|
|||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
start()
|
start()
|
||||||
loadStart()
|
loadStart()
|
||||||
if (getAppId() && to.query?.appId && getAppId() != to.query?.appId) {
|
if (getAccessToken()) {
|
||||||
removeToken()
|
if (to.path === '/login') {
|
||||||
cache?.local?.delete('appInfo')
|
next({ path: '/' })
|
||||||
cache?.local?.delete('roleRouters')
|
|
||||||
cache?.local?.delete('user')
|
|
||||||
cache?.local?.delete('App_ID')
|
|
||||||
next(`/login`)
|
|
||||||
} else {
|
|
||||||
if (getAccessToken()) {
|
|
||||||
if (to.path === '/login') {
|
|
||||||
next({ path: '/' })
|
|
||||||
} else {
|
|
||||||
// 获取所有字典
|
|
||||||
const dictStore = useDictStoreWithOut()
|
|
||||||
const userStore = useUserStoreWithOut()
|
|
||||||
const permissionStore = usePermissionStoreWithOut()
|
|
||||||
if (!dictStore.getIsSetDict) {
|
|
||||||
await dictStore.setDictMap()
|
|
||||||
}
|
|
||||||
if (!userStore.getIsSetUser) {
|
|
||||||
isRelogin.show = true
|
|
||||||
await userStore.setUserInfoAction()
|
|
||||||
isRelogin.show = false
|
|
||||||
// 后端过滤菜单
|
|
||||||
await permissionStore.generateRoutes()
|
|
||||||
permissionStore.getAddRouters.forEach((route) => {
|
|
||||||
router.addRoute(route) // 动态添加可访问路由表
|
|
||||||
})
|
|
||||||
const redirectPath = from.query.redirect || to.path
|
|
||||||
const redirect = decodeURIComponent(redirectPath)
|
|
||||||
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
|
|
||||||
next(nextData)
|
|
||||||
} else {
|
|
||||||
next()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (whiteList.indexOf(to.path) !== -1) {
|
// 获取所有字典
|
||||||
next()
|
const dictStore = useDictStoreWithOut()
|
||||||
} else {
|
const userStore = useUserStoreWithOut()
|
||||||
// const tenantId = getTenantId()
|
const permissionStore = usePermissionStoreWithOut()
|
||||||
// const appId = getAppId()
|
if (!dictStore.getIsSetDict) {
|
||||||
// if (tenantId && appId) {
|
await dictStore.setDictMap()
|
||||||
// next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
||||||
// } else {
|
|
||||||
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
if (!userStore.getIsSetUser) {
|
||||||
|
isRelogin.show = true
|
||||||
|
await userStore.setUserInfoAction()
|
||||||
|
isRelogin.show = false
|
||||||
|
// 后端过滤菜单
|
||||||
|
await permissionStore.generateRoutes()
|
||||||
|
permissionStore.getAddRouters.forEach((route) => {
|
||||||
|
router.addRoute(route) // 动态添加可访问路由表
|
||||||
|
})
|
||||||
|
const redirectPath = from.query.redirect || to.path
|
||||||
|
const redirect = decodeURIComponent(redirectPath)
|
||||||
|
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
|
||||||
|
next(nextData)
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
// const tenantId = getTenantId()
|
||||||
|
// const appId = getAppId()
|
||||||
|
// if (tenantId && appId) {
|
||||||
|
// next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||||
|
// } else {
|
||||||
|
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user