From 3c138388676fdbf735e8746255133da853a113c8 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Fri, 31 Jul 2026 16:56:44 +0800 Subject: [PATCH] feat(webui): standardize content loading states Use consistent delayed placeholders across data-backed console surfaces. Avoid flashing loading UI for fast local responses while keeping slower transitions stable. Keep failures visible and prevent gated content from opening on incomplete checks. --- packages/webui/README.md | 7 + packages/webui/src/App.tsx | 86 ++- .../components/config/notification-opt-in.tsx | 277 ++++---- .../src/components/interior/skeleton-swap.tsx | 177 +++++ .../components/overview/deliveries-widget.tsx | 99 ++- .../src/components/pages/config-page.tsx | 236 ++++--- .../webui/src/components/pages/debug-page.tsx | 48 +- .../webui/src/components/pages/logs-page.tsx | 253 ++++--- .../src/components/pages/overview-page.tsx | 575 ++++++++++------ .../src/components/pages/processes-page.tsx | 277 ++++---- .../src/components/pages/settings-page.tsx | 59 +- .../src/components/process-probe-dialog.tsx | 96 +-- .../settings/global-config-panel.tsx | 220 ++++--- .../settings/notifications-panel.tsx | 209 +++--- .../src/components/settings/storage-panel.tsx | 622 +++++++++--------- .../src/components/settings/system-panel.tsx | 380 ++++++----- packages/webui/src/components/ui/picker.tsx | 115 ++-- .../webui/src/contexts/AppStateContext.tsx | 16 + .../src/hooks/use-onebot-instance-config.ts | 43 +- packages/webui/src/index.css | 13 + packages/webui/src/router/app-layout.tsx | 182 ++++- packages/webui/tests/skeleton-swap.test.tsx | 30 + 22 files changed, 2493 insertions(+), 1527 deletions(-) create mode 100644 packages/webui/src/components/interior/skeleton-swap.tsx create mode 100644 packages/webui/tests/skeleton-swap.test.tsx diff --git a/packages/webui/README.md b/packages/webui/README.md index 901af770..08955be4 100644 --- a/packages/webui/README.md +++ b/packages/webui/README.md @@ -11,6 +11,13 @@ status, OneBot configuration, logs, storage, and server settings. automatically after a visible countdown. - Routine, high-frequency adjustments should not generate a notice for every intermediate edit. +- Data-backed surfaces use the Interior Skeleton Swap defaults (120 ms delay, + 380 ms minimum visibility) so fast local responses do not flash a placeholder. + Submission, upload, and other explicit operation progress keeps its spinner. +- Variable-height content must release the skeleton's reserved box after it is + ready; do not introduce a second scrolling region inside the page. +- The mobile navigation menu uses a controlled Icon Morph whose visual state + follows the actual drawer state. - Failures must remain visible in the affected control and in the operation result; do not convert failed responses into successful feedback. - Password change flows use floating labels and inline validation consistently. diff --git a/packages/webui/src/App.tsx b/packages/webui/src/App.tsx index d9f4b117..43d7a347 100644 --- a/packages/webui/src/App.tsx +++ b/packages/webui/src/App.tsx @@ -1,17 +1,22 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { RouterProvider } from '@tanstack/react-router'; +import { AlertTriangle, LogOut, RefreshCw } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Card, CardContent } from '@/components/ui/card'; import { TooltipProvider } from '@/components/ui/tooltip'; import { ThemeProvider } from '@/contexts/ThemeContext'; import { SessionProvider } from '@/contexts/SessionContext'; import { LoginPage } from '@/components/pages/login-page'; import { ChangePasswordPage } from '@/components/pages/change-password-page'; import { ConsentPage } from '@/components/pages/consent-page'; +import { SkeletonSwap, useSkeletonSwap } from '@/components/interior/skeleton-swap'; import { ApiProvider, createApiClient, useApi, type ApiClient } from '@/lib/api'; import { DebugTaskProvider } from '@/contexts/DebugTaskContext'; import { TaskBadge } from '@/components/debug/task-badge'; import { AdaptivePointer } from '@/components/ui/adaptive-pointer'; import { GlobalContextMenu } from '@/components/ui/global-context-menu'; import { + actionErrorMessage, ActionFeedbackProvider, ActionFeedbackViewport, useActionFeedback, @@ -58,12 +63,15 @@ function AuthBoundary() { // Agreement consent gate, shown after login but BEFORE the forced password // change. `agreements === null` while the post-auth fetch is in flight. const [agreements, setAgreements] = useState(null); + const [agreementsError, setAgreementsError] = useState(null); const [needsConsent, setNeedsConsent] = useState(false); // The password from *this* session's login, carried into the forced // change-password gate so it doesn't have to render an old-password field // (which browsers autofill, misleading users on upgrade). Stays undefined // for a returning session that's already authed but still must change. const [loginPassword, setLoginPassword] = useState(undefined); + const authLoading = !authChecked || (authed && agreements === null && agreementsError === null); + const { showSkeleton: showAuthSkeleton } = useSkeletonSwap({ ready: !authLoading }); const client = useMemo( () => @@ -77,14 +85,15 @@ function AuthBoundary() { ); const refreshAgreements = useCallback(async () => { + setAgreements(null); + setAgreementsError(null); try { const payload = await client.agreements.get(); setAgreements(payload); setNeedsConsent(payload.consentRequired); - } catch { - // Fail open on a fetch error so a transient hiccup can't wedge the gate. - setAgreements({ version: '', consentRequired: false, documents: [] }); - setNeedsConsent(false); + } catch (error) { + console.error('agreement status load failed', error); + setAgreementsError(actionErrorMessage(error)); } }, [client]); @@ -126,6 +135,7 @@ function AuthBoundary() { setStatus('未连接'); setMustChange(false); setAgreements(null); + setAgreementsError(null); setNeedsConsent(false); setLoginPassword(undefined); }, []); @@ -136,8 +146,8 @@ function AuthBoundary() { }, [client, handleLoggedOut]); let view: React.ReactNode; - if (!authChecked) { - view = 初始化中…; + if (authLoading || showAuthSkeleton) { + view = {authChecked ? '加载中…' : '初始化中…'}; } else if (!authed) { view = ( ); - } else if (agreements === null) { - view = 加载中…; - } else if (needsConsent) { + } else if (agreementsError) { + view = ( + { void refreshAgreements(); }} + onLogout={() => { void handleDecline(); }} + /> + ); + } else if (needsConsent && agreements) { view = ( void; + onLogout: () => void; +}) { + return ( +
+ + +
+
+ +
+
+

协议状态加载失败

+

+ 无法确认当前用户协议与隐私政策状态。为避免绕过必要确认,控制台暂不放行。 +

+

{detail}

+
+
+
+ + +
+
+
+
+ ); +} + function Splash({ children }: { children: React.ReactNode }) { return (
- {children} + + {null} +
); } diff --git a/packages/webui/src/components/config/notification-opt-in.tsx b/packages/webui/src/components/config/notification-opt-in.tsx index 3c83900c..a68e93ba 100644 --- a/packages/webui/src/components/config/notification-opt-in.tsx +++ b/packages/webui/src/components/config/notification-opt-in.tsx @@ -6,10 +6,12 @@ // Scales to many channels (40+): collapsed by default to a one-line summary of // selected channels as removable chips; expanded into a searchable, bulk- // actionable, height-bounded scroll list so it never blows up the page. -import { useEffect, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { AnimatePresence, motion } from 'motion/react'; -import { ChevronDown, Loader2, Search, X } from 'lucide-react'; +import { ChevronDown, Search, X } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; +import { Button } from '@/components/ui/button'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { ScrollArea } from '@/components/ui/scroll-area'; @@ -29,24 +31,27 @@ const CHIP_CAP = 8; export function NotificationOptIn({ selectedIds, onChange }: NotificationOptInProps) { const api = useApi(); const [channels, setChannels] = useState(null); + const [loadError, setLoadError] = useState(null); const [expanded, setExpanded] = useState(false); const [query, setQuery] = useState(''); - useEffect(() => { - let cancelled = false; - void (async () => { - try { - const cfg = await api.notifications.getConfig(); - if (!cancelled) setChannels(cfg.channels); - } catch { - if (!cancelled) setChannels([]); - } - })(); - return () => { - cancelled = true; - }; + const load = useCallback(async () => { + setChannels(null); + setLoadError(null); + try { + const cfg = await api.notifications.getConfig(); + setChannels(cfg.channels); + } catch (error) { + console.error('load notification opt-ins failed', error); + setLoadError(error instanceof Error ? error.message : '加载通知渠道失败'); + setChannels([]); + } }, [api]); + useEffect(() => { + void load(); + }, [load]); + const selected = useMemo(() => new Set(selectedIds), [selectedIds]); const toggle = (id: string, on: boolean) => { @@ -105,124 +110,136 @@ export function NotificationOptIn({ selectedIds, onChange }: NotificationOptInPr /> - {channels === null ? ( -
- 加载渠道… -
- ) : total === 0 ? ( -

还没有全局渠道——先到「设置 → 通知」添加。

- ) : ( - <> - {/* collapsed: selected channels as removable chips */} - {!expanded && - (selectedCount === 0 ? ( -

未选择任何渠道。展开以选择。

- ) : ( -
- {selectedChips.slice(0, CHIP_CAP).map((ch) => ( - - {ch.name} - - - ))} - {selectedCount > CHIP_CAP && ( - - )} -
- ))} - - {/* expanded: search + bulk + bounded scroll list */} - - {expanded && ( - -
-

- 该账号上线 / 下线时向选中的渠道推送通知。渠道在「设置 → 通知」中全局定义。 -

- -
-
- - setQuery(e.target.value)} - placeholder="搜索渠道…" - className="h-8 pl-8 text-xs" - /> -
- - + + {channels !== null ? ( + loadError ? ( +
+ {loadError} + +
+ ) : total === 0 ? ( +

还没有全局渠道——先到「设置 → 通知」添加。

+ ) : ( + <> + {/* collapsed: selected channels as removable chips */} + {!expanded && + (selectedCount === 0 ? ( +

未选择任何渠道。展开以选择。

+ ) : ( +
+ {selectedChips.slice(0, CHIP_CAP).map((ch) => ( + + {ch.name} + + + ))} + {selectedCount > CHIP_CAP && ( + + )}
+ ))} - {filtered.length === 0 ? ( -

无匹配渠道

- ) : ( - -
- {filtered.map((ch) => ( -
-
-
- {ch.name || ch.id} - {!ch.enabled && ( - (已全局禁用) - )} -
-

{ch.url}

-
- toggle(ch.id, v)} - ariaLabel={`为该账号启用渠道 ${ch.name || ch.id}`} - disabled={!ch.enabled} - /> -
- ))} + {/* expanded: search + bulk + bounded scroll list */} + + {expanded && ( + +
+

+ 该账号上线 / 下线时向选中的渠道推送通知。渠道在「设置 → 通知」中全局定义。 +

+ +
+
+ + setQuery(e.target.value)} + placeholder="搜索渠道…" + className="h-8 pl-8 text-xs" + /> +
+ +
- - )} -
-
- )} -
- - )} + + {filtered.length === 0 ? ( +

无匹配渠道

+ ) : ( + +
+ {filtered.map((ch) => ( +
+
+
+ {ch.name || ch.id} + {!ch.enabled && ( + (已全局禁用) + )} +
+

{ch.url}

+
+ toggle(ch.id, v)} + ariaLabel={`为该账号启用渠道 ${ch.name || ch.id}`} + disabled={!ch.enabled} + /> +
+ ))} +
+
+ )} +
+ + )} + + + ) + ) : null} +
); } diff --git a/packages/webui/src/components/interior/skeleton-swap.tsx b/packages/webui/src/components/interior/skeleton-swap.tsx new file mode 100644 index 00000000..9c0cb86f --- /dev/null +++ b/packages/webui/src/components/interior/skeleton-swap.tsx @@ -0,0 +1,177 @@ +'use client'; + +import { useEffect, useRef, useState } from 'react'; +import { AnimatePresence, motion, useReducedMotion } from 'motion/react'; + +const CROSSFADE = { + type: 'spring', + stiffness: 260, + damping: 34, + mass: 0.8, +} as const; + +const WIDTHS = [100, 93, 97, 88, 95, 91] as const; + +function widthFor(index: number, total: number) { + if (total > 1 && index === total - 1) return 62; + return WIDTHS[(index * 7 + 3) % WIDTHS.length]; +} + +export type UseSkeletonSwapOptions = { + ready: boolean; + delay?: number; + minVisible?: number; +}; + +export function useSkeletonSwap({ + ready, + delay = 120, + minVisible = 380, +}: UseSkeletonSwapOptions) { + const [visible, setVisible] = useState(false); + const shownAt = useRef(0); + + useEffect(() => { + if (!ready) { + if (visible) return; + const t = setTimeout(() => { + shownAt.current = performance.now(); + setVisible(true); + }, delay); + return () => clearTimeout(t); + } + + if (!visible) return; + const rest = Math.max(0, minVisible - (performance.now() - shownAt.current)); + const t = setTimeout(() => setVisible(false), rest); + return () => clearTimeout(t); + }, [ready, visible, delay, minVisible]); + + return { showSkeleton: visible, busy: !ready }; +} + +export type SkeletonSwapProps = { + ready: boolean; + children: React.ReactNode; + lines?: number; + lineHeight?: number; + barHeight?: number; + reserve?: number; + delay?: number; + minVisible?: number; + label?: string; + skeleton?: React.ReactNode; + className?: string; +}; + +export function SkeletonSwap({ + ready, + children, + lines = 3, + lineHeight = 21, + barHeight = 9, + reserve, + delay = 120, + minVisible = 380, + label, + skeleton, + className = '', +}: SkeletonSwapProps) { + const { showSkeleton } = useSkeletonSwap({ ready, delay, minVisible }); + const reduced = useReducedMotion(); + + const shell = useRef(null); + const body = useRef(null); + const [scrollable, setScrollable] = useState(false); + + const box = reserve ?? lines * lineHeight; + + useEffect(() => { + const el = shell.current; + const inner = body.current; + if (!el || typeof ResizeObserver === 'undefined') return; + + const check = () => setScrollable(el.scrollHeight - el.clientHeight > 1); + check(); + + const ro = new ResizeObserver(check); + ro.observe(el); + if (inner) ro.observe(inner); + return () => ro.disconnect(); + }, []); + + return ( +
+ + {children} + + + + {showSkeleton ? ( + + {skeleton ?? ( +
+ {Array.from({ length: lines }, (_, i) => ( +
+
+
+ ))} +
+ )} + + ) : null} + + + {label ? ( + + {ready ? `${label} loaded` : ''} + + ) : null} +
+ ); +} diff --git a/packages/webui/src/components/overview/deliveries-widget.tsx b/packages/webui/src/components/overview/deliveries-widget.tsx index 807bdd38..8a6ec4b6 100644 --- a/packages/webui/src/components/overview/deliveries-widget.tsx +++ b/packages/webui/src/components/overview/deliveries-widget.tsx @@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'; import { Bell, CheckCircle2, XCircle } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { cn } from '@/lib/utils'; import { useApi } from '@/lib/api'; import { useTheme } from '@/contexts/ThemeContext'; @@ -15,6 +16,7 @@ export function DeliveriesWidget() { const api = useApi(); const { formatClock } = useTheme(); const [records, setRecords] = useState(null); + const [loadError, setLoadError] = useState(null); useEffect(() => { let active = true; @@ -27,10 +29,17 @@ export function DeliveriesWidget() { api.notifications .recent(50) .then((r) => { - if (active) setRecords(r); + if (active) { + setLoadError(null); + setRecords(r); + } }) - .catch(() => { - if (active) setRecords((prev) => prev ?? []); + .catch((error) => { + console.error('load recent notification deliveries failed', error); + if (active) { + setLoadError(error instanceof Error ? error.message : '加载最近投递失败'); + setRecords((prev) => prev ?? []); + } }) .finally(() => { inFlight = false; }); }; @@ -55,40 +64,58 @@ export function DeliveriesWidget() { - {records === null ? ( -

加载中…

- ) : records.length === 0 ? ( -
- -

暂无投递记录

-
- ) : ( -
- {records.map((r, i) => ( -
- {r.ok ? ( - - ) : ( - - )} - {formatClock(r.time)} - - {r.event === 'online' ? '上线' : '下线'} - - {r.uin} - - {r.channelId} - {!r.ok && r.error && · {r.error}} - + + {records !== null ? ( + loadError && records.length === 0 ? ( +

+ {loadError} +

+ ) : records.length === 0 ? ( +
+ +

暂无投递记录

- ))} -
- )} + ) : ( +
+ {loadError && ( +

+ {loadError};当前显示上次成功读取的投递记录。 +

+ )} + {records.map((r, i) => ( +
+ {r.ok ? ( + + ) : ( + + )} + {formatClock(r.time)} + + {r.event === 'online' ? '上线' : '下线'} + + {r.uin} + + {r.channelId} + {!r.ok && r.error && · {r.error}} + +
+ ))} +
+ ) + ) : null} + ); diff --git a/packages/webui/src/components/pages/config-page.tsx b/packages/webui/src/components/pages/config-page.tsx index a455d99c..1965af42 100644 --- a/packages/webui/src/components/pages/config-page.tsx +++ b/packages/webui/src/components/pages/config-page.tsx @@ -10,10 +10,10 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { motion } from 'motion/react'; import { Check, Loader2, MousePointerClick, Plus, Save } from 'lucide-react'; import { Button } from '@/components/ui/button'; -import { Skeleton } from '@/components/ui/skeleton'; import { Badge } from '@/components/ui/badge'; import { ScrollableTabList } from '@/components/ui/tabs'; import { ConfirmDialog } from '@/components/confirm-dialog'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { cn } from '@/lib/utils'; import type { AdapterStatus, @@ -41,9 +41,19 @@ type DialogState = // index: null → create with `seed`, otherwise edit the item at that position. export function ConfigPage() { - const { qqList, connections, selectedUin, setSelectedUin } = useAppState(); + const { + qqList, + connections, + selectedUin, + setSelectedUin, + resources, + refreshQqList, + } = useAppState(); const { config, + loading, + loadError, + reload, setConfig, dirty, requestSwitchUin, @@ -57,7 +67,6 @@ export function ConfigPage() { selectedUin, onSelectedUinChange: setSelectedUin, }); - const { pages, setPages } = useLayout(); const [activeTab, setActiveTabState] = useState(() => { const t = pages.configTab; @@ -169,99 +178,136 @@ export function ConfigPage() { }; return ( -
- setSidebarCollapsed((v) => !v)} - /> - -
- {!selectedUin ? ( - - ) : !config ? ( - + + {resources.qqList.ready ? ( + resources.qqList.error && qqList.length === 0 ? ( + ) : ( -
- openCreate(activeTab as NetworkKind) : undefined - } - /> +
+ {resources.qqList.error && ( +
+ {resources.qqList.error};当前显示上次成功读取的账号列表。 +
+ )} +
+ setSidebarCollapsed((v) => !v)} + /> - +
+ {!selectedUin ? ( + + ) : ( + + {!loading ? ( + loadError || !config ? ( + + ) : ( +
+ openCreate(activeTab as NetworkKind) : undefined + } + /> -
- {activeTab === 'general' ? ( - - ) : ( - openCreate(activeTab)} - onEdit={(idx) => openEdit(activeTab, idx)} - onDelete={(idx) => handleDelete(activeTab, idx)} - onToggleEnabled={(idx, v) => handleToggleEnabled(activeTab, idx, v)} + + +
+ {activeTab === 'general' ? ( + + ) : ( + openCreate(activeTab)} + onEdit={(idx) => openEdit(activeTab, idx)} + onDelete={(idx) => handleDelete(activeTab, idx)} + onToggleEnabled={(idx, v) => handleToggleEnabled(activeTab, idx, v)} + /> + )} +
+
+ ) + ) : null} + + )} +
+ + {/* Single dialog covers create + edit across all 4 kinds. */} + {dialog.open && config && ( + !open && setDialog({ open: false })} + kind={dialog.kind} + initial={dialog.seed} + isEdit={dialog.index != null} + otherNames={otherNames(config.networks, dialog.kind, dialog.index)} + onSubmit={(item) => { + if (dialog.index == null) handleCreate(dialog.kind, item); + else handleEdit(dialog.kind, dialog.index, item); + }} /> )} + + !open && cancelSwitch()} + title="放弃未保存的修改?" + description={ + <> +

+ 当前会话 {selectedUin} 还有未保存的修改。 +

+

+ 切换到 {pendingSwitchAccount?.uin ?? pendingSwitchUin} + {pendingSwitchAccount?.nickname ? `(${pendingSwitchAccount.nickname})` : ''} 会丢弃这些修改。 +

+ + } + confirmText="放弃并切换" + destructive + onConfirm={confirmSwitch} + />
- )} -
- - {/* Single dialog covers create + edit across all 4 kinds. */} - {dialog.open && config && ( - !open && setDialog({ open: false })} - kind={dialog.kind} - initial={dialog.seed} - isEdit={dialog.index != null} - otherNames={otherNames(config.networks, dialog.kind, dialog.index)} - onSubmit={(item) => { - if (dialog.index == null) handleCreate(dialog.kind, item); - else handleEdit(dialog.kind, dialog.index, item); - }} - /> - )} - - !open && cancelSwitch()} - title="放弃未保存的修改?" - description={ - <> -

- 当前会话 {selectedUin} 还有未保存的修改。 -

-

- 切换到 {pendingSwitchAccount?.uin ?? pendingSwitchUin} - {pendingSwitchAccount?.nickname ? `(${pendingSwitchAccount.nickname})` : ''} 会丢弃这些修改。 -

- - } - confirmText="放弃并切换" - destructive - onConfirm={confirmSwitch} - /> -
+ ) + ) : null} +
); } @@ -494,13 +540,13 @@ function EmptyState() { ); } -function LoadingSkeleton() { +function ConfigLoadError({ message, onRetry }: { message: string; onRetry: () => void }) { return ( -
- - - - +
+

{message}

+
); } diff --git a/packages/webui/src/components/pages/debug-page.tsx b/packages/webui/src/components/pages/debug-page.tsx index 476d91c0..c77d0f90 100644 --- a/packages/webui/src/components/pages/debug-page.tsx +++ b/packages/webui/src/components/pages/debug-page.tsx @@ -11,6 +11,7 @@ import { ActionTester } from '@/components/debug/action-tester'; import { MessageComposer } from '@/components/debug/message-composer'; import { LiveActivity } from '@/components/debug/live-activity'; import { ApiBrowser } from '@/components/debug/api-browser'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { useApi } from '@/lib/api'; import type { DebugActionDoc, QQInfo } from '@/types'; @@ -20,6 +21,8 @@ export function DebugPage() { const api = useApi(); const [accounts, setAccounts] = useState([]); const [docs, setDocs] = useState([]); + const [ready, setReady] = useState(false); + const [loadError, setLoadError] = useState(null); const [tab, setTab] = useState('tester'); const [preset, setPreset] = useState<{ name: string; nonce: number } | undefined>(); @@ -29,7 +32,12 @@ export function DebugPage() { const [qq, acts] = await Promise.all([api.qqList(), api.debug.actions()]); setAccounts(qq); setDocs(acts.actions); - } catch { /* surfaced lazily on invoke */ } + } catch (error) { + console.error('load debug tools', error); + setLoadError(error instanceof Error ? error.message : '加载开发者工具失败'); + } finally { + setReady(true); + } })(); }, [api]); @@ -66,15 +74,35 @@ export function DebugPage() { /> - {/* Tester / compose / activity stay MOUNTED and toggle via CSS so the - live feed's SSE never drops (it must capture events fired from other - tabs) and in-progress params/messages survive a peek at another tab. - ApiBrowser has no state worth preserving and is heavy (~520 rows), so - it mounts on demand. */} -
-
-
- {tab === 'api' && } + {loadError && ( +
+ {loadError} +
+ )} + + + {ready ? ( + <> + {/* Tester / compose / activity stay MOUNTED and toggle via CSS so the + live feed's SSE never drops (it must capture events fired from other + tabs) and in-progress params/messages survive a peek at another tab. + ApiBrowser has no state worth preserving and is heavy (~520 rows), so + it mounts on demand. */} +
+
+
+ {tab === 'api' && } + + ) : null} +
); } diff --git a/packages/webui/src/components/pages/logs-page.tsx b/packages/webui/src/components/pages/logs-page.tsx index 949173bd..b4e02678 100644 --- a/packages/webui/src/components/pages/logs-page.tsx +++ b/packages/webui/src/components/pages/logs-page.tsx @@ -9,6 +9,7 @@ import { Input } from '@/components/ui/input'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; import { ConfirmDialog } from '@/components/confirm-dialog'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { cn } from '@/lib/utils'; import type { LogEntry, LogLevel, LogsPreset, UiHighlightRule } from '@/types'; import { useApi } from '@/lib/api'; @@ -107,10 +108,14 @@ export function LogsPage() { const prefs = pages.logs; const [logs, setLogs] = useState([]); + const [logsReady, setLogsReady] = useState(false); + const [logsError, setLogsError] = useState(null); const [streamStatus, setStreamStatus] = useState('连接中'); const [filter, setFilter] = useState(''); const [confirmClear, setConfirmClear] = useState(false); const [serverLevel, setServerLevel] = useState(null); + const [serverLevelReady, setServerLevelReady] = useState(false); + const [serverLevelError, setServerLevelError] = useState(null); const [levelBusy, setLevelBusy] = useState(false); const [confirmTrace, setConfirmTrace] = useState(false); const [traceExportBusy, setTraceExportBusy] = useState(false); @@ -133,23 +138,39 @@ export function LogsPage() { const enabled = useMemo(() => new Set(prefs.visibleLevels as LogLevel[]), [prefs.visibleLevels]); const loadLogs = useCallback(async () => { + setLogsError(null); try { // Backfill is capped at the server's ring-buffer size (1000); `maxLines` // can exceed that, but only the live SSE stream grows the view past 1000. setLogs(await api.logs.list(Math.min(1000, maxLinesRef.current))); } catch (e) { console.error('logs', e); + setLogsError(e instanceof Error ? e.message : '加载日志失败'); + } finally { + setLogsReady(true); } }, [api]); useEffect(() => { void loadLogs(); }, [loadLogs]); - useEffect(() => { - api.logs.getLevel().then(({ level }) => setServerLevel(level)).catch((err) => { - console.error('getLevel', err); - }); + const loadServerLevel = useCallback(async () => { + setServerLevelReady(false); + setServerLevelError(null); + try { + const { level } = await api.logs.getLevel(); + setServerLevel(level); + } catch (error) { + console.error('get server log level failed', error); + setServerLevelError(error instanceof Error ? error.message : '加载服务端日志级别失败'); + } finally { + setServerLevelReady(true); + } }, [api]); + useEffect(() => { + void loadServerLevel(); + }, [loadServerLevel]); + const applyServerLevel = useCallback(async (lv: LogLevel) => { if (lv === serverLevel || levelBusy) return; setLevelBusy(true); @@ -587,29 +608,50 @@ export function LogsPage() { 服务端日志级别 · 普通日志仅影响控制台 / 实时流;首次登录凭据始终可见;文件等级由环境变量决定,默认为 debug
-
- {LEVELS.map((lv) => { - const active = serverLevel === lv; - return ( - - ); - })} -
+ + {serverLevelReady ? ( + serverLevelError ? ( +
+ {serverLevelError} + +
+ ) : ( +
+ {LEVELS.map((lv) => { + const active = serverLevel === lv; + return ( + + ); + })} +
+ ) + ) : null} +
{/* Highlight rules */} @@ -674,7 +716,7 @@ export function LogsPage() {
{/* Column header lives OUTSIDE the scroll viewport so the virtualizer's scroll element contains only the rows (no sticky-offset math). */} - {filtered.length > 0 && ( + {logsReady && filtered.length > 0 && (
时间 级别 @@ -682,75 +724,100 @@ export function LogsPage() { 消息
)} + {logsReady && logsError && logs.length > 0 && ( +
+ {logsError};当前显示已读取和实时接收的日志。 +
+ )} div]:!block', maskCls)}> -
- {filtered.length === 0 ? ( -
- {logs.length === 0 ? ( - <> - - 暂无日志 - + + {logsReady ? ( +
+ {logsError && logs.length === 0 ? ( +
+ + {logsError} + +
+ ) : filtered.length === 0 ? ( +
+ {logs.length === 0 ? ( + <> + + 暂无日志 + + ) : ( + <> + + 没有符合筛选条件的日志 + + + )} +
) : ( - <> - - 没有符合筛选条件的日志 - - +
+ {rowVirtualizer.getVirtualItems().map((vRow) => { + const log = filtered[vRow.index]; + if (!log) return null; // guard a transient count/measurement skew + const hl = matchHighlight(log.message, prefs.highlightRules); + // Entrance is decided entirely by animatingRef (populated in + // the flush from real arrivals, pruned at 260ms), so it fires + // on the first paint, never replays on scroll-into-view, and + // is immune to filter/idle churn. Outer = positioning + + // measurement (its translateY); inner = visual row + the + // transform-based entrance, kept separate so they never collide. + const entering = animatingRef.current.has(log.id); + return ( +
+
+
+ {formatClock(log.time)} + + + {log.level.toUpperCase()} + + [{log.scope}] +
+ + {log.req !== undefined && ( + #{log.req} + )} + {log.message} + +
+
+ ); + })} +
)}
- ) : ( -
- {rowVirtualizer.getVirtualItems().map((vRow) => { - const log = filtered[vRow.index]; - if (!log) return null; // guard a transient count/measurement skew - const hl = matchHighlight(log.message, prefs.highlightRules); - // Entrance is decided entirely by animatingRef (populated in - // the flush from real arrivals, pruned at 260ms), so it fires - // on the first paint, never replays on scroll-into-view, and - // is immune to filter/idle churn. Outer = positioning + - // measurement (its translateY); inner = visual row + the - // transform-based entrance, kept separate so they never collide. - const entering = animatingRef.current.has(log.id); - return ( -
-
-
- {formatClock(log.time)} - - - {log.level.toUpperCase()} - - [{log.scope}] -
- - {log.req !== undefined && ( - #{log.req} - )} - {log.message} - -
-
- ); - })} -
- )} -
+ ) : null} +
diff --git a/packages/webui/src/components/pages/overview-page.tsx b/packages/webui/src/components/pages/overview-page.tsx index 743d2570..aa0120e0 100644 --- a/packages/webui/src/components/pages/overview-page.tsx +++ b/packages/webui/src/components/pages/overview-page.tsx @@ -12,7 +12,7 @@ import { Progress } from '@/components/ui/progress'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; -import { Skeleton } from '@/components/ui/skeleton'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { cn, formatBytes, formatUptime } from '@/lib/utils'; import type { AppPath } from '@/router'; import type { @@ -64,7 +64,7 @@ function renderWidget(block: UiLayoutItem): ReactNode { } export function OverviewPage() { - const { qqList, processList } = useAppState(); + const { qqList, processList, resources } = useAppState(); const { overviewBlocks, setOverviewBlocks, overviewMobile, setOverviewMobile, resetLayout, editing, setEditing, @@ -153,7 +153,7 @@ export function OverviewPage() { )} {/* First-run nudge — always shown (not a grid widget) so it can't be hidden. */} - {qqList.length === 0 && ( + {resources.qqList.ready && !resources.qqList.error && qqList.length === 0 && ( @@ -502,10 +503,32 @@ function StatTile({ > {icon}
- {details ? ( - {copy} + {details && ready ? ( + + + {copy} + + ) : ( -
{copy}
+ + {ready ? copy : null} + )} {to && } @@ -521,7 +544,7 @@ function StatTile({ } function StatTileWidget({ id }: { id: string }) { - const { qqList, processList, systemInfo } = useAppState(); + const { qqList, processList, systemInfo, resources } = useAppState(); const { status } = useSession(); const online = status === '已连接'; @@ -541,8 +564,11 @@ function StatTileWidget({ id }: { id: string }) { } label="在线账号" - value={qqList.length} - subtext={`已接入 ${qqList.length} 个会话`} + ready={resources.qqList.ready} + value={resources.qqList.error && qqList.length === 0 ? '—' : qqList.length} + subtext={resources.qqList.error + ? qqList.length > 0 ? '更新失败,显示上次数据' : '加载失败' + : `已接入 ${qqList.length} 个会话`} /> ); case 'stat:processes': { @@ -552,19 +578,25 @@ function StatTileWidget({ id }: { id: string }) { } label="进程注入" - value={`${onlineProcs} 在线`} - subtext={`${processList.length} 进程 · ${loadableProcs} 可注入`} + ready={resources.processList.ready} + value={resources.processList.error && processList.length === 0 ? '—' : `${onlineProcs} 在线`} + subtext={resources.processList.error + ? processList.length > 0 ? '更新失败,显示上次数据' : '加载失败' + : `${processList.length} 进程 · ${loadableProcs} 可注入`} to="/processes" /> ); } case 'stat:host': { const value = systemInfo?.hostname ?? '—'; - const subtext = systemInfo ? `${shortDistro(systemInfo.distro)} · ${systemInfo.archLabel}` : '加载中'; + const subtext = systemInfo + ? `${shortDistro(systemInfo.distro)} · ${systemInfo.archLabel}` + : resources.systemInfo.error ? '加载失败' : '加载中'; return ( } label="主机名" + ready={resources.systemInfo.ready} value={value} subtext={subtext} details={systemInfo @@ -580,6 +612,7 @@ function StatTileWidget({ id }: { id: string }) { } label="系统运行" + ready={resources.systemInfo.ready} value={systemUptime} subtext={processUptime ? `进程 ${processUptime}` : undefined} details={processUptime @@ -598,7 +631,7 @@ function StatTileWidget({ id }: { id: string }) { const HOST_GRID_COLS: Record = { 1: 'lg:grid-cols-1', 2: 'lg:grid-cols-2', 3: 'lg:grid-cols-3' }; function HostBlock({ config }: { config: HostConfig }) { - const { systemInfo, refreshSystem } = useAppState(); + const { systemInfo, refreshSystem, resources } = useAppState(); const panelCount = [config.cpu, config.memory, config.runtime].filter(Boolean).length; return ( @@ -607,8 +640,10 @@ function HostBlock({ config }: { config: HostConfig }) { 主机资源 {systemInfo - ? `${systemInfo.cpu.model.trim()} · ${systemInfo.cpu.cores} 核 · Node ${systemInfo.nodeVersion}` - : '正在采集主机信息…'} + ? `${systemInfo.cpu.model.trim()} · ${systemInfo.cpu.cores} 核 · Node ${systemInfo.nodeVersion}${ + resources.systemInfo.error ? ' · 更新失败,显示上次数据' : '' + }` + : resources.systemInfo.error ?? '正在采集主机信息…'}
- -

- 负载: {systemInfo ? systemInfo.cpu.loadAvg.map((v) => v.toFixed(2)).join(' / ') : '—'} -

- {systemInfo && systemInfo.cpu.perCore.length > 0 && ( -
- {systemInfo.cpu.perCore.map((p, i) => ( -
- + {systemInfo ? ( + <> + +

+ 负载: {systemInfo.cpu.loadAvg.map((v) => v.toFixed(2)).join(' / ')} +

+ {systemInfo.cpu.perCore.length > 0 && ( +
- {i} - -
- ))} -
- )} + {systemInfo.cpu.perCore.map((p, i) => ( +
+ + {i} + +
+ ))} +
+ )} + + ) : resources.systemInfo.error ? ( +

{resources.systemInfo.error}

+ ) : null} +
)} {/* Memory */} @@ -673,39 +724,51 @@ function HostBlock({ config }: { config: HostConfig }) { {systemInfo ? `${systemInfo.memory.usagePercent.toFixed(1)}%` : '—'} - {systemInfo ? (() => { - const m = systemInfo.memory; - const rss = Math.min(systemInfo.runtime.rss, m.used); - const other = Math.max(0, m.used - rss); - const segs = [ - { key: 'proc', label: '本进程', bytes: rss, grow: (rss / m.total) * 100, color: 'var(--primary)' }, - { key: 'other', label: '其他已用', bytes: other, grow: (other / m.total) * 100, color: 'color-mix(in oklab, var(--primary) 45%, transparent)' }, - { key: 'free', label: '空闲', bytes: m.free, grow: (m.free / m.total) * 100, color: 'color-mix(in oklab, var(--muted) 85%, transparent)' }, - ]; - return ( - <> -
- {segs.map((seg) => ( - - ))} -
-
- {segs.map((seg) => ( - - - {seg.label} - {formatBytes(seg.bytes)} - - ))} -
- - ); - })() : } + + {systemInfo ? (() => { + const m = systemInfo.memory; + const rss = Math.min(systemInfo.runtime.rss, m.used); + const other = Math.max(0, m.used - rss); + const segs = [ + { key: 'proc', label: '本进程', bytes: rss, grow: (rss / m.total) * 100, color: 'var(--primary)' }, + { key: 'other', label: '其他已用', bytes: other, grow: (other / m.total) * 100, color: 'color-mix(in oklab, var(--primary) 45%, transparent)' }, + { key: 'free', label: '空闲', bytes: m.free, grow: (m.free / m.total) * 100, color: 'color-mix(in oklab, var(--muted) 85%, transparent)' }, + ]; + return ( + <> +
+ {segs.map((seg) => ( + + ))} +
+
+ {segs.map((seg) => ( + + + {seg.label} + {formatBytes(seg.bytes)} + + ))} +
+ + ); + })() : resources.systemInfo.error ? ( +

{resources.systemInfo.error}

+ ) : null} +
)} {/* Runtime */} @@ -720,29 +783,36 @@ function HostBlock({ config }: { config: HostConfig }) { {systemInfo ? `PID ${systemInfo.runtime.pid}` : '—'} - {!systemInfo ? ( -
- - -
- ) : ( -
-
- RSS - {formatBytes(systemInfo.runtime.rss)} + + {systemInfo ? ( +
+
+ RSS + {formatBytes(systemInfo.runtime.rss)} +
+
+ 堆内存 + + {formatBytes(systemInfo.runtime.heapUsed)} / {formatBytes(systemInfo.runtime.heapTotal)} + +
+
+ 外部内存 + {formatBytes(systemInfo.runtime.external)} +
-
- 堆内存 - - {formatBytes(systemInfo.runtime.heapUsed)} / {formatBytes(systemInfo.runtime.heapTotal)} - -
-
- 外部内存 - {formatBytes(systemInfo.runtime.external)} -
-
- )} + ) : resources.systemInfo.error ? ( +

{resources.systemInfo.error}

+ ) : null} +
)} @@ -753,7 +823,7 @@ function HostBlock({ config }: { config: HostConfig }) { // ─────────────── online sessions ─────────────── function SessionsBlock({ config }: { config: SessionsConfig }) { - const { qqList } = useAppState(); + const { qqList, resources } = useAppState(); const off = useTheme().appearance.disableMotion; const list = useMemo(() => { const f = config.filter.trim().toLowerCase(); @@ -775,37 +845,60 @@ function SessionsBlock({ config }: { config: SessionsConfig }) { - {list.length === 0 ? ( -
- -

{qqList.length === 0 ? '暂无在线会话' : '无匹配的会话'}

-
- ) : ( - -
- {list.map((q, idx) => ( - - - - {(q.nickname || q.uin).slice(0, 2)} - -
-
{q.nickname}
-
{q.uin}
+ + {resources.qqList.ready ? ( + resources.qqList.error && qqList.length === 0 ? ( +

+ {resources.qqList.error} +

+ ) : list.length === 0 ? ( +
+ +

{qqList.length === 0 ? '暂无在线会话' : '无匹配的会话'}

+
+ ) : ( +
+ {resources.qqList.error && ( +

+ {resources.qqList.error};当前显示上次成功读取的在线会话。 +

+ )} + +
+ {list.map((q, idx) => ( + + + + {(q.nickname || q.uin).slice(0, 2)} + +
+
{q.nickname}
+
{q.uin}
+
+ +
+ ))}
- - - ))} -
- - )} + +
+ ) + ) : null} + ); @@ -837,7 +930,7 @@ const CONN_STATUS_RANK: Record = { }; function ConnectionsBlock({ config }: { config: ConnectionsConfig }) { - const { connections } = useAppState(); + const { connections, resources } = useAppState(); const list = useMemo(() => { const f = config.filter.trim().toLowerCase(); // Optionally drop healthy adapters, then accounts left with none. @@ -869,51 +962,72 @@ function ConnectionsBlock({ config }: { config: ConnectionsConfig }) { - {list.length === 0 ? ( -
- -

{filtered ? '无匹配的连接' : '暂无已接入的账号实例'}

-
- ) : ( -
- {list.map((acc) => ( -
-
- {acc.nickname || acc.uin} - {acc.uin} -
- {acc.databaseMigration && acc.databaseMigration.phase !== 'complete' && ( - - )} - {acc.adapters.length > 0 ? ( -
- {acc.adapters.map((adp) => ( -
- - {CONN_STATUS_LABEL[adp.status]} - -
-
- {adp.name} - {ADAPTER_KIND_LABEL[adp.kind]} -
-
{adp.detail}
- {adp.lastError && adp.lastErrorAt && ( -
- {new Date(adp.lastErrorAt).toLocaleString()} · {adp.lastError} -
- )} -
-
- ))} -
- ) : acc.databaseMigration?.usable !== false ? ( -

未配置任何协议端点

- ) : null} + + {resources.connections.ready ? ( + resources.connections.error && connections.length === 0 ? ( +

+ {resources.connections.error} +

+ ) : list.length === 0 ? ( +
+ +

{filtered ? '无匹配的连接' : '暂无已接入的账号实例'}

- ))} -
- )} + ) : ( +
+ {resources.connections.error && ( +

+ {resources.connections.error};当前显示上次成功读取的连接状态。 +

+ )} + {list.map((acc) => ( +
+
+ {acc.nickname || acc.uin} + {acc.uin} +
+ {acc.databaseMigration && acc.databaseMigration.phase !== 'complete' && ( + + )} + {acc.adapters.length > 0 ? ( +
+ {acc.adapters.map((adp) => ( +
+ + {CONN_STATUS_LABEL[adp.status]} + +
+
+ {adp.name} + {ADAPTER_KIND_LABEL[adp.kind]} +
+
{adp.detail}
+ {adp.lastError && adp.lastErrorAt && ( +
+ {new Date(adp.lastErrorAt).toLocaleString()} · {adp.lastError} +
+ )} +
+
+ ))} +
+ ) : acc.databaseMigration?.usable !== false ? ( +

未配置任何协议端点

+ ) : null} +
+ ))} +
+ ) + ) : null} + ); @@ -1013,7 +1127,7 @@ function LinkWidget({ config }: { config: LinkConfig }) { } function AccountWidget({ config }: { config: AccountConfig }) { - const { qqList } = useAppState(); + const { qqList, resources } = useAppState(); const acct = qqList.find((q) => q.uin === config.uin); if (!config.uin) { return ( @@ -1027,20 +1141,34 @@ function AccountWidget({ config }: { config: AccountConfig }) { } return ( - - - - {(acct?.nickname || config.uin).slice(0, 2)} - -
-

{acct?.nickname || '未接入账号'}

-

{config.uin}

-
- -
+ + {resources.qqList.ready ? ( + + + + {(acct?.nickname || config.uin).slice(0, 2)} + +
+

+ {resources.qqList.error ? '账号状态加载失败' : acct?.nickname || '未接入账号'} +

+

{config.uin}

+
+ +
+ ) : null} +
); } @@ -1062,24 +1190,32 @@ const ALERT_LEVEL_CLASS: Record = { function RecentAlertsCard({ config }: { config: AlertsConfig }) { const api = useApi(); const { formatClock } = useTheme(); - const [alerts, setAlerts] = useState([]); + const [alerts, setAlerts] = useState(null); + const [loadError, setLoadError] = useState(null); const { count } = config; const levelsKey = config.levels.join(','); useEffect(() => { const levels = new Set(levelsKey.split(',') as LogLevel[]); let active = true; + setAlerts(null); + setLoadError(null); api.logs .list(Math.max(200, count * 4)) .then((list) => { if (!active) return; setAlerts(list.filter((l) => levels.has(l.level)).slice(-count)); }) - .catch(() => { /* ignore */ }); + .catch((error) => { + if (!active) return; + console.error('load recent alerts failed', error); + setLoadError(error instanceof Error ? error.message : '加载最近告警失败'); + setAlerts((previous) => previous ?? []); + }); const stop = api.logs.stream({ onLine: (entry) => { if (!levels.has(entry.level)) return; - setAlerts((prev) => [...prev.filter((a) => a.id !== entry.id), entry].slice(-count)); + setAlerts((prev) => [...(prev ?? []).filter((a) => a.id !== entry.id), entry].slice(-count)); }, }); return () => { active = false; stop(); }; @@ -1099,24 +1235,45 @@ function RecentAlertsCard({ config }: { config: AlertsConfig }) { - {alerts.length === 0 ? ( -
- -

暂无告警

-
- ) : ( -
- {alerts.map((a) => ( -
- {formatClock(a.time)} - - {a.level.toUpperCase()} - - [{a.scope}] {a.message} + + {alerts !== null ? ( + loadError && alerts.length === 0 ? ( +

+ {loadError} +

+ ) : alerts.length === 0 ? ( +
+ +

暂无告警

- ))} -
- )} + ) : ( +
+ {loadError && ( +

+ {loadError};当前显示已收到的实时告警。 +

+ )} + {alerts.map((a) => ( +
+ {formatClock(a.time)} + + {a.level.toUpperCase()} + + [{a.scope}] {a.message} +
+ ))} +
+ ) + ) : null} + ); diff --git a/packages/webui/src/components/pages/processes-page.tsx b/packages/webui/src/components/pages/processes-page.tsx index bbc870ea..b983e88f 100644 --- a/packages/webui/src/components/pages/processes-page.tsx +++ b/packages/webui/src/components/pages/processes-page.tsx @@ -6,6 +6,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com import { Badge } from '@/components/ui/badge'; import { ConfirmDialog } from '@/components/confirm-dialog'; import { ProcessProbeDialog } from '@/components/process-probe-dialog'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { cn } from '@/lib/utils'; import type { HookProcessInfo } from '@/types'; import { useAppState } from '@/contexts/AppStateContext'; @@ -48,7 +49,7 @@ function processBadgeVariant(status: HookProcessInfo['status']) { * regardless of which page is mounted. */ export function ProcessesPage() { - const { processList, processOps, refreshProcesses } = useAppState(); + const { processList, processOps, refreshProcesses, resources } = useAppState(); const { statusOf, banner: processActionStatus, load, unload, refresh } = processOps; const { pages, setPages } = useLayout(); const off = useTheme().appearance.disableMotion; @@ -95,7 +96,12 @@ export function ProcessesPage() { })}
)} -
@@ -111,129 +117,154 @@ export function ProcessesPage() { {processActionStatus}
)} - {processList.length === 0 ? ( -
- -

未检测到可加载 QQ 主进程

-

请确认 QQ 已启动后点击右上角刷新

-
- ) : ( -
- {sorted.map((proc, idx) => { - const op = statusOf(proc.pid); - const loading = op === 'load' || proc.status === 'loading'; - const unloading = op === 'unload'; - const refreshing = op === 'refresh'; - const busy = op != null || proc.status === 'loading'; - const isOnline = proc.status === 'online'; - const canUnload = proc.injected; - // Refresh is meaningful whenever a hook may exist (so the user - // can re-check the pipe and trigger a reconnect on demand). - const showRefresh = proc.injected || proc.status === 'connecting' || proc.status === 'disconnected'; - return ( - - {/* icon + info stay horizontal; on phones the actions drop to - a second row so name / PID / path get the full width - instead of collapsing to "Q..". */} -
-
- {isOnline ? ( - - ) : proc.status === 'error' ? ( - - ) : ( - - )} -
-
-
- {proc.name || 'QQ.exe'} - - {processStatusLabel[proc.status]} - -
-
- PID {proc.pid} - {proc.uin && proc.uin !== '0' ? ` · UIN ${proc.uin}` : ''} -
- {proc.path && ( -
- {proc.path} -
- )} - {proc.error && ( -
- {proc.error} -
- )} -
-
-
- - {showRefresh && ( - - )} - -
-
- ); - })} + {resources.processList.error && processList.length > 0 && ( +
+ {resources.processList.error};当前显示上次成功读取的进程状态。
)} + + {resources.processList.ready ? ( + resources.processList.error && processList.length === 0 ? ( +
+ +

{resources.processList.error}

+ +
+ ) : processList.length === 0 ? ( +
+ +

未检测到可加载 QQ 主进程

+

请确认 QQ 已启动后点击右上角刷新

+
+ ) : ( +
+ {sorted.map((proc, idx) => { + const op = statusOf(proc.pid); + const loading = op === 'load' || proc.status === 'loading'; + const unloading = op === 'unload'; + const refreshing = op === 'refresh'; + const busy = op != null || proc.status === 'loading'; + const isOnline = proc.status === 'online'; + const canUnload = proc.injected; + // Refresh is meaningful whenever a hook may exist (so the user + // can re-check the pipe and trigger a reconnect on demand). + const showRefresh = proc.injected || proc.status === 'connecting' || proc.status === 'disconnected'; + return ( + + {/* icon + info stay horizontal; on phones the actions drop to + a second row so name / PID / path get the full width + instead of collapsing to "Q..". */} +
+
+ {isOnline ? ( + + ) : proc.status === 'error' ? ( + + ) : ( + + )} +
+
+
+ {proc.name || 'QQ.exe'} + + {processStatusLabel[proc.status]} + +
+
+ PID {proc.pid} + {proc.uin && proc.uin !== '0' ? ` · UIN ${proc.uin}` : ''} +
+ {proc.path && ( +
+ {proc.path} +
+ )} + {proc.error && ( +
+ {proc.error} +
+ )} +
+
+
+ + {showRefresh && ( + + )} + +
+
+ ); + })} +
+ ) + ) : null} +
diff --git a/packages/webui/src/components/pages/settings-page.tsx b/packages/webui/src/components/pages/settings-page.tsx index 82dac2eb..f3dda514 100644 --- a/packages/webui/src/components/pages/settings-page.tsx +++ b/packages/webui/src/components/pages/settings-page.tsx @@ -38,6 +38,7 @@ import { NAV_ITEMS } from '@/components/layout/sidebar'; import { TOPBAR_CATALOGUE } from '@/components/layout/top-bar'; import { ChangePasswordDialog } from '@/components/change-password-dialog'; import { ConfirmDialog } from '@/components/confirm-dialog'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { useApi } from '@/lib/api'; import { useAppState } from '@/contexts/AppStateContext'; import { cn } from '@/lib/utils'; @@ -739,6 +740,7 @@ function FontField({ const listId = useId(); const [fonts, setFonts] = useState(null); const [loading, setLoading] = useState(false); + const [fontLoadError, setFontLoadError] = useState(null); const canQuery = typeof (window as FontQueryWindow).queryLocalFonts === 'function'; const isCustom = value === FONT_CUSTOM_ID; @@ -747,16 +749,17 @@ function FontField({ { value: FONT_CUSTOM_ID, label: '自定义' }, ]; - // Lazily enumerate local fonts the first time the field is focused. A denied - // permission (or any failure) just leaves the plain text box — no error UI. + // Lazily enumerate local fonts the first time the field is focused. const loadFonts = async () => { if (fonts !== null || loading || !canQuery) return; setLoading(true); + setFontLoadError(null); try { const arr = await (window as FontQueryWindow).queryLocalFonts!(); setFonts(Array.from(new Set(arr.map((f) => f.family))).sort((x, y) => x.localeCompare(y))); - } catch { - setFonts([]); + } catch (error) { + console.error('Failed to enumerate local fonts', error); + setFontLoadError('无法读取本机字体,请检查浏览器权限后重试。'); } finally { setLoading(false); } @@ -784,11 +787,32 @@ function FontField({ {fonts.map((f) =>
)}
@@ -1250,7 +1274,7 @@ function assetHint(latest: string, platform?: string, arch?: string): string | n // Advisory software update, shown as a grouped list. Read-only: links to the // GitHub release; SnowLuma never downloads or applies anything itself. function UpdateGroup() { - const { updateInfo, refreshUpdate, systemInfo } = useAppState(); + const { updateInfo, refreshUpdate, systemInfo, resources } = useAppState(); const { runAction } = useActionFeedback(); const [checking, setChecking] = useState(false); @@ -1286,7 +1310,8 @@ function UpdateGroup() { const disabledCheck = updateInfo?.error === 'disabled'; let status: ReactNode; - if (!updateInfo) status = 正在检查…; + if (!updateInfo && resources.updateInfo.error) status = 无法检查; + else if (!updateInfo) status = null; else if (disabledCheck) status = 检查已关闭; else if (updateInfo.error) status = 无法检查; else if (updateInfo.hasUpdate && updateInfo.latest) status = 发现新版本; @@ -1337,7 +1362,17 @@ function UpdateGroup() {
- {status} + + {resources.updateInfo.ready ? status : null} + {!disabledCheck && ( -
+ + {!loading && (loadFailed || !config) ? ( +
+ +

加载全局配置失败

+ +
+ ) : null} +
); } @@ -128,101 +133,110 @@ export function GlobalConfigPanel() { commit({ ...config, rkey: { fallbackServers: next } }, false); return ( -
- {/* rkey fallback servers */} -
-
- -

+ +

+ {/* rkey fallback servers */} +
+
+ +

图片 / 文件下载链接需要服务器签发的 rkey。SnowLuma 默认走内核获取; 当内核在你的环境下持续取不到时,会按顺序向这里配置的 HTTP 端点回退。 - 默认留空=关闭,不配置就不会联系任何第三方。 + 默认留空=关闭,不配置就不会联系任何第三方。 建议填你自建的端点。 -

-
- -
-
- - +

- {servers.length === 0 ? ( -

+

+
+ + +
+ + {servers.length === 0 ? ( +

未配置回退服务器(rkey 回退已关闭) -

- ) : ( -
- {servers.map((url, i) => { - const invalid = url.trim().length > 0 && !isHttpUrl(url.trim()); - return ( -
- setServers(servers.map((s, idx) => (idx === i ? e.target.value : s)))} - /> - -
- ); - })} -

+

+ ) : ( +
+ {servers.map((url, i) => { + const invalid = url.trim().length > 0 && !isHttpUrl(url.trim()); + return ( +
+ setServers(servers.map((s, idx) => (idx === i ? e.target.value : s)))} + /> + +
+ ); + })} +

端点需返回 {'{ group_rkey, private_rkey, expired_time }'} (兼容 NapCat rkey 服务格式)。非 http(s) 链接会被忽略。 -

-
- )} -
-
- - {/* music sign URL */} -
-
- -

音乐分享卡片的签名服务,对所有账号统一生效。留空则使用内置默认服务。

-
-
- - 0 && !isHttpUrl(config.musicSignUrl.trim())} - className={cn( - 'font-mono text-xs', - config.musicSignUrl.trim().length > 0 && !isHttpUrl(config.musicSignUrl.trim()) - && 'border-destructive focus-visible:ring-destructive', +

+
)} - onChange={(e) => commit({ ...config, musicSignUrl: e.target.value })} - /> -

- 内置默认:{MUSIC_SIGN_DEFAULT} -

+
-
- {msg &&

{msg.text}

} -
+ {/* music sign URL */} +
+
+ +

音乐分享卡片的签名服务,对所有账号统一生效。留空则使用内置默认服务。

+
+
+ + 0 && !isHttpUrl(config.musicSignUrl.trim())} + className={cn( + 'font-mono text-xs', + config.musicSignUrl.trim().length > 0 && !isHttpUrl(config.musicSignUrl.trim()) + && 'border-destructive focus-visible:ring-destructive', + )} + onChange={(e) => commit({ ...config, musicSignUrl: e.target.value })} + /> +

+ 内置默认:{MUSIC_SIGN_DEFAULT} +

+
+
+ + {msg &&

{msg.text}

} +
+ ); } diff --git a/packages/webui/src/components/settings/notifications-panel.tsx b/packages/webui/src/components/settings/notifications-panel.tsx index 18c03679..688d1ac3 100644 --- a/packages/webui/src/components/settings/notifications-panel.tsx +++ b/packages/webui/src/components/settings/notifications-panel.tsx @@ -2,11 +2,12 @@ // info-only cards (name / url / template + an inline enable toggle); creating // and editing always go through a dialog. All changes auto-save (debounced), // like the per-account config page — no explicit save button. -import { useEffect, useRef, useState } from 'react'; +import { useCallback, useEffect, useRef, useState } from 'react'; import { motion } from 'motion/react'; import { Bell, Loader2, Pencil, Plus, Send, Trash2 } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { ToggleSwitch } from '@/components/ui/toggle-switch'; @@ -48,23 +49,22 @@ export function NotificationsPanel() { const saveTimer = useRef(null); const saveGen = useRef(0); - useEffect(() => { - let cancelled = false; - void (async () => { - try { - const cfg = await api.notifications.getConfig(); - if (!cancelled) setConfig(cfg); - } catch { - if (!cancelled) setMsg({ kind: 'err', text: '加载通知配置失败' }); - } finally { - if (!cancelled) setLoading(false); - } - })(); - return () => { - cancelled = true; - }; + const load = useCallback(async () => { + setLoading(true); + try { + setConfig(await api.notifications.getConfig()); + } catch (error) { + console.error('load notifications config failed', error); + setMsg({ kind: 'err', text: '加载通知配置失败' }); + } finally { + setLoading(false); + } }, [api, setMsg]); + useEffect(() => { + void load(); + }, [load]); + useEffect( () => () => { if (saveTimer.current) clearTimeout(saveTimer.current); @@ -111,9 +111,23 @@ export function NotificationsPanel() { if (loading || !config) { return ( -
- 加载中… -
+ + {!loading && !config ? ( +
+ {msg?.text ?? '加载通知配置失败'} + +
+ ) : null} +
); } @@ -172,89 +186,98 @@ export function NotificationsPanel() { }; return ( -
- {/* Global settings */} -
-
- -

+ +

+ {/* Global settings */} +
+
+ +

账号上线 / 下线时向启用的渠道 POST 一条通知(机械转发,仅去抖防刷屏)。渠道在此全局定义,每个账号在其「配置」页勾选启用哪些。 -

-
-
- - { - const n = Math.trunc(Number(e.target.value)); - commit({ ...config, debounceSeconds: Number.isFinite(n) ? Math.min(3600, Math.max(0, n)) : 0 }); - }} - /> -

+

+
+
+ + { + const n = Math.trunc(Number(e.target.value)); + commit({ ...config, debounceSeconds: Number.isFinite(n) ? Math.min(3600, Math.max(0, n)) : 0 }); + }} + /> +

下线后在该秒数内自愈则不发;超时才发「下线」,恢复时再发「上线」。0 = 立即发、不去抖。 -

+

+
-
- {/* Channels */} -
-
-

通知渠道

- {channels.length > 0 && ( - + {/* Channels */} +
+
+

通知渠道

+ {channels.length > 0 && ( + + )} +
+ + {channels.length === 0 ? ( +
+ +

还没有通知渠道

+ +
+ ) : ( +
+ {channels.map((ch, i) => ( + setChannels( + channels.map((c, idx) => (idx === i ? { ...c, enabled: v } : c)), + { title: '正在更新通知渠道', successTitle: '通知渠道已更新' }, + )} + onTest={() => void test(ch.id)} + onEdit={() => openEdit(i)} + onDelete={() => setChannels( + channels.filter((_, idx) => idx !== i), + { title: '正在删除通知渠道', successTitle: '通知渠道已删除' }, + )} + /> + ))} +
)}
- {channels.length === 0 ? ( -
- -

还没有通知渠道

- -
- ) : ( -
- {channels.map((ch, i) => ( - setChannels( - channels.map((c, idx) => (idx === i ? { ...c, enabled: v } : c)), - { title: '正在更新通知渠道', successTitle: '通知渠道已更新' }, - )} - onTest={() => void test(ch.id)} - onEdit={() => openEdit(i)} - onDelete={() => setChannels( - channels.filter((_, idx) => idx !== i), - { title: '正在删除通知渠道', successTitle: '通知渠道已删除' }, - )} - /> - ))} -
+ {msg &&

{msg.text}

} + + {dialog.open && ( + !open && setDialog((d) => ({ ...d, open: false }))} + isEdit={dialog.index != null} + initial={dialog.seed} + otherIds={otherIds(dialog.index)} + onSubmit={submitChannel} + /> )}
- - {msg &&

{msg.text}

} - - {dialog.open && ( - !open && setDialog((d) => ({ ...d, open: false }))} - isEdit={dialog.index != null} - initial={dialog.seed} - otherIds={otherIds(dialog.index)} - onSubmit={submitChannel} - /> - )} -
+ ); } diff --git a/packages/webui/src/components/settings/storage-panel.tsx b/packages/webui/src/components/settings/storage-panel.tsx index 0db53334..7f75cc85 100644 --- a/packages/webui/src/components/settings/storage-panel.tsx +++ b/packages/webui/src/components/settings/storage-panel.tsx @@ -28,6 +28,7 @@ import { Label } from '@/components/ui/label'; import { Progress } from '@/components/ui/progress'; import { ToggleSwitch } from '@/components/ui/toggle-switch'; import { ConfirmDialog } from '@/components/confirm-dialog'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { useActionFeedback } from '@/contexts/ActionFeedbackContext'; import { useFlashMessage } from '@/hooks/use-flash-message'; import { useApi } from '@/lib/api'; @@ -107,12 +108,16 @@ export function StoragePanel() { }; const load = async (showSpinner = false): Promise => { - if (showSpinner) setRefreshing(true); + if (showSpinner) { + if (data === null) setLoading(true); + else setRefreshing(true); + } try { const overview = await api.storage.get(); applyOverview(overview); return true; } catch (error) { + console.error('load storage overview failed', error); setMsg({ kind: 'err', text: error instanceof Error ? error.message : '加载存储信息失败', @@ -222,26 +227,28 @@ export function StoragePanel() { } }; - if (loading) { + if (loading || !data) { return ( -
- - 加载存储信息… -
- ); - } - - if (!data) { - return ( - - -

存储信息暂时不可用。

- -
-
+ + {!loading && !data ? ( + + +

存储信息暂时不可用。

+ +
+
+ ) : null} +
); } @@ -259,310 +266,319 @@ export function StoragePanel() { ) as Record; return ( -
- {msg && ( -
- {msg.text} -
- )} - - - -
- - - 存储概览 - - - 只统计 SnowLuma 管理的日志、账号数据库和文件传输临时数据。 - -
- -
- -
- - - - -
- -
-
-
-

日志容量

-

- {formatBytes(snapshot.logs.totalBytes)} / {formatBytes(snapshot.logs.maxTotalBytes)} -

-
- - {logPresentation.label} - -
- -
- {snapshot.logs.fileCount} 个文件 - {snapshot.logs.activeFileCount} 个活动文件 - 丢弃 {snapshot.logs.droppedLines} 行磁盘日志 -
- {snapshot.logs.lastError && ( -
- - {snapshot.logs.lastError} -
+ +
+ {msg && ( +
+ {msg.text}
+ )} - {data.lastCleanup && } - - - - - - - - 日志策略 - - - 总量上限始终生效;保留天数设为 0 时仅按总量淘汰。保存后立即应用。 - - - -
-
- - setMaxTotalMb(event.target.value)} - disabled={isLocked('logMaxTotalMb') || saving || operation !== null} - /> -
-
- - setRetainDays(event.target.value)} - disabled={isLocked('logRetainDays') || saving || operation !== null} - /> -
-
- -
+ +
-

- 按账号额外写入日志 - -

-

- 开启后,同一条带账号上下文的日志还会写入账号子目录,占用会增加。 -

+ + + 存储概览 + + + 只统计 SnowLuma 管理的日志、账号数据库和文件传输临时数据。 +
- -
- -
-
-
-
- - - - - - 全局数据清理 - - - 日志清理会轮转活动文件;临时数据清理会自动跳过正在进行的上传和下载。 - - - - setPendingCleanup({ - request: { scope: 'logs' }, - title: '清理全部日志?', - description: 'SnowLuma 会先轮转活动日志,再删除旧日志,只保留新建的空文件。', - })} - /> - setPendingCleanup({ - request: { scope: 'temporary' }, - title: '清理非活动临时数据?', - description: '正在上传或下载的项目会保留,其余 SnowLuma 文件传输临时数据将被删除。', - })} - /> - - - - - - - - 账号数据 - - - 仅清理选中的数据库分类。账号必须离线,配置、凭据和聊天内容导出不在此页面提供。 - - - - {snapshot.accounts.length === 0 ? ( -
- 尚未发现账号数据库。 + + +
+ + + +
- ) : ( - snapshot.accounts.map((account) => ( - { - const info = CATEGORY_INFO[category]; - setPendingCleanup({ - request: { scope: 'account', category, uin: account.uin }, - title: `清理 ${account.nickname || account.uin} 的${info.label}?`, - description: `将删除账号 ${account.uin} 的${info.label}数据库及其边车文件,其他分类和配置不受影响。`, - }); - }} - /> - )) - )} - {snapshot.accounts.length > 0 && (
-
+
-

- - 全部账号 -

-

- {onlineCount > 0 - ? `${onlineCount} 个账号仍在线,全部账号清理暂不可用` - : '选择一个分类,并在弹窗中输入确认短语'} +

日志容量

+

+ {formatBytes(snapshot.logs.totalBytes)} / {formatBytes(snapshot.logs.maxTotalBytes)}

+ + {logPresentation.label} +
-
- {CATEGORIES.map((category) => ( -
+ + {data.lastCleanup && } + + + + + + + + 日志策略 + + + 总量上限始终生效;保留天数设为 0 时仅按总量淘汰。保存后立即应用。 + + + +
+
+ + setMaxTotalMb(event.target.value)} + disabled={isLocked('logMaxTotalMb') || saving || operation !== null} + /> +
+
+ + setRetainDays(event.target.value)} + disabled={isLocked('logRetainDays') || saving || operation !== null} + /> +
+
+ +
+
+

+ 按账号额外写入日志 + +

+

+ 开启后,同一条带账号上下文的日志还会写入账号子目录,占用会增加。 +

+
+ +
+ +
+ +
+
+
+ + + + + + 全局数据清理 + + + 日志清理会轮转活动文件;临时数据清理会自动跳过正在进行的上传和下载。 + + + + setPendingCleanup({ + request: { scope: 'logs' }, + title: '清理全部日志?', + description: 'SnowLuma 会先轮转活动日志,再删除旧日志,只保留新建的空文件。', + })} + /> + setPendingCleanup({ + request: { scope: 'temporary' }, + title: '清理非活动临时数据?', + description: '正在上传或下载的项目会保留,其余 SnowLuma 文件传输临时数据将被删除。', + })} + /> + + + + + + + + 账号数据 + + + 仅清理选中的数据库分类。账号必须离线,配置、凭据和聊天内容导出不在此页面提供。 + + + + {snapshot.accounts.length === 0 ? ( +
+ 尚未发现账号数据库。 +
+ ) : ( + snapshot.accounts.map((account) => ( + { + const info = CATEGORY_INFO[category]; + setPendingCleanup({ + request: { scope: 'account', category, uin: account.uin }, + title: `清理 ${account.nickname || account.uin} 的${info.label}?`, + description: `将删除账号 ${account.uin} 的${info.label}数据库及其边车文件,其他分类和配置不受影响。`, + }); + }} + /> + )) + )} + + {snapshot.accounts.length > 0 && ( +
+
+
+

+ + 全部账号 +

+

+ {onlineCount > 0 + ? `${onlineCount} 个账号仍在线,全部账号清理暂不可用` + : '选择一个分类,并在弹窗中输入确认短语'} +

+
+
+
+ {CATEGORIES.map((category) => ( + - ))} + } + className="justify-between" + > + 清理全部{CATEGORY_INFO[category].label} + + {formatBytes(allCategoryBytes[category])} + + + ))} +
-
- )} - - + )} + + - { - if (!open && operation === null) setPendingCleanup(null); - }} - title={pendingCleanup?.title ?? ''} - description={pendingCleanup?.description} - confirmText="确认清理" - destructive - onConfirm={async () => { - if (!pendingCleanup) return; - await runCleanup(pendingCleanup.request); - setPendingCleanup(null); - }} - /> + { + if (!open && operation === null) setPendingCleanup(null); + }} + title={pendingCleanup?.title ?? ''} + description={pendingCleanup?.description} + confirmText="确认清理" + destructive + onConfirm={async () => { + if (!pendingCleanup) return; + await runCleanup(pendingCleanup.request); + setPendingCleanup(null); + }} + /> - { - if (!open && operation === null) setAllAccountsCategory(null); - }} - onConfirm={async (category) => { - await runCleanup({ - scope: 'allAccounts', - category, - confirmation: ALL_ACCOUNTS_CONFIRMATION, - }); - setAllAccountsCategory(null); - }} - /> -
+ { + if (!open && operation === null) setAllAccountsCategory(null); + }} + onConfirm={async (category) => { + await runCleanup({ + scope: 'allAccounts', + category, + confirmation: ALL_ACCOUNTS_CONFIRMATION, + }); + setAllAccountsCategory(null); + }} + /> +
+ ); } diff --git a/packages/webui/src/components/settings/system-panel.tsx b/packages/webui/src/components/settings/system-panel.tsx index 2eedf952..c93adbbc 100644 --- a/packages/webui/src/components/settings/system-panel.tsx +++ b/packages/webui/src/components/settings/system-panel.tsx @@ -9,6 +9,7 @@ import { motion } from 'motion/react'; import { AlertTriangle, Database, Download, Loader2, Lock, Pencil, Save, ShieldCheck, Trash2, Upload } from 'lucide-react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; +import { SkeletonSwap } from '@/components/interior/skeleton-swap'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; @@ -57,7 +58,8 @@ export function SystemPanel() { setTrustProxy(res.settings.trustProxy); setTlsEnabled(res.settings.tlsEnabled); return true; - } catch { + } catch (error) { + console.error('load system settings failed', error); setMsg({ kind: 'err', text: '加载系统设置失败' }); return false; } finally { @@ -211,8 +213,33 @@ export function SystemPanel() { } }; - if (loading) { - return
加载中…
; + if (loading || !data) { + return ( + + {!loading && !data ? ( +
+ {msg?.text ?? '加载系统设置失败'} + +
+ ) : null} +
+ ); } const EnvBadge = ({ field }: { field: string }) => @@ -221,190 +248,199 @@ export function SystemPanel() { : null; return ( - - {/* restart-to-apply notice */} -
- - 监听相关设置(端口 / 绑定地址 / HTTPS)属服务级配置,保存后需重启 SnowLuma 才生效;本机无自动重启。 -
+ + + {/* restart-to-apply notice */} +
+ + 监听相关设置(端口 / 绑定地址 / HTTPS)属服务级配置,保存后需重启 SnowLuma 才生效;本机无自动重启。 +
- {msg && ( -
{msg.text}
- )} + {msg && ( +
{msg.text}
+ )} - - - 服务监听 - WebUI 当前监听端口:{data?.listeningPort} - - -
- - setPort(e.target.value)} inputMode="numeric" placeholder="5099" /> -
-
- - -
-
- - setTrustProxy(e.target.value)} placeholder="留空=只信任 socket 对端;1=信任反代头" /> -

仅在 WebUI 位于受信任反向代理之后时才设为 1 / loopback / IP 列表。

-
-
- -
-
-
+ + + 服务监听 + WebUI 当前监听端口:{data?.listeningPort} + + +
+ + setPort(e.target.value)} inputMode="numeric" placeholder="5099" /> +
+
+ + +
+
+ + setTrustProxy(e.target.value)} placeholder="留空=只信任 socket 对端;1=信任反代头" /> +

仅在 WebUI 位于受信任反向代理之后时才设为 1 / loopback / IP 列表。

+
+
+ +
+
+
- - - - HTTPS / TLS - - - {data?.hasCert ? '已安装证书。' : '尚未安装证书。'} 启用 TLS 需先安装有效的证书与私钥(PEM)。 - - - -
- - -
+ + + + HTTPS / TLS + + + {data?.hasCert ? '已安装证书。' : '尚未安装证书。'} 启用 TLS 需先安装有效的证书与私钥(PEM)。 + + + +
+ + +
- {data?.hasCert && !editingCert ? ( + {data?.hasCert && !editingCert ? ( // Cert already installed — don't re-render the sensitive PEM. Show a // summary + actions; private key is never sent back to the client. -
-
- - 证书与私钥已安装(出于安全不回显,未改变)。 -
-
- - -
-
- ) : ( - <> -
- -