From f56e474c81bb25845b46cf99c85bd313dbfcd3b5 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期六, 31 一月 2026 19:26:25 +0800
Subject: [PATCH] 项目初始化+首页+公告详情页面
---
src/router/index.js | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/router/index.js b/src/router/index.js
new file mode 100644
index 0000000..82fc678
--- /dev/null
+++ b/src/router/index.js
@@ -0,0 +1,23 @@
+import { createRouter, createWebHistory } from 'vue-router'
+import authPage from '@/router/auth/index.js'
+import errorPage from '@/router/error/index.js'
+import mainPage from '@/router/main/index.js'
+
+const router = createRouter({
+ history: createWebHistory(import.meta.env.BASE_URL),
+ routes: [...mainPage, ...authPage, ...errorPage],
+})
+
+router.beforeEach((to, from, next) => {
+ if (!to.matched.length) {
+ if (to.path === '/') {
+ next({ path: '/main/home' })
+ } else {
+ next({ path: '/error/404', query: { errorUrl: to.path } })
+ }
+ } else {
+ next()
+ }
+})
+
+export default router
--
Gitblit v1.8.0