956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 1 | import React from "react";
|
| 2 | import MovieIcon from "@mui/icons-material/Movie";
|
| 3 | import EmailIcon from "@mui/icons-material/Email";
|
| 4 | import MusicNoteIcon from "@mui/icons-material/MusicNote";
|
| 5 | import EmojiPeopleIcon from "@mui/icons-material/EmojiPeople";
|
| 6 | import SportsEsportsIcon from "@mui/icons-material/SportsEsports";
|
| 7 | import SportsMartialArtsIcon from "@mui/icons-material/SportsMartialArts";
|
| 8 | import PersonIcon from "@mui/icons-material/Person";
|
| 9 | import AccountCircleIcon from "@mui/icons-material/AccountCircle";
|
| 10 | import "./App.css";
|
| 11 | import { useNavigate } from "react-router-dom";
|
22301133 | 0f9623f | 2025-06-06 00:22:05 +0800 | [diff] [blame^] | 12 | import { API_BASE_URL } from "./config";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 13 |
|
| 14 | const 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" },
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 22 | { label: "发布", icon: <AccountCircleIcon />, path: "/publish" }, // Added Publish option
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 23 | ];
|
| 24 |
|
| 25 | const sportTypes = [""];
|
| 26 |
|
| 27 | const 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 |
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 35 | const exampleTorrents = [
|
| 36 | { type: "Soccer", title: "实例1", id: 1 },
|
| 37 | { type: "Basketball", title: "实例2", id: 2 },
|
| 38 | { type: "Tennis", title: "实例3", id: 3 },
|
| 39 | ];
|
| 40 |
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 41 | export default function SportPage() {
|
| 42 | const navigate = useNavigate();
|
| 43 | const [activeTab, setActiveTab] = React.useState(0);
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 44 | const [sportList, setSportList] = React.useState([]);
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 45 |
|
| 46 | // 每个tab对应的运动类型
|
| 47 | const sportTypesList = [
|
| 48 | ["篮球赛事", "篮球技巧", "篮球明星"], // 篮球
|
| 49 | ["足球赛事", "足球技巧", "足球明星"], // 足球
|
| 50 | ["羽毛球赛事", "羽毛球技巧"], // 羽毛球
|
| 51 | ["排球赛事", "排球技巧"], // 排球
|
| 52 | ["电竞赛事", "电竞技巧"], // 电竞
|
| 53 | ];
|
| 54 | const sportTypes = sportTypesList[activeTab] || [];
|
| 55 |
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 56 | React.useEffect(() => {
|
| 57 | // 假设后端接口为 /api/sports?area=篮球
|
| 58 | const area = areaTabs[activeTab].label;
|
22301133 | 0f9623f | 2025-06-06 00:22:05 +0800 | [diff] [blame^] | 59 | fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 60 | .then(res => res.json())
|
| 61 | .then(data => setSportList(data))
|
| 62 | .catch(() => setSportList([]));
|
| 63 | }, [activeTab]);
|
| 64 |
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 65 | 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">
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 168 | <table className="sport-table">
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 169 | <thead>
|
| 170 | <tr>
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 171 | <th>体育类型</th>
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 172 | <th>标题</th>
|
| 173 | <th>发布者</th>
|
| 174 | </tr>
|
| 175 | </thead>
|
| 176 | <tbody>
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 177 | {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 | )}
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 210 | </tbody>
|
| 211 | </table>
|
| 212 | </div>
|
| 213 | <div style={{ height: 32 }} />
|
| 214 | <Pagination />
|
| 215 | </div>
|
| 216 | );
|
| 217 | }
|
| 218 |
|
| 219 | function 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 | }
|