修改前端页面

Change-Id: I344849fc3dfca5725e0ef2a107e2c89a14fce8da
diff --git a/front/src/TVPage.js b/front/src/TVPage.js
index 7e33a87..d75a172 100644
--- a/front/src/TVPage.js
+++ b/front/src/TVPage.js
@@ -1,4 +1,5 @@
 import React, { useState, useEffect } from "react";

+import HomeIcon from "@mui/icons-material/Home";

 import MovieIcon from "@mui/icons-material/Movie";

 import EmailIcon from "@mui/icons-material/Email";

 import MusicNoteIcon from "@mui/icons-material/MusicNote";

@@ -7,11 +8,14 @@
 import SportsMartialArtsIcon from "@mui/icons-material/SportsMartialArts";

 import PersonIcon from "@mui/icons-material/Person";

 import AccountCircleIcon from "@mui/icons-material/AccountCircle";

-import { useNavigate } from "react-router-dom";

+import ForumIcon from "@mui/icons-material/Forum";

+import HelpIcon from "@mui/icons-material/Help";

 import "./App.css";

+import { useNavigate } from "react-router-dom";

 import { API_BASE_URL } from "./config";

 

 const navItems = [

+  { label: "首页", icon: <HomeIcon />, path: "/home" },

   { label: "电影", icon: <MovieIcon />, path: "/movie" },

   { label: "剧集", icon: <EmailIcon />, path: "/tv" },

   { label: "音乐", icon: <MusicNoteIcon />, path: "/music" },

@@ -19,15 +23,9 @@
   { label: "游戏", icon: <SportsEsportsIcon />, path: "/game" },

   { label: "体育", icon: <SportsMartialArtsIcon />, path: "/sport" },

   { label: "资料", icon: <PersonIcon />, path: "/info" },

-  { label: "发布", icon: <AccountCircleIcon />, path: "/publish" }, // Added Publish option

-];

-

-const tvTypesList = [

-  ["华语剧集(大陆)", "欧美剧集", "日韩剧集", "港台剧集", "其他"], // 大陆

-  ["港台都市", "港台爱情", "港台悬疑", "港台其他"], // 港台

-  ["欧美悬疑", "欧美历史", "欧美其他"], // 欧美

-  ["日韩青春", "日韩家庭", "日韩其他"], // 日韩

-  ["其他类型1", "其他类型2"] // 其他

+  { label: "论坛", icon: <ForumIcon />, path: "/forum" },

+  { label: "发布", icon: <AccountCircleIcon />, path: "/publish" },

+  { label: "求种", icon: <HelpIcon />, path: "/begseed" },

 ];

 

 const areaTabs = [

@@ -35,36 +33,33 @@
   { label: "港剧", icon: <EmailIcon fontSize="small" /> },

   { label: "欧美剧", icon: <PersonIcon fontSize="small" /> },

   { label: "日韩剧", icon: <EmojiPeopleIcon fontSize="small" /> },

-  // { label: "其他", icon: <PersonIcon fontSize="small" /> },

 ];

 

 export default function TVPage() {

   const navigate = useNavigate();

   const [searchText, setSearchText] = React.useState('');

-    const [userInfo, setUserInfo] = useState({ avatar_url: '', username: '' });

-    const [userPT, setUserPT] = useState({ magic: 0, ratio: 0, upload: 0, download: 0 });

+  const [userInfo, setUserInfo] = useState({ avatar_url: '', username: '' });

+  const [userPT, setUserPT] = useState({ magic: 0, ratio: 0, upload: 0, download: 0 });

   const [activeTab, setActiveTab] = React.useState(0);

   const [tvList, setTvList] = React.useState([]);

 

-    useEffect(() => {

-      const match = document.cookie.match('(^|;)\\s*userId=([^;]+)');

-      const userId = match ? match[2] : null;

-      console.log("User ID from cookie:", userId);

-      if (!userId) return;

-      fetch(`${API_BASE_URL}/api/get-userpt?userid=${encodeURIComponent(userId)}`)

-        .then(res => res.json())

-        .then(data => {

-          console.log('用户PT信息:', data); 

-          setUserInfo({ avatar_url: data.user.avatar_url, username: data.user.username });

-          setUserPT({

-            magic: data.magic_value || data.magic || 0,

-            ratio: data.share_ratio || data.share || 0,

-            upload: data.upload_amount || data.upload || 0,

-            download: data.download_amount || data.download || 0,

-          });

-        })

-        .catch(err => console.error('Fetching user profile failed', err));

-    }, []);

+  useEffect(() => {

+    const match = document.cookie.match('(^|;)\\s*userId=([^;]+)');

+    const userId = match ? match[2] : null;

+    if (!userId) return;

+    fetch(`${API_BASE_URL}/api/get-userpt?userid=${encodeURIComponent(userId)}`)

+      .then(res => res.json())

+      .then(data => {

+        setUserInfo({ avatar_url: data.user.avatar_url, username: data.user.username });

+        setUserPT({

+          magic: data.magic_value || data.magic || 0,

+          ratio: data.share_ratio || data.share || 0,

+          upload: data.upload_amount || data.upload || 0,

+          download: data.download_amount || data.download || 0,

+        });

+      })

+      .catch(err => console.error('Fetching user profile failed', err));

+  }, []);

 

   React.useEffect(() => {

     // 假设后端接口为 /api/tvs?area=大陆

@@ -75,19 +70,25 @@
       .catch(() => setTvList([]));

   }, [activeTab]);

 

-    // 搜索按钮处理

-    const handleSearch = () => {

-      const area = areaTabs[activeTab].label;

-      fetch(`${API_BASE_URL}/api/search-seeds?tag=${encodeURIComponent(area)}&keyword=${encodeURIComponent(searchText)}`)

-        .then(res => res.json())

-        .then(data => {

-          console.log('搜索返回数据:', data);

-          setTvList(data);

-        })

-        .catch(() => setTvList([]));

-    };

+  // 搜索按钮处理

+  const handleSearch = () => {

+    const area = areaTabs[activeTab].label;

+    fetch(`${API_BASE_URL}/api/search-seeds?tag=${encodeURIComponent(area)}&keyword=${encodeURIComponent(searchText)}`)

+      .then(res => res.json())

+      .then(data => {

+        console.log('搜索返回数据:', data);

+        setTvList(data);

+      })

+      .catch(() => setTvList([]));

+  };

 

-  // 每个tab对应的剧集类型

+  const tvTypesList = [

+    ["华语剧集(大陆)", "欧美剧集", "日韩剧集", "港台剧集", "其他"], // 大陆

+    ["港台都市", "港台爱情", "港台悬疑", "港台其他"], // 港台

+    ["欧美悬疑", "欧美历史", "欧美其他"], // 欧美

+    ["日韩青春", "日韩家庭", "日韩其他"], // 日韩

+    ["其他类型1", "其他类型2"] // 其他

+  ];

   const tvTypes = tvTypesList[activeTab] || [];

 

   return (

@@ -153,6 +154,9 @@
               <th>剧集类型</th>

               <th>标题</th>

               <th>发布者</th>

+              <th>大小</th>

+              <th>热度</th>

+              <th>折扣倍率</th>

             </tr>

           </thead>

           <tbody>

@@ -169,7 +173,10 @@
                       {item.title}

                     </a>

                   </td>

-                  <td>{item.user.username}</td>

+                  <td>{item.username}</td>

+                  <td>{item.seedsize}</td>

+                  <td>{item.downloadtimes}</td>

+                  <td>{item.discount == null ? 1 : item.discount}</td>

                 </tr>

               ))

             ) : (

@@ -186,6 +193,9 @@
                     </a>

                   </td>

                   <td>发布者{index + 1}</td>

+                  <td>--</td>

+                  <td>--</td>

+                  <td>1</td>

                 </tr>

               ))

             )}