|
@@ -11,19 +11,16 @@ NProgress.configure({ showSpinner: false })
|
|
|
|
|
|
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
|
|
|
|
|
|
-router.beforeEach((to, from, next) => {
|
|
|
+router.beforeEach(async(to, from, next) => {
|
|
|
if (to.path !== from.path) {
|
|
|
NProgress.start();
|
|
|
}
|
|
|
- if (methods.getQueryVariable('TenantId') && !sessionStorage.TenantId) {
|
|
|
- sessionStorage.TenantId = methods.getQueryVariable('TenantId')
|
|
|
- }
|
|
|
- if (methods.getQueryVariable('TenantId') && sessionStorage.TenantId == undefined) {
|
|
|
- sessionStorage.TenantId = methods.getQueryVariable('TenantId')
|
|
|
- }
|
|
|
- if (methods.getQueryVariable('TenantId') && sessionStorage.TenantId != methods.getQueryVariable('TenantId')) {
|
|
|
- sessionStorage.TenantId = methods.getQueryVariable('TenantId')
|
|
|
+
|
|
|
+ if (!store.state.TENANT_NANE) {
|
|
|
+ await store.dispatch('findTenantId')
|
|
|
}
|
|
|
+ // TENANT_NANE
|
|
|
+ // TenantId
|
|
|
if (getToken()) {
|
|
|
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
|
|
/* has token*/
|
|
@@ -46,16 +43,11 @@ router.beforeEach((to, from, next) => {
|
|
|
})
|
|
|
})
|
|
|
} else {
|
|
|
- if (!to.query.TenantId) {
|
|
|
- to.query.TenantId = sessionStorage.TenantId
|
|
|
- next(to)
|
|
|
- } else {
|
|
|
if (!to.path.includes('/user/profile')) {
|
|
|
checkFunc()
|
|
|
}
|
|
|
console.log("to:",to)
|
|
|
next()
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -64,11 +56,7 @@ router.beforeEach((to, from, next) => {
|
|
|
// 在免登录白名单,直接进入
|
|
|
next()
|
|
|
} else {
|
|
|
- if (sessionStorage.TenantId == undefined) {
|
|
|
- next(`/login`) // 否则全部重定向到登录页
|
|
|
- } else {
|
|
|
- next(`/login?redirect=${to.fullPath}&TenantId=${sessionStorage.TenantId}`) // 否则全部重定向到登录页
|
|
|
- }
|
|
|
+ next(`/login`)
|
|
|
NProgress.done()
|
|
|
}
|
|
|
}
|