feat: 前端界面优化

This commit is contained in:
npc0-hue
2026-07-20 21:03:52 +08:00
parent a0e69417db
commit 0c5e3d2c39
6 changed files with 213 additions and 85 deletions
@@ -22,7 +22,9 @@ describe("shared operation dialogs", () => {
expect(html).toContain('aria-labelledby=');
expect(html).toContain('aria-describedby=');
expect(html).toContain('aria-busy="true"');
expect(html).toContain("关闭确认停用");
expect(operationControlsSource).toContain('event.key === "Escape"');
expect(operationControlsSource).toContain('document.body.style.overflow = "hidden"');
expect(operationControlsSource).toContain("previousFocus?.focus()");
});
+11 -2
View File
@@ -32,7 +32,13 @@ export function ConfirmDialog({ open, title, description, confirmLabel, danger,
aria-busy={busy}
onClick={(event) => event.stopPropagation()}
>
<h2 id={titleId}>{title}</h2>
<div className="panel-header dialog-panel-header">
<h2 id={titleId}>{title}</h2>
<button type="button" className="theme-upload drawer-close" aria-label={`关闭${title}`} onClick={onCancel} disabled={busy}>
<X size={14} />
<span></span>
</button>
</div>
<p id={descriptionId}>{description}</p>
{children}
<div className="confirm-actions">
@@ -75,7 +81,7 @@ export function ManagementDialog({ open, title, description, wide, onClose, chil
aria-describedby={description ? descriptionId : undefined}
onClick={(event) => event.stopPropagation()}
>
<div className="panel-header">
<div className="panel-header dialog-panel-header">
<h2 id={titleId}>{title}</h2>
<button type="button" className="theme-upload drawer-close" aria-label={`关闭${title}`} onClick={onClose}>
<X size={14} />
@@ -109,8 +115,11 @@ function useDialogLifecycle(open: boolean, onClose: () => void, canClose: boolea
}
document.addEventListener("keydown", handleKeyDown);
const previousBodyOverflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
return () => {
document.removeEventListener("keydown", handleKeyDown);
document.body.style.overflow = previousBodyOverflow;
previousFocus?.focus();
};
}, [canClose, onClose, open]);