import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { useGlobalStore, useUserStore } from "@/store/module"; import { useTranslate } from "@/utils/i18n"; import showAboutSiteDialog from "./AboutSiteDialog"; import Icon from "./Icon"; import UserAvatar from "./UserAvatar"; import Dropdown from "./kit/Dropdown"; const UserBanner = () => { const t = useTranslate(); const navigate = useNavigate(); const globalStore = useGlobalStore(); const userStore = useUserStore(); const { systemStatus } = globalStore.state; const { user } = userStore.state; const [username, setUsername] = useState("Memos"); useEffect(() => { if (user) { setUsername(user.nickname || user.username); } }, [user]); const handleMyAccountClick = () => { navigate(`/u/${user?.username}`); }; const handleAboutBtnClick = () => { showAboutSiteDialog(); }; const handleSignOutBtnClick = async () => { await userStore.doSignOut(); window.location.href = "/auth"; }; return (
{user != undefined ? username : systemStatus.customizedProfile.name} {user?.role === "HOST" ? ( MOD ) : null}
} actionsClassName="min-w-[128px] max-w-full" positionClassName="top-full mt-2" actions={ <> {user != undefined && ( <> RSS )} {user != undefined && ( )} } /> ); }; export default UserBanner;