更新架构

This commit is contained in:
2026-01-27 18:01:54 +08:00
parent 2420ce7660
commit da378a01be
33 changed files with 1490 additions and 239 deletions
+11 -33
View File
@@ -1,7 +1,7 @@
import { createRouter, createWebHashHistory } from "vue-router";
import { convertMenusToRoutes } from "./dynamicRoutes";
// 静态路由:登录页独立,404 页面独立
// 静态路由:登录页独立,404 页面独立home 导航门户独立
const staticRoutes = [
{
path: "/login",
@@ -14,22 +14,14 @@ const staticRoutes = [
name: "Main",
component: () => import("@/views/Main.vue"),
redirect: "/dashboard",
children: [
{
path: "dashboard",
name: "Dashboard",
component: () => import("@/views/dashboard/index.vue"),
meta: {
requiresAuth: true,
title: "仪表盘",
icon: "fa-solid fa-gauge",
id: 1,
isStatic: true
}
}
],
meta: { requiresAuth: true }
},
{
path: "/home",
name: "Home",
component: () => import("@/views/home/index.vue"),
meta: { requiresAuth: true, title: "系统导航", isStandalone: true }
},
{
path: "/:pathMatch(.*)*",
name: "NotFound",
@@ -108,21 +100,7 @@ function addDynamicRoutes(menus) {
component: () => import("@/views/Main.vue"),
redirect: "/dashboard",
meta: { requiresAuth: true },
children: [
{
path: "dashboard",
name: "Dashboard",
component: () => import("@/views/dashboard/index.vue"),
meta: {
requiresAuth: true,
title: "仪表盘",
icon: "fa-solid fa-gauge",
id: 1,
isStatic: true
}
},
...dynamicRoutes // 嵌套路由直接加入 children
]
children: dynamicRoutes // 嵌套路由直接加入 children
});
dynamicRoutesAdded = true;
@@ -167,7 +145,7 @@ router.beforeEach(async (to, from, next) => {
if (!dynamicRoutesAdded) {
await loadAndAddDynamicRoutes();
}
next({ path: "/" });
next({ path: "/home" });
} else {
next();
}
@@ -186,9 +164,9 @@ router.beforeEach(async (to, from, next) => {
return;
}
// 如果匹配不到路由,跳转到404
// 如果匹配不到路由,跳转到首页导航门户
if (to.matched.length === 0) {
next({ name: "NotFound" });
next({ path: "/home" });
return;
}