|
@@ -15,6 +15,7 @@ import { usePermissionStoreHook } from "/@/store/modules/permission";
|
|
|
const Layout = () => import("/@/layout/index.vue");
|
|
|
const IFrame = () => import("/@/layout/frameView.vue");
|
|
|
import { useUserStoreHook } from "/@/store/modules/user";
|
|
|
+import { getAsyncRoutes } from "../api/user";
|
|
|
// https://cn.vitejs.dev/guide/features.html#glob-import
|
|
|
const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}");
|
|
|
|
|
@@ -112,14 +113,18 @@ function resetRouter(): void {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+const whiteRoutes = ["Welcome", "/", "Login", "Accept", "Redirect"];
|
|
|
+
|
|
|
// 初始化路由
|
|
|
function initRouter(data = {}) {
|
|
|
+ // removeRoutes();
|
|
|
return new Promise((resolve, reject) => {
|
|
|
useUserStoreHook()
|
|
|
.postMenuList(data)
|
|
|
.then(({ code, data }) => {
|
|
|
if (code === 0) {
|
|
|
const arrag: Array<any> = [];
|
|
|
+
|
|
|
data.forEach(e => {
|
|
|
const [icon] = e.menu_img.split("ep:");
|
|
|
const eitem = {
|
|
@@ -142,13 +147,13 @@ function initRouter(data = {}) {
|
|
|
meta: {
|
|
|
icon: s.menu_img,
|
|
|
showLink: s.is_private + "" === "1",
|
|
|
- title: `${s.menu_name}`
|
|
|
+ title: `${s.menu_name} `
|
|
|
}
|
|
|
};
|
|
|
// console.log(sitem);
|
|
|
eitem.children.push(sitem);
|
|
|
if (si === 0) {
|
|
|
- eitem.redirect += `/${s.menu_route}`;
|
|
|
+ eitem.redirect += `/ ${s.menu_route} `;
|
|
|
}
|
|
|
});
|
|
|
arrag.push(eitem);
|
|
@@ -172,7 +177,12 @@ function initRouter(data = {}) {
|
|
|
router.options.routes[0].children.push(v);
|
|
|
// 最终路由进行升序
|
|
|
ascending(router.options.routes[0].children);
|
|
|
- if (!router.hasRoute(v?.name)) router.addRoute(v);
|
|
|
+ v.name = v.path;
|
|
|
+
|
|
|
+ if (!router.hasRoute(v?.name)) {
|
|
|
+ router.addRoute(v);
|
|
|
+ }
|
|
|
+
|
|
|
const flattenRouters = router
|
|
|
.getRoutes()
|
|
|
.find(n => n.path === "/");
|
|
@@ -215,6 +225,7 @@ function formatFlatteningRoutes(routesList: RouteRecordRaw[]) {
|
|
|
.concat(hierarchyList[i].children, hierarchyList.slice(i + 1));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return hierarchyList;
|
|
|
}
|
|
|
|
|
@@ -231,7 +242,7 @@ function formatTwoStageRoutes(routesList: RouteRecordRaw[]) {
|
|
|
if (v.path === "/") {
|
|
|
newRoutesList.push({
|
|
|
component: v.component,
|
|
|
- name: v.name,
|
|
|
+ name: v.path,
|
|
|
path: v.path,
|
|
|
redirect: v.redirect,
|
|
|
meta: v.meta,
|