From 71be3ae2e18779133df866a17c09b22bfd4c8fb4 Mon Sep 17 00:00:00 2001
From: DrSmoothl <1787882683@qq.com>
Date: Sat, 30 May 2026 16:56:34 +0800
Subject: [PATCH] feat(webui): split overview into a processes page +
mobile/ultrawide pass
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The homepage was doing double duty — monitoring + injection control. Split it:
- New /processes page ("进程注入", sidebar #2) owns the QQ-process control
surface (load / unload / refresh / probe-login + its dialogs). Overview is
now a read-only dashboard: stats, host metrics, online accounts, plus a
read-only injection-summary tile (online / loadable, links to /processes)
and a first-run CTA that points at /processes while nothing is online.
Route + AppPath + nav item wired; state/polling stay layout-owned.
Responsive + a11y pass:
- Mobile sidebar Sheet gets an sr-only title + description, fixing the Radix
"DialogContent requires a DialogTitle" accessibility error.
- Log rows stack on phones (meta line + full-width message) instead of a
~40px column that broke every few chars; time parses defensively so a
non-ISO value never renders "Invalid Date".
- Process cards stack on phones (info row + actions row) so name / PID / path
stop collapsing to "Q.."; the status badge no longer wraps.
- Config tab strip scrolls horizontally on phones instead of wrapping to
three rows; account strip defaults collapsed ≤lg; header buttons wrap.
- Dialogs keep a 1rem gutter on tiny screens via w-[calc(100vw-2rem)].
- Content widens to 1600px on ≥2xl; account/process grids gain a column at
2xl so >1700px screens aren't mostly empty gutter.
---
.../src/components/layout/main-layout.tsx | 9 +-
.../webui/src/components/layout/sidebar.tsx | 3 +-
.../src/components/pages/config-page.tsx | 12 +-
.../webui/src/components/pages/logs-page.tsx | 28 +-
.../src/components/pages/overview-page.tsx | 294 ++++--------------
.../src/components/pages/processes-page.tsx | 222 +++++++++++++
packages/webui/src/components/ui/dialog.tsx | 6 +-
packages/webui/src/components/ui/sheet.tsx | 27 +-
packages/webui/src/router/index.tsx | 13 +-
9 files changed, 369 insertions(+), 245 deletions(-)
create mode 100644 packages/webui/src/components/pages/processes-page.tsx
diff --git a/packages/webui/src/components/layout/main-layout.tsx b/packages/webui/src/components/layout/main-layout.tsx
index 6a39f70a..22e71261 100644
--- a/packages/webui/src/components/layout/main-layout.tsx
+++ b/packages/webui/src/components/layout/main-layout.tsx
@@ -1,7 +1,7 @@
import { useEffect, useState, type ReactNode } from 'react';
import { motion, AnimatePresence } from 'motion/react';
import { useRouterState } from '@tanstack/react-router';
-import { Sheet, SheetContent } from '@/components/ui/sheet';
+import { Sheet, SheetContent, SheetDescription, SheetTitle } from '@/components/ui/sheet';
import { ScrollArea } from '@/components/ui/scroll-area';
import { Sidebar } from '@/components/layout/sidebar';
import { TopBar } from '@/components/layout/top-bar';
@@ -44,6 +44,11 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) {
{isMobile && (
+ {/* Radix Dialog (the Sheet primitive) requires an accessible name +
+ description; the nav itself is the visible content, so these are
+ screen-reader-only. */}
+ 导航菜单
+ 切换 SnowLuma 控制台的页面。 setMobileOpen(false)} />
@@ -62,7 +67,7 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) {
-
+
('general');
- const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
+ // 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(
+ () => typeof window !== 'undefined' && window.matchMedia('(max-width: 1024px)').matches,
+ );
const [confirmSave, setConfirmSave] = useState(false);
// The edit dialog is modal and blocks every other click in the page,
// so `selectedUin` cannot change while it's open — no defensive close
@@ -244,7 +248,7 @@ function HeaderBar({ selectedUin, dirty, saveStatus, onSave, activeTab, onCreate
UIN {selectedUin}
-
+
{saveStatus && (
+
{ALL_TABS.map((key) => {
const label = key === 'general' ? '通用设置' : NETWORK_TABS[key].title;
const count = key === 'general' ? null : counts[key];
@@ -299,7 +303,7 @@ function TabStrip({ activeTab, onChange, counts }: TabStripProps) {
type="button"
onClick={() => onChange(key)}
className={cn(
- 'group relative inline-flex items-center gap-1.5 px-3 py-2 text-sm transition-colors cursor-pointer',
+ 'group relative inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap px-3 py-2 text-sm transition-colors cursor-pointer',
active ? 'text-foreground' : 'text-muted-foreground hover:text-foreground',
)}
>
diff --git a/packages/webui/src/components/pages/logs-page.tsx b/packages/webui/src/components/pages/logs-page.tsx
index 6201bc06..05dbe644 100644
--- a/packages/webui/src/components/pages/logs-page.tsx
+++ b/packages/webui/src/components/pages/logs-page.tsx
@@ -21,6 +21,13 @@ const levelClass: Record = {
const LEVELS: LogLevel[] = ['debug', 'info', 'success', 'warn', 'error'];
+/** Show a locale time when the backend sends an ISO timestamp (it does);
+ * fall back to the raw string otherwise so we never render "Invalid Date". */
+function formatTime(t: string): string {
+ const d = new Date(t);
+ return Number.isNaN(d.getTime()) ? t : d.toLocaleTimeString();
+}
+
export function LogsPage() {
const api = useApi();
const [logs, setLogs] = useState([]);
@@ -205,16 +212,19 @@ export function LogsPage() {
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.12 }}
- className="flex gap-2 whitespace-pre-wrap px-3 py-0.5 leading-5 hover:bg-accent/30"
+ className="flex flex-col gap-0.5 px-3 py-1 leading-5 hover:bg-accent/30 sm:flex-row sm:gap-2 sm:py-0.5"
>
-
- {new Date(log.time).toLocaleTimeString()}
-
-
- {log.level.toUpperCase()}
-
- [{log.scope}]
- {log.message}
+ {/* Meta drops to its own line on phones so the message gets
+ the full width instead of a ~40px column that breaks
+ every few characters. On sm+ it's the dense single row. */}
+
+ {processList.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..". */}
+