|
|
@ -7,7 +7,8 @@ import { usePageLoading } from '@/hooks/web/usePageLoading' |
|
|
|
import { useDictStoreWithOut } from '@/store/modules/dict' |
|
|
|
import { useDictStoreWithOut } from '@/store/modules/dict' |
|
|
|
import { useUserStoreWithOut } from '@/store/modules/user' |
|
|
|
import { useUserStoreWithOut } from '@/store/modules/user' |
|
|
|
import { usePermissionStoreWithOut } from '@/store/modules/permission' |
|
|
|
import { usePermissionStoreWithOut } from '@/store/modules/permission' |
|
|
|
import { getTenantId, getAppId } from '@/utils/auth' |
|
|
|
import { useAppStoreWithOut } from '@/store/modules/app' |
|
|
|
|
|
|
|
import { getTenantId, getAppId, setTenantId, setAppId } from '@/utils/auth' |
|
|
|
import cache from '@/plugins/cache' |
|
|
|
import cache from '@/plugins/cache' |
|
|
|
|
|
|
|
|
|
|
|
const { start, done } = useNProgress() |
|
|
|
const { start, done } = useNProgress() |
|
|
@ -39,13 +40,20 @@ router.beforeEach(async (to, from, next) => { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (getAccessToken()) { |
|
|
|
if (getAccessToken()) { |
|
|
|
if (to.path === '/login') { |
|
|
|
if (to.path === '/login') { |
|
|
|
|
|
|
|
if (to.query?.tenantId && to.query?.appId) { |
|
|
|
|
|
|
|
setApp(to.query.tenantId, to.query.appId) |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
next({ path: '/' }) |
|
|
|
next({ path: '/' }) |
|
|
|
|
|
|
|
}, 1500) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
next({ path: '/' }) |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 获取所有字典
|
|
|
|
// 获取所有字典
|
|
|
|
const dictStore = useDictStoreWithOut() |
|
|
|
const dictStore = useDictStoreWithOut() |
|
|
|
const userStore = useUserStoreWithOut() |
|
|
|
const userStore = useUserStoreWithOut() |
|
|
|
const permissionStore = usePermissionStoreWithOut() |
|
|
|
const permissionStore = usePermissionStoreWithOut() |
|
|
|
if (!dictStore.getIsSetDict && to.path != '/nm-detail') { |
|
|
|
if (!dictStore.getIsSetDict) { |
|
|
|
await dictStore.setDictMap() |
|
|
|
await dictStore.setDictMap() |
|
|
|
} |
|
|
|
} |
|
|
|
if (!userStore.getIsSetUser) { |
|
|
|
if (!userStore.getIsSetUser) { |
|
|
@ -72,15 +80,23 @@ router.beforeEach(async (to, from, next) => { |
|
|
|
const tenantId = getTenantId() |
|
|
|
const tenantId = getTenantId() |
|
|
|
const appId = getAppId() |
|
|
|
const appId = getAppId() |
|
|
|
if (tenantId && appId) { |
|
|
|
if (tenantId && appId) { |
|
|
|
next(`/crm/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
|
|
next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
next(`/crm/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
|
|
next(`/oa/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setApp(tenantId, appId) { |
|
|
|
|
|
|
|
setTenantId(tenantId) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setAppId(appId) |
|
|
|
|
|
|
|
const appStore = useAppStoreWithOut() |
|
|
|
|
|
|
|
appStore.setAppInfo(appId) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
router.afterEach((to) => { |
|
|
|
router.afterEach((to) => { |
|
|
|
useTitle(to?.meta?.title) |
|
|
|
useTitle(to?.meta?.title) |
|
|
|
done() // 结束Progress
|
|
|
|
done() // 结束Progress
|
|
|
|