fix: 更新路由为后台配置,修改admim文件名称为admin

This commit is contained in:
2025-03-12 09:05:28 +08:00
parent 6735d8dedb
commit ace23e89ee
29 changed files with 2107 additions and 617 deletions

View File

@@ -4,7 +4,7 @@ import { store } from "@/store";
import router from "@/router";
import MenuAPI, { type RouteVO } from "@/api/account/menu";
const isTest = true//是否是本地调试
const isTest = false//是否是本地调试
const modules = import.meta.glob("../../views/**/**.vue");
const Layout = () => import("@/layout/index.vue");
@@ -34,6 +34,7 @@ export const usePermissionStore = defineStore("permission", () => {
if (!isTest) {
const dynamicRoutes = parseDynamicRoutes(data.filter(v => v.type == 0));
routes.value = [...constantRoutes, ...dynamicRoutes];
console.log(routes.value)
isRoutesLoaded.value = true;
resolve(dynamicRoutes);
} else {
@@ -103,7 +104,6 @@ export const usePermissionStore = defineStore("permission", () => {
const parseDynamicRoutes = (rawRoutes: RouteVO[]): RouteRecordRaw[] => {
const parsedRoutes: RouteRecordRaw[] = [];
rawRoutes.forEach((route) => {
console.log(route.path)
const normalizedRoute = {
path: route.path,
meta: {
@@ -113,24 +113,26 @@ const parseDynamicRoutes = (rawRoutes: RouteVO[]): RouteRecordRaw[] => {
alwaysShow: route.path && route.path.startsWith('/') ? true : false,
hidden: route.hidden,
},
name: route.name,
children: route.children,
component: route.component,
} as RouteRecordRaw;
// 处理组件路径
normalizedRoute.component =
!normalizedRoute.component
? Layout
: modules[`../../views/${normalizedRoute.component}.vue`] ||
modules["../../views/error-page/404.vue"];
// 递归解析子路由
if (normalizedRoute.children) {
// normalizedRoute.redirect = (!normalizedRoute.redirect && route.children.length <= 1) ? normalizedRoute.children[0].path : normalizedRoute.path
normalizedRoute.children = parseDynamicRoutes(route.children);
}
console.log(normalizedRoute)
parsedRoutes.push(normalizedRoute);
if (normalizedRoute.path !== '/' && normalizedRoute.path) {
parsedRoutes.push(normalizedRoute);
}
});
return parsedRoutes;