diff --git a/src/router/index.ts b/src/router/index.ts index 9290694b..f2b5a21c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,5 +1,5 @@ import { createRouter, createWebHashHistory } from 'vue-router' -import menus, { LoginPath } from './menu' +import menus, { AccountCenterBindPath, InitHomePath, LoginPath } from './menu' import { cleanToken, getToken } from '@/utils/comm' import { useUserInfo } from '@/store/userInfo' import { useSystem } from '@/store/system' @@ -14,6 +14,8 @@ const router = createRouter({ } }) +const filterPath = [ InitHomePath, AccountCenterBindPath ] + router.beforeEach((to, from, next) => { // TODO 切换路由取消请求 const token = getToken() @@ -24,7 +26,7 @@ router.beforeEach((to, from, next) => { const userInfo = useUserInfo() const system = useSystem() const menu = useMenuStore() - if (!menu.siderMenus.length) { + if (!menu.siderMenus.length && !filterPath.includes(to.path)) { userInfo.getUserInfo().then(() => { system.getSystemVersion().then((menuData: any[]) => { menuData.forEach(r => { diff --git a/src/router/menu.ts b/src/router/menu.ts index 823178a7..cd2e8bf8 100644 --- a/src/router/menu.ts +++ b/src/router/menu.ts @@ -1,4 +1,6 @@ export const LoginPath = '/login' +export const InitHomePath = '/init-home' +export const AccountCenterBindPath = '/account/center/bind' export const AccountMenu = { path: '/account', @@ -55,11 +57,11 @@ export default [ component: () => import('@/views/user/Login/index.vue') }, { - path: '/account/center/bind', + path: AccountCenterBindPath, component: () => import('@/views/account/Center/bind/index.vue') }, { - path: '/init-home', // 初始化 + path: InitHomePath, // 初始化 component: () => import('@/views/init-home/index.vue') }, diff --git a/src/views/user/Login/index.vue b/src/views/user/Login/index.vue index a1ec8cdb..ffa0eab2 100644 --- a/src/views/user/Login/index.vue +++ b/src/views/user/Login/index.vue @@ -237,7 +237,7 @@ const onFinish = async () => { username: form.username, }); LocalStore.set(TOKEN_KEY, res?.result.token); - if (res.result.username === 'admin') { + if (res.result.user?.username === 'admin') { const resp: any = await getInitSet(); if (resp.status === 200 && !resp.result.length) { window.location.href = '/#/init-home';