956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 1 | import React, { useState } 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 |
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 25 | const gameTypesList = [
|
| 26 | ["PC"],
|
| 27 | ["主机"],
|
| 28 | ["移动"],
|
| 29 | ["掌机"],
|
| 30 | ["视频"]
|
| 31 | ];
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 32 |
|
| 33 | const areaTabs = [
|
| 34 | { label: "PC", icon: <MovieIcon fontSize="small" /> },
|
| 35 | { label: "主机", icon: <EmailIcon fontSize="small" /> },
|
| 36 | { label: "移动", icon: <PersonIcon fontSize="small" /> },
|
| 37 | { label: "掌机", icon: <EmojiPeopleIcon fontSize="small" /> },
|
| 38 | { label: "视频", icon: <PersonIcon fontSize="small" /> },
|
| 39 | ];
|
| 40 |
|
| 41 | export default function GamePage() {
|
| 42 | const navigate = useNavigate();
|
| 43 | const [activeTab, setActiveTab] = useState(0);
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 44 | const [gameList, setGameList] = useState([]);
|
| 45 |
|
| 46 | const gameTypes = gameTypesList[activeTab] || [];
|
| 47 |
|
| 48 | React.useEffect(() => {
|
| 49 | const area = areaTabs[activeTab].label;
|
22301133 | 0f9623f | 2025-06-06 00:22:05 +0800 | [diff] [blame] | 50 | fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 51 | .then(res => res.json())
|
| 52 | .then(data => setGameList(data))
|
| 53 | .catch(() => setGameList([]));
|
| 54 | }, [activeTab]);
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 55 |
|
| 56 | return (
|
| 57 | <div className="container">
|
| 58 | {/* 预留顶部空间用于放图片 */}
|
| 59 | <div style={{ height: 80 }} />
|
| 60 | <div
|
| 61 | className="user-bar"
|
| 62 | style={{
|
| 63 | position: "fixed",
|
| 64 | top: 18,
|
| 65 | right: 42,
|
| 66 | zIndex: 100,
|
| 67 | display: "flex",
|
| 68 | alignItems: "center",
|
| 69 | background: "#e0f3ff",
|
| 70 | borderRadius: 12,
|
| 71 | padding: "6px 18px",
|
| 72 | boxShadow: "0 2px 8px #b2d8ea",
|
| 73 | minWidth: 320,
|
| 74 | minHeight: 48,
|
| 75 | width: 420,
|
| 76 | }}
|
| 77 | >
|
| 78 | <div
|
| 79 | style={{ cursor: "pointer", marginRight: 16 }}
|
| 80 | onClick={() => navigate("/user")}
|
| 81 | >
|
| 82 | <AccountCircleIcon
|
| 83 | style={{
|
| 84 | fontSize: 38,
|
| 85 | color: "#1a237e",
|
| 86 | background: "#e0f3ff",
|
| 87 | borderRadius: "50%",
|
| 88 | }}
|
| 89 | />
|
| 90 | </div>
|
| 91 | <div style={{ color: "#222", fontWeight: 500, marginRight: 24 }}>
|
| 92 | 用户栏
|
| 93 | </div>
|
| 94 | <div
|
| 95 | style={{
|
| 96 | display: "flex",
|
| 97 | gap: 28,
|
| 98 | flex: 1,
|
| 99 | justifyContent: "flex-end",
|
| 100 | alignItems: "center",
|
| 101 | }}
|
| 102 | >
|
| 103 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 104 | 魔力值: <b>12345</b>
|
| 105 | </span>
|
| 106 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 107 | 分享率: <b>2.56</b>
|
| 108 | </span>
|
| 109 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 110 | 上传量: <b>100GB</b>
|
| 111 | </span>
|
| 112 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 113 | 下载量: <b>50GB</b>
|
| 114 | </span>
|
| 115 | </div>
|
| 116 | </div>
|
| 117 | {/* 下方内容整体下移,留出与音乐界面一致的间距 */}
|
| 118 | <div style={{ height: 32 }} />
|
| 119 | <nav className="nav-bar card">
|
| 120 | {navItems.map((item) => (
|
| 121 | <div
|
| 122 | key={item.label}
|
| 123 | className={item.label === "游戏" ? "nav-item active" : "nav-item"}
|
| 124 | onClick={() => navigate(item.path)}
|
| 125 | >
|
| 126 | {item.icon}
|
| 127 | <span>{item.label}</span>
|
| 128 | </div>
|
| 129 | ))}
|
| 130 | </nav>
|
| 131 | <div className="search-section card">
|
| 132 | <input className="search-input" placeholder="输入搜索关键词" />
|
| 133 | <button className="search-btn">
|
| 134 | <span role="img" aria-label="search">
|
| 135 | 🔍
|
| 136 | </span>
|
| 137 | </button>
|
| 138 | </div>
|
| 139 | <div
|
| 140 | className="area-tabs"
|
| 141 | style={{
|
| 142 | display: "flex",
|
| 143 | justifyContent: "center",
|
| 144 | gap: 24,
|
| 145 | margin: "18px 0",
|
| 146 | }}
|
| 147 | >
|
| 148 | {areaTabs.map((tab, idx) => (
|
| 149 | <div
|
| 150 | key={tab.label}
|
| 151 | className={activeTab === idx ? "area-tab active" : "area-tab"}
|
| 152 | onClick={() => setActiveTab(idx)}
|
| 153 | >
|
| 154 | {tab.icon} <span>{tab.label}</span>
|
| 155 | </div>
|
| 156 | ))}
|
| 157 | </div>
|
| 158 | <div className="table-section">
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 159 | <table className="game-table">
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 160 | <thead>
|
| 161 | <tr>
|
| 162 | <th>游戏类型</th>
|
| 163 | <th>标题</th>
|
| 164 | <th>发布者</th>
|
| 165 | </tr>
|
| 166 | </thead>
|
| 167 | <tbody>
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 168 | {gameList.length > 0 ? (
|
| 169 | gameList.map((item, idx) => (
|
| 170 | <tr key={item.id || idx}>
|
| 171 | <td>
|
| 172 | <a href={`/torrent/${item.seedid}`} style={{ color: "#1a237e", textDecoration: "none" }}>
|
| 173 | {item.seedtag}
|
| 174 | </a>
|
| 175 | </td>
|
| 176 | <td>
|
| 177 | <a href={`/torrent/${item.seedid}`} style={{ color: "#1a237e", textDecoration: "none" }}>
|
| 178 | {item.title}
|
| 179 | </a>
|
| 180 | </td>
|
| 181 | <td>{item.user.username}</td>
|
| 182 | </tr>
|
| 183 | ))
|
| 184 | ) : (
|
| 185 | gameTypes.map((type, idx) => (
|
| 186 | <tr key={type}>
|
| 187 | <td>
|
| 188 | <a href={`/torrent/${type}`} style={{ color: "#1a237e", textDecoration: "none" }}>
|
| 189 | {type}
|
| 190 | </a>
|
| 191 | </td>
|
| 192 | <td>
|
| 193 | <a href={`/torrent/${type}`} style={{ color: "#1a237e", textDecoration: "none" }}>
|
| 194 | 种子{idx + 1}
|
| 195 | </a>
|
| 196 | </td>
|
| 197 | <td></td>
|
| 198 | </tr>
|
| 199 | ))
|
| 200 | )}
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 201 | </tbody>
|
| 202 | </table>
|
| 203 | </div>
|
| 204 | <div style={{ height: 32 }} />
|
| 205 | <Pagination />
|
| 206 | </div>
|
| 207 | );
|
| 208 | }
|
| 209 |
|
| 210 | function Pagination() {
|
| 211 | const [page, setPage] = React.useState(3);
|
| 212 | const total = 5;
|
| 213 | return (
|
| 214 | <div className="pagination">
|
| 215 | <button
|
| 216 | onClick={() => setPage((p) => Math.max(1, p - 1))}
|
| 217 | disabled={page === 1}
|
| 218 | >
|
| 219 | 上一页
|
| 220 | </button>
|
| 221 | <span className="page-num">
|
| 222 | {page}/{total}
|
| 223 | </span>
|
| 224 | <button
|
| 225 | onClick={() => setPage((p) => Math.min(total, p + 1))}
|
| 226 | disabled={page === total}
|
| 227 | >
|
| 228 | 下一页
|
| 229 | </button>
|
| 230 | <span className="page-info">
|
| 231 | 第 <b>{page}</b> 页
|
| 232 | </span>
|
| 233 | </div>
|
| 234 | );
|
| 235 | }
|