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