22301133 | 9e29215 | 2025-06-08 00:34:37 +0800 | [diff] [blame] | 1 | import React, { useState, useEffect } from "react";
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 2 | import HomeIcon from "@mui/icons-material/Home";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 3 | import MovieIcon from "@mui/icons-material/Movie";
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 4 | import TvIcon from "@mui/icons-material/Tv";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 5 | import MusicNoteIcon from "@mui/icons-material/MusicNote";
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 6 | import AnimationIcon from "@mui/icons-material/Animation";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 7 | import SportsEsportsIcon from "@mui/icons-material/SportsEsports";
|
| 8 | import SportsMartialArtsIcon from "@mui/icons-material/SportsMartialArts";
|
| 9 | import PersonIcon from "@mui/icons-material/Person";
|
| 10 | import AccountCircleIcon from "@mui/icons-material/AccountCircle";
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 11 | import ForumIcon from "@mui/icons-material/Forum";
|
| 12 | import HelpIcon from "@mui/icons-material/Help";
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 13 | import "./SharedStyles.css";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 14 | import { useNavigate } from "react-router-dom";
|
22301133 | 0f9623f | 2025-06-06 00:22:05 +0800 | [diff] [blame] | 15 | import { API_BASE_URL } from "./config";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 16 |
|
| 17 | const navItems = [
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 18 | { label: "首页", icon: <HomeIcon className="emerald-nav-icon" />, path: "/home", type: "home" },
|
| 19 | { label: "电影", icon: <MovieIcon className="emerald-nav-icon" />, path: "/movie", type: "movie" },
|
| 20 | { label: "剧集", icon: <TvIcon className="emerald-nav-icon" />, path: "/tv", type: "tv" },
|
| 21 | { label: "音乐", icon: <MusicNoteIcon className="emerald-nav-icon" />, path: "/music", type: "music" },
|
| 22 | { label: "动漫", icon: <AnimationIcon className="emerald-nav-icon" />, path: "/anime", type: "anime" },
|
| 23 | { label: "游戏", icon: <SportsEsportsIcon className="emerald-nav-icon" />, path: "/game", type: "game" },
|
| 24 | { label: "体育", icon: <SportsMartialArtsIcon className="emerald-nav-icon" />, path: "/sport", type: "sport" },
|
| 25 | { label: "资料", icon: <PersonIcon className="emerald-nav-icon" />, path: "/info", type: "info" },
|
| 26 | { label: "论坛", icon: <ForumIcon className="emerald-nav-icon" />, path: "/forum", type: "forum" },
|
| 27 | { label: "发布", icon: <AccountCircleIcon className="emerald-nav-icon" />, path: "/publish", type: "publish" },
|
| 28 | { label: "求种", icon: <HelpIcon className="emerald-nav-icon" />, path: "/begseed", type: "help" },
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 29 | ];
|
| 30 |
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 31 | // 体育地区标签
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 32 | const areaTabs = [
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 33 | { label: "篮球", value: "basketball" },
|
| 34 | { label: "足球", value: "football" },
|
| 35 | { label: "羽毛球", value: "badminton" },
|
| 36 | { label: "排球", value: "volleyball" },
|
| 37 | { label: "电竞", value: "esports" }
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 38 | ];
|
| 39 |
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 40 | export default function SportPage() {
|
| 41 | const navigate = useNavigate();
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 42 | const [searchText, setSearchText] = useState('');
|
| 43 | const [userInfo, setUserInfo] = useState({ avatar_url: '', username: '' });
|
| 44 | const [userPT, setUserPT] = useState({ magic: 0, ratio: 0, upload: 0, download: 0 });
|
| 45 | const [activeTab, setActiveTab] = useState(0);
|
| 46 | const [sportList, setSportList] = useState([]);
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 47 |
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 48 | useEffect(() => {
|
| 49 | const match = document.cookie.match('(^|;)\\s*userId=([^;]+)');
|
| 50 | const userId = match ? match[2] : null;
|
| 51 | if (!userId) return;
|
| 52 | fetch(`${API_BASE_URL}/api/get-userpt?userid=${encodeURIComponent(userId)}`)
|
| 53 | .then(res => res.json())
|
| 54 | .then(data => {
|
| 55 | setUserInfo({ avatar_url: data.user.avatar_url, username: data.user.username });
|
| 56 | setUserPT({
|
| 57 | magic: data.magic_value || data.magic || 0,
|
| 58 | ratio: data.share_ratio || data.share || 0,
|
| 59 | upload: data.upload_amount || data.upload || 0,
|
| 60 | download: data.download_amount || data.download || 0,
|
| 61 | });
|
| 62 | })
|
| 63 | .catch(err => console.error('Fetching user profile failed', err));
|
| 64 | }, []);
|
22301133 | 9e29215 | 2025-06-08 00:34:37 +0800 | [diff] [blame] | 65 |
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 66 | // 每个tab对应的体育类型
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 67 | const sportTypesList = [
|
| 68 | ["篮球赛事", "篮球技巧", "篮球明星"], // 篮球
|
| 69 | ["足球赛事", "足球技巧", "足球明星"], // 足球
|
| 70 | ["羽毛球赛事", "羽毛球技巧"], // 羽毛球
|
| 71 | ["排球赛事", "排球技巧"], // 排球
|
| 72 | ["电竞赛事", "电竞技巧"], // 电竞
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 73 | ["其他类型1", "其他类型2"] // 其他
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 74 | ];
|
| 75 | const sportTypes = sportTypesList[activeTab] || [];
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 76 | useEffect(() => {
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 77 | // 根据选中的标签获取体育列表
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 78 | const area = areaTabs[activeTab].label;
|
22301133 | 0f9623f | 2025-06-06 00:22:05 +0800 | [diff] [blame] | 79 | fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 80 | .then(res => res.json())
|
| 81 | .then(data => setSportList(data))
|
| 82 | .catch(() => setSportList([]));
|
| 83 | }, [activeTab]);
|
| 84 |
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 85 | // 搜索按钮处理
|
| 86 | const handleSearch = () => {
|
| 87 | const area = areaTabs[activeTab].label;
|
| 88 | fetch(`${API_BASE_URL}/api/search-seeds?tag=${encodeURIComponent(area)}&keyword=${encodeURIComponent(searchText)}`)
|
| 89 | .then(res => res.json())
|
| 90 | .then(data => {
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 91 | console.log('搜索返回数据:', data);
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 92 | setSportList(data);
|
| 93 | })
|
| 94 | .catch(() => setSportList([]));
|
| 95 | };
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 96 | return (
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 97 | <div className="emerald-home-container">
|
| 98 | {/* 流星雨背景效果 */}
|
| 99 | <div className="meteor-shower">
|
| 100 | <div className="meteor">💫</div>
|
| 101 | <div className="meteor">⭐</div>
|
| 102 | <div className="meteor">✨</div>
|
| 103 | <div className="meteor">🌟</div>
|
| 104 | <div className="meteor">💫</div>
|
| 105 | <div className="meteor">⭐</div>
|
| 106 | <div className="meteor">✨</div>
|
| 107 | <div className="meteor">🌟</div>
|
| 108 | <div className="meteor">💫</div>
|
| 109 | <div className="meteor">⭐</div>
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 110 | </div>
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 111 |
|
| 112 | {/* 浮动园林装饰元素 */}
|
| 113 | <div className="floating-garden-elements">
|
| 114 | <div className="garden-element">🌿</div>
|
| 115 | <div className="garden-element">🦋</div>
|
| 116 | <div className="garden-element">🌺</div>
|
| 117 | <div className="garden-element">🌸</div>
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 118 | </div>
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 119 |
|
| 120 | <div className="emerald-content">
|
| 121 | {/* NeuraFlux用户栏 */}
|
| 122 | <div className="emerald-user-bar">
|
| 123 | <div className="emerald-user-avatar" onClick={() => navigate('/user')}>
|
| 124 | {userInfo.avatar_url ? (
|
| 125 | <img src={userInfo.avatar_url} alt="用户头像" style={{ width: 38, height: 38, borderRadius: '50%', objectFit: 'cover' }} />
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 126 | ) : (
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 127 | <AccountCircleIcon style={{ fontSize: 38, color: 'white' }} />
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 128 | )}
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 129 | </div>
|
| 130 | <div className="emerald-brand-section">
|
| 131 | <div className="emerald-brand-icon">⚡</div>
|
| 132 | <div className="emerald-user-label">NeuraFlux</div>
|
| 133 | </div>
|
| 134 | <div className="emerald-user-stats">
|
| 135 | <span className="emerald-stat-item">
|
| 136 | 魔力值: <span className="emerald-stat-value">{userPT.magic}</span>
|
| 137 | </span>
|
| 138 | <span className="emerald-stat-item">
|
| 139 | 分享率: <span className="emerald-stat-value">{userPT.ratio}</span>
|
| 140 | </span>
|
| 141 | <span className="emerald-stat-item">
|
| 142 | 上传: <span className="emerald-stat-value">{userPT.upload}GB</span>
|
| 143 | </span>
|
| 144 | <span className="emerald-stat-item">
|
| 145 | 下载: <span className="emerald-stat-value">{userPT.download}GB</span>
|
| 146 | </span>
|
| 147 | </div>
|
| 148 | </div>
|
| 149 |
|
| 150 | {/* NeuraFlux导航栏 */}
|
| 151 | <nav className="emerald-nav-bar">
|
| 152 | {navItems.map((item) => (
|
| 153 | <div
|
| 154 | key={item.label}
|
| 155 | className={`emerald-nav-item ${item.label === "体育" ? "active" : ""}`}
|
| 156 | data-type={item.type}
|
| 157 | onClick={() => navigate(item.path)}
|
| 158 | >
|
| 159 | {item.icon}
|
| 160 | <span className="emerald-nav-label">{item.label}</span>
|
| 161 | </div>
|
| 162 | ))}
|
| 163 | </nav>
|
| 164 |
|
| 165 | {/* 体育内容区域 */}
|
| 166 | <div className="emerald-content-section">
|
| 167 | <h1 className="emerald-page-title">⚽ 体育资源</h1>
|
| 168 | <p style={{ textAlign: 'center', color: '#2d5016', fontSize: '18px', marginBottom: '30px' }}>
|
| 169 | 欢迎来到NeuraFlux体育频道,这里有最新最热门的体育资源
|
| 170 | </p>
|
| 171 |
|
| 172 | {/* 搜索栏 */}
|
| 173 | <div style={{
|
| 174 | display: 'flex',
|
| 175 | justifyContent: 'center',
|
| 176 | marginBottom: '30px',
|
| 177 | gap: '15px'
|
| 178 | }}>
|
| 179 | <input
|
| 180 | type="text"
|
| 181 | placeholder="搜索体育资源..."
|
| 182 | value={searchText}
|
| 183 | onChange={(e) => setSearchText(e.target.value)}
|
| 184 | style={{
|
| 185 | padding: '12px 20px',
|
| 186 | borderRadius: '20px',
|
| 187 | border: '2px solid rgba(144, 238, 144, 0.3)',
|
| 188 | background: 'rgba(240, 255, 240, 0.5)',
|
| 189 | fontSize: '16px',
|
| 190 | width: '300px',
|
| 191 | fontFamily: 'Lora, serif'
|
| 192 | }}
|
| 193 | />
|
| 194 | <button
|
| 195 | onClick={handleSearch}
|
| 196 | style={{
|
| 197 | padding: '12px 24px',
|
| 198 | borderRadius: '20px',
|
| 199 | border: 'none',
|
| 200 | background: 'linear-gradient(135deg, #2d5016 0%, #90ee90 100%)',
|
| 201 | color: 'white',
|
| 202 | fontSize: '16px',
|
| 203 | cursor: 'pointer',
|
| 204 | fontFamily: 'Lora, serif'
|
| 205 | }}
|
| 206 | >
|
| 207 | 搜索
|
| 208 | </button>
|
| 209 | </div>
|
| 210 |
|
| 211 | {/* 地区分类标签 */}
|
| 212 | <div style={{
|
| 213 | display: 'flex',
|
| 214 | justifyContent: 'center',
|
| 215 | marginBottom: '30px',
|
| 216 | gap: '15px',
|
| 217 | flexWrap: 'wrap'
|
| 218 | }}>
|
| 219 | {areaTabs.map((tab, index) => (
|
| 220 | <button
|
| 221 | key={tab.value}
|
| 222 | onClick={() => setActiveTab(index)}
|
| 223 | style={{
|
| 224 | padding: '10px 20px',
|
| 225 | borderRadius: '15px',
|
| 226 | border: '2px solid rgba(144, 238, 144, 0.3)',
|
| 227 | background: activeTab === index
|
| 228 | ? 'linear-gradient(135deg, #90ee90 0%, #2d5016 100%)'
|
| 229 | : 'rgba(240, 255, 240, 0.3)',
|
| 230 | color: activeTab === index ? 'white' : '#2d5016',
|
| 231 | fontSize: '14px',
|
| 232 | cursor: 'pointer',
|
| 233 | fontFamily: 'Lora, serif',
|
| 234 | transition: 'all 0.3s ease'
|
| 235 | }}
|
| 236 | >
|
| 237 | {tab.label}
|
| 238 | </button>
|
| 239 | ))}
|
| 240 | </div>
|
| 241 |
|
| 242 | {/* 体育列表 */}
|
| 243 | <div className="emerald-table-section">
|
| 244 | <table className="emerald-table">
|
| 245 | <thead>
|
| 246 | <tr>
|
| 247 | <th>体育类型</th>
|
| 248 | <th>标题</th>
|
| 249 | <th>发布者</th>
|
| 250 | <th>大小</th>
|
| 251 | <th>热度</th>
|
| 252 | <th>折扣倍率</th>
|
| 253 | </tr>
|
| 254 | </thead>
|
| 255 | <tbody>
|
| 256 | {sportList.length > 0 ? (
|
| 257 | sportList.map((item, index) => (
|
| 258 | <tr key={item.id || index}>
|
| 259 | <td>{item.seedtag}</td>
|
| 260 | <td>
|
| 261 | <a href={`/torrent/${item.seedid}`}>
|
| 262 | {item.title}
|
| 263 | </a>
|
| 264 | </td>
|
| 265 | <td>{item.username}</td>
|
| 266 | <td>{item.seedsize}</td>
|
| 267 | <td>{item.downloadtimes}</td>
|
| 268 | <td>{item.discount == null ? 1 : item.discount}</td>
|
| 269 | </tr>
|
| 270 | ))
|
| 271 | ) : (
|
| 272 | sportTypes.map((type, index) => (
|
| 273 | <tr key={type}>
|
| 274 | <td>{type}</td>
|
| 275 | <td>
|
| 276 | <a href={`/torrent/${type}`}>
|
| 277 | 种子{index + 1}
|
| 278 | </a>
|
| 279 | </td>
|
| 280 | <td>发布者{index + 1}</td>
|
| 281 | <td>--</td>
|
| 282 | <td>--</td>
|
| 283 | <td>1</td>
|
| 284 | </tr>
|
| 285 | ))
|
| 286 | )}
|
| 287 | </tbody>
|
| 288 | </table>
|
| 289 | </div>
|
| 290 | </div>
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 291 | </div>
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 292 | </div>
|
| 293 | );
|
| 294 | }
|
| 295 |
|
TRM-coding | fa3ffdf | 2025-06-09 22:47:42 +0800 | [diff] [blame] | 296 | // Pagination组件暂时不使用
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 297 | function Pagination() {
|
| 298 | const [page, setPage] = React.useState(3);
|
| 299 | const total = 5;
|
| 300 | return (
|
| 301 | <div className="pagination">
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 302 | <button onClick={() => setPage(p => Math.max(1, p - 1))} disabled={page === 1}>上一页</button>
|
| 303 | <span className="page-num">{page}/{total}</span>
|
| 304 | <button onClick={() => setPage(p => Math.min(total, p + 1))} disabled={page === total}>下一页</button>
|
| 305 | <span className="page-info">第 <b>{page}</b> 页</span>
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 306 | </div>
|
| 307 | );
|
wht | 338fc03 | 2025-06-09 17:16:22 +0800 | [diff] [blame] | 308 | } |