import React from "react";
import { useState } from "react";
import { XphAuth } from "xph-crud";
import { Button } from "antd";
const ReactApp: React.FC = () => {
const [myPermissions, setMyPermissions] = useState<string[]>([]);
const auth = (key) => {
return myPermissions.includes(key);
};
const onClickGetAllPermissionsBtn = () => {
setMyPermissions(["add", "edit", "delete"]);
};
const onClickGetAddPermissionBtn = () => {
setMyPermissions(["add"]);
};
return (
<div>
<Button onClick={onClickGetAllPermissionsBtn}>点击获取所有权限</Button>
<Button onClick={onClickGetAddPermissionBtn}>点击获取["add"] 权限</Button>
{}
<XphAuth auth={auth} authCode={["add", "edit", "delete"]}>
<p>我是需要鉴权的内容</p>
</XphAuth>
</div>
);
};
export default ReactApp;