feat: 初始化

This commit is contained in:
2026-06-02 13:38:43 +08:00
parent b5aaeb3962
commit 116fe86f47
34 changed files with 3209 additions and 0 deletions

19
src/router/guard.ts Normal file
View File

@@ -0,0 +1,19 @@
import type { Router } from 'vue-router'
/**
* 通用路由守卫
*/
function setupCommonGuard(router: Router) {
// @ts-ignore
router.beforeEach(async (to, from) => {
// TODO: 路由守卫
return true
})
}
// 路由守卫
function createRouterGuard(router: Router) {
setupCommonGuard(router)
}
export { createRouterGuard }

16
src/router/index.ts Normal file
View File

@@ -0,0 +1,16 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouterGuard } from './guard.ts'
import routes from './routes.ts'
/**
* 创建路由实例
*/
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: routes
})
// 创建路由守卫
createRouterGuard(router)
export default router

29
src/router/routes.ts Normal file
View File

@@ -0,0 +1,29 @@
import type { RouteRecordRaw } from 'vue-router'
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Root',
component: () => import('@/views/HomeView.vue'),
children: []
},
{
path: '/auth',
name: 'Authentication',
component: () => import('@/layouts/AuthPageLayout.vue'),
children: [
{
path: 'login',
name: 'Login',
component: () => import('@/views/auth/login.vue')
},
{
path: 'register',
name: 'Register',
component: () => import('@/views/auth/register.vue')
}
]
}
]
export default routes