修改提示框样式、完成付费片单、推荐跳转
Change-Id: Ie84c53d4e306435144b1f26ceb39cc182e99d57a
diff --git a/src/components/AuthButton.jsx b/src/components/AuthButton.jsx
new file mode 100644
index 0000000..b5cc431
--- /dev/null
+++ b/src/components/AuthButton.jsx
@@ -0,0 +1,22 @@
+import {useContext} from "react";
+import { UserContext } from "../context/UserContext";
+import toast from "react-hot-toast";
+const AuthButton = ({children, roles,onClick, ...rest }) => {
+ const {user} = useContext(UserContext);
+ const {levelRole} = user;
+ let clickFunc = onClick
+ if(!roles || roles.length === 0 || roles.includes(levelRole)){
+ clickFunc = onClick;
+ }else{
+ clickFunc = () => {
+ toast.error("权限不足");
+ }
+ }
+
+ return (
+ <button onClick={clickFunc} {...rest}>
+ {children}
+ </button>
+ )
+}
+export default AuthButton;
\ No newline at end of file