diff --git a/web/src/components/AboutDialog.tsx b/web/src/components/AboutDialog.tsx deleted file mode 100644 index fb12a783..00000000 --- a/web/src/components/AboutDialog.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { ExternalLinkIcon, ScissorsIcon } from "lucide-react"; -import { Badge } from "@/components/ui/badge"; -import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; -import { useInstance } from "@/contexts/InstanceContext"; -import { WEB_CLIPPER_URL } from "@/lib/constants"; -import { useTranslate } from "@/utils/i18n"; - -const GITHUB_COMMIT_URL_PREFIX = "https://github.com/usememos/memos/commit/"; -const GITHUB_RELEASE_URL_PREFIX = "https://github.com/usememos/memos/releases/tag/v"; - -const DEFAULT_TITLE = "Memos"; -const DEFAULT_TAGLINE = "Capture first. Keep it yours."; -const DEFAULT_LOGO = "/logo.webp"; - -const isCommitSha = (commit: string) => /^[0-9a-f]{7,40}$/i.test(commit); -const isSemver = (version: string) => /^\d+\.\d+\.\d+/.test(version); - -const Chip = ({ href, children }: { href?: string; children: React.ReactNode }) => { - const className = "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 font-mono text-xs text-muted-foreground"; - if (href) { - return ( - - {children} - - ); - } - return {children}; -}; - -const SectionLabel = ({ children }: { children: React.ReactNode }) => ( -

{children}

-); - -interface Props { - open: boolean; - onOpenChange: (open: boolean) => void; -} - -const AboutDialog = ({ open, onOpenChange }: Props) => { - const t = useTranslate(); - const { profile, generalSetting } = useInstance(); - - const customProfile = generalSetting.customProfile; - const instanceTitle = customProfile?.title || DEFAULT_TITLE; - const instanceTagline = customProfile?.description || DEFAULT_TAGLINE; - const instanceLogo = customProfile?.logoUrl || DEFAULT_LOGO; - const isCustomBranded = instanceTitle !== DEFAULT_TITLE; - - const hasSemver = isSemver(profile.version); - const releaseUrl = hasSemver ? `${GITHUB_RELEASE_URL_PREFIX}${profile.version}` : ""; - const versionLabel = hasSemver ? `v${profile.version}` : profile.version; - const hasCommitSha = isCommitSha(profile.commit); - const commitUrl = hasCommitSha ? `${GITHUB_COMMIT_URL_PREFIX}${profile.commit}` : ""; - const shortCommit = hasCommitSha ? profile.commit.slice(0, 7) : ""; - - const buildRows: { label: string; value: React.ReactNode }[] = []; - if (profile.version) { - buildRows.push({ label: t("common.version"), value: {versionLabel} }); - } - if (shortCommit) { - buildRows.push({ label: t("about.commit"), value: {shortCommit} }); - } - buildRows.push({ label: t("about.license"), value: MIT }); - if (isCustomBranded) { - buildRows.push({ - label: t("about.distribution"), - value: {t("about.powered-by")}, - }); - } - - const projectLinks = [ - { label: t("about.official-website"), note: t("about.official-website-note"), href: "https://usememos.com/" }, - { label: t("about.documents"), note: t("about.documents-note"), href: "https://usememos.com/docs" }, - { label: t("about.api-docs"), note: t("about.api-docs-note"), href: "https://usememos.com/docs/api" }, - { - label: t("about.github-repository"), - note: t("about.github-repository-note"), - href: "https://github.com/usememos/memos", - }, - { label: t("about.web-clipper"), note: t("about.web-clipper-platforms"), href: WEB_CLIPPER_URL, icon: ScissorsIcon }, - ]; - - return ( - - - {t("common.about")} -
-
- -
-
-

{instanceTitle}

- {profile.demo && {t("about.demo")}} -
-

{instanceTagline}

-
-
- -
- {t("about.build")} -
- {buildRows.map((row) => ( -
-
{row.label}
-
{row.value}
-
- ))} -
-
- -
- {t("about.project")} - -
-
-
-
- ); -}; - -export default AboutDialog; diff --git a/web/src/components/AppSidebar/AppSidebar.tsx b/web/src/components/AppSidebar/AppSidebar.tsx index 23ca5052..9b3863d6 100644 --- a/web/src/components/AppSidebar/AppSidebar.tsx +++ b/web/src/components/AppSidebar/AppSidebar.tsx @@ -61,7 +61,7 @@ import { User_Role, UserNotification_Status } from "@/types/proto/api/v1/user_se import { useTranslate } from "@/utils/i18n"; import MemosLogo from "../MemosLogo"; import { getSidebarRouteKind } from "./routes"; -import SidebarRow, { SIDEBAR_ROW_CLASSES, SIDEBAR_ROW_ICON_CLASSES } from "./SidebarRow"; +import SidebarRow, { SIDEBAR_ROW_CLASSES, SIDEBAR_ROW_COUNT_CLASSES, SIDEBAR_ROW_ICON_CLASSES } from "./SidebarRow"; import SidebarSectionHeader from "./SidebarSectionHeader"; import TagsSection from "./TagsSection"; @@ -395,7 +395,6 @@ interface GlobalNavItem { icon: LucideIcon; active: boolean; count?: number; - opensDialog?: boolean; } const GlobalNavigation = () => { @@ -404,7 +403,7 @@ const GlobalNavigation = () => { const navigate = useNavigate(); const currentUser = useCurrentUser(); const { data: notifications = [] } = useNotifications(); - const { memoDetail, memoScope, setAboutOpen, setMemoScope, setMobileOpen } = useAppSidebar(); + const { memoDetail, memoScope, setMemoScope, setMobileOpen } = useAppSidebar(); const { filters } = useMemoFilterContext(); const unreadCount = notifications.filter((notification) => notification.status === UserNotification_Status.UNREAD).length; const routeKind = getSidebarRouteKind(location.pathname); @@ -464,7 +463,7 @@ const GlobalNavigation = () => { icon: EarthIcon, active: routeKind === "explore" || routeKind === "profile" || routeKind === "memo", }, - { id: "about", label: t("common.about"), path: ROUTES.ABOUT, icon: InfoIcon, active: false, opensDialog: true }, + { id: "about", label: t("common.about"), path: ROUTES.ABOUT, icon: InfoIcon, active: false }, ]; const scopeTrigger = ( @@ -556,20 +555,7 @@ const GlobalNavigation = () => { )} ); - const content = item.opensDialog ? ( - - ) : ( + const content = ( { ); }; +const StaticNavigation = () => { + const t = useTranslate(); + const location = useLocation(); + const currentUser = useCurrentUser(); + const { data: notifications = [] } = useNotifications(); + const { setMobileOpen } = useAppSidebar(); + const unreadCount = notifications.filter((notification) => notification.status === UserNotification_Status.UNREAD).length; + const primaryItems: Array<{ id: string; label: string; path: string; icon: LucideIcon }> = currentUser + ? [ + { id: "home", label: t("common.home"), path: ROUTES.HOME, icon: HouseIcon }, + { id: "explore", label: t("common.explore"), path: ROUTES.EXPLORE, icon: EarthIcon }, + ] + : [{ id: "explore", label: t("common.explore"), path: ROUTES.EXPLORE, icon: EarthIcon }]; + const personalItems: Array<{ id: string; label: string; path: string; icon: LucideIcon; count?: number }> = currentUser + ? [ + { id: "attachments", label: t("common.attachments"), path: ROUTES.ATTACHMENTS, icon: PaperclipIcon }, + { id: "inbox", label: t("common.inbox"), path: ROUTES.INBOX, icon: BellIcon, count: unreadCount }, + ] + : []; + + const renderLink = (item: (typeof primaryItems)[number] | (typeof personalItems)[number]) => { + const Icon = item.icon; + const count = "count" in item ? item.count : undefined; + return ( + setMobileOpen(false)} + className={cn(SIDEBAR_ROW_CLASSES, "text-muted-foreground hover:bg-sidebar-accent/65 hover:text-foreground")} + > + + {item.label} + {count != null && count > 0 && {count}} + + ); + }; + + return ( +
+ + +
+ ); +}; + const AppSidebar = ({ className }: { className?: string }) => { const t = useTranslate(); + const location = useLocation(); const currentUser = useCurrentUser(); const { setMobileOpen, setQuickFindOpen } = useAppSidebar(); + const staticMode = getSidebarRouteKind(location.pathname) === "empty"; return (