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