blob: 1de4d303b39dcf52f96a83844fba59c1446ebf5c [file] [log] [blame]
956303669a32fc2c2025-06-02 19:45:53 +08001import React, { useState } 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
rhjc6a4ee02025-06-06 00:45:18 +080025const gameTypesList = [
26 ["PC"],
27 ["主机"],
28 ["移动"],
29 ["掌机"],
30 ["视频"]
31];
956303669a32fc2c2025-06-02 19:45:53 +080032
33const 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
41export default function GamePage() {
42 const navigate = useNavigate();
43 const [activeTab, setActiveTab] = useState(0);
rhjc6a4ee02025-06-06 00:45:18 +080044 const [gameList, setGameList] = useState([]);
45
46 const gameTypes = gameTypesList[activeTab] || [];
47
48 React.useEffect(() => {
49 const area = areaTabs[activeTab].label;
223011330f9623f2025-06-06 00:22:05 +080050 fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
rhjc6a4ee02025-06-06 00:45:18 +080051 .then(res => res.json())
52 .then(data => setGameList(data))
53 .catch(() => setGameList([]));
54 }, [activeTab]);
956303669a32fc2c2025-06-02 19:45:53 +080055
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">
9563036699e95ae32025-06-02 21:42:11 +0800159 <table className="game-table">
956303669a32fc2c2025-06-02 19:45:53 +0800160 <thead>
161 <tr>
162 <th>游戏类型</th>
163 <th>标题</th>
164 <th>发布者</th>
165 </tr>
166 </thead>
167 <tbody>
rhjc6a4ee02025-06-06 00:45:18 +0800168 {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 )}
956303669a32fc2c2025-06-02 19:45:53 +0800201 </tbody>
202 </table>
203 </div>
204 <div style={{ height: 32 }} />
205 <Pagination />
206 </div>
207 );
208}
209
210function 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}