forked from UzTech/Vue3-typescript-demo
format
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user