feat(webui): deep-link settings tabs via ?tab= and jump update banner to 关于
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.
This commit is contained in:
3 files changed
+22
-4
No files matched your search
@@ -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<string, unknown>): { 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',
|
||||
|
||||
Reference in new issue
Block a user