docs: 全文档合规检查与修正 - 代码示例规范/行数准确性/路径一致性/状态同步
This commit is contained in:
@@ -127,10 +127,10 @@ import { useTransition } from "react"
|
||||
import { toast } from "sonner"
|
||||
import type { ActionState } from "@/shared/types/action-state"
|
||||
|
||||
export function useActionWithToast<T>() {
|
||||
export function useActionWithToast<T>(): { isPending: boolean; execute: (action: () => Promise<ActionState<T>>) => Promise<void> } {
|
||||
const [isPending, startTransition] = useTransition()
|
||||
|
||||
const execute = async (action: () => Promise<ActionState<T>>) => {
|
||||
const execute = async (action: () => Promise<ActionState<T>>): Promise<void> => {
|
||||
startTransition(async () => {
|
||||
const result = await action()
|
||||
if (result.success) {
|
||||
@@ -362,7 +362,7 @@ import rehypeSanitize from "rehype-sanitize"
|
||||
#### 方案
|
||||
|
||||
```typescript
|
||||
export function formatDate(date: string | Date, locale = "zh-CN") {
|
||||
export function formatDate(date: string | Date, locale = "zh-CN"): string {
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
|
||||
Reference in New Issue
Block a user