update:1.更新支持编辑章节概要内容
This commit is contained in:
@@ -2856,11 +2856,11 @@ async def update_chapter_expansion_plan(
|
|||||||
db: AsyncSession = Depends(get_db)
|
db: AsyncSession = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
更新章节的展开规划信息
|
更新章节的展开规划信息和情节概要
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chapter_id: 章节ID
|
chapter_id: 章节ID
|
||||||
expansion_plan: 规划信息更新数据
|
expansion_plan: 规划信息更新数据(包含summary和expansion_plan字段)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
更新后的章节规划信息
|
更新后的章节规划信息
|
||||||
@@ -2881,7 +2881,16 @@ async def update_chapter_expansion_plan(
|
|||||||
# 准备更新数据(排除None值)
|
# 准备更新数据(排除None值)
|
||||||
plan_data = expansion_plan.model_dump(exclude_unset=True, exclude_none=True)
|
plan_data = expansion_plan.model_dump(exclude_unset=True, exclude_none=True)
|
||||||
|
|
||||||
# 如果已有规划,合并更新;否则创建新规划
|
# 分离summary和expansion_plan数据
|
||||||
|
summary_value = plan_data.pop('summary', None)
|
||||||
|
|
||||||
|
# 更新summary字段(如果提供)
|
||||||
|
if summary_value is not None:
|
||||||
|
chapter.summary = summary_value
|
||||||
|
logger.info(f"更新章节概要: {chapter_id}")
|
||||||
|
|
||||||
|
# 更新expansion_plan字段(如果有其他字段)
|
||||||
|
if plan_data:
|
||||||
if chapter.expansion_plan:
|
if chapter.expansion_plan:
|
||||||
try:
|
try:
|
||||||
existing_plan = json.loads(chapter.expansion_plan)
|
existing_plan = json.loads(chapter.expansion_plan)
|
||||||
@@ -2904,6 +2913,7 @@ async def update_chapter_expansion_plan(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"id": chapter.id,
|
"id": chapter.id,
|
||||||
|
"summary": chapter.summary,
|
||||||
"expansion_plan": updated_plan,
|
"expansion_plan": updated_plan,
|
||||||
"message": "规划信息更新成功"
|
"message": "规划信息更新成功"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ class SceneData(BaseModel):
|
|||||||
|
|
||||||
class ExpansionPlanUpdate(BaseModel):
|
class ExpansionPlanUpdate(BaseModel):
|
||||||
"""章节规划更新模型"""
|
"""章节规划更新模型"""
|
||||||
|
summary: Optional[str] = Field(None, description="章节情节概要")
|
||||||
key_events: Optional[List[str]] = Field(None, description="关键事件列表")
|
key_events: Optional[List[str]] = Field(None, description="关键事件列表")
|
||||||
character_focus: Optional[List[str]] = Field(None, description="涉及角色列表")
|
character_focus: Optional[List[str]] = Field(None, description="涉及角色列表")
|
||||||
emotional_tone: Optional[str] = Field(None, description="情感基调")
|
emotional_tone: Optional[str] = Field(None, description="情感基调")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Modal, Form, Input, InputNumber, Select, Tag, Space, Button, message } from 'antd';
|
import { Modal, Form, Input, InputNumber, Select, Tag, Space, Button, message, Divider } from 'antd';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import type { ExpansionPlanData, Character } from '../types';
|
import type { ExpansionPlanData, Character } from '../types';
|
||||||
@@ -9,14 +9,16 @@ const { TextArea } = Input;
|
|||||||
interface ExpansionPlanEditorProps {
|
interface ExpansionPlanEditorProps {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
planData: ExpansionPlanData | null;
|
planData: ExpansionPlanData | null;
|
||||||
|
chapterSummary: string | null;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
onSave: (data: ExpansionPlanData) => Promise<void>;
|
onSave: (data: ExpansionPlanData & { summary?: string }) => Promise<void>;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ExpansionPlanEditor({
|
export default function ExpansionPlanEditor({
|
||||||
visible,
|
visible,
|
||||||
planData,
|
planData,
|
||||||
|
chapterSummary,
|
||||||
projectId,
|
projectId,
|
||||||
onSave,
|
onSave,
|
||||||
onCancel
|
onCancel
|
||||||
@@ -69,12 +71,14 @@ export default function ExpansionPlanEditor({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 当planData变化时更新状态
|
// 当planData或chapterSummary变化时更新状态
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (visible) {
|
||||||
if (planData) {
|
if (planData) {
|
||||||
setKeyEvents(planData.key_events || []);
|
setKeyEvents(planData.key_events || []);
|
||||||
setCharacters(planData.character_focus || []);
|
setCharacters(planData.character_focus || []);
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
|
summary: chapterSummary || '',
|
||||||
emotional_tone: planData.emotional_tone,
|
emotional_tone: planData.emotional_tone,
|
||||||
narrative_goal: planData.narrative_goal,
|
narrative_goal: planData.narrative_goal,
|
||||||
conflict_type: planData.conflict_type,
|
conflict_type: planData.conflict_type,
|
||||||
@@ -84,9 +88,12 @@ export default function ExpansionPlanEditor({
|
|||||||
// 重置状态
|
// 重置状态
|
||||||
setKeyEvents([]);
|
setKeyEvents([]);
|
||||||
setCharacters([]);
|
setCharacters([]);
|
||||||
form.resetFields();
|
form.setFieldsValue({
|
||||||
|
summary: chapterSummary || ''
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [planData, form, visible]);
|
}
|
||||||
|
}, [planData, chapterSummary, form, visible]);
|
||||||
|
|
||||||
const handleAddKeyEvent = () => {
|
const handleAddKeyEvent = () => {
|
||||||
if (keyEventInput.trim()) {
|
if (keyEventInput.trim()) {
|
||||||
@@ -120,7 +127,8 @@ export default function ExpansionPlanEditor({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedPlan: ExpansionPlanData = {
|
const updatedPlan: ExpansionPlanData & { summary?: string } = {
|
||||||
|
summary: values.summary,
|
||||||
key_events: keyEvents,
|
key_events: keyEvents,
|
||||||
character_focus: characters,
|
character_focus: characters,
|
||||||
emotional_tone: values.emotional_tone,
|
emotional_tone: values.emotional_tone,
|
||||||
@@ -173,6 +181,22 @@ export default function ExpansionPlanEditor({
|
|||||||
estimated_words: 3000
|
estimated_words: 3000
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* 情节概要 */}
|
||||||
|
<Form.Item
|
||||||
|
label="情节概要"
|
||||||
|
name="summary"
|
||||||
|
tooltip="简要描述本章的主要情节和故事走向"
|
||||||
|
>
|
||||||
|
<TextArea
|
||||||
|
rows={3}
|
||||||
|
placeholder="简要描述本章的主要情节,例如:主角遇到意外事件,开始了一段新的冒险..."
|
||||||
|
maxLength={500}
|
||||||
|
showCount
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Divider orientation="left">详细规划</Divider>
|
||||||
|
|
||||||
{/* 关键事件 */}
|
{/* 关键事件 */}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="关键事件"
|
label="关键事件"
|
||||||
|
|||||||
@@ -2045,6 +2045,7 @@ export default function Chapters() {
|
|||||||
<ExpansionPlanEditor
|
<ExpansionPlanEditor
|
||||||
visible={planEditorVisible}
|
visible={planEditorVisible}
|
||||||
planData={parsedPlanData}
|
planData={parsedPlanData}
|
||||||
|
chapterSummary={editingPlanChapter.summary || null}
|
||||||
projectId={currentProject.id}
|
projectId={currentProject.id}
|
||||||
onSave={handleSavePlan}
|
onSave={handleSavePlan}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user