feat: first commit
This commit is contained in:
commit
8a85cf5b78
64 files changed
+7832
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import Login from '@/pages/common/login.vue'
|
||||
import Layout from '@/layouts/Layout.vue'
|
||||
|
||||
export const asyncRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
name: 'dashboard',
|
||||
path: 'dashboard',
|
||||
component: () => import('@/pages/dashboard/index.vue'),
|
||||
meta: {
|
||||
title: '仪表盘',
|
||||
icon: 'app'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'users',
|
||||
path: 'users',
|
||||
component: () => import('@/pages/user/index.vue'),
|
||||
meta: {
|
||||
title: '用户',
|
||||
icon: 'user'
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
name: 'layout',
|
||||
component: Layout,
|
||||
path: '/',
|
||||
redirect: {
|
||||
name: 'dashboard'
|
||||
},
|
||||
children: asyncRoutes
|
||||
},
|
||||
{
|
||||
name: 'login',
|
||||
path: '/login',
|
||||
component: Login
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.name !== 'login') {
|
||||
const appStore = useAppStore()
|
||||
appStore.isLogin ? next() : next({ name: 'login' })
|
||||
return
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in new issue
Block a user