From 5763ec8dba9be0e08d602f155d914786a20ede58 Mon Sep 17 00:00:00 2001 From: Innei Date: Sun, 30 Nov 2025 23:12:36 +0800 Subject: [PATCH] feat: enhance gallery page header with responsive social media links and view mode options - Updated `PageHeaderLeft` to conditionally display social media links on larger screens. - Introduced `MoreActionMenu` in `PageHeaderRight` for mobile users, allowing access to view mode settings and social links. - Modified `ViewModeSegment` to ensure consistent display across different screen sizes. - Enhanced `DropdownMenuItem` to support child components for better flexibility in dropdown menus. Signed-off-by: Innei --- .../gallery/PageHeader/PageHeaderLeft.tsx | 2 +- .../gallery/PageHeader/PageHeaderRight.tsx | 84 ++++++++++++++++++- .../gallery/PageHeader/ViewModeSegment.tsx | 2 +- packages/ui/src/dropdown-menu.tsx | 80 +++++++++++------- 4 files changed, 136 insertions(+), 32 deletions(-) diff --git a/apps/web/src/modules/gallery/PageHeader/PageHeaderLeft.tsx b/apps/web/src/modules/gallery/PageHeader/PageHeaderLeft.tsx index 651af5be..f26d285b 100644 --- a/apps/web/src/modules/gallery/PageHeader/PageHeaderLeft.tsx +++ b/apps/web/src/modules/gallery/PageHeader/PageHeaderLeft.tsx @@ -43,7 +43,7 @@ export const PageHeaderLeft = () => { {visiblePhotoCount} {(githubUrl || twitterUrl || hasRss) && ( -
+
{githubUrl && } {twitterUrl && } {hasRss && } diff --git a/apps/web/src/modules/gallery/PageHeader/PageHeaderRight.tsx b/apps/web/src/modules/gallery/PageHeader/PageHeaderRight.tsx index 843f1ae6..034f79c3 100644 --- a/apps/web/src/modules/gallery/PageHeader/PageHeaderRight.tsx +++ b/apps/web/src/modules/gallery/PageHeader/PageHeaderRight.tsx @@ -14,13 +14,13 @@ import { Drawer } from 'vaul' import { gallerySettingAtom, isCommandPaletteOpenAtom } from '~/atoms/app' import { sessionUserAtom } from '~/atoms/session' -import { injectConfig } from '~/config' +import { injectConfig, siteConfig } from '~/config' import { useMobile } from '~/hooks/useMobile' import { authApi } from '~/lib/api/auth' import { UserAvatar } from '../../social/comments/UserAvatar' import { ViewPanel } from '../panels/ViewPanel' -import { ActionIconButton } from './utils' +import { ActionIconButton, resolveSocialUrl } from './utils' export const PageHeaderRight = () => { const { t } = useTranslation() @@ -77,6 +77,8 @@ export const PageHeaderRight = () => { )} + + {isMobile && }
{/* Auth Section - Only show when useCloud is true */} @@ -89,6 +91,84 @@ export const PageHeaderRight = () => { ) } +const MoreActionMenu = () => { + const { t } = useTranslation() + const [settings, setSettings] = useAtom(gallerySettingAtom) + + const githubUrl = + siteConfig.social && siteConfig.social.github + ? resolveSocialUrl(siteConfig.social.github, { baseUrl: 'https://github.com/' }) + : undefined + const twitterUrl = + siteConfig.social && siteConfig.social.twitter + ? resolveSocialUrl(siteConfig.social.twitter, { baseUrl: 'https://twitter.com/', stripAt: true }) + : undefined + const hasRss = true + + return ( + + + + + +
{t('action.view.title')}
+ setSettings((prev) => ({ ...prev, viewMode: 'masonry' }))} + className="justify-between" + > + + + {t('gallery.view.masonry')} + + {settings.viewMode === 'masonry' && } + + setSettings((prev) => ({ ...prev, viewMode: 'list' }))} + className="justify-between" + > + + + {t('gallery.view.list')} + + {settings.viewMode === 'list' && } + + + {(githubUrl || twitterUrl || hasRss) && } + + {githubUrl && ( + + + + GitHub + + + )} + {twitterUrl && ( + + + + Twitter + + + )} + {hasRss && ( + + + + RSS + + + )} +
+
+ ) +} + // 紧凑版本的桌面端视图按钮 const DesktopViewButton = ({ icon, diff --git a/apps/web/src/modules/gallery/PageHeader/ViewModeSegment.tsx b/apps/web/src/modules/gallery/PageHeader/ViewModeSegment.tsx index 6b64752b..0ef5adf5 100644 --- a/apps/web/src/modules/gallery/PageHeader/ViewModeSegment.tsx +++ b/apps/web/src/modules/gallery/PageHeader/ViewModeSegment.tsx @@ -15,7 +15,7 @@ export const ViewModeSegment = () => { } return ( -
+