import { useEffect, useState } from 'react' import { Link, useParams } from 'react-router-dom' import { useProjectStore } from '../stores/project' import { useAuthStore } from '../stores/auth' import { getTasks } from '../api/project' import type { Task } from '../api/types' import StyleSelector from '../components/StyleSelector' const STATUS_LABELS: Record = { pending: { label: '等待中', color: 'var(--text-muted)' }, running: { label: '运行中', color: 'var(--warning)' }, completed: { label: '已完成', color: 'var(--success)' }, failed: { label: '失败', color: 'var(--error)' }, } export default function ProjectPage() { const { projectId = 'proj-default' } = useParams() const { user, logout } = useAuthStore() const { name, style, loading, loadProject, loadStyle, updateStyle, saveStyle, } = useProjectStore() const [tasks, setTasks] = useState([]) const [saving, setSaving] = useState(false) useEffect(() => { loadProject(projectId) loadStyle(projectId) getTasks(projectId).then(setTasks) }, [projectId, loadProject, loadStyle]) const handleSave = async () => { setSaving(true) try { await saveStyle() } finally { setSaving(false) } } return (
{/* 顶栏 */}

{loading ? '加载中...' : name}

{user?.username}
{/* 工程风格 */}

工程风格

{/* 任务列表 */}

历史任务

新建生成
{tasks.length === 0 ? (

暂无任务

) : ( {tasks.map(task => { const statusInfo = STATUS_LABELS[task.status] ?? STATUS_LABELS.pending return ( ) })}
提示词 类型 状态 创建时间 操作
{task.prompt} {task.assetType} {statusInfo.label} {new Date(task.createdAt).toLocaleString('zh-CN')} {task.status === 'completed' && ( 查看结果 )}
)}
) } const thStyle: React.CSSProperties = { textAlign: 'left', padding: '10px 12px', fontSize: 13, color: 'var(--text-secondary)', fontWeight: 600, } const tdStyle: React.CSSProperties = { padding: '10px 12px', fontSize: 13, }