update:1.修复大纲展开功能bug,按顺序展开 2.优化大纲细化UI展示,大纲设置为卷 3.实现角色关系修改功能 4.优化提示词避免出现过多特殊符号 5.优化向导页面的AI生产进度页面和灵感模式保持统一,支持重试 6.优化项目生成过长中断添加自动恢复逻辑
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { Card, Table, Tag, Button, Space, message, Modal, Form, Select, Slider, Input, Tabs, AutoComplete } from 'antd';
|
||||
import { PlusOutlined, TeamOutlined, UserOutlined } from '@ant-design/icons';
|
||||
import { PlusOutlined, TeamOutlined, UserOutlined, EditOutlined } from '@ant-design/icons';
|
||||
import { useStore } from '../store';
|
||||
import axios from 'axios';
|
||||
|
||||
@@ -40,6 +40,8 @@ export default function Relationships() {
|
||||
const [characters, setCharacters] = useState<Character[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [isEditMode, setIsEditMode] = useState(false);
|
||||
const [editingRelationship, setEditingRelationship] = useState<Relationship | null>(null);
|
||||
const [form] = Form.useForm();
|
||||
const [isMobile, setIsMobile] = useState(window.innerWidth <= 768);
|
||||
const [pageSize, setPageSize] = useState(10);
|
||||
@@ -103,6 +105,49 @@ export default function Relationships() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditRelationship = (record: Relationship) => {
|
||||
setEditingRelationship(record);
|
||||
setIsEditMode(true);
|
||||
form.setFieldsValue({
|
||||
character_from_id: record.character_from_id,
|
||||
character_to_id: record.character_to_id,
|
||||
relationship_name: record.relationship_name,
|
||||
intimacy_level: record.intimacy_level,
|
||||
status: record.status,
|
||||
description: record.description,
|
||||
});
|
||||
setIsModalOpen(true);
|
||||
};
|
||||
|
||||
const handleUpdateRelationship = async (values: {
|
||||
character_from_id: string;
|
||||
character_to_id: string;
|
||||
relationship_name: string;
|
||||
intimacy_level: number;
|
||||
status: string;
|
||||
description?: string;
|
||||
}) => {
|
||||
if (!editingRelationship) return;
|
||||
|
||||
try {
|
||||
await axios.put(`/api/relationships/${editingRelationship.id}`, {
|
||||
relationship_name: values.relationship_name,
|
||||
intimacy_level: values.intimacy_level,
|
||||
status: values.status,
|
||||
description: values.description,
|
||||
});
|
||||
message.success('关系更新成功');
|
||||
setIsModalOpen(false);
|
||||
setIsEditMode(false);
|
||||
setEditingRelationship(null);
|
||||
form.resetFields();
|
||||
loadData();
|
||||
} catch (error) {
|
||||
message.error('更新关系失败');
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteRelationship = async (id: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
@@ -218,16 +263,26 @@ export default function Relationships() {
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: (_: unknown, record: Relationship) => (
|
||||
<Button
|
||||
type="link"
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => handleDeleteRelationship(record.id)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
<Space size="small">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => handleEditRelationship(record)}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => handleDeleteRelationship(record.id)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
width: 80,
|
||||
width: 140,
|
||||
fixed: isMobile ? ('right' as const) : undefined,
|
||||
},
|
||||
];
|
||||
@@ -345,10 +400,12 @@ export default function Relationships() {
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
title="添加关系"
|
||||
title={isEditMode ? '编辑关系' : '添加关系'}
|
||||
open={isModalOpen}
|
||||
onCancel={() => {
|
||||
setIsModalOpen(false);
|
||||
setIsEditMode(false);
|
||||
setEditingRelationship(null);
|
||||
form.resetFields();
|
||||
}}
|
||||
footer={null}
|
||||
@@ -360,7 +417,7 @@ export default function Relationships() {
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={handleCreateRelationship}
|
||||
onFinish={isEditMode ? handleUpdateRelationship : handleCreateRelationship}
|
||||
>
|
||||
<Form.Item
|
||||
name="character_from_id"
|
||||
@@ -370,6 +427,7 @@ export default function Relationships() {
|
||||
<Select
|
||||
placeholder="选择角色"
|
||||
showSearch
|
||||
disabled={isEditMode}
|
||||
filterOption={(input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
@@ -404,6 +462,7 @@ export default function Relationships() {
|
||||
<Select
|
||||
placeholder="选择角色"
|
||||
showSearch
|
||||
disabled={isEditMode}
|
||||
filterOption={(input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
@@ -450,9 +509,14 @@ export default function Relationships() {
|
||||
|
||||
<Form.Item>
|
||||
<Space style={{ width: '100%', justifyContent: 'flex-end' }}>
|
||||
<Button onClick={() => setIsModalOpen(false)}>取消</Button>
|
||||
<Button onClick={() => {
|
||||
setIsModalOpen(false);
|
||||
setIsEditMode(false);
|
||||
setEditingRelationship(null);
|
||||
form.resetFields();
|
||||
}}>取消</Button>
|
||||
<Button type="primary" htmlType="submit">
|
||||
创建
|
||||
{isEditMode ? '更新' : '创建'}
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
|
||||
Reference in New Issue
Block a user