blob: 5e97433594a9fd3c370988e858ea2978282168ec [file] [log] [blame]
223010144ce05872025-06-08 22:33:28 +08001import React, { useMemo } from 'react';
2import { Layout, Steps, Card, Typography } from 'antd';
3import { FileTextOutlined, FileImageOutlined, SaveOutlined, SendOutlined } from '@ant-design/icons';
4import { BasicInfoStep, CoverUploadStep, VersionManagementStep, ConfirmPublishStep } from './CreatWorkComponents';
5import { useCreateWorkForm } from './hooks';
6
7
8const { Content } = Layout;
9const { Title, Paragraph } = Typography;
10
11const CreateWork: React.FC = () => {
12 const { currentStep, formData, handleUpdateFormData, handleNext, handlePrev, handlePublish } = useCreateWorkForm();
13
14 const steps = useMemo(() => [
15 { title: '基础信息', description: '填写作品基本信息', icon: <FileTextOutlined /> },
16 { title: '上传封面', description: '上传作品封面图片', icon: <FileImageOutlined /> },
17 { title: '版本管理', description: '添加作品版本和文件', icon: <SaveOutlined /> },
18 { title: '确认发布', description: '检查并发布作品', icon: <SendOutlined /> },
19 ], []);
20
21 const renderStepContent = useMemo(() => {
22 const commonProps = { data: formData, onUpdate: handleUpdateFormData, onNext: handleNext, onPrev: handlePrev };
23
24 switch (currentStep) {
25 case 0: return <BasicInfoStep {...commonProps} />;
26 case 1: return <CoverUploadStep {...commonProps} />;
27 case 2: return <VersionManagementStep {...commonProps} />;
28 case 3: return <ConfirmPublishStep {...commonProps} onPublish={handlePublish} />;
29 default: return null;
30 }
31 }, [currentStep, formData, handleUpdateFormData, handleNext, handlePrev, handlePublish]);
32
33 return (
34 <Layout style={{ minHeight: '100vh', backgroundColor: '#f5f5f5' }}>
35 <Content style={{ padding: '20px' }}>
36 <div style={{ maxWidth: 1000, margin: '0 auto' }}>
37 <Card style={{ marginBottom: 24 }}>
38 <Title level={2} style={{ marginBottom: 8 }}>创建新作品</Title>
39 <Paragraph type="secondary">通过以下步骤发布您的创意作品,与社区分享您的才华</Paragraph>
40 </Card>
41
42 <Card style={{ marginBottom: 24 }}>
43 <Steps current={currentStep} items={steps} />
44 </Card>
45
46 {renderStepContent}
47 </div>
48 </Content>
49 </Layout>
50 );
51};
52
53export default CreateWork;