feat(webui): settings tabs, password dialog, instant node save, error pages
Five WebUI changes: 1. Settings page rebuilt around mini tabs (外观 / 数据刷新 / 账号安全) instead of three stacked cards; content and behaviour unchanged. 2. "修改访问密码" now opens an independent ChangePasswordDialog modal rather than swapping the whole page for the forced-change screen. The form is extracted to a shared ChangePasswordForm used by both the modal and the forced full-screen ChangePasswordPage — behaviour identical. 3. Node config: creating / editing / deleting / enable-toggling an HTTP/WS endpoint now persists immediately — clicking 保存 in the editor dialog IS the save. Previously it only marked the config dirty until you also hit the top-right 保存, which silently cost many users their token edits. `save()` takes an explicit config so it persists the freshly computed value, not the stale closed-over state. The general-settings tab keeps its explicit top-right save. 4. Forced first-time change-password no longer renders an old-password field: it carries the password the user just logged in with. Browsers (Edge/Chrome) were autofilling that field on upgrade, so users thought the old password was pre-filled correctly and could never save. A returning already-authed session (no fresh login) still shows the field. 5. Added default error + 404 screens (status-screens.tsx), wired into the TanStack router via defaultErrorComponent / defaultNotFoundComponent.
This commit is contained in:
9 files changed
+768
-495
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { motion } from 'motion/react';
|
||||
import { AlertTriangle, Compass, Home, RotateCw } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
type Tone = 'primary' | 'destructive';
|
||||
|
||||
function StatusShell({
|
||||
tone,
|
||||
icon,
|
||||
code,
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
}: {
|
||||
tone: Tone;
|
||||
icon: ReactNode;
|
||||
code?: string;
|
||||
title: string;
|
||||
description: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex min-h-[60vh] w-full flex-col items-center justify-center px-4 text-center">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 16, scale: 0.98 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
transition={{ duration: 0.4, ease: [0.16, 1, 0.3, 1] }}
|
||||
className="flex w-full max-w-md flex-col items-center"
|
||||
>
|
||||
<div
|
||||
className={
|
||||
tone === 'destructive'
|
||||
? 'flex size-14 items-center justify-center rounded-2xl bg-destructive/10 ring-1 ring-destructive/20'
|
||||
: 'flex size-14 items-center justify-center rounded-2xl bg-primary/10 ring-1 ring-primary/20'
|
||||
}
|
||||
>
|
||||
{icon}
|
||||
</div>
|
||||
{code && (
|
||||
<span className="mt-4 font-mono text-4xl font-bold tracking-tight tabular-nums text-muted-foreground/60">
|
||||
{code}
|
||||
</span>
|
||||
)}
|
||||
<h1 className="mt-2 text-xl font-semibold tracking-tight">{title}</h1>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{description}</p>
|
||||
<div className="mt-6 flex flex-wrap items-center justify-center gap-2">{children}</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Rendered by the router for any unmatched path. */
|
||||
export function NotFoundPage() {
|
||||
return (
|
||||
<StatusShell
|
||||
tone="primary"
|
||||
icon={<Compass className="size-7 text-primary" strokeWidth={1.75} />}
|
||||
code="404"
|
||||
title="页面不存在"
|
||||
description="你访问的地址没有对应的页面,可能链接已失效或输入有误。"
|
||||
>
|
||||
<Button onClick={() => window.location.assign('/')}>
|
||||
<Home className="size-4" /> 返回首页
|
||||
</Button>
|
||||
</StatusShell>
|
||||
);
|
||||
}
|
||||
|
||||
/** Rendered by the router when a route component throws while rendering. */
|
||||
export function ErrorPage({ error, reset }: { error?: Error; reset?: () => void }) {
|
||||
const message = error?.message?.trim();
|
||||
return (
|
||||
<StatusShell
|
||||
tone="destructive"
|
||||
icon={<AlertTriangle className="size-7 text-destructive" strokeWidth={1.75} />}
|
||||
title="页面出错了"
|
||||
description="渲染该页面时发生了意外错误。可以重试,或返回首页继续操作。"
|
||||
>
|
||||
{reset && (
|
||||
<Button variant="outline" onClick={reset}>
|
||||
<RotateCw className="size-4" /> 重试
|
||||
</Button>
|
||||
)}
|
||||
<Button onClick={() => window.location.assign('/')}>
|
||||
<Home className="size-4" /> 返回首页
|
||||
</Button>
|
||||
{message && (
|
||||
<pre className="mt-3 max-h-32 w-full overflow-auto rounded-md border bg-muted/40 px-3 py-2 text-left text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap">
|
||||
{message}
|
||||
</pre>
|
||||
)}
|
||||
</StatusShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user