From 333d41bc5e76ebdb02bb6242fbaec634450cf32e Mon Sep 17 00:00:00 2001 From: "X.Mo" Date: Tue, 19 Nov 2024 21:48:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(front-permission):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=9D=83=E9=99=90=E6=A3=80=E6=9F=A5=E6=97=B6?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=80=BC=E4=B8=BA=E7=A9=BA=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E6=97=B6=EF=BC=9A{}=EF=BC=8C=E8=BF=9B=E5=85=A5=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=9D=A1=E4=BB=B6=EF=BC=8C=E5=AF=BC=E8=87=B4=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=97=A0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/router/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/src/router/index.ts b/web/src/router/index.ts index 561b66de..ca869c4b 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -15,6 +15,7 @@ import '@/assets/styles/nprogress.scss' import hasAuth from '@/utils/permission/hasAuth.ts' import hasRole from '@/utils/permission/hasRole.ts' import hasUser from '@/utils/permission/hasUser.ts' +import { isEmpty } from 'radash' const { isLoading } = useNProgress() @@ -53,16 +54,19 @@ router.afterEach(async (to) => { isLoading.value = false const keepAliveStore = useKeepAliveStore() - if (to.meta.auth && !hasAuth(to.meta.auth as string[])) { + if (!isEmpty(to.meta.auth) && !hasAuth(to.meta.auth as string[])) { await router.push({ path: '/403' }) + return } - if (to.meta.role && !hasRole(to.meta.role as string[])) { + if (!isEmpty(to.meta.role) && !hasRole(to.meta.role as string[])) { await router.push({ path: '/403' }) + return } - if (to.meta.user && !hasUser(to.meta.user as string[])) { + if (!isEmpty(to.meta.user) && !hasUser(to.meta.user as string[])) { await router.push({ path: '/403' }) + return } if (to.meta.cache) {