blob: 3299a9303e475189127f4ce2775879604cc28119 [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 sportTypes = [""];
25
26const areaTabs = [
27 { label: "篮球", icon: <MovieIcon fontSize="small" /> },
28 { label: "足球", icon: <EmailIcon fontSize="small" /> },
29 { label: "羽毛球", icon: <EmojiPeopleIcon fontSize="small" /> },
30 { label: "排球", icon: <PersonIcon fontSize="small" /> },
31 { label: "电竞", icon: <PersonIcon fontSize="small" />, active: true },
32];
33
9563036699e95ae32025-06-02 21:42:11 +080034const exampleTorrents = [
35 { type: "Soccer", title: "实例1", id: 1 },
36 { type: "Basketball", title: "实例2", id: 2 },
37 { type: "Tennis", title: "实例3", id: 3 },
38];
39
956303669a32fc2c2025-06-02 19:45:53 +080040export default function SportPage() {
41 const navigate = useNavigate();
42 const [activeTab, setActiveTab] = React.useState(0);
kjWei53b79ae2025-06-05 09:18:35 +000043 const [sportList, setSportList] = React.useState([]);
956303669a32fc2c2025-06-02 19:45:53 +080044
45 // 每个tab对应的运动类型
46 const sportTypesList = [
47 ["篮球赛事", "篮球技巧", "篮球明星"], // 篮球
48 ["足球赛事", "足球技巧", "足球明星"], // 足球
49 ["羽毛球赛事", "羽毛球技巧"], // 羽毛球
50 ["排球赛事", "排球技巧"], // 排球
51 ["电竞赛事", "电竞技巧"], // 电竞
52 ];
53 const sportTypes = sportTypesList[activeTab] || [];
54
kjWei53b79ae2025-06-05 09:18:35 +000055 React.useEffect(() => {
56 // 假设后端接口为 /api/sports?area=篮球
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 => setSportList(data))
61 .catch(() => setSportList([]));
62 }, [activeTab]);
63
956303669a32fc2c2025-06-02 19:45:53 +080064 return (
65 <div className="container">
66 {/* 顶部空白与音乐界面一致,用户栏绝对定位在页面右上角 */}
67 <div style={{ height: 80 }} />
68 <div
69 className="user-bar"
70 style={{
71 position: "fixed",
72 top: 18,
73 right: 42,
74 zIndex: 100,
75 display: "flex",
76 alignItems: "center",
77 background: "#e0f3ff",
78 borderRadius: 12,
79 padding: "6px 18px",
80 boxShadow: "0 2px 8px #b2d8ea",
81 minWidth: 320,
82 minHeight: 48,
83 width: 420,
84 }}
85 >
86 <div
87 style={{ cursor: "pointer", marginRight: 16 }}
88 onClick={() => navigate("/user")}
89 >
90 <AccountCircleIcon
91 style={{
92 fontSize: 38,
93 color: "#1a237e",
94 background: "#e0f3ff",
95 borderRadius: "50%",
96 }}
97 />
98 </div>
99 <div style={{ color: "#222", fontWeight: 500, marginRight: 24 }}>
100 用户栏
101 </div>
102 <div
103 style={{
104 display: "flex",
105 gap: 28,
106 flex: 1,
107 justifyContent: "flex-end",
108 alignItems: "center",
109 }}
110 >
111 <span style={{ color: "#1976d2", fontWeight: 500 }}>
112 魔力值: <b>12345</b>
113 </span>
114 <span style={{ color: "#1976d2", fontWeight: 500 }}>
115 分享率: <b>2.56</b>
116 </span>
117 <span style={{ color: "#1976d2", fontWeight: 500 }}>
118 上传量: <b>100GB</b>
119 </span>
120 <span style={{ color: "#1976d2", fontWeight: 500 }}>
121 下载量: <b>50GB</b>
122 </span>
123 </div>
124 </div>
125 {/* 下方内容整体下移,留出与音乐界面一致的间距 */}
126 <div style={{ height: 32 }} />
127 <nav className="nav-bar card">
128 {navItems.map((item) => (
129 <div
130 key={item.label}
131 className={item.label === "体育" ? "nav-item active" : "nav-item"}
132 onClick={() => navigate(item.path)}
133 >
134 {item.icon}
135 <span>{item.label}</span>
136 </div>
137 ))}
138 </nav>
139 <div className="search-section card">
140 <input className="search-input" placeholder="输入搜索关键词" />
141 <button className="search-btn">
142 <span role="img" aria-label="search">
143 🔍
144 </span>
145 </button>
146 </div>
147 <div
148 className="area-tabs"
149 style={{
150 display: "flex",
151 justifyContent: "center",
152 gap: 24,
153 margin: "18px 0",
154 }}
155 >
156 {areaTabs.map((tab, idx) => (
157 <div
158 key={tab.label}
159 className={activeTab === idx ? "area-tab active" : "area-tab"}
160 onClick={() => setActiveTab(idx)}
161 >
162 {tab.icon} <span>{tab.label}</span>
163 </div>
164 ))}
165 </div>
166 <div className="table-section">
9563036699e95ae32025-06-02 21:42:11 +0800167 <table className="sport-table">
956303669a32fc2c2025-06-02 19:45:53 +0800168 <thead>
169 <tr>
9563036699e95ae32025-06-02 21:42:11 +0800170 <th>体育类型</th>
956303669a32fc2c2025-06-02 19:45:53 +0800171 <th>标题</th>
172 <th>发布者</th>
173 </tr>
174 </thead>
175 <tbody>
kjWei53b79ae2025-06-05 09:18:35 +0000176 {sportList.length > 0 ? (
177 sportList.map((item, index) => (
178 <tr key={item.id || index}>
179 <td>
180 <a href={`/torrent/${item.seedid}`} style={{ color: "#1a237e", textDecoration: "none" }}>
181 {item.seedtag}
182 </a>
183 </td>
184 <td>
185 <a href={`/torrent/${item.seedid}`} style={{ color: "#1a237e", textDecoration: "none" }}>
186 {item.title}
187 </a>
188 </td>
189 <td>{item.user.username}</td>
190 </tr>
191 ))
192 ) : (
193 sportTypes.map((type, index) => (
194 <tr key={type}>
195 <td>
196 <a href={`/torrent/${type}`} style={{ color: "#1a237e", textDecoration: "none" }}>
197 {type}
198 </a>
199 </td>
200 <td>
201 <a href={`/torrent/${type}`} style={{ color: "#1a237e", textDecoration: "none" }}>
202 种子{index + 1}
203 </a>
204 </td>
205 <td>发布者{index + 1}</td>
206 </tr>
207 ))
208 )}
956303669a32fc2c2025-06-02 19:45:53 +0800209 </tbody>
210 </table>
211 </div>
212 <div style={{ height: 32 }} />
213 <Pagination />
214 </div>
215 );
216}
217
218function Pagination() {
219 const [page, setPage] = React.useState(3);
220 const total = 5;
221 return (
222 <div className="pagination">
223 <button
224 onClick={() => setPage((p) => Math.max(1, p - 1))}
225 disabled={page === 1}
226 >
227 上一页
228 </button>
229 <span className="page-num">
230 {page}/{total}
231 </span>
232 <button
233 onClick={() => setPage((p) => Math.min(total, p + 1))}
234 disabled={page === total}
235 >
236 下一页
237 </button>
238 <span className="page-info">
239 <b>{page}</b>
240 </span>
241 </div>
242 );
243}