From 914dc61571fc489ee7b76212366e355720d62fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=83=E5=B9=B4=E5=A4=8F?= <2098833867@qq.com> Date: Mon, 6 Mar 2023 16:30:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8F=91=E5=B8=83=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=97=A0=E6=B3=95=E6=88=90=E5=8A=9F=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E8=B7=AF=E7=94=B1=E9=A1=B5=E9=9D=A2=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/use-permission.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hooks/use-permission.ts b/src/hooks/use-permission.ts index 69d3b04..4050e38 100644 --- a/src/hooks/use-permission.ts +++ b/src/hooks/use-permission.ts @@ -152,9 +152,12 @@ export function filterAsyncRouter({ menuList, roles, codes }: { menuList; roles? // accessRoutes = filterAsyncRouterByCodes(roleCodeRoutes, codes) //by codes // } + // @ts-ignore + const views = import.meta.glob('../views/**/*.vue') as Record Promise> + function scanRouter(items: any[]) { for (const item of items) { - if (item.component === 'Layout') item.component = () => Layout + if (item.component === 'Layout') item.component = async () => Layout else if (typeof item.component === 'string') { let url: string = item.component if (url.startsWith('@/')) { @@ -163,7 +166,7 @@ export function filterAsyncRouter({ menuList, roles, codes }: { menuList; roles? item.component = async () => { let component try { - component = await import(/* @vite-ignore */ url) + component = await views[url]() } catch (e) { console.error(e) component = await import('../views/error-page/404.vue')