From a9703f34dcdec8f2b7d292cb7b416e31085cf744 Mon Sep 17 00:00:00 2001 From: Innei Date: Sun, 30 Nov 2025 01:27:48 +0800 Subject: [PATCH] refactor: remove RSS support from social configuration - Eliminated the RSS field from social settings in configuration files and UI schemas. - Updated related documentation and localization files to reflect the removal of RSS support. - Adjusted components to ensure compatibility with the updated social configuration. Signed-off-by: Innei --- DEVELOPMENT.md | 2 +- .../gallery/MasonryHeaderMasonryItem.tsx | 5 +- .../gallery/PageHeader/PageHeaderRight.tsx | 158 +++++++++++++++++- be/apps/core/src/locales/ui-schema/en.ts | 5 - be/apps/core/src/locales/ui-schema/zh-CN.ts | 5 - .../configuration/setting/setting.constant.ts | 19 --- .../site-setting/site-setting.service.ts | 8 +- .../site-setting/site-setting.type.ts | 1 - .../site-setting/site-setting.ui-schema.ts | 12 -- be/session | 2 +- config.example.json | 5 +- docs/configuration.md | 2 +- locales/app/en.json | 3 + locales/app/zh-CN.json | 3 + site.config.ts | 1 - 15 files changed, 171 insertions(+), 60 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 93dfa6c6..554a0ddd 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -103,7 +103,7 @@ Notes: - `name` / `title` / `description` / `url` / `accentColor` - `author`: `{ name, url, avatar }` -- `social`: `{ github?, twitter?, rss? }` +- `social`: `{ github?, twitter? }` - `feed`: supports `folo.challenge.feedId` and `userId` - `map`: map providers, e.g. `["maplibre"]` - `mapStyle`: `builtin` or provider-specific style diff --git a/apps/web/src/modules/gallery/MasonryHeaderMasonryItem.tsx b/apps/web/src/modules/gallery/MasonryHeaderMasonryItem.tsx index e7aa0ab8..2da18600 100644 --- a/apps/web/src/modules/gallery/MasonryHeaderMasonryItem.tsx +++ b/apps/web/src/modules/gallery/MasonryHeaderMasonryItem.tsx @@ -41,6 +41,7 @@ export const MasonryHeaderMasonryItem = ({ style, className }: { style?: React.C siteConfig.social && siteConfig.social.twitter ? resolveSocialUrl(siteConfig.social.twitter, { baseUrl: 'https://twitter.com/', stripAt: true }) : undefined + const hasRss = true return (
{siteConfig.name} {/* Social media links */} - {siteConfig.social && ( + {(githubUrl || twitterUrl || hasRss) && (
{githubUrl && ( )} - {siteConfig.social.rss && ( + {hasRss && ( { const [gallerySetting] = useAtom(gallerySettingAtom) const setCommandPaletteOpen = useSetAtom(isCommandPaletteOpenAtom) const navigate = useNavigate() + const sessionUser = useAtomValue(sessionUserAtom) // 计算视图设置是否有自定义配置 const hasViewCustomization = gallerySetting.columns !== 'auto' || gallerySetting.sortOrder !== 'desc' @@ -66,6 +78,13 @@ export const PageHeaderRight = () => { )}
+ + {/* Auth Section - Only show when useCloud is true */} + {injectConfig.useCloud && ( +
+ {sessionUser ? : } +
+ )}
) } @@ -143,3 +162,138 @@ const MobileViewButton = ({ ) } + +// 登录按钮 +const LoginButton = () => { + const { t } = useTranslation() + const [isOpen, setIsOpen] = useState(false) + const { data: socialProviders } = useQuery({ + queryKey: ['socialProviders'], + queryFn: authApi.getSocialProviders, + enabled: isOpen, + }) + + const handleSignIn = async (provider: string) => { + try { + const { url } = await authApi.signInSocial(provider) + window.location.href = url + } catch (error) { + console.error('Sign in failed:', error) + } + } + + return ( + + + + + +
{t('comments.chooseProvider')}
+ + {socialProviders?.providers.map((provider) => ( + handleSignIn(provider.id)} + icon={} + > + {t('comments.signInWith', { provider: provider.name })} + + ))} +
+
+ ) +} + +// 登录平台图标 +const LoginPlatformIcon = ({ provider }: { provider: string }) => { + switch (provider) { + case 'github': { + return + } + case 'google': { + return ( + + + + + + + ) + } + default: { + return + } + } +} + +// 用户菜单按钮 +const UserMenuButton = ({ + user, +}: { + user: { id: string; name?: string | null; image?: string | null; role?: string | null } +}) => { + const { t } = useTranslation() + const isAdmin = user.role === 'admin' || user.role === 'superadmin' + + // 如果是 admin,点击头像直接导航到 dashboard + if (isAdmin) { + return ( + + ) + } + + // 非 admin 用户显示菜单 + return ( + + + + + +
+
{user.name || user.id}
+
+ + { + // TODO: Implement sign out + window.location.reload() + }} + icon={} + > + {t('action.signOut')} + +
+
+ ) +} diff --git a/be/apps/core/src/locales/ui-schema/en.ts b/be/apps/core/src/locales/ui-schema/en.ts index b813ac3e..59126647 100644 --- a/be/apps/core/src/locales/ui-schema/en.ts +++ b/be/apps/core/src/locales/ui-schema/en.ts @@ -149,11 +149,6 @@ const enUiSchema = { title: 'GitHub', helper: 'Supports full URLs or usernames.', }, - rss: { - title: 'Expose RSS feed', - description: 'Enable to publish an RSS endpoint on the public site.', - helper: 'Visitors can subscribe to the latest photos via RSS.', - }, }, }, }, diff --git a/be/apps/core/src/locales/ui-schema/zh-CN.ts b/be/apps/core/src/locales/ui-schema/zh-CN.ts index 691933d5..5c230fea 100644 --- a/be/apps/core/src/locales/ui-schema/zh-CN.ts +++ b/be/apps/core/src/locales/ui-schema/zh-CN.ts @@ -148,11 +148,6 @@ const zhCnUiSchema = { title: 'GitHub', helper: '支持完整链接或用户名。', }, - rss: { - title: '生成 RSS 订阅源', - description: '启用后将在前台站点暴露 RSS 订阅入口。', - helper: '开启后访客可通过 RSS 订阅最新照片。', - }, }, }, }, diff --git a/be/apps/core/src/modules/configuration/setting/setting.constant.ts b/be/apps/core/src/modules/configuration/setting/setting.constant.ts index 51d92388..7d435d20 100644 --- a/be/apps/core/src/modules/configuration/setting/setting.constant.ts +++ b/be/apps/core/src/modules/configuration/setting/setting.constant.ts @@ -134,25 +134,6 @@ export const DEFAULT_SETTING_DEFINITIONS = { isSensitive: false, schema: z.string().trim(), }, - 'site.social.rss': { - isSensitive: false, - schema: z - .string() - .trim() - .transform((value) => value.toLowerCase()) - .superRefine((value, ctx) => { - if (value.length === 0) { - return - } - - if (value !== 'true' && value !== 'false') { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: 'RSS toggle must be either "true" or "false"', - }) - } - }), - }, 'site.feed.folo.challenge.feedId': { isSensitive: false, schema: z.string().trim(), diff --git a/be/apps/core/src/modules/configuration/site-setting/site-setting.service.ts b/be/apps/core/src/modules/configuration/site-setting/site-setting.service.ts index 04db1a19..d669e6c1 100644 --- a/be/apps/core/src/modules/configuration/site-setting/site-setting.service.ts +++ b/be/apps/core/src/modules/configuration/site-setting/site-setting.service.ts @@ -1,7 +1,7 @@ import { authUsers } from '@afilmory/db' import { DbAccessor } from 'core/database/database.provider' import { BizException, ErrorCode } from 'core/errors' -import { normalizeStringToUndefined, parseBoolean } from 'core/helpers/normalize.helper' +import { normalizeStringToUndefined } from 'core/helpers/normalize.helper' import { requireTenantContext } from 'core/modules/platform/tenant/tenant.context' import { asc, eq, sql } from 'drizzle-orm' import { injectable } from 'tsyringe' @@ -309,7 +309,6 @@ interface SiteConfigAuthor { interface SiteConfigSocial { twitter?: string github?: string - rss?: boolean } interface SiteConfigFeed { @@ -408,11 +407,6 @@ function buildSocialConfig(values: SiteSettingValueMap): SiteConfig['social'] | social.github = value }) - const rss = parseBoolean(values['site.social.rss']) - if (typeof rss === 'boolean') { - social.rss = rss - } - return Object.keys(social).length > 0 ? social : undefined } diff --git a/be/apps/core/src/modules/configuration/site-setting/site-setting.type.ts b/be/apps/core/src/modules/configuration/site-setting/site-setting.type.ts index 529f0c24..eb56dbfb 100644 --- a/be/apps/core/src/modules/configuration/site-setting/site-setting.type.ts +++ b/be/apps/core/src/modules/configuration/site-setting/site-setting.type.ts @@ -10,7 +10,6 @@ export const SITE_SETTING_KEYS = [ 'site.accentColor', 'site.social.twitter', 'site.social.github', - 'site.social.rss', 'site.feed.folo.challenge.feedId', 'site.feed.folo.challenge.userId', 'site.map.providers', diff --git a/be/apps/core/src/modules/configuration/site-setting/site-setting.ui-schema.ts b/be/apps/core/src/modules/configuration/site-setting/site-setting.ui-schema.ts index a3388684..c4cb00db 100644 --- a/be/apps/core/src/modules/configuration/site-setting/site-setting.ui-schema.ts +++ b/be/apps/core/src/modules/configuration/site-setting/site-setting.ui-schema.ts @@ -128,18 +128,6 @@ export function createSiteSettingUiSchema(t: UiSchemaTFunction): UiSchemaDefault Site

Default Site

Default Site

\ No newline at end of file +Default Site

Default Site

Default Site

\ No newline at end of file diff --git a/config.example.json b/config.example.json index 3aadfa4c..c467fc1b 100644 --- a/config.example.json +++ b/config.example.json @@ -11,8 +11,7 @@ }, "social": { "github": "", - "twitter": "", - "rss": false + "twitter": "" }, "feed": { "folo": { @@ -27,4 +26,4 @@ ], "mapStyle": "builtin", "mapProjection": "mercator" -} \ No newline at end of file +} diff --git a/docs/configuration.md b/docs/configuration.md index 84925ea7..1f6e1f36 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -4,7 +4,7 @@ - `name`, `title`, `description`, `url`, `accentColor` - `author`: `{ name, url, avatar }` -- `social`: `{ github?, twitter?, rss? }` +- `social`: `{ github?, twitter? }` - `feed`: optional `folo.challenge.feedId` and `userId` - `map`: e.g. `["maplibre"]` - `mapStyle`: `builtin` or provider style diff --git a/locales/app/en.json b/locales/app/en.json index b253eeba..b7f122c7 100644 --- a/locales/app/en.json +++ b/locales/app/en.json @@ -6,12 +6,14 @@ "action.camera.not-found": "No cameras match your search", "action.camera.search": "Search Cameras", "action.columns.setting": "Column Settings", + "action.dashboard": "Dashboard", "action.filter.title": "Filter Photos", "action.lens.clear": "Clear", "action.lens.empty": "No lenses available", "action.lens.filter": "Lens Filter", "action.lens.not-found": "No lenses match your search", "action.lens.search": "Search Lenses", + "action.login": "Sign In", "action.map.explore": "Map Explore", "action.rating.filter": "Rating Filter", "action.rating.filter-above": "Show {{rating}} stars and above", @@ -27,6 +29,7 @@ "action.search.results": "Found {{count}} photos", "action.search.title": "Search Photos", "action.search.unified.title": "Search & Filter", + "action.signOut": "Sign Out", "action.sort.mode": "Sort Mode", "action.sort.newest.first": "Newest First", "action.sort.oldest.first": "Oldest First", diff --git a/locales/app/zh-CN.json b/locales/app/zh-CN.json index 2a96d11c..e984ab8f 100644 --- a/locales/app/zh-CN.json +++ b/locales/app/zh-CN.json @@ -6,12 +6,14 @@ "action.camera.not-found": "没有相机匹配您的搜索", "action.camera.search": "搜索相机", "action.columns.setting": "列设置", + "action.dashboard": "仪表盘", "action.filter.title": "筛选照片", "action.lens.clear": "清除", "action.lens.empty": "暂无镜头", "action.lens.filter": "镜头筛选", "action.lens.not-found": "没有镜头匹配您的搜索", "action.lens.search": "搜索镜头", + "action.login": "登录", "action.map.explore": "地图探索", "action.rating.filter": "评分筛选", "action.rating.filter-above": "显示 {{rating}} 星及以上", @@ -27,6 +29,7 @@ "action.search.results": "找到 {{count}} 张照片", "action.search.title": "搜索照片", "action.search.unified.title": "搜索和筛选", + "action.signOut": "登出", "action.sort.mode": "排序模式", "action.sort.newest.first": "最新优先", "action.sort.oldest.first": "最早优先", diff --git a/site.config.ts b/site.config.ts index 107ba77f..1b77abc6 100644 --- a/site.config.ts +++ b/site.config.ts @@ -39,7 +39,6 @@ interface Author { interface Social { twitter?: string github?: string - rss?: boolean } const defaultConfig: SiteConfig = {