feat(webui): per-page preferences (phase 7)
A `pages` section in config/ui.json (3rd section-merge alongside appearance + layout): - defaultRoute: the page to open after login (chosen in Settings → 数据与格式; DefaultRouteRedirect navigates there once, only from '/', respecting deep-links + later navigation). - logs: persisted visible levels, max lines, auto-scroll, line-wrap, and keyword→colour highlight rules — edited live on the logs page; maxLines is read via a ref so it never re-subscribes the SSE. - processes: pid / name / status sort (persisted, default from prefs). - config: remembers the last-used tab. "重置全部" now also clears pages. The server normalizer is total and caps the logs fields (levels subset, maxLines 100-5000, <=20 highlight rules, trimmed keywords). Verified by an adversarial review round (normalizePages total against 30 adversarial inputs; zero MUST/SHOULD-FIX).
This commit is contained in:
8 files changed
+412
-91
No files matched your search
@@ -22,6 +22,7 @@ import type {
|
||||
} from '@/types';
|
||||
import { useOneBotInstanceConfig } from '@/hooks/use-onebot-instance-config';
|
||||
import { useAppState } from '@/contexts/AppStateContext';
|
||||
import { useLayout } from '@/contexts/LayoutContext';
|
||||
import { AccountSidebar } from '@/components/config/account-sidebar';
|
||||
import { GeneralSettingsTab } from '@/components/config/general-settings-tab';
|
||||
import { NodeSummaryCard } from '@/components/config/node-summary-card';
|
||||
@@ -55,7 +56,16 @@ export function ConfigPage() {
|
||||
onSelectedUinChange: setSelectedUin,
|
||||
});
|
||||
|
||||
const [activeTab, setActiveTab] = useState<TabKey>('general');
|
||||
const { pages, setPages } = useLayout();
|
||||
const [activeTab, setActiveTabState] = useState<TabKey>(() => {
|
||||
const t = pages.configTab;
|
||||
return t === 'general' || (!!t && t in NETWORK_TABS) ? (t as TabKey) : 'general';
|
||||
});
|
||||
// Persist the last-used tab as the default for next time.
|
||||
const setActiveTab = useCallback((t: TabKey) => {
|
||||
setActiveTabState(t);
|
||||
setPages({ configTab: t });
|
||||
}, [setPages]);
|
||||
// Default the account strip to its 56px avatar-only form on narrow screens
|
||||
// (≤lg) so the editor pane isn't squeezed; the user can still expand it.
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(
|
||||
|
||||
Reference in new issue
Block a user