修复种子评论区错误
Change-Id: Ifaf42c7ba9e71b9f394d7aceaa80fcc29d1d5767
diff --git a/src/pages/Torrent/torrentAudit.tsx b/src/pages/Torrent/torrentAudit.tsx
index 278a3cd..e90af3c 100644
--- a/src/pages/Torrent/torrentAudit.tsx
+++ b/src/pages/Torrent/torrentAudit.tsx
@@ -1,8 +1,9 @@
import React, { useEffect, useState } from 'react';
-import { useSearchParams, useNavigate } from 'react-router-dom';
+import { useParams,useSearchParams, useNavigate } from 'react-router-dom';
import { Card, Button, Spin, Tag, message, Input } from 'antd';
import { ArrowLeftOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons';
-import { getTorrentInfo,auditTorrent } from '../../services/bt/index';
+import { getTorrentInfo,auditTorrent,downloadTorrent } from '../../services/bt/index';
+
// 状态映射
const statusMap: Record<number, string> = {
@@ -14,8 +15,7 @@
};
const TorrentAudit: React.FC = () => {
- const [searchParams] = useSearchParams();
- const id = searchParams.get('id');
+ const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
const [loading, setLoading] = useState(true);
@@ -34,7 +34,20 @@
.then(res => setTorrent(res.data))
.finally(() => setLoading(false));
}, [id, navigate]);
-
+const handleDownload = async () => {
+ try {
+ const res = await downloadTorrent({ id: id! });
+ const blob = new Blob([res], { type: 'application/x-bittorrent' });
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `${torrent?.title || 'torrent'}.torrent`;
+ a.click();
+ window.URL.revokeObjectURL(url);
+ } catch {
+ message.error('下载失败');
+ }
+};
const handleAudit = async (status: 1 | 2) => {
if (status === 2 && !rejectReason.trim()) {
message.warning('请填写拒绝理由');
@@ -102,6 +115,16 @@
<span style={{ marginLeft: 24 }}>下载人数:{torrent.leechers}</span>
<span style={{ marginLeft: 24 }}>完成次数:{torrent.completed}</span>
</div>
+ <div style={{ marginBottom: 16 }}>
+ <Button
+ type="primary"
+ icon={<CheckOutlined />}
+ onClick={() => downloadTorrent(torrent.id)}
+ disabled={!torrent.infoHash}
+ >
+ 下载种子
+ </Button>
+ </div>
<div
style={{
background: '#f6f8fa',