mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-17 00:52:51 +00:00
31 lines
568 B
TypeScript
31 lines
568 B
TypeScript
import { useStore } from "../store";
|
|
import { isObject } from "lodash";
|
|
|
|
function parse(value: any) {
|
|
const { menu } = useStore();
|
|
|
|
if (typeof value == "string") {
|
|
return value ? menu.perms.some((e: any) => e.includes(value.replace(/\s/g, ""))) : false;
|
|
} else {
|
|
return Boolean(value);
|
|
}
|
|
}
|
|
|
|
export function checkPerm(value: any) {
|
|
if (!value) {
|
|
return false;
|
|
}
|
|
|
|
if (isObject(value)) {
|
|
if (value.or) {
|
|
return value.or.some(parse);
|
|
}
|
|
|
|
if (value.and) {
|
|
return value.and.some((e: any) => !parse(e)) ? false : true;
|
|
}
|
|
}
|
|
|
|
return parse(value);
|
|
}
|