|
|
@ -1,6 +1,5 @@
|
|
|
|
import * as api from "@/helpers/api";
|
|
|
|
import * as api from "@/helpers/api";
|
|
|
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
|
|
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
|
|
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
|
|
|
|
|
|
|
import { useGlobalStore } from "@/store/module";
|
|
|
|
import { useGlobalStore } from "@/store/module";
|
|
|
|
import { useTranslate } from "@/utils/i18n";
|
|
|
|
import { useTranslate } from "@/utils/i18n";
|
|
|
|
import showAboutSiteDialog from "./AboutSiteDialog";
|
|
|
|
import showAboutSiteDialog from "./AboutSiteDialog";
|
|
|
@ -10,30 +9,24 @@ import Dropdown from "./kit/Dropdown";
|
|
|
|
|
|
|
|
|
|
|
|
const UserBanner = () => {
|
|
|
|
const UserBanner = () => {
|
|
|
|
const t = useTranslate();
|
|
|
|
const t = useTranslate();
|
|
|
|
const navigateTo = useNavigateTo();
|
|
|
|
|
|
|
|
const globalStore = useGlobalStore();
|
|
|
|
const globalStore = useGlobalStore();
|
|
|
|
const { systemStatus } = globalStore.state;
|
|
|
|
const { systemStatus } = globalStore.state;
|
|
|
|
const user = useCurrentUser();
|
|
|
|
const user = useCurrentUser();
|
|
|
|
const title = user ? user.nickname || user.username : systemStatus.customizedProfile.name || "memos";
|
|
|
|
const title = user ? user.nickname || user.username : systemStatus.customizedProfile.name || "memos";
|
|
|
|
|
|
|
|
|
|
|
|
const handleMyAccountClick = () => {
|
|
|
|
|
|
|
|
navigateTo(`/u/${encodeURIComponent(user.username)}`);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleAboutBtnClick = () => {
|
|
|
|
const handleAboutBtnClick = () => {
|
|
|
|
showAboutSiteDialog();
|
|
|
|
showAboutSiteDialog();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSignOutBtnClick = async () => {
|
|
|
|
const handleSignOutBtnClick = async () => {
|
|
|
|
await api.signout();
|
|
|
|
await api.signout();
|
|
|
|
localStorage.removeItem("userId");
|
|
|
|
|
|
|
|
window.location.href = "/auth";
|
|
|
|
window.location.href = "/auth";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="relative w-full h-auto px-1 shrink-0">
|
|
|
|
<div className="relative w-full h-auto px-1 shrink-0">
|
|
|
|
<Dropdown
|
|
|
|
<Dropdown
|
|
|
|
className="w-auto"
|
|
|
|
className="w-auto inline-flex"
|
|
|
|
trigger={
|
|
|
|
trigger={
|
|
|
|
<div className="px-3 py-2 max-w-full flex flex-row justify-start items-center cursor-pointer rounded-2xl hover:shadow hover:bg-white dark:hover:bg-zinc-700">
|
|
|
|
<div className="px-3 py-2 max-w-full flex flex-row justify-start items-center cursor-pointer rounded-2xl hover:shadow hover:bg-white dark:hover:bg-zinc-700">
|
|
|
|
<UserAvatar className="shadow shrink-0 mr-2" avatarUrl={user?.avatarUrl} />
|
|
|
|
<UserAvatar className="shadow shrink-0 mr-2" avatarUrl={user?.avatarUrl} />
|
|
|
@ -44,23 +37,6 @@ const UserBanner = () => {
|
|
|
|
positionClassName="top-full mt-2"
|
|
|
|
positionClassName="top-full mt-2"
|
|
|
|
actions={
|
|
|
|
actions={
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
{user != undefined && (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded flex flex-row justify-start items-center dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
|
|
|
|
|
|
|
onClick={handleMyAccountClick}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Icon.User className="w-5 h-auto mr-2 opacity-80" /> {t("common.profile")}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<a
|
|
|
|
|
|
|
|
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded flex flex-row justify-start items-center dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
|
|
|
|
|
|
|
href={`/u/${user?.id}/rss.xml`}
|
|
|
|
|
|
|
|
target="_blank"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Icon.Rss className="w-5 h-auto mr-2 opacity-80" /> RSS
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded flex flex-row justify-start items-center dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
|
|
|
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded flex flex-row justify-start items-center dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
|
|
|
onClick={handleAboutBtnClick}
|
|
|
|
onClick={handleAboutBtnClick}
|
|
|
|