This commit is contained in:
none
2023-03-23 17:29:43 +08:00
parent 9f90bd75d3
commit 89b6307e2d
16 changed files with 163 additions and 161 deletions

View File

@@ -1,19 +1,19 @@
import React from "react";
import styles from "./index.module.less";
import { Button, Dropdown, MenuProps } from "antd";
import { useSelector } from "../../store/hooks";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { LoginOutActionCreator } from "../../store/user/userActions";
import avatar from "../../assets/images/commen/avatar.png";
import { logoutAction } from "../../store/user/loginUserSlice";
export const Header: React.FC = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const user = useSelector((state: any) => state.user);
const user = useSelector((state: any) => state.loginUser.value.user);
const onClick: MenuProps["onClick"] = ({ key }) => {
if (key === "login_out") {
dispatch(LoginOutActionCreator());
dispatch(logoutAction());
navigate("/login");
} else if (key === "change_password") {
navigate("/change-password");

View File

@@ -1,5 +1,5 @@
import { Button } from "antd";
import { useSelector } from "../../store/hooks";
import { useSelector } from "react-redux";
interface PropInterface {
type: "link" | "text" | "primary" | "default";
@@ -12,16 +12,18 @@ interface PropInterface {
}
export const PerButton = (props: PropInterface) => {
const permisssions = useSelector((state: any) => state.permisssions);
const through = () => {
if (!permisssions) {
const permissions = useSelector(
(state: any) => state.loginUser.value.permissions
);
const isThrough = () => {
if (!permissions) {
return false;
}
return typeof permisssions[props.p] !== "undefined";
return typeof permissions[props.p] !== "undefined";
};
return (
<>
{through() && props.type === "link" && (
{isThrough() && props.type === "link" && (
<Button
className={props.class}
type="link"
@@ -35,7 +37,7 @@ export const PerButton = (props: PropInterface) => {
{props.text}
</Button>
)}
{through() && props.type !== "link" && (
{isThrough() && props.type !== "link" && (
<Button
className={props.class}
type={props.type}