blob: a221c09b0cece019e3874bf8e0898cc90f86751d [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";
2230113338fd3882025-06-06 23:33:57 +080013import ForumIcon from "@mui/icons-material/Forum";
956303669a32fc2c2025-06-02 19:45:53 +080014
15const navItems = [
16 { label: "电影", icon: <MovieIcon />, path: "/movie" },
17 { label: "剧集", icon: <EmailIcon />, path: "/tv" },
18 { label: "音乐", icon: <MusicNoteIcon />, path: "/music" },
19 { label: "动漫", icon: <EmojiPeopleIcon />, path: "/anime" },
20 { label: "游戏", icon: <SportsEsportsIcon />, path: "/game" },
21 { label: "体育", icon: <SportsMartialArtsIcon />, path: "/sport" },
22 { label: "资料", icon: <PersonIcon />, path: "/info" },
2230113338fd3882025-06-06 23:33:57 +080023 { label: "论坛", icon: <ForumIcon />, path: "/forum" },
9563036699e95ae32025-06-02 21:42:11 +080024 { label: "发布", icon: <AccountCircleIcon />, path: "/publish" }, // Added Publish option
956303669a32fc2c2025-06-02 19:45:53 +080025];
26
27const sportTypes = [""];
28
29const areaTabs = [
30 { label: "篮球", icon: <MovieIcon fontSize="small" /> },
31 { label: "足球", icon: <EmailIcon fontSize="small" /> },
32 { label: "羽毛球", icon: <EmojiPeopleIcon fontSize="small" /> },
33 { label: "排球", icon: <PersonIcon fontSize="small" /> },
34 { label: "电竞", icon: <PersonIcon fontSize="small" />, active: true },
35];
36
9563036699e95ae32025-06-02 21:42:11 +080037const exampleTorrents = [
38 { type: "Soccer", title: "实例1", id: 1 },
39 { type: "Basketball", title: "实例2", id: 2 },
40 { type: "Tennis", title: "实例3", id: 3 },
41];
42
956303669a32fc2c2025-06-02 19:45:53 +080043export default function SportPage() {
44 const navigate = useNavigate();
45 const [activeTab, setActiveTab] = React.useState(0);
rhjc6a4ee02025-06-06 00:45:18 +080046 const [sportList, setSportList] = React.useState([]);
956303669a32fc2c2025-06-02 19:45:53 +080047
48 // 每个tab对应的运动类型
49 const sportTypesList = [
50 ["篮球赛事", "篮球技巧", "篮球明星"], // 篮球
51 ["足球赛事", "足球技巧", "足球明星"], // 足球
52 ["羽毛球赛事", "羽毛球技巧"], // 羽毛球
53 ["排球赛事", "排球技巧"], // 排球
54 ["电竞赛事", "电竞技巧"], // 电竞
55 ];
56 const sportTypes = sportTypesList[activeTab] || [];
57
rhjc6a4ee02025-06-06 00:45:18 +080058 React.useEffect(() => {
59 // 假设后端接口为 /api/sports?area=篮球
60 const area = areaTabs[activeTab].label;
223011330f9623f2025-06-06 00:22:05 +080061 fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
rhjc6a4ee02025-06-06 00:45:18 +080062 .then(res => res.json())
63 .then(data => setSportList(data))
64 .catch(() => setSportList([]));
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="sport-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>
rhjc6a4ee02025-06-06 00:45:18 +0800179 {sportList.length > 0 ? (
180 sportList.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 sportTypes.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}