forked from Gitlink/forgeplus-react
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import React, { useEffect, useState } from "react";
|
|
import { Menu } from "antd";
|
|
import "./menu.scss";
|
|
|
|
function user_menu({ is_current_user, login, props }) {
|
|
const [defaultMenu, setDefaultMenu] = useState("memos");
|
|
const handleClick = (e) => {
|
|
setDefaultMenu(e.key);
|
|
props.history.push(`/accounts/${login}/${e.key}`);
|
|
};
|
|
useEffect(() => {
|
|
const location_path = props.location.pathname.split("/");
|
|
const current_path = location_path[location_path.length - 1];
|
|
if (location_path.length > 3 && current_path) {
|
|
setDefaultMenu(current_path);
|
|
} else {
|
|
setDefaultMenu("memos");
|
|
}
|
|
}, [props.location]);
|
|
const show_name = is_current_user ? "我" : "TA";
|
|
return (
|
|
<div className="mt15 educontent clearfix edu-txt-center user-menu">
|
|
<Menu
|
|
onClick={(e) => handleClick(e)}
|
|
selectedKeys={defaultMenu}
|
|
mode="horizontal"
|
|
>
|
|
{/* <Menu.Item key="p_projects">{show_name}管理的</Menu.Item>
|
|
<Menu.Item key="l_projects">{show_name}参与的</Menu.Item> */}
|
|
<Menu.Item key="memos">{show_name}的帖子</Menu.Item>
|
|
<Menu.Item key="replies">{show_name}的回帖</Menu.Item>
|
|
{is_current_user && (
|
|
<Menu.Item key="histories">{show_name}的足迹</Menu.Item>
|
|
)}
|
|
{is_current_user && (
|
|
<Menu.Item key="stars">{show_name}的收藏</Menu.Item>
|
|
)}
|
|
{is_current_user && (
|
|
<Menu.Item key="interesting">{show_name}感兴趣的论坛</Menu.Item>
|
|
)}
|
|
{is_current_user && <Menu.Item key="blocks">黑名单</Menu.Item>}
|
|
</Menu>
|
|
</div>
|
|
);
|
|
}
|
|
export default user_menu;
|