import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { useUserStore } from "../store/module"; import Dropdown from "./base/Dropdown"; import showAboutSiteDialog from "./AboutSiteDialog"; import UserAvatar from "./UserAvatar"; import showSettingDialog from "./SettingDialog"; import Icon from "./Icon"; const UserBanner = () => { const { t } = useTranslation(); const userStore = useUserStore(); const { user } = userStore.state; const [username, setUsername] = useState("Memos"); useEffect(() => { if (user) { setUsername(user.nickname || user.username); } }, [user]); const handleMyAccountClick = () => { showSettingDialog("my-account"); }; const handleAboutBtnClick = () => { showAboutSiteDialog(); }; const handleSignOutBtnClick = async () => { await userStore.doSignOut(); window.location.href = "/auth"; }; return (
{username} {user?.role === "HOST" ? ( MOD ) : null}
} actionsClassName="min-w-[128px] max-w-full" positionClassName="top-full mt-2" actions={ <> {!userStore.isVisitorMode() && ( <> RSS )} {!userStore.isVisitorMode() && ( )} } /> ); }; export default UserBanner;