feat(ux): 空状态组件,替换各页面空白提示

新增 EmptyState 组件,ProjectPage 暂无任务时显示带操作按钮的
友好提示,AssetPreview 暂无素材时显示引导文案。
This commit is contained in:
2026-05-24 21:23:02 +08:00
parent f063ec564e
commit aaf846a60d
3 changed files with 53 additions and 9 deletions
+2 -5
View File
@@ -1,4 +1,5 @@
import type { Asset } from '../api/types'
import EmptyState from './EmptyState'
interface AssetPreviewProps {
assets: Asset[]
@@ -6,11 +7,7 @@ interface AssetPreviewProps {
export default function AssetPreview({ assets }: AssetPreviewProps) {
if (assets.length === 0) {
return (
<div style={{ color: 'var(--text-muted)', textAlign: 'center', padding: 40 }}>
暂无素材
</div>
)
return <EmptyState title="暂无素材" description="生成完成后,素材将在这里展示" />
}
return (
+43
View File
@@ -0,0 +1,43 @@
interface EmptyStateProps {
icon?: string
title: string
description?: string
action?: {
label: string
onClick: () => void
}
}
export default function EmptyState({ icon = '📭', title, description, action }: EmptyStateProps) {
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: '48px 24px',
textAlign: 'center',
}}
>
<span style={{ fontSize: 48, marginBottom: 16, opacity: 0.6 }}>{icon}</span>
<h3 style={{ fontSize: 16, color: 'var(--text-secondary)', marginBottom: 8 }}>
{title}
</h3>
{description && (
<p style={{ fontSize: 13, color: 'var(--text-muted)', marginBottom: action ? 20 : 0 }}>
{description}
</p>
)}
{action && (
<button
className="btn-primary"
onClick={action.onClick}
style={{ padding: '8px 24px', fontSize: 13 }}
>
{action.label}
</button>
)}
</div>
)
}