Final push for project

Change-Id: I9103078156eca93df2482b9fe3854d9301bb98b3
diff --git a/frontend/my-app/src/pages/UploadTorrent.jsx b/frontend/my-app/src/pages/UploadTorrent.jsx
index 493cdce..465afda 100644
--- a/frontend/my-app/src/pages/UploadTorrent.jsx
+++ b/frontend/my-app/src/pages/UploadTorrent.jsx
@@ -4,43 +4,44 @@
   TextField, Button, Stack
 } from '@mui/material';
 import CloudUploadIcon from '@mui/icons-material/CloudUpload';
-// Assuming your base.css is in a relative path like src/styles/base/base.css
-// If your component is in src/components/Upload.js, this path would be ../styles/base/base.css
-// Adjust if your project structure is different.
-// For this example, I'll assume it's correctly linked.
-// import '../styles/base/base.css'; 
+
 
 function Upload() {
   const [title, setTitle] = useState('');
   const [file, setFile] = useState(null);
 
   const handleUpload = () => {
-    const formData = new FormData();
-    if (file) {
-      formData.append('file', file);
-    }
-    formData.append('title', title);
+  const formData = new FormData();
+  if (file) {
+    formData.append('file', file);
+  }
+  formData.append('title', title);
 
-    // Replace with your actual API endpoint and error handling
-    fetch('/api/torrents/upload', {
-      method: 'POST',
-      body: formData
-    })
+  const token = localStorage.getItem('jwt_token'); // 假设你登录后将 token 存在 localStorage
+
+  fetch('http://localhost:8080/api/torrents/upload', {
+    method: 'POST',
+    headers: {
+      Authorization: `Bearer ${token}`,
+    },
+    body: formData,
+  })
     .then(response => {
       if (response.ok) {
-        // Use a more modern way to show messages, e.g., a Snackbar
-        console.log('上传成功'); 
-        alert('上传成功 (建议使用Snackbar等UI组件替代alert)');
+        console.log('上传成功');
+        alert('上传成功');
       } else {
-        console.error('上传失败');
-        alert('上传失败 (建议使用Snackbar等UI组件替代alert)');
+        return response.text().then(text => {
+          console.error('上传失败:', text);
+          alert('上传失败: ' + text);
+        });
       }
     })
     .catch(error => {
       console.error('上传出错:', error);
-      alert('上传出错 (建议使用Snackbar等UI组件替代alert)');
+      alert('上传出错: ' + error.message);
     });
-  };
+};
 
   return (
     <Box sx={{ minHeight: '100vh', py: 4, background: 'linear-gradient(135deg, #2c3e50, #4ca1af)', color: 'white' }}> {/* Moved body styles here for self-containment */}