From 84021a19dc9bcf03287bbbb5af9bb71a7cd0e876 Mon Sep 17 00:00:00 2001
From: DrSmoothl <1787882683@qq.com>
Date: Sun, 14 Jun 2026 15:45:42 +0800
Subject: [PATCH] =?UTF-8?q?feat(webui):=20deep-link=20settings=20tabs=20vi?=
=?UTF-8?q?a=20=3Ftab=3D=20and=20jump=20update=20banner=20to=20=E5=85=B3?=
=?UTF-8?q?=E4=BA=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The settings sub-tab now lives in the URL (typed `?tab=` search param on the
/settings route, validated against the tab whitelist; default 外观 omits it).
The active tab is derived from the URL and tab clicks navigate (replace), so
tabs are shareable/back-button friendly. The sidebar "有新版本可用" banner now
links to /settings?tab=about, landing directly on 关于 (where 软件更新 lives)
instead of the default settings tab.
---
packages/webui/src/components/layout/sidebar.tsx | 1 +
.../webui/src/components/pages/settings-page.tsx | 11 ++++++++---
packages/webui/src/router/index.tsx | 14 +++++++++++++-
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/packages/webui/src/components/layout/sidebar.tsx b/packages/webui/src/components/layout/sidebar.tsx
index e92f30dd..bffdd7e3 100644
--- a/packages/webui/src/components/layout/sidebar.tsx
+++ b/packages/webui/src/components/layout/sidebar.tsx
@@ -170,6 +170,7 @@ export function Sidebar({ collapsed = false, onItemClick }: SidebarProps) {
('appearance');
+ // Active tab lives in the URL (`?tab=`) so it's deep-linkable — e.g. the
+ // sidebar update banner jumps straight to 关于. Default tab omits the param.
+ const { tab: urlTab } = settingsRoute.useSearch();
+ const navigate = settingsRoute.useNavigate();
+ const tab: SettingsTab = urlTab ?? 'appearance';
+ const setTab = (t: SettingsTab) =>
+ void navigate({ to: '/settings', search: t === 'appearance' ? {} : { tab: t }, replace: true });
const active = TABS.find((t) => t.key === tab);
return (
diff --git a/packages/webui/src/router/index.tsx b/packages/webui/src/router/index.tsx
index 238f1edc..e5dd108b 100644
--- a/packages/webui/src/router/index.tsx
+++ b/packages/webui/src/router/index.tsx
@@ -64,9 +64,21 @@ const logsRoute = createRoute({
),
});
-const settingsRoute = createRoute({
+/** Settings sub-tabs — also the contract for the `?tab=` deep link. */
+export const SETTINGS_TABS = ['appearance', 'data', 'advanced', 'account', 'about'] as const;
+export type SettingsTab = (typeof SETTINGS_TABS)[number];
+
+export const settingsRoute = createRoute({
path: '/settings',
getParentRoute: () => appLayoutRoute,
+ // `?tab=` deep-links a settings sub-tab (e.g. the sidebar update banner jumps
+ // straight to 关于). Unknown/missing → omitted (the page falls back to 外观).
+ validateSearch: (search: Record): { tab?: SettingsTab } => {
+ const t = search.tab;
+ return typeof t === 'string' && (SETTINGS_TABS as readonly string[]).includes(t)
+ ? { tab: t as SettingsTab }
+ : {};
+ },
component: lazyRouteComponent(
() => import('@/components/pages/settings-page'),
'SettingsPage',