mirror of
https://github.com/PlayEdu/backend
synced 2025-12-23 07:19:32 +08:00
部门按钮替换为权限按钮
This commit is contained in:
@@ -3,4 +3,5 @@ export * from "./header";
|
||||
export * from "./left-menu";
|
||||
export * from "./upload-image-button";
|
||||
export * from "./tree-department";
|
||||
export * from "./back-bar";
|
||||
export * from "./back-bar";
|
||||
export * from "./permission-button";
|
||||
0
src/compenents/permission-button/index.module.less
Normal file
0
src/compenents/permission-button/index.module.less
Normal file
50
src/compenents/permission-button/index.tsx
Normal file
50
src/compenents/permission-button/index.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Button } from "antd";
|
||||
import { useSelector } from "../../store/hooks";
|
||||
|
||||
interface PropInterface {
|
||||
type: "link" | "text" | "primary" | "default";
|
||||
text: string;
|
||||
p: string;
|
||||
class: string;
|
||||
icon: any;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export const PerButton = (props: PropInterface) => {
|
||||
const permisssions = useSelector((state: any) => state.permisssions);
|
||||
const through = () => {
|
||||
if (!permisssions) {
|
||||
return false;
|
||||
}
|
||||
return typeof permisssions[props.p] !== "undefined";
|
||||
};
|
||||
return (
|
||||
<>
|
||||
{through() && props.type === "link" && (
|
||||
<Button
|
||||
className={props.class}
|
||||
type="link"
|
||||
danger
|
||||
icon={props.icon}
|
||||
onClick={() => {
|
||||
props.onClick();
|
||||
}}
|
||||
>
|
||||
{props.text}
|
||||
</Button>
|
||||
)}
|
||||
{through() && props.type !== "link" && (
|
||||
<Button
|
||||
className={props.class}
|
||||
type={props.type}
|
||||
icon={props.icon}
|
||||
onClick={() => {
|
||||
props.onClick();
|
||||
}}
|
||||
>
|
||||
{props.text}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user