mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 17:07:19 +08:00
fix: 采用import.meta.glob方法匹配动态路由
This commit is contained in:
parent
07aff1fcfc
commit
ad0281839f
@ -10,6 +10,9 @@ import permissionRouter from "./modules/permission";
|
|||||||
import remainingRouter from "./modules/remaining"; //静态路由
|
import remainingRouter from "./modules/remaining"; //静态路由
|
||||||
import Layout from "/@/layout/index.vue";
|
import Layout from "/@/layout/index.vue";
|
||||||
|
|
||||||
|
// https://cn.vitejs.dev/guide/features.html#glob-import
|
||||||
|
const modulesRoutes = import.meta.glob("/src/views/*/*/*.vue");
|
||||||
|
|
||||||
import { getAsyncRoutes } from "/@/api/routes";
|
import { getAsyncRoutes } from "/@/api/routes";
|
||||||
import { storageSession } from "../utils/storage";
|
import { storageSession } from "../utils/storage";
|
||||||
import { i18n } from "/@/plugins/i18n/index";
|
import { i18n } from "/@/plugins/i18n/index";
|
||||||
@ -31,9 +34,7 @@ const addAsyncRoutes = (arrRoutes: Array<string>) => {
|
|||||||
if (v.redirect) {
|
if (v.redirect) {
|
||||||
v.component = Layout;
|
v.component = Layout;
|
||||||
} else {
|
} else {
|
||||||
// https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
|
v.component = modulesRoutes[`/src/views${v.path}/index.vue`];
|
||||||
v.component = () =>
|
|
||||||
import(/* @vite-ignore */ `/@/views${v.path}/index.vue`);
|
|
||||||
}
|
}
|
||||||
if (v.children) {
|
if (v.children) {
|
||||||
addAsyncRoutes(v.children);
|
addAsyncRoutes(v.children);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user