- {connections.map((acc) => (
+ {list.map((acc) => (
{acc.nickname || acc.uin}
diff --git a/packages/webui/src/components/pages/widget-config-forms.tsx b/packages/webui/src/components/pages/widget-config-forms.tsx
index bc53d222..719bf4b0 100644
--- a/packages/webui/src/components/pages/widget-config-forms.tsx
+++ b/packages/webui/src/components/pages/widget-config-forms.tsx
@@ -1,6 +1,9 @@
import { Input } from '@/components/ui/input';
+import { ToggleSwitch } from '@/components/ui/toggle-switch';
import { cn } from '@/lib/utils';
-import { ALL_LOG_LEVELS, parseAlertsConfig, parseSessionsConfig } from '@/lib/dashboard-layout';
+import {
+ ALL_LOG_LEVELS, parseAlertsConfig, parseConnectionsConfig, parseHostConfig, parseSessionsConfig,
+} from '@/lib/dashboard-layout';
// Per-widget config forms, shown inside a dialog opened from a dashboard
// widget's edit-overlay gear. `config` is the widget's opaque block.config;
@@ -83,3 +86,72 @@ export function SessionsConfigForm({ config, onChange }: FormProps) {
);
}
+
+const HOST_PANELS: { key: 'cpu' | 'memory' | 'runtime'; label: string }[] = [
+ { key: 'cpu', label: 'CPU 使用率' },
+ { key: 'memory', label: '内存使用' },
+ { key: 'runtime', label: '运行进程' },
+];
+
+export function HostConfigForm({ config, onChange }: FormProps) {
+ const c = parseHostConfig(config);
+ return (
+
+ 显示的指标
+ {HOST_PANELS.map((p) => (
+
+ ))}
+
+ );
+}
+
+const CONN_SORTS: { key: 'default' | 'name' | 'status'; label: string }[] = [
+ { key: 'default', label: '默认' },
+ { key: 'name', label: '名称' },
+ { key: 'status', label: '异常优先' },
+];
+
+export function ConnectionsConfigForm({ config, onChange }: FormProps) {
+ const c = parseConnectionsConfig(config);
+ return (
+
+
+
排序
+
+ {CONN_SORTS.map((s) => (
+
+ ))}
+
+
+
+
+
+ );
+}
diff --git a/packages/webui/src/lib/dashboard-layout.ts b/packages/webui/src/lib/dashboard-layout.ts
index caccd75d..6ac574bd 100644
--- a/packages/webui/src/lib/dashboard-layout.ts
+++ b/packages/webui/src/lib/dashboard-layout.ts
@@ -123,12 +123,18 @@ export const ALL_LOG_LEVELS: LogLevel[] = ['trace', 'debug', 'info', 'success',
export interface AlertsConfig { count: number; levels: LogLevel[] }
export interface SessionsConfig { sort: 'recent' | 'uin' | 'nickname'; filter: string }
+/** Host widget: which resource sub-panels to show. */
+export interface HostConfig { cpu: boolean; memory: boolean; runtime: boolean }
+/** Connections widget: filter + sort + issues-only. */
+export interface ConnectionsConfig { filter: string; onlyIssues: boolean; sort: 'default' | 'name' | 'status' }
export const DEFAULT_ALERTS_CONFIG: AlertsConfig = { count: 5, levels: ['warn', 'error'] };
export const DEFAULT_SESSIONS_CONFIG: SessionsConfig = { sort: 'recent', filter: '' };
+export const DEFAULT_HOST_CONFIG: HostConfig = { cpu: true, memory: true, runtime: true };
+export const DEFAULT_CONNECTIONS_CONFIG: ConnectionsConfig = { filter: '', onlyIssues: false, sort: 'default' };
/** Widgets that expose a config form (gear) in the layout editor. */
-export const CONFIGURABLE_WIDGETS = new Set(['alerts', 'sessions']);
+export const CONFIGURABLE_WIDGETS = new Set(['alerts', 'sessions', 'host', 'connections']);
export function parseAlertsConfig(config: Record
| undefined): AlertsConfig {
const c = config ?? {};
@@ -149,3 +155,27 @@ export function parseSessionsConfig(config: Record | undefined)
const filter = typeof c.filter === 'string' ? c.filter.slice(0, 100) : '';
return { sort, filter };
}
+
+export function parseHostConfig(config: Record | undefined): HostConfig {
+ const c = config ?? {};
+ const bool = (v: unknown, d: boolean) => (typeof v === 'boolean' ? v : d);
+ const cfg = {
+ cpu: bool(c.cpu, true),
+ memory: bool(c.memory, true),
+ runtime: bool(c.runtime, true),
+ };
+ // Never let every panel be hidden — that leaves an empty card; fall back to all.
+ return cfg.cpu || cfg.memory || cfg.runtime ? cfg : { ...DEFAULT_HOST_CONFIG };
+}
+
+export function parseConnectionsConfig(config: Record | undefined): ConnectionsConfig {
+ const c = config ?? {};
+ const sort = c.sort === 'name' || c.sort === 'status' || c.sort === 'default'
+ ? c.sort
+ : DEFAULT_CONNECTIONS_CONFIG.sort;
+ return {
+ filter: typeof c.filter === 'string' ? c.filter.slice(0, 100) : '',
+ onlyIssues: typeof c.onlyIssues === 'boolean' ? c.onlyIssues : false,
+ sort,
+ };
+}