feat(webui): log buffer export + view presets (B3)

- 导出当前视图: a toolbar button dumps the current (filtered) log view to a
  client-side `.log` text file — no server endpoint, respects the active level
  filter + search.
- 视图预设: 开发 / 运维 / 精简 presets bundle the existing display prefs
  (visibleLevels / maxLines / autoScroll / wrap); a new `UiLogsPrefs.preset`
  field stores the active id. Any hand edit to those prefs drops to 自定义.
  The client owns the preset→prefs bundles; the server just stores + validates
  the id (oneOf, defaults custom). No non-chronological reordering, per plan.
This commit is contained in:
DrSmoothl committed 2026-06-16 14:36:02 +08:00
1 parent 1a0bc12ec0
commit 7355fe9ea4
4 files changed
+88 -7

No files matched your search

+7
View File
@@ -158,6 +158,8 @@ export interface UiHighlightRule {
color: string;
}
export type LogsPreset = 'dev' | 'ops' | 'minimal' | 'custom';
export interface UiLogsPrefs {
/** Log levels shown by default (client display filter). */
visibleLevels: string[];
@@ -167,6 +169,9 @@ export interface UiLogsPrefs {
wrap: boolean;
/** Keyword → colour row highlights. */
highlightRules: UiHighlightRule[];
/** Active view preset id; 'custom' = the operator hand-tuned the prefs. The
* client owns the preset → prefs bundles; the server just stores the id. */
preset: LogsPreset;
}
export interface UiPages {
@@ -278,6 +283,7 @@ const DEFAULT_PAGES: UiPages = {
autoScroll: true,
wrap: true,
highlightRules: [],
preset: 'custom',
},
processesSort: 'pid',
configTab: '',
@@ -571,6 +577,7 @@ export function normalizePages(value: unknown): UiPages {
autoScroll: boolOr(logs.autoScroll, DEFAULT_PAGES.logs.autoScroll),
wrap: boolOr(logs.wrap, DEFAULT_PAGES.logs.wrap),
highlightRules: normalizeHighlightRules(logs.highlightRules),
preset: oneOf<LogsPreset>(logs.preset, ['dev', 'ops', 'minimal', 'custom'], 'custom'),
},
processesSort: idOr(v.processesSort, DEFAULT_PAGES.processesSort),
configTab: typeof v.configTab === 'string' ? v.configTab.slice(0, 64) : DEFAULT_PAGES.configTab,