This commit is contained in:
zhangdongxue
2021-09-18 22:05:32 +08:00
parent 71c513e07c
commit e97467a46a

View File

@@ -1,6 +1,6 @@
import vuex from '@/store'
import type {MyRouteMeta, MyRouteRecordRaw} from '@/types/router'
import {createRouter, createWebHistory} from 'vue-router'
import type { MyRouteMeta, MyRouteRecordRaw } from '@/types/router'
import { createRouter, createWebHistory } from 'vue-router'
import auth from './routers/auth'
import user from './routers/user'
@@ -53,9 +53,9 @@ router.beforeEach((to, from, next) => {
const isAuthenticated: string = vuex.getters.isLogin
if (to.name !== 'AuthLogin' && to.meta.requiresAuth && !isAuthenticated) {
next({name: 'AuthLogin', query: {to: to.path}})
next({ name: 'AuthLogin', query: { to: to.path }})
} else if (isAuthenticated && (to.name == 'AuthLogin' || to.name == 'AuthRegister')) {
next({name: 'Home'})
next({ name: 'Home' })
} else {
next()
}