diff --git a/frontend/src/components/AssetPreview.tsx b/frontend/src/components/AssetPreview.tsx index 5686d7a..e983f78 100644 --- a/frontend/src/components/AssetPreview.tsx +++ b/frontend/src/components/AssetPreview.tsx @@ -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 ( -
- 暂无素材 -
- ) + return } return ( diff --git a/frontend/src/components/EmptyState.tsx b/frontend/src/components/EmptyState.tsx new file mode 100644 index 0000000..d21c457 --- /dev/null +++ b/frontend/src/components/EmptyState.tsx @@ -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 ( +
+ {icon} +

+ {title} +

+ {description && ( +

+ {description} +

+ )} + {action && ( + + )} +
+ ) +} diff --git a/frontend/src/pages/ProjectPage.tsx b/frontend/src/pages/ProjectPage.tsx index 0755997..70c21e6 100644 --- a/frontend/src/pages/ProjectPage.tsx +++ b/frontend/src/pages/ProjectPage.tsx @@ -1,10 +1,11 @@ import { useEffect, useState } from 'react' -import { Link, useParams } from 'react-router-dom' +import { Link, useNavigate, useParams } from 'react-router-dom' import { useProjectStore } from '../stores/project' import { getTasks } from '../api/project' import type { Task } from '../api/types' import StyleSelector from '../components/StyleSelector' import Skeleton from '../components/Skeleton' +import EmptyState from '../components/EmptyState' const STATUS_LABELS: Record = { pending: { label: '等待中', color: 'var(--text-muted)' }, @@ -15,6 +16,7 @@ const STATUS_LABELS: Record = { export default function ProjectPage() { const { projectId = 'proj-default' } = useParams() + const navigate = useNavigate() const { name, style, @@ -95,9 +97,11 @@ export default function ProjectPage() { {tasks.length === 0 ? ( -

- 暂无任务 -

+ navigate(`/projects/${projectId}/generate`) }} + /> ) : (