This commit is contained in:
ky_sunl
2021-04-22 13:37:25 +00:00
parent 575a22954f
commit d1c9e5a71e
699 changed files with 1062425 additions and 40640 deletions

34
Web/src/router/index.js Normal file
View File

@@ -0,0 +1,34 @@
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const router = new Router({
mode: 'history',
routes: [{
path: '/',
component: () => import('@/views/main/index'),
}, {
path: '/login',
component: () => import('@/views/login/index')
}]
})
// 路由守卫
import { token } from '@/common/token'
router.beforeEach((to, from, next) => {
if (token.value) {
if (to.path === '/login') {
next({
path: '/'
})
} else {
next()
}
} else if (!token.value && to.path !== '/login') {
next({ path: '/login' })
}
next()
})
export default router