美化前端
Change-Id: I46437caf832dd8f18358354f024724f7e31524cb
diff --git a/src/pages/Torrent/torrentUpload.tsx b/src/pages/Torrent/torrentUpload.tsx
index b5d45bc..434d65b 100644
--- a/src/pages/Torrent/torrentUpload.tsx
+++ b/src/pages/Torrent/torrentUpload.tsx
@@ -15,7 +15,9 @@
import{
getCategories,
addTorrent,
- uploadTorrentFile
+ uploadTorrentFile,
+ deleteTorrent,
+ getTracker,
} from '../../services/bt/index';
const { Option } = Select;
@@ -89,16 +91,41 @@
subheading: values.subheading || '',
remark: values.remark || '',
});
- if (!addRes?.id) {
+ if (!addRes?.data) {
throw new Error('种子信息添加失败');
}
// 2. 上传.torrent文件
- await uploadTorrentFile(fileList[0], addRes.id);
-
+ let upRes = await uploadTorrentFile(fileList[0], addRes.data);
+ console.log('上传结果:', upRes);
+ if (upRes.code == 500) {
+ throw new Error(upRes.msg);
+ await deleteTorrent( addRes.data);
+ }else{
message.success('种子上传成功');
form.resetFields();
setFileList([]);
setCustomTags([]);
+ // 获取并显示 trackerUrl
+ const trackerRes = await getTracker();
+ if (trackerRes.data) {
+ const trackerUrl = trackerRes.data;
+ Modal.info({
+ title: 'Tracker 服务器',
+ content: (
+ <div style={{ marginTop: 12, color: '#232946', wordBreak: 'break-all' }}>
+ {trackerUrl}
+ <br />
+ <span style={{ color: '#667eea', fontWeight: 500 }}>
+ torrentId={addRes.data}
+ </span>
+ </div>
+ ),
+ width: 480,
+ okText: '关闭',
+ });
+ }
+ }
+
} catch (err: any) {
message.error(err.message || '上传失败');
} finally {
@@ -270,7 +297,11 @@
}}
>
{categories.map((cat) => (
- <Option key={cat.id} value={cat.id}>
+ <Option
+ key={cat.id}
+ value={cat.id}
+ style={{ color: '#fff', background: '#232946' }}
+ >
{cat.name}
</Option>
))}
@@ -424,6 +455,41 @@
>
上传
</Button>
+ <Button
+ type="default"
+ block
+ style={{
+ marginTop: 16,
+ background: 'rgba(102,126,234,0.10)',
+ border: '1px solid #667eea',
+ color: '#bfcfff',
+ fontWeight: 500,
+ letterSpacing: 1,
+ }}
+ onClick={async () => {
+ try {
+ const res = await getTracker();
+ if (res.data) {
+ Modal.info({
+ title: 'Tracker 服务器',
+ content: (
+ <div style={{ marginTop: 12, color: '#232946' }}>
+ {res.data}
+ </div>
+ ),
+ width: 480,
+ okText: '关闭',
+ });
+ } else {
+ message.info('暂无可用的 Tracker 服务器');
+ }
+ } catch (err) {
+ message.error('获取 Tracker 服务器失败');
+ }
+ }}
+ >
+ 查看 Tracker 服务器
+ </Button>
</Form.Item>
</Form>
</div>