fix: 优化跳转初始化页面
This commit is contained in:
parent
ea4cb2492b
commit
a1b67ce45c
|
@ -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 => {
|
||||
|
|
|
@ -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')
|
||||
},
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue