From ce60f630c4c55f65001dd0ddb958e953a8a726e9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 4 Jan 2025 11:14:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86=EF=BC=9A=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20el-table-v2=20=E8=A7=A3=E5=86=B3=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E8=BF=87=E5=A4=9A=E5=90=8E=EF=BC=8C=E5=AD=98=E5=9C=A8=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/directives/permission/hasPermi.ts | 21 +- src/views/system/area/index.vue | 20 +- src/views/system/menu/index.vue | 345 +++++++++----------------- 3 files changed, 141 insertions(+), 245 deletions(-) diff --git a/src/directives/permission/hasPermi.ts b/src/directives/permission/hasPermi.ts index 931f44b3..02e2fbc7 100644 --- a/src/directives/permission/hasPermi.ts +++ b/src/directives/permission/hasPermi.ts @@ -5,18 +5,10 @@ const { t } = useI18n() // 国际化 export function hasPermi(app: App) { app.directive('hasPermi', (el, binding) => { - const { wsCache } = useCache() const { value } = binding - const all_permission = '*:*:*' - const userInfo = wsCache.get(CACHE_KEY.USER) - const permissions = userInfo?.permissions || [] if (value && value instanceof Array && value.length > 0) { - const permissionFlag = value - - const hasPermissions = permissions.some((permission: string) => { - return all_permission === permission || permissionFlag.includes(permission) - }) + const hasPermissions = hasPermission(value) if (!hasPermissions) { el.parentNode && el.parentNode.removeChild(el) @@ -26,3 +18,14 @@ export function hasPermi(app: App) { } }) } + +export const hasPermission = (permission: string[]) => { + const { wsCache } = useCache() + const all_permission = '*:*:*' + const userInfo = wsCache.get(CACHE_KEY.USER) + const permissions = userInfo?.permissions || [] + + return permissions.some((p: string) => { + return all_permission === p || permission.includes(p) + }) +} \ No newline at end of file diff --git a/src/views/system/area/index.vue b/src/views/system/area/index.vue index 72cbcad2..339ecefb 100644 --- a/src/views/system/area/index.vue +++ b/src/views/system/area/index.vue @@ -16,6 +16,7 @@ - - \ No newline at end of file