From cce9fb9ed8f4be0d134b5cd7d60156dbd0707df9 Mon Sep 17 00:00:00 2001 From: freefire Date: Fri, 28 Aug 2026 03:04:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=8B=E9=93=BE=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=81=E8=87=B3=E7=AB=99=E7=82=B9=E5=8C=BA=E5=B9=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=B7=A6=E5=8F=B3=E9=A1=B5=E8=84=9A=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复左侧栏/页脚开关无法关闭的问题,改为专用设置接口可靠写入。 Co-authored-by: Cursor --- frontend/src/api/client.ts | 15 +- frontend/src/api/types.ts | 6 + frontend/src/components/Sidebar.tsx | 6 +- frontend/src/components/SiteFooter.tsx | 14 +- frontend/src/hooks/useForumLimits.ts | 2 + frontend/src/pages/admin/AdminLinksPage.tsx | 194 +++++++++++++++++- .../src/pages/admin/AdminSettingsPage.tsx | 2 + frontend/src/styles/global.css | 19 ++ handler/friend_link.go | 57 ++++- service/settings.go | 70 +++++++ 10 files changed, 364 insertions(+), 21 deletions(-) diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index a349565..bf54e1a 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -423,8 +423,19 @@ export const api = { reciprocal_check_enabled?: boolean; }>(`/api/admin/friend-link-applies${qs ? `?${qs}` : ''}`); }, - adminUpdateFriendLinkSettings: (body: { reciprocal_check_enabled: boolean }) => - request<{ message: string; reciprocal_check_enabled: boolean }>('/api/admin/friend-link-settings', { + adminUpdateFriendLinkSettings: (body: { + reciprocal_check_enabled?: boolean; + nav_show_friend_links?: boolean; + footer_show_friend_links?: boolean; + aside_show_friend_links?: boolean; + }) => + request<{ + message: string; + reciprocal_check_enabled: boolean; + nav_show_friend_links: boolean; + footer_show_friend_links: boolean; + aside_show_friend_links: boolean; + }>('/api/admin/friend-link-settings', { method: 'PUT', body: JSON.stringify(body), }), diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index aad28e5..25d0ade 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -233,6 +233,10 @@ export interface ForumLimits { aside_show_friend_links: boolean; /** 右侧栏可选组件顺序与开关 */ aside_widgets: AsideWidget[]; + /** 左侧栏「站点」展示友情链接入口 */ + nav_show_friend_links: boolean; + /** 页脚展示友情链接入口 */ + footer_show_friend_links: boolean; /** 首页列表样式:title 仅标题 / thumbnail 缩略图 */ feed_list_style: 'title' | 'excerpt' | 'thumbnail'; /** 伪静态(固定链接)开关 */ @@ -259,6 +263,8 @@ export interface ForumLimitsPublic { aside_show_recent_comments: boolean; aside_show_friend_links: boolean; aside_widgets: AsideWidget[]; + nav_show_friend_links: boolean; + footer_show_friend_links: boolean; feed_list_style: 'title' | 'excerpt' | 'thumbnail'; permalink_enabled: boolean; permalink_ext: string; diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index fdfe5ad..160d147 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -66,6 +66,8 @@ export default function Sidebar({ const isAdmin = user?.role === 'admin'; const { navPages } = useSitePages(); const { limits } = useForumLimits(); + const showFriendLinksNav = limits.nav_show_friend_links !== false; + const showSiteSection = navPages.length > 0 || showFriendLinksNav; const keyword = params.get('keyword') || ''; const menuKey = resolveMenuKey(loc.pathname, activeBoard, keyword); @@ -135,7 +137,6 @@ export default function Sidebar({ {feedNavLink('all', buildHomeUrl(0, sort, permalinkOpts), '全部帖子', , 0)} {user && navItem('favorites', '我的收藏', , () => nav('/favorites'))} {navItem('projects', '开源码桶', , () => nav('/projects'))} - {navItem('links', '友情链接', , () => nav('/links'))} {(boardsLoading && boards.length === 0) ? ( @@ -191,10 +192,11 @@ export default function Sidebar({ ) : null} - {(navPages.length > 0) && ( + {showSiteSection && ( <>
站点