“实现帖子与评论上传图片,删除评论,评论计数,管理员界面”

Change-Id: I33d5331e41de0411f2d6f1913f3a939db61f665d
diff --git a/src/api/torrent.js b/src/api/torrent.js
index 7118436..6c56fce 100644
--- a/src/api/torrent.js
+++ b/src/api/torrent.js
@@ -1,16 +1,23 @@
 // src/api/torrent.js

 import { api } from './auth'; // 复用已有的axios实例

 

-export const createTorrent = (torrentName, description, username, category, region, resolution, subtitle, filePath) => {

-  return api.post('/torrent', { 

-    torrentName, 

-    description,

-    username,

-    category,

-    region,

-    resolution,

-    subtitle,

-    filePath

+export const createTorrent = (torrentData, file) => {

+  const formData = new FormData();

+  const token = localStorage.getItem('token');

+

+  // 添加文件

+  if (file) {

+    formData.append('file', file);

+  }

+  // 通过这个方式就可以指定 ContentType 了

+  formData.append('body', JSON.stringify(torrentData))

+

+  console.log(formData);

+  return api.post('/torrent', formData, {

+    headers: {

+      'Content-Type': 'multipart/form-data',

+      'Authorization': `${token}`

+    },

   });

 };