From 4403ee5f5ec8f4575c6b965b157255bb560c5dd1 Mon Sep 17 00:00:00 2001 From: SaarHV Date: Fri, 27 Jan 2023 14:13:49 +0800 Subject: [PATCH 1/3] Add authFuntion util --- src/utils/authFuntion.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/utils/authFuntion.ts diff --git a/src/utils/authFuntion.ts b/src/utils/authFuntion.ts new file mode 100644 index 0000000..468ea43 --- /dev/null +++ b/src/utils/authFuntion.ts @@ -0,0 +1,6 @@ +import { useUserStore } from '/@/store/userInfo' + +export function auth(value: string): boolean { + const stores = useUserStore() + return stores.userInfos.authBtnList.some((v: string) => v === value) +} -- Gitee From 9641dc54f3c89ac97bef64ce393e1ef52b9dc5aa Mon Sep 17 00:00:00 2001 From: SaarHV Date: Fri, 27 Jan 2023 14:15:20 +0800 Subject: [PATCH 2/3] Add multiple auth funtion util --- src/utils/authFuntion.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/utils/authFuntion.ts b/src/utils/authFuntion.ts index 468ea43..b28bea9 100644 --- a/src/utils/authFuntion.ts +++ b/src/utils/authFuntion.ts @@ -4,3 +4,16 @@ export function auth(value: string): boolean { const stores = useUserStore() return stores.userInfos.authBtnList.some((v: string) => v === value) } + +// Multiple permission verifications, true if one is satisfied +export function auths(value: Array): boolean { + let flag = false + const stores = useUserStore() + stores.userInfos.authBtnList.map((val: string) => { + value.map((v: string) => { + if (val === v) flag = true + }) + }) + return flag + } + \ No newline at end of file -- Gitee From 0edf0c89091fabbf2ee4ff1ab05fabe2f0b8ded7 Mon Sep 17 00:00:00 2001 From: SaarHV Date: Fri, 27 Jan 2023 14:16:33 +0800 Subject: [PATCH 3/3] Add all-permission auth funtion util --- src/utils/authFuntion.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils/authFuntion.ts b/src/utils/authFuntion.ts index b28bea9..21631f8 100644 --- a/src/utils/authFuntion.ts +++ b/src/utils/authFuntion.ts @@ -1,4 +1,5 @@ import { useUserStore } from '/@/store/userInfo' +import { judementSameArr } from '/@/utils/arrayOperation' export function auth(value: string): boolean { const stores = useUserStore() @@ -16,4 +17,10 @@ export function auths(value: Array): boolean { }) return flag } + + // Multiple permission verifications, true if all is satisfied +export function authAll(value: Array): boolean { + const stores = useUserStore() + return judementSameArr(value, stores.userInfos.authBtnList) + } \ No newline at end of file -- Gitee