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