修改前端页面
Change-Id: I344849fc3dfca5725e0ef2a107e2c89a14fce8da
diff --git a/front/src/PublishPage.js b/front/src/PublishPage.js
index 52eb956..df03cae 100644
--- a/front/src/PublishPage.js
+++ b/front/src/PublishPage.js
@@ -31,7 +31,7 @@
const file = e.target.files[0];
if (file && file.name.split('.').pop() !== 'torrent') {
alert('仅能上传.torrent类型文件');
- e.target.value = null; // Clear the input
+ e.target.value = null;
} else {
setFormData({ ...formData, torrentFile: file });
}
@@ -39,25 +39,21 @@
const handleSubmit = async (e) => {
e.preventDefault();
- // 假设userid和tag可以从表单或用户信息中获取,这里用示例数据
- const userid = '550e8400-e29b-41d4-a716-446655440000';
- const tag = formData.type ? formData.type : '高清';
+ const match = document.cookie.match('(^|;)\\s*userId=([^;]+)');
+ const userId = match ? match[2] : null;
+
if (!formData.torrentFile) {
alert('请上传.torrent文件');
return;
}
const data = new FormData();
- data.append('userid', userid);
+ data.append('userid', userId);
data.append('title', formData.title);
data.append('tag', subType);
data.append('file', formData.torrentFile);
data.append('subtitle', formData.subtitle);
- // data.append('subtype', subType);
- // console.log(data.get('tag'));
try {
- // console.log(data.get('userid'));
- // console.log(data.get('title'));
const response = await fetch(`${API_BASE_URL}/api/save-torrent`, {
method: 'POST',
body: data,