feature:新增世界设定-编辑基础信息功能(移除首页编辑功能)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Card, Button, Empty, Modal, message, Spin, Row, Col, Statistic, Space, Tag, Progress, Typography, Badge, Alert, Upload, Checkbox, Divider, Switch, Dropdown, Form, Input, InputNumber } from 'antd';
|
||||
import { Card, Button, Empty, Modal, message, Spin, Row, Col, Statistic, Space, Tag, Progress, Typography, Badge, Alert, Upload, Checkbox, Divider, Switch, Dropdown } from 'antd';
|
||||
import { EditOutlined, DeleteOutlined, BookOutlined, RocketOutlined, CalendarOutlined, FileTextOutlined, TrophyOutlined, FireOutlined, SettingOutlined, InfoCircleOutlined, CloseOutlined, UploadOutlined, DownloadOutlined, ApiOutlined, MoreOutlined, BulbOutlined, LoadingOutlined, FileSearchOutlined } from '@ant-design/icons';
|
||||
import { projectApi } from '../services/api';
|
||||
import { useStore } from '../store';
|
||||
@@ -29,11 +29,6 @@ export default function ProjectList() {
|
||||
includeWritingStyles: true,
|
||||
includeGenerationHistory: true,
|
||||
});
|
||||
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||
const [editingProject, setEditingProject] = useState<any>(null);
|
||||
const [editForm] = Form.useForm();
|
||||
const [updating, setUpdating] = useState(false);
|
||||
|
||||
const { refreshProjects, deleteProject } = useProjectSync();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -78,45 +73,6 @@ export default function ProjectList() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleEditProject = (project: any) => {
|
||||
setEditingProject(project);
|
||||
editForm.setFieldsValue({
|
||||
description: project.description || '',
|
||||
target_words: project.target_words || 0,
|
||||
});
|
||||
setEditModalVisible(true);
|
||||
};
|
||||
|
||||
const handleCloseEditModal = () => {
|
||||
setEditModalVisible(false);
|
||||
setEditingProject(null);
|
||||
editForm.resetFields();
|
||||
};
|
||||
|
||||
const handleUpdateProject = async () => {
|
||||
try {
|
||||
const values = await editForm.validateFields();
|
||||
setUpdating(true);
|
||||
|
||||
await projectApi.updateProject(editingProject.id, {
|
||||
description: values.description,
|
||||
target_words: values.target_words,
|
||||
});
|
||||
|
||||
message.success('项目更新成功');
|
||||
handleCloseEditModal();
|
||||
await refreshProjects();
|
||||
} catch (error: any) {
|
||||
if (error.errorFields) {
|
||||
message.error('请检查表单填写');
|
||||
} else {
|
||||
message.error('更新失败,请重试');
|
||||
}
|
||||
} finally {
|
||||
setUpdating(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEnterProject = async (project: any) => {
|
||||
// 检查项目是否未完成生成(wizard_status为incomplete)
|
||||
if (project.wizard_status === 'incomplete') {
|
||||
@@ -1031,20 +987,6 @@ export default function ProjectList() {
|
||||
{formatDate(project.updated_at)}
|
||||
</Text>
|
||||
<Space size={4}>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
icon={<EditOutlined />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleEditProject(project);
|
||||
}}
|
||||
style={{
|
||||
borderRadius: 8,
|
||||
color: 'var(--color-primary)',
|
||||
transition: 'all 0.2s ease'
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
@@ -1353,65 +1295,6 @@ export default function ProjectList() {
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
{/* 编辑项目对话框 */}
|
||||
<Modal
|
||||
title={`编辑项目: ${editingProject?.title || ''}`}
|
||||
open={editModalVisible}
|
||||
onOk={handleUpdateProject}
|
||||
onCancel={handleCloseEditModal}
|
||||
confirmLoading={updating}
|
||||
okText="保存"
|
||||
cancelText="取消"
|
||||
width={window.innerWidth <= 768 ? '90%' : 600}
|
||||
centered
|
||||
styles={{
|
||||
body: {
|
||||
maxHeight: window.innerWidth <= 768 ? '60vh' : 'auto',
|
||||
overflowY: 'auto',
|
||||
padding: window.innerWidth <= 768 ? '16px' : '24px'
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Form
|
||||
form={editForm}
|
||||
layout="vertical"
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item
|
||||
label="项目简介"
|
||||
name="description"
|
||||
rules={[
|
||||
{ max: 1000, message: '简介不能超过1000字' }
|
||||
]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={4}
|
||||
placeholder="请输入项目简介(选填)"
|
||||
showCount
|
||||
maxLength={1000}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="目标字数"
|
||||
name="target_words"
|
||||
rules={[
|
||||
{ type: 'number', min: 0, message: '目标字数不能为负数' },
|
||||
{ type: 'number', max: 2147483647, message: '目标字数超出范围' }
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请输入目标字数(选填,最大21亿字)"
|
||||
min={0}
|
||||
max={2147483647}
|
||||
step={1000}
|
||||
addonAfter="字"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<ChangelogFloatingButton />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Card, Descriptions, Empty, Typography, Button, Modal, Form, Input, message, Flex } from 'antd';
|
||||
import { GlobalOutlined, EditOutlined, SyncOutlined } from '@ant-design/icons';
|
||||
import { Card, Descriptions, Empty, Typography, Button, Modal, Form, Input, message, Flex, InputNumber, Select } from 'antd';
|
||||
import { GlobalOutlined, EditOutlined, SyncOutlined, FormOutlined } from '@ant-design/icons';
|
||||
import { useState } from 'react';
|
||||
import { useStore } from '../store';
|
||||
import { cardStyles } from '../components/CardStyles';
|
||||
@@ -14,6 +14,9 @@ export default function WorldSetting() {
|
||||
const [isEditModalVisible, setIsEditModalVisible] = useState(false);
|
||||
const [editForm] = Form.useForm();
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isEditProjectModalVisible, setIsEditProjectModalVisible] = useState(false);
|
||||
const [editProjectForm] = Form.useForm();
|
||||
const [isSavingProject, setIsSavingProject] = useState(false);
|
||||
const [isRegenerating, setIsRegenerating] = useState(false);
|
||||
const [regenerateProgress, setRegenerateProgress] = useState(0);
|
||||
const [regenerateMessage, setRegenerateMessage] = useState('');
|
||||
@@ -198,6 +201,27 @@ export default function WorldSetting() {
|
||||
>
|
||||
<span className="button-text-mobile">AI重新生成</span>
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<FormOutlined />}
|
||||
onClick={() => {
|
||||
editProjectForm.setFieldsValue({
|
||||
title: currentProject.title || '',
|
||||
description: currentProject.description || '',
|
||||
theme: currentProject.theme || '',
|
||||
genre: currentProject.genre || '',
|
||||
narrative_perspective: currentProject.narrative_perspective || '',
|
||||
target_words: currentProject.target_words || 0,
|
||||
});
|
||||
setIsEditProjectModalVisible(true);
|
||||
}}
|
||||
style={{
|
||||
minWidth: 'fit-content',
|
||||
flex: '1 1 auto'
|
||||
}}
|
||||
>
|
||||
<span className="button-text-mobile">编辑基础信息</span>
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<EditOutlined />}
|
||||
@@ -432,6 +456,144 @@ export default function WorldSetting() {
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 编辑项目基础信息模态框 */}
|
||||
<Modal
|
||||
title="编辑项目基础信息"
|
||||
open={isEditProjectModalVisible}
|
||||
centered
|
||||
onCancel={() => {
|
||||
setIsEditProjectModalVisible(false);
|
||||
editProjectForm.resetFields();
|
||||
}}
|
||||
onOk={async () => {
|
||||
try {
|
||||
const values = await editProjectForm.validateFields();
|
||||
setIsSavingProject(true);
|
||||
|
||||
const updatedProject = await projectApi.updateProject(currentProject.id, {
|
||||
title: values.title,
|
||||
description: values.description,
|
||||
theme: values.theme,
|
||||
genre: values.genre,
|
||||
narrative_perspective: values.narrative_perspective,
|
||||
target_words: values.target_words,
|
||||
});
|
||||
|
||||
setCurrentProject(updatedProject);
|
||||
message.success('项目基础信息更新成功');
|
||||
setIsEditProjectModalVisible(false);
|
||||
editProjectForm.resetFields();
|
||||
} catch (error) {
|
||||
console.error('更新项目基础信息失败:', error);
|
||||
message.error('更新失败,请重试');
|
||||
} finally {
|
||||
setIsSavingProject(false);
|
||||
}
|
||||
}}
|
||||
confirmLoading={isSavingProject}
|
||||
width={800}
|
||||
okText="保存"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Form
|
||||
form={editProjectForm}
|
||||
layout="vertical"
|
||||
style={{ marginTop: 16 }}
|
||||
>
|
||||
<Form.Item
|
||||
label="小说名称"
|
||||
name="title"
|
||||
rules={[
|
||||
{ required: true, message: '请输入小说名称' },
|
||||
{ max: 200, message: '名称不能超过200字' }
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
placeholder="请输入小说名称"
|
||||
showCount
|
||||
maxLength={200}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="小说简介"
|
||||
name="description"
|
||||
rules={[
|
||||
{ max: 1000, message: '简介不能超过1000字' }
|
||||
]}
|
||||
>
|
||||
<TextArea
|
||||
rows={4}
|
||||
placeholder="请输入小说简介(选填)"
|
||||
showCount
|
||||
maxLength={1000}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="小说主题"
|
||||
name="theme"
|
||||
rules={[
|
||||
{ max: 500, message: '主题不能超过500字' }
|
||||
]}
|
||||
>
|
||||
<TextArea
|
||||
rows={3}
|
||||
placeholder="请输入小说主题(选填)"
|
||||
showCount
|
||||
maxLength={500}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="小说类型"
|
||||
name="genre"
|
||||
rules={[
|
||||
{ max: 100, message: '类型不能超过100字' }
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
placeholder="请输入小说类型,如:玄幻、都市、科幻等(选填)"
|
||||
showCount
|
||||
maxLength={100}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="叙事视角"
|
||||
name="narrative_perspective"
|
||||
>
|
||||
<Select
|
||||
placeholder="请选择叙事视角(选填)"
|
||||
allowClear
|
||||
options={[
|
||||
{ label: '第一人称', value: '第一人称' },
|
||||
{ label: '第三人称', value: '第三人称' },
|
||||
{ label: '全知视角', value: '全知视角' }
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="目标字数"
|
||||
name="target_words"
|
||||
rules={[
|
||||
{ type: 'number', min: 0, message: '目标字数不能为负数' },
|
||||
{ type: 'number', max: 2147483647, message: '目标字数超出范围' }
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请输入目标字数(选填,最大21亿字)"
|
||||
min={0}
|
||||
max={2147483647}
|
||||
step={1000}
|
||||
addonAfter="字"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* AI重新生成加载遮罩 */}
|
||||
<SSELoadingOverlay
|
||||
loading={isRegenerating}
|
||||
|
||||
Reference in New Issue
Block a user