blob: 755d9227941abd4bffcedd5ed5571f5df5f37309 [file] [log] [blame]
956303669a32fc2c2025-06-02 19:45:53 +08001import React from "react";
2import MovieIcon from "@mui/icons-material/Movie";
3import EmailIcon from "@mui/icons-material/Email";
4import MusicNoteIcon from "@mui/icons-material/MusicNote";
5import EmojiPeopleIcon from "@mui/icons-material/EmojiPeople";
6import SportsEsportsIcon from "@mui/icons-material/SportsEsports";
7import SportsMartialArtsIcon from "@mui/icons-material/SportsMartialArts";
8import PersonIcon from "@mui/icons-material/Person";
9import AccountCircleIcon from "@mui/icons-material/AccountCircle";
10import "./App.css";
11import { useNavigate } from "react-router-dom";
12
13const navItems = [
14 { label: "电影", icon: <MovieIcon />, path: "/movie" },
15 { label: "剧集", icon: <EmailIcon />, path: "/tv" },
16 { label: "音乐", icon: <MusicNoteIcon />, path: "/music" },
17 { label: "动漫", icon: <EmojiPeopleIcon />, path: "/anime" },
18 { label: "游戏", icon: <SportsEsportsIcon />, path: "/game" },
19 { label: "体育", icon: <SportsMartialArtsIcon />, path: "/sport" },
20 { label: "资料", icon: <PersonIcon />, path: "/info" },
9563036699e95ae32025-06-02 21:42:11 +080021 { label: "发布", icon: <AccountCircleIcon />, path: "/publish" }, // Added Publish option
956303669a32fc2c2025-06-02 19:45:53 +080022];
23
24const infoTypes = [""];
25
26const areaTabs = [
27 { label: "出版物", icon: <MovieIcon fontSize="small" /> },
28 { label: "学习教程", icon: <EmailIcon fontSize="small" /> },
29 { label: "素材模板", icon: <PersonIcon fontSize="small" /> },
30 { label: "演讲交流", icon: <EmojiPeopleIcon fontSize="small" /> },
31 { label: "日常娱乐", icon: <PersonIcon fontSize="small" />, active: true },
32];
33
9563036699e95ae32025-06-02 21:42:11 +080034const exampleTorrents = [
35 { type: "Documentary", title: "实例1", id: 1 },
36 { type: "Biography", title: "实例2", id: 2 },
37 { type: "History", title: "实例3", id: 3 },
38];
39
956303669a32fc2c2025-06-02 19:45:53 +080040export default function InfoPage() {
41 const navigate = useNavigate();
42 const [activeTab, setActiveTab] = React.useState(0);
kjWei53b79ae2025-06-05 09:18:35 +000043 const [infoList, setInfoList] = React.useState(0);
956303669a32fc2c2025-06-02 19:45:53 +080044
45 // 每个tab对应的资料类型
46 const infoTypesList = [
47 ["出版物A", "出版物B", "出版物C"], // 出版物
48 ["教程A", "教程B", "教程C"], // 学习教程
49 ["模板A", "模板B"], // 素材模板
50 ["演讲A", "演讲B"], // 演讲交流
51 ["娱乐A", "娱乐B"], // 日常娱乐
52 ];
53 const infoTypes = infoTypesList[activeTab] || [];
54
kjWei53b79ae2025-06-05 09:18:35 +000055 React.useEffect(() => {
56 // 这里假设后端接口为 /api/get-seed-list-by-tag?tag=大陆
57 const area = areaTabs[activeTab].label;
58 fetch(`http://192.168.5.9:8080/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
59 .then(res => res.json())
60 .then(data => {
61 console.log('资料区返回数据:', data);
62 setInfoList(data);
63 })
64 .catch(() => setInfoList([]));
65 }, [activeTab]);
66
956303669a32fc2c2025-06-02 19:45:53 +080067 return (
68 <div className="container">
69 {/* 顶部空白与音乐界面一致,用户栏绝对定位在页面右上角 */}
70 <div style={{ height: 80 }} />
71 <div
72 className="user-bar"
73 style={{
74 position: "fixed",
75 top: 18,
76 right: 42,
77 zIndex: 100,
78 display: "flex",
79 alignItems: "center",
80 background: "#e0f3ff",
81 borderRadius: 12,
82 padding: "6px 18px",
83 boxShadow: "0 2px 8px #b2d8ea",
84 minWidth: 320,
85 minHeight: 48,
86 width: 420,
87 }}
88 >
89 <div
90 style={{ cursor: "pointer", marginRight: 16 }}
91 onClick={() => navigate("/user")}
92 >
93 <AccountCircleIcon
94 style={{
95 fontSize: 38,
96 color: "#1a237e",
97 background: "#e0f3ff",
98 borderRadius: "50%",
99 }}
100 />
101 </div>
102 <div style={{ color: "#222", fontWeight: 500, marginRight: 24 }}>
103 用户栏
104 </div>
105 <div
106 style={{
107 display: "flex",
108 gap: 28,
109 flex: 1,
110 justifyContent: "flex-end",
111 alignItems: "center",
112 }}
113 >
114 <span style={{ color: "#1976d2", fontWeight: 500 }}>
115 魔力值: <b>12345</b>
116 </span>
117 <span style={{ color: "#1976d2", fontWeight: 500 }}>
118 分享率: <b>2.56</b>
119 </span>
120 <span style={{ color: "#1976d2", fontWeight: 500 }}>
121 上传量: <b>100GB</b>
122 </span>
123 <span style={{ color: "#1976d2", fontWeight: 500 }}>
124 下载量: <b>50GB</b>
125 </span>
126 </div>
127 </div>
128 {/* 下方内容整体下移,留出与音乐界面一致的间距 */}
129 <div style={{ height: 32 }} />
130 <nav className="nav-bar card">
131 {navItems.map((item) => (
132 <div
133 key={item.label}
134 className={item.label === "资料" ? "nav-item active" : "nav-item"}
135 onClick={() => navigate(item.path)}
136 >
137 {item.icon}
138 <span>{item.label}</span>
139 </div>
140 ))}
141 </nav>
142 <div className="search-section card">
143 <input className="search-input" placeholder="输入搜索关键词" />
144 <button className="search-btn">
145 <span role="img" aria-label="search">
146 🔍
147 </span>
148 </button>
149 </div>
150 <div
151 className="area-tabs"
152 style={{
153 display: "flex",
154 justifyContent: "center",
155 gap: 24,
156 margin: "18px 0",
157 }}
158 >
159 {areaTabs.map((tab, idx) => (
160 <div
161 key={tab.label}
162 className={activeTab === idx ? "area-tab active" : "area-tab"}
163 onClick={() => setActiveTab(idx)}
164 >
165 {tab.icon} <span>{tab.label}</span>
166 </div>
167 ))}
168 </div>
169 <div className="table-section">
9563036699e95ae32025-06-02 21:42:11 +0800170 <table className="info-table">
956303669a32fc2c2025-06-02 19:45:53 +0800171 <thead>
172 <tr>
9563036699e95ae32025-06-02 21:42:11 +0800173 <th>资料类型</th>
956303669a32fc2c2025-06-02 19:45:53 +0800174 <th>标题</th>
175 <th>发布者</th>
176 </tr>
177 </thead>
178 <tbody>
kjWei53b79ae2025-06-05 09:18:35 +0000179 {infoList.length > 0 ? (
180 infoList.map((item, index) => (
181 <tr key={item.id || index}>
182 <td>
183 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
184 {item.seedtag}
185 </a>
186 </td>
187 <td>
188 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
189 {item.title}
190 </a>
191 </td>
192 <td>{item.user.username}</td>
193 </tr>
194 ))
195 ) : (
196 infoTypesList.map((type, index) => (
197 <tr key={type}>
198 <td>
199 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
200 {type}
201 </a>
202 </td>
203 <td>
204 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
205 种子{index + 1}
206 </a>
207 </td>
208 <td>发布者{index + 1}</td>
209 </tr>
210 ))
211 )}
956303669a32fc2c2025-06-02 19:45:53 +0800212 </tbody>
213 </table>
214 </div>
215 <div style={{ height: 32 }} />
216 <Pagination />
217 </div>
218 );
219}
220
221function Pagination() {
222 const [page, setPage] = React.useState(3);
223 const total = 5;
224 return (
225 <div className="pagination">
226 <button
227 onClick={() => setPage((p) => Math.max(1, p - 1))}
228 disabled={page === 1}
229 >
230 上一页
231 </button>
232 <span className="page-num">
233 {page}/{total}
234 </span>
235 <button
236 onClick={() => setPage((p) => Math.min(total, p + 1))}
237 disabled={page === total}
238 >
239 下一页
240 </button>
241 <span className="page-info">
242 <b>{page}</b>
243 </span>
244 </div>
245 );
246}