update:1.支持删除章节

This commit is contained in:
xiamuceer
2025-11-19 14:01:30 +08:00
parent 458df0029c
commit 4360b0cb8b
2 changed files with 56 additions and 3 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ docker-compose up -d
>
> 1. **`.env` 文件挂载**: `docker-compose.yml` 会自动将 `.env` 挂载到容器,确保文件存在
> 2. **数据库初始化**: `init_postgres.sql` 会在首次启动时自动执行,安装必要的PostgreSQL扩展
> 3. **自行构建**: 如需从源码构建,请先下载 embedding 模型文件([加群获取](https://linux.do/t/topic/1100112)
> 3. **自行构建**: 如需从源码构建,请先下载 embedding 模型文件([加群获取](frontend\public\qq.jpg)
### 使用 Docker Hub 镜像(推荐新手)
+55 -2
View File
@@ -1,6 +1,6 @@
import { useState, useEffect, useRef, useMemo } from 'react';
import { List, Button, Modal, Form, Input, Select, message, Empty, Space, Badge, Tag, Card, Tooltip, InputNumber, Progress, Alert, Radio, Descriptions, Collapse } from 'antd';
import { EditOutlined, FileTextOutlined, ThunderboltOutlined, LockOutlined, DownloadOutlined, SettingOutlined, FundOutlined, SyncOutlined, CheckCircleOutlined, CloseCircleOutlined, RocketOutlined, StopOutlined, InfoCircleOutlined, CaretRightOutlined } from '@ant-design/icons';
import { List, Button, Modal, Form, Input, Select, message, Empty, Space, Badge, Tag, Card, Tooltip, InputNumber, Progress, Alert, Radio, Descriptions, Collapse, Popconfirm } from 'antd';
import { EditOutlined, FileTextOutlined, ThunderboltOutlined, LockOutlined, DownloadOutlined, SettingOutlined, FundOutlined, SyncOutlined, CheckCircleOutlined, CloseCircleOutlined, RocketOutlined, StopOutlined, InfoCircleOutlined, CaretRightOutlined, DeleteOutlined } from '@ant-design/icons';
import { useStore } from '../store';
import { useChapterSync } from '../store/hooks';
import { projectApi, writingStyleApi } from '../services/api';
@@ -59,6 +59,7 @@ export default function Chapters() {
const {
refreshChapters,
updateChapter,
deleteChapter,
generateChapterContentStream
} = useChapterSync();
@@ -827,6 +828,26 @@ export default function Chapters() {
}
};
// 删除章节处理函数
const handleDeleteChapter = async (chapterId: string) => {
try {
await deleteChapter(chapterId);
// 刷新章节列表
await refreshChapters();
// 刷新项目信息以更新总字数统计
if (currentProject) {
const updatedProject = await projectApi.getProject(currentProject.id);
setCurrentProject(updatedProject);
}
message.success('章节删除成功');
} catch (error: any) {
message.error('删除章节失败:' + (error.message || '未知错误'));
}
};
return (
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
<div style={{
@@ -957,6 +978,22 @@ export default function Chapters() {
>
</Button>,
<Popconfirm
title="确定删除这个章节吗?"
description="删除后将无法恢复,章节内容和分析结果都将被删除。"
onConfirm={() => handleDeleteChapter(item.id)}
okText="确定删除"
cancelText="取消"
okButtonProps={{ danger: true }}
>
<Button
type="text"
danger
icon={<DeleteOutlined />}
>
</Button>
</Popconfirm>,
]}
>
<div style={{ width: '100%' }}>
@@ -1049,6 +1086,22 @@ export default function Chapters() {
size="small"
title="修改信息"
/>
<Popconfirm
title="确定删除?"
description="删除后无法恢复"
onConfirm={() => handleDeleteChapter(item.id)}
okText="删除"
cancelText="取消"
okButtonProps={{ danger: true }}
>
<Button
type="text"
danger
icon={<DeleteOutlined />}
size="small"
title="删除章节"
/>
</Popconfirm>
</Space>
)}
</div>