mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-10 03:10:25 +08:00
feat: 前端升级至vue3,后端代码结构重构,新增权限管理相关功能
This commit is contained in:
23
mayfly_go_web/src/common/utils/authFunction.ts
Normal file
23
mayfly_go_web/src/common/utils/authFunction.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { store } from '@/store/index.ts';
|
||||
import { judementSameArr } from '@/common/utils/arrayOperation.ts';
|
||||
|
||||
// 单个权限验证
|
||||
export function auth(value: string) {
|
||||
return store.state.userInfos.userInfos.permissions.some((v: any) => v === value);
|
||||
}
|
||||
|
||||
// 多个权限验证,满足一个则为 true
|
||||
export function auths(value: Array<string>) {
|
||||
let flag = false;
|
||||
store.state.userInfos.userInfos.permissions.map((val: any) => {
|
||||
value.map((v: any) => {
|
||||
if (val === v) flag = true;
|
||||
});
|
||||
});
|
||||
return flag;
|
||||
}
|
||||
|
||||
// 多个权限验证,全部满足则为 true
|
||||
export function authAll(value: Array<string>) {
|
||||
return judementSameArr(value, store.state.userInfos.userInfos.permissions);
|
||||
}
|
||||
Reference in New Issue
Block a user