64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
'use client'
|
|
|
|
import { AlertCircle, Inbox } from 'lucide-react'
|
|
|
|
/** 统一的错误提示横幅 */
|
|
export function ErrorBanner({
|
|
message,
|
|
onDismiss,
|
|
}: {
|
|
message: string
|
|
onDismiss?: () => void
|
|
}) {
|
|
return (
|
|
<div className="rounded-md bg-destructive/10 border border-destructive/20 px-4 py-3 text-sm text-destructive flex items-center gap-2">
|
|
<AlertCircle className="h-4 w-4 shrink-0" />
|
|
<span className="flex-1">{message}</span>
|
|
{onDismiss && (
|
|
<button
|
|
onClick={onDismiss}
|
|
className="underline cursor-pointer shrink-0"
|
|
>
|
|
关闭
|
|
</button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** 统一的空状态占位 */
|
|
export function EmptyState({
|
|
message = '暂无数据',
|
|
}: {
|
|
message?: string
|
|
}) {
|
|
return (
|
|
<div className="flex h-64 flex-col items-center justify-center gap-2 text-muted-foreground">
|
|
<Inbox className="h-8 w-8" />
|
|
<span className="text-sm">{message}</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** 统一的加载失败提示 + 重试 */
|
|
export function ErrorRetry({
|
|
message = '请求失败,请重试',
|
|
onRetry,
|
|
}: {
|
|
message?: string
|
|
onRetry: () => void
|
|
}) {
|
|
return (
|
|
<div className="flex h-64 flex-col items-center justify-center gap-3 text-muted-foreground">
|
|
<AlertCircle className="h-8 w-8 text-destructive" />
|
|
<span className="text-sm">{message}</span>
|
|
<button
|
|
onClick={onRetry}
|
|
className="rounded-md bg-primary px-4 py-2 text-sm text-primary-foreground hover:bg-primary/90 transition-colors cursor-pointer"
|
|
>
|
|
重新加载
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|