feat(webui): customizable dashboard + nav layout (phase 3)
The "C" half — reorder + show/hide the overview cards and the sidebar nav,
persisted to config/ui.json's layout section.
- LayoutContext loads the layout (authed GET /api/ui) and persists edits via
the section-merge POST /api/ui {layout} (debounced). reconcileLayoutItems
keeps stored order/visibility, appends new catalogue entries (forward-compat),
and forces pinned items visible.
- Overview is refactored into a block registry (stats/connections/alerts/host/
sessions). A 「编辑布局」 mode (motion Reorder — zero new deps) edits both the
cards and the nav in place, with per-item show/hide and a reset; an all-hidden
dashboard shows an empty state with 恢复默认.
- Anti-self-lock: PINNED_NAV = ['/', '/settings'] can be reordered but never
hidden — the overview hosts the layout editor and settings hosts
account/appearance, so the user can never strand themselves.
- api.ui.save now takes Partial<UiConfig> (the section-merge contract).
A late initial GET can't clobber an in-flight edit (dirtyRef); a pending edit
flushes on unmount. Verified across 2 adversarial review rounds.
This commit is contained in:
6 files changed
+613
-225
No files matched your search
@@ -7,6 +7,7 @@ import { MainLayout } from '@/components/layout/main-layout';
|
||||
import { ConfirmDialog } from '@/components/confirm-dialog';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { AppStateProvider } from '@/contexts/AppStateContext';
|
||||
import { LayoutProvider } from '@/contexts/LayoutContext';
|
||||
import { useSession } from '@/contexts/SessionContext';
|
||||
import type { AccountConnections, HookProcessInfo, QQInfo, SystemInfo, UpdateInfo } from '@/types';
|
||||
|
||||
@@ -125,15 +126,17 @@ export function AppLayout() {
|
||||
onLogout: handleLogout,
|
||||
}}
|
||||
>
|
||||
<MainLayout status={session.status} onLogout={handleLogout}>
|
||||
{/* Routes use `lazyRouteComponent` (router/index.tsx) for
|
||||
code-splitting, which suspends until the chunk is fetched.
|
||||
The chrome (sidebar / top bar) stays mounted across this
|
||||
boundary so only the page surface flashes a skeleton. */}
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
</MainLayout>
|
||||
<LayoutProvider>
|
||||
<MainLayout status={session.status} onLogout={handleLogout}>
|
||||
{/* Routes use `lazyRouteComponent` (router/index.tsx) for
|
||||
code-splitting, which suspends until the chunk is fetched.
|
||||
The chrome (sidebar / top bar) stays mounted across this
|
||||
boundary so only the page surface flashes a skeleton. */}
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
</MainLayout>
|
||||
</LayoutProvider>
|
||||
|
||||
<ConfirmDialog
|
||||
open={!!unloadFailedAlert}
|
||||
|
||||
Reference in new issue
Block a user