diff --git a/web/src/components/BrandBanner.tsx b/web/src/components/BrandBanner.tsx new file mode 100644 index 00000000..1c4746f3 --- /dev/null +++ b/web/src/components/BrandBanner.tsx @@ -0,0 +1,34 @@ +import useCurrentUser from "@/hooks/useCurrentUser"; +import useNavigateTo from "@/hooks/useNavigateTo"; +import { Routes } from "@/router"; +import { workspaceStore } from "@/store/v2"; +import { cn } from "@/utils"; +import UserAvatar from "./UserAvatar"; + +interface Props { + className?: string; + collapsed?: boolean; +} + +const BrandBanner = (props: Props) => { + const { collapsed } = props; + const navigateTo = useNavigateTo(); + const currentUser = useCurrentUser(); + const workspaceGeneralSetting = workspaceStore.state.generalSetting; + const title = workspaceGeneralSetting.customProfile?.title || "Memos"; + const avatarUrl = workspaceGeneralSetting.customProfile?.logoUrl || "/full-logo.webp"; + + return ( +
+
navigateTo(currentUser ? Routes.ROOT : Routes.EXPLORE)} + > + + {!collapsed && {title}} +
+
+ ); +}; + +export default BrandBanner; diff --git a/web/src/components/HomeSidebar/HomeSidebar.tsx b/web/src/components/HomeSidebar/HomeSidebar.tsx index 446f91ed..6de6127b 100644 --- a/web/src/components/HomeSidebar/HomeSidebar.tsx +++ b/web/src/components/HomeSidebar/HomeSidebar.tsx @@ -1,4 +1,4 @@ -import { Globe2Icon, HomeIcon, LogInIcon } from "lucide-react"; +import { Globe2Icon, HomeIcon } from "lucide-react"; import { NavLink } from "react-router-dom"; import useDebounce from "react-use/lib/useDebounce"; import SearchBar from "@/components/SearchBar"; @@ -41,14 +41,8 @@ const HomeSidebar = (props: Props) => { title: t("common.explore"), icon: , }; - const signInNavLink: NavLinkItem = { - id: "header-auth", - path: Routes.AUTH, - title: t("common.sign-in"), - icon: , - }; - const navLinks: NavLinkItem[] = currentUser ? [homeNavLink, exploreNavLink] : [exploreNavLink, signInNavLink]; + const navLinks: NavLinkItem[] = currentUser ? [homeNavLink, exploreNavLink] : [exploreNavLink]; useDebounce( async () => { diff --git a/web/src/components/Navigation.tsx b/web/src/components/Navigation.tsx index 809b7b8d..07b7d31b 100644 --- a/web/src/components/Navigation.tsx +++ b/web/src/components/Navigation.tsx @@ -1,5 +1,5 @@ import { Tooltip } from "@mui/joy"; -import { ArchiveIcon, BellIcon, PaperclipIcon, SettingsIcon, SmileIcon } from "lucide-react"; +import { ArchiveIcon, BellIcon, PaperclipIcon, SettingsIcon, UserCircleIcon } from "lucide-react"; import { observer } from "mobx-react-lite"; import { useEffect } from "react"; import { NavLink } from "react-router-dom"; @@ -9,6 +9,7 @@ import { userStore } from "@/store/v2"; import { Inbox_Status } from "@/types/proto/api/v1/inbox_service"; import { cn } from "@/utils"; import { useTranslate } from "@/utils/i18n"; +import BrandBanner from "./BrandBanner"; import UserBanner from "./UserBanner"; interface NavLinkItem { @@ -26,11 +27,11 @@ interface Props { const Navigation = observer((props: Props) => { const { collapsed, className } = props; const t = useTranslate(); - const user = useCurrentUser(); + const currentUser = useCurrentUser(); const hasUnreadInbox = userStore.state.inboxes.some((inbox) => inbox.status === Inbox_Status.UNREAD); useEffect(() => { - if (!user) { + if (!currentUser) { return; } @@ -68,21 +69,24 @@ const Navigation = observer((props: Props) => { title: t("common.settings"), icon: , }; - const aboutNavLink: NavLinkItem = { - id: "header-about", - path: Routes.ABOUT, - title: t("common.about"), - icon: , + const signInNavLink: NavLinkItem = { + id: "header-auth", + path: Routes.AUTH, + title: t("common.sign-in"), + icon: , }; - const navLinks: NavLinkItem[] = user ? [resourcesNavLink, inboxNavLink, archivedNavLink, settingNavLink] : [aboutNavLink]; + const navLinks: NavLinkItem[] = currentUser ? [resourcesNavLink, inboxNavLink, archivedNavLink, settingNavLink] : [signInNavLink]; return (
- -
+
+ {navLinks.map((navLink) => ( @@ -108,6 +112,7 @@ const Navigation = observer((props: Props) => { ))}
+ {currentUser && }
); }); diff --git a/web/src/components/UserBanner.tsx b/web/src/components/UserBanner.tsx index 37e187ba..900683d1 100644 --- a/web/src/components/UserBanner.tsx +++ b/web/src/components/UserBanner.tsx @@ -1,10 +1,9 @@ import { Dropdown, Menu, MenuButton, MenuItem } from "@mui/joy"; -import { LogOutIcon, SmileIcon, User2Icon } from "lucide-react"; +import { LogOutIcon, User2Icon, SmileIcon } from "lucide-react"; import { authServiceClient } from "@/grpcweb"; import useCurrentUser from "@/hooks/useCurrentUser"; import useNavigateTo from "@/hooks/useNavigateTo"; import { Routes } from "@/router"; -import { workspaceStore } from "@/store/v2"; import { cn } from "@/utils"; import { useTranslate } from "@/utils/i18n"; import UserAvatar from "./UserAvatar"; @@ -18,13 +17,10 @@ const UserBanner = (props: Props) => { const t = useTranslate(); const navigateTo = useNavigateTo(); const currentUser = useCurrentUser(); - const workspaceGeneralSetting = workspaceStore.state.generalSetting; - const title = (currentUser ? currentUser.nickname || currentUser.username : workspaceGeneralSetting.customProfile?.title) || "Memos"; - const avatarUrl = (currentUser ? currentUser.avatarUrl : workspaceGeneralSetting.customProfile?.logoUrl) || "/full-logo.webp"; const handleSignOut = async () => { await authServiceClient.signOut({}); - window.location.href = "/auth"; + window.location.href = Routes.AUTH; }; return ( @@ -38,23 +34,27 @@ const UserBanner = (props: Props) => { )} onClick={() => navigateTo(currentUser ? Routes.ROOT : Routes.EXPLORE)} > - - {!collapsed && {title}} + {currentUser.avatarUrl ? ( + + ) : ( + + )} + {!collapsed && ( + + {currentUser.nickname || currentUser.username} + + )} navigateTo(`/u/${encodeURIComponent(currentUser.username)}`)}> - + {t("common.profile")} {t("common.sign-out")} - navigateTo(Routes.ABOUT)}> - - {t("common.about")} - diff --git a/web/src/layouts/HomeLayout.tsx b/web/src/layouts/HomeLayout.tsx index 59a5544c..423082fc 100644 --- a/web/src/layouts/HomeLayout.tsx +++ b/web/src/layouts/HomeLayout.tsx @@ -15,19 +15,19 @@ const HomeLayout = observer(() => { )} -
- {md && ( -
- -
- )} -
+ {md && ( +
+ +
+ )} +
+
diff --git a/web/src/pages/About.tsx b/web/src/pages/About.tsx deleted file mode 100644 index f55d0d28..00000000 --- a/web/src/pages/About.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { Link } from "@mui/joy"; -import { DotIcon } from "lucide-react"; -import MobileHeader from "@/components/MobileHeader"; -import { useTranslate } from "@/utils/i18n"; - -const About = () => { - const t = useTranslate(); - - return ( -
- -
-
- - memos - -

{t("about.description")}

-
- - {t("about.github-repository")} - - - - {t("about.official-website")} - - - - {t("about.blogs")} - - - - {t("about.documents")} - -
-
-
-
- ); -}; - -export default About; diff --git a/web/src/router/index.tsx b/web/src/router/index.tsx index 1bf26197..2069cb9f 100644 --- a/web/src/router/index.tsx +++ b/web/src/router/index.tsx @@ -6,7 +6,6 @@ import RootLayout from "@/layouts/RootLayout"; import Home from "@/pages/Home"; import Loading from "@/pages/Loading"; -const About = lazy(() => import("@/pages/About")); const AdminSignIn = lazy(() => import("@/pages/AdminSignIn")); const Archived = lazy(() => import("@/pages/Archived")); const AuthCallback = lazy(() => import("@/pages/AuthCallback")); @@ -29,7 +28,6 @@ export enum Routes { ARCHIVED = "/archived", SETTING = "/setting", EXPLORE = "/explore", - ABOUT = "/about", AUTH = "/auth", } @@ -144,14 +142,6 @@ const router = createBrowserRouter([ ), }, - { - path: Routes.ABOUT, - element: ( - }> - - - ), - }, // Redirect old path to new path. { path: "m/:uid",