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:
DrSmoothl committed 2026-05-30 13:34:41 +08:00
1 parent 74b6fe97e5
commit 76c6ebc700
9 files changed
+768 -495

No files matched your search

@@ -68,40 +68,47 @@ export function ConfigPage() {
[pendingSwitchUin, qqList],
);
// Per-kind helpers (typed at the call site so the dialog's onSubmit
// payload is exactly the kind's adapter shape).
function updateKind<K extends NetworkKind>(kind: K, next: OneBotNetworks[K]): void {
// A discrete node mutation (create / edit / delete / enable-toggle) is
// persisted the moment it happens — clicking 保存 inside the editor dialog
// (or flipping the enable switch) IS the save. This removes the old
// two-step trap where editing a token in the dialog only marked the config
// "dirty" until you also pressed the top-right 保存, which silently cost
// many users their token edits. The general-settings tab keeps its explicit
// top-right save (it's a continuously-edited free-form surface).
function commitKind<K extends NetworkKind>(kind: K, nextList: OneBotNetworks[K]): void {
if (!config) return;
setConfig({ ...config, networks: { ...config.networks, [kind]: next } });
const next = { ...config, networks: { ...config.networks, [kind]: nextList } };
setConfig(next);
void save(next);
}
function handleCreate<K extends NetworkKind>(kind: K, item: OneBotNetworks[K][number]): void {
if (!config) return;
const list = config.networks[kind] as OneBotNetworks[K];
updateKind(kind, [...list, item] as OneBotNetworks[K]);
commitKind(kind, [...list, item] as OneBotNetworks[K]);
}
function handleEdit<K extends NetworkKind>(kind: K, index: number, item: OneBotNetworks[K][number]): void {
if (!config) return;
const list = config.networks[kind] as OneBotNetworks[K];
const next = list.map((it, i) => (i === index ? item : it)) as OneBotNetworks[K];
updateKind(kind, next);
commitKind(kind, list.map((it, i) => (i === index ? item : it)) as OneBotNetworks[K]);
}
function handleDelete<K extends NetworkKind>(kind: K, index: number): void {
if (!config) return;
const list = config.networks[kind] as OneBotNetworks[K];
const next = list.filter((_, i) => i !== index) as OneBotNetworks[K];
updateKind(kind, next);
commitKind(kind, list.filter((_, i) => i !== index) as OneBotNetworks[K]);
}
function handleToggleEnabled<K extends NetworkKind>(kind: K, index: number, enabled: boolean): void {
if (!config) return;
const list = config.networks[kind] as OneBotNetworks[K];
const next = list.map((it, i) =>
i === index ? ({ ...it, enabled: enabled ? undefined : false } as OneBotNetworks[K][number]) : it,
) as OneBotNetworks[K];
updateKind(kind, next);
commitKind(
kind,
list.map((it, i) =>
i === index ? ({ ...it, enabled: enabled ? undefined : false } as OneBotNetworks[K][number]) : it,
) as OneBotNetworks[K],
);
}
const openCreate = (kind: NetworkKind) => {