增加私信后端和标签上传
Change-Id: I4d5fbb6a634649359eef53091f07912c6099caeb
diff --git a/react-ui/src/pages/Torrent/index.tsx b/react-ui/src/pages/Torrent/index.tsx
index 30b7ef3..552a53c 100644
--- a/react-ui/src/pages/Torrent/index.tsx
+++ b/react-ui/src/pages/Torrent/index.tsx
@@ -45,6 +45,9 @@
const [uploadFile, setUploadFile] = useState<File | null>(null); // State to store selected file
const [uploadForm] = Form.useForm(); // Form for upload modal
const [torrentTags, setTorrentTags] = useState<BtTorrentTag[]>([]); // 修改为数组类型来存储多个标签
+ const [tagModalVisible, setTagModalVisible] = useState(false);
+ const [currentTorrent, setCurrentTorrent] = useState<BtTorrent | null>(null);
+ const [tagForm] = Form.useForm();
// Columns for the ProTable (the table displaying torrents)
const columns: ProColumns<BtTorrent>[] = [
@@ -131,6 +134,11 @@
message.error('下载失败');
}
}}>下载</Button>,
+ <Button key="tags" type="link" onClick={() => {
+ setCurrentTorrent(record);
+ handleGetTags(record.torrentId!);
+ setTagModalVisible(true);
+ }}>设置标签</Button>,
],
},
@@ -330,25 +338,7 @@
<Button icon={<UploadOutlined />}>选择 .torrent 文件</Button>
</Upload>
</Form.Item>
- <Form.Item
- name="description"
- label="介绍"
- rules={[{ required: true, message: '请输入种子介绍' }]}
- >
- <Input.TextArea rows={4} placeholder="请输入种子文件的详细介绍" />
- </Form.Item>
- <Form.Item
- name="tags"
- label="标签"
- rules={[{ required: true, message: '请输入标签' }]}
- >
- <Select
- mode="tags"
- style={{ width: '100%' }}
- placeholder="请输入标签,按回车键确认"
- tokenSeparators={[',']}
- />
- </Form.Item>
+
</Form>
</Modal>
@@ -449,6 +439,54 @@
</>
)}
</Drawer>
+
+ {/* 设置标签的Modal */}
+ <Modal
+ title="设置标签"
+ open={tagModalVisible}
+ onCancel={() => {
+ setTagModalVisible(false);
+ tagForm.resetFields();
+ }}
+ onOk={async () => {
+ try {
+ const values = await tagForm.validateFields();
+ if (currentTorrent?.torrentId && values.tags) {
+ // 添加新标签
+ for (const tag of values.tags) {
+ await addBtTorrentTag({
+ torrentId: currentTorrent.torrentId,
+ tag: tag
+ });
+ }
+ message.success('标签设置成功');
+ setTagModalVisible(false);
+ tagForm.resetFields();
+ // 刷新标签列表
+ if (currentTorrent.torrentId === current?.torrentId) {
+ handleGetTags(currentTorrent.torrentId);
+ }
+ }
+ } catch (error) {
+ message.error('设置标签失败');
+ }
+ }}
+ >
+ <Form form={tagForm} layout="vertical">
+ <Form.Item
+ name="tags"
+ label="标签"
+ rules={[{ required: true, message: '请输入标签' }]}
+ >
+ <Select
+ mode="tags"
+ style={{ width: '100%' }}
+ placeholder="请输入标签,按回车键确认"
+ tokenSeparators={[',']}
+ />
+ </Form.Item>
+ </Form>
+ </Modal>
</Card>
</Content>
);