feat: 新增第二种按钮权限指令(根据登录接口返回的permissions字段进行判断) (#1177)

* feat: 新增第二种按钮权限指令(根据登录接口返回的`permissions`字段进行判断)
This commit is contained in:
xiaoming
2024-08-12 13:32:04 +08:00
committed by GitHub
parent 96152ed134
commit 244ab7f990
20 changed files with 361 additions and 22 deletions

View File

@@ -0,0 +1,5 @@
import perms from "./src/perms";
const Perms = perms;
export { Perms };

View File

@@ -0,0 +1,20 @@
import { defineComponent, Fragment } from "vue";
import { hasPerms } from "@/utils/auth";
export default defineComponent({
name: "Perms",
props: {
value: {
type: undefined,
default: []
}
},
setup(props, { slots }) {
return () => {
if (!slots) return null;
return hasPerms(props.value) ? (
<Fragment>{slots.default?.()}</Fragment>
) : null;
};
}
});