docs: 全文档合规检查与修正 - 代码示例规范/行数准确性/路径一致性/状态同步

This commit is contained in:
SpecialX
2026-06-18 03:31:07 +08:00
parent 0423b2b984
commit 4d659ad9a1
18 changed files with 595 additions and 522 deletions

View File

@@ -203,12 +203,13 @@
```tsx
"use client"
import { useAriaLive } from "@/shared/hooks/use-aria-live"
function MyForm() {
function MyForm(): JSX.Element {
const { announce, liveRegion } = useAriaLive()
const handleSubmit = async () => {
const handleSubmit = async (): Promise<void> => {
const result = await submitAction()
if (result.success) {
announce("保存成功", { politeness: "polite" })
@@ -231,7 +232,7 @@ function MyForm() {
```tsx
import { useA11yId, describeInput } from "@/shared/lib/a11y"
function EmailField({ error }: { error?: string }) {
function EmailField({ error }: { error?: string }): JSX.Element {
const hintId = useA11yId("email-hint")
const errorId = useA11yId("email-error")
const { ariaDescribedBy, ariaInvalid } = describeInput(
@@ -263,7 +264,13 @@ function EmailField({ error }: { error?: string }) {
```tsx
import { FocusTrap } from "@/shared/components/a11y/focus-trap"
function CustomModal({ open, onClose, children }) {
interface CustomModalProps {
open: boolean
onClose: () => void
children: React.ReactNode
}
function CustomModal({ open, onClose, children }: CustomModalProps): JSX.Element {
return (
<FocusTrap active={open} restoreFocus>
<div role="dialog" aria-modal="true">