import { isUndefined } from "lodash-es"; import { useEffect } from "react"; import { Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { useLocationStore, useUserStore } from "../store/module"; import Icon from "./Icon"; import showDailyReviewDialog from "./DailyReviewDialog"; import showResourcesDialog from "./ResourcesDialog"; import showSettingDialog from "./SettingDialog"; import showAskAIDialog from "./AskAIDialog"; import showArchivedMemoDialog from "./ArchivedMemoDialog"; import UserBanner from "./UserBanner"; import "../less/header.less"; const Header = () => { const { t } = useTranslation(); const userStore = useUserStore(); const locationStore = useLocationStore(); const query = locationStore.state.query; useEffect(() => { toggleHeader(false); }, [query]); return ( <>
toggleHeader(false)}>
{t("common.home")} {t("common.explore")} {!userStore.isVisitorMode() && ( <> )}
); }; export const toggleHeader = (show?: boolean) => { const headerEl = document.body.querySelector(".header-wrapper") as HTMLDivElement; const maskEl = headerEl.previousSibling as HTMLDivElement; if (isUndefined(show)) { show = !headerEl.classList.contains("show"); } if (show) { headerEl.classList.add("show"); maskEl.classList.add("show"); } else { headerEl.classList.remove("show"); maskEl.classList.remove("show"); } }; export default Header;