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";
|
22301133 | 38fd388 | 2025-06-06 23:33:57 +0800 | [diff] [blame] | 13 | import ForumIcon from "@mui/icons-material/Forum";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 14 |
|
| 15 | const navItems = [
|
| 16 | { label: "电影", icon: <MovieIcon />, path: "/movie" },
|
| 17 | { label: "剧集", icon: <EmailIcon />, path: "/tv" },
|
| 18 | { label: "音乐", icon: <MusicNoteIcon />, path: "/music" },
|
| 19 | { label: "动漫", icon: <EmojiPeopleIcon />, path: "/anime" },
|
| 20 | { label: "游戏", icon: <SportsEsportsIcon />, path: "/game" },
|
| 21 | { label: "体育", icon: <SportsMartialArtsIcon />, path: "/sport" },
|
| 22 | { label: "资料", icon: <PersonIcon />, path: "/info" },
|
22301133 | 38fd388 | 2025-06-06 23:33:57 +0800 | [diff] [blame] | 23 | { label: "论坛", icon: <ForumIcon />, path: "/forum" },
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 24 | { label: "发布", icon: <AccountCircleIcon />, path: "/publish" }, // Added Publish option
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 25 | ];
|
| 26 |
|
| 27 | const infoTypes = [""];
|
| 28 |
|
| 29 | const areaTabs = [
|
| 30 | { label: "出版物", icon: <MovieIcon fontSize="small" /> },
|
| 31 | { label: "学习教程", icon: <EmailIcon fontSize="small" /> },
|
| 32 | { label: "素材模板", icon: <PersonIcon fontSize="small" /> },
|
| 33 | { label: "演讲交流", icon: <EmojiPeopleIcon fontSize="small" /> },
|
| 34 | { label: "日常娱乐", icon: <PersonIcon fontSize="small" />, active: true },
|
| 35 | ];
|
| 36 |
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 37 | const exampleTorrents = [
|
| 38 | { type: "Documentary", title: "实例1", id: 1 },
|
| 39 | { type: "Biography", title: "实例2", id: 2 },
|
| 40 | { type: "History", title: "实例3", id: 3 },
|
| 41 | ];
|
| 42 |
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 43 | export default function InfoPage() {
|
| 44 | const navigate = useNavigate();
|
| 45 | const [activeTab, setActiveTab] = React.useState(0);
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 46 | const [infoList, setInfoList] = React.useState(0);
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 47 |
|
| 48 | // 每个tab对应的资料类型
|
| 49 | const infoTypesList = [
|
| 50 | ["出版物A", "出版物B", "出版物C"], // 出版物
|
| 51 | ["教程A", "教程B", "教程C"], // 学习教程
|
| 52 | ["模板A", "模板B"], // 素材模板
|
| 53 | ["演讲A", "演讲B"], // 演讲交流
|
| 54 | ["娱乐A", "娱乐B"], // 日常娱乐
|
| 55 | ];
|
| 56 | const infoTypes = infoTypesList[activeTab] || [];
|
| 57 |
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 58 | React.useEffect(() => {
|
| 59 | // 这里假设后端接口为 /api/get-seed-list-by-tag?tag=大陆
|
| 60 | const area = areaTabs[activeTab].label;
|
22301133 | 0f9623f | 2025-06-06 00:22:05 +0800 | [diff] [blame] | 61 | fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 62 | .then(res => res.json())
|
| 63 | .then(data => {
|
| 64 | console.log('资料区返回数据:', data);
|
| 65 | setInfoList(data);
|
| 66 | })
|
| 67 | .catch(() => setInfoList([]));
|
| 68 | }, [activeTab]);
|
| 69 |
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 70 | return (
|
| 71 | <div className="container">
|
| 72 | {/* 顶部空白与音乐界面一致,用户栏绝对定位在页面右上角 */}
|
| 73 | <div style={{ height: 80 }} />
|
| 74 | <div
|
| 75 | className="user-bar"
|
| 76 | style={{
|
| 77 | position: "fixed",
|
| 78 | top: 18,
|
| 79 | right: 42,
|
| 80 | zIndex: 100,
|
| 81 | display: "flex",
|
| 82 | alignItems: "center",
|
| 83 | background: "#e0f3ff",
|
| 84 | borderRadius: 12,
|
| 85 | padding: "6px 18px",
|
| 86 | boxShadow: "0 2px 8px #b2d8ea",
|
| 87 | minWidth: 320,
|
| 88 | minHeight: 48,
|
| 89 | width: 420,
|
| 90 | }}
|
| 91 | >
|
| 92 | <div
|
| 93 | style={{ cursor: "pointer", marginRight: 16 }}
|
| 94 | onClick={() => navigate("/user")}
|
| 95 | >
|
| 96 | <AccountCircleIcon
|
| 97 | style={{
|
| 98 | fontSize: 38,
|
| 99 | color: "#1a237e",
|
| 100 | background: "#e0f3ff",
|
| 101 | borderRadius: "50%",
|
| 102 | }}
|
| 103 | />
|
| 104 | </div>
|
| 105 | <div style={{ color: "#222", fontWeight: 500, marginRight: 24 }}>
|
| 106 | 用户栏
|
| 107 | </div>
|
| 108 | <div
|
| 109 | style={{
|
| 110 | display: "flex",
|
| 111 | gap: 28,
|
| 112 | flex: 1,
|
| 113 | justifyContent: "flex-end",
|
| 114 | alignItems: "center",
|
| 115 | }}
|
| 116 | >
|
| 117 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 118 | 魔力值: <b>12345</b>
|
| 119 | </span>
|
| 120 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 121 | 分享率: <b>2.56</b>
|
| 122 | </span>
|
| 123 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 124 | 上传量: <b>100GB</b>
|
| 125 | </span>
|
| 126 | <span style={{ color: "#1976d2", fontWeight: 500 }}>
|
| 127 | 下载量: <b>50GB</b>
|
| 128 | </span>
|
| 129 | </div>
|
| 130 | </div>
|
| 131 | {/* 下方内容整体下移,留出与音乐界面一致的间距 */}
|
| 132 | <div style={{ height: 32 }} />
|
| 133 | <nav className="nav-bar card">
|
| 134 | {navItems.map((item) => (
|
| 135 | <div
|
| 136 | key={item.label}
|
| 137 | className={item.label === "资料" ? "nav-item active" : "nav-item"}
|
| 138 | onClick={() => navigate(item.path)}
|
| 139 | >
|
| 140 | {item.icon}
|
| 141 | <span>{item.label}</span>
|
| 142 | </div>
|
| 143 | ))}
|
| 144 | </nav>
|
| 145 | <div className="search-section card">
|
| 146 | <input className="search-input" placeholder="输入搜索关键词" />
|
| 147 | <button className="search-btn">
|
| 148 | <span role="img" aria-label="search">
|
| 149 | 🔍
|
| 150 | </span>
|
| 151 | </button>
|
| 152 | </div>
|
| 153 | <div
|
| 154 | className="area-tabs"
|
| 155 | style={{
|
| 156 | display: "flex",
|
| 157 | justifyContent: "center",
|
| 158 | gap: 24,
|
| 159 | margin: "18px 0",
|
| 160 | }}
|
| 161 | >
|
| 162 | {areaTabs.map((tab, idx) => (
|
| 163 | <div
|
| 164 | key={tab.label}
|
| 165 | className={activeTab === idx ? "area-tab active" : "area-tab"}
|
| 166 | onClick={() => setActiveTab(idx)}
|
| 167 | >
|
| 168 | {tab.icon} <span>{tab.label}</span>
|
| 169 | </div>
|
| 170 | ))}
|
| 171 | </div>
|
| 172 | <div className="table-section">
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 173 | <table className="info-table">
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 174 | <thead>
|
| 175 | <tr>
|
956303669 | 9e95ae3 | 2025-06-02 21:42:11 +0800 | [diff] [blame] | 176 | <th>资料类型</th>
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 177 | <th>标题</th>
|
| 178 | <th>发布者</th>
|
| 179 | </tr>
|
| 180 | </thead>
|
| 181 | <tbody>
|
rhj | c6a4ee0 | 2025-06-06 00:45:18 +0800 | [diff] [blame] | 182 | {infoList.length > 0 ? (
|
| 183 | infoList.map((item, index) => (
|
| 184 | <tr key={item.id || index}>
|
| 185 | <td>
|
| 186 | <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
|
| 187 | {item.seedtag}
|
| 188 | </a>
|
| 189 | </td>
|
| 190 | <td>
|
| 191 | <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
|
| 192 | {item.title}
|
| 193 | </a>
|
| 194 | </td>
|
| 195 | <td>{item.user.username}</td>
|
| 196 | </tr>
|
| 197 | ))
|
| 198 | ) : (
|
| 199 | infoTypesList.map((type, index) => (
|
| 200 | <tr key={type}>
|
| 201 | <td>
|
| 202 | <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
|
| 203 | {type}
|
| 204 | </a>
|
| 205 | </td>
|
| 206 | <td>
|
| 207 | <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
|
| 208 | 种子{index + 1}
|
| 209 | </a>
|
| 210 | </td>
|
| 211 | <td>发布者{index + 1}</td>
|
| 212 | </tr>
|
| 213 | ))
|
| 214 | )}
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 215 | </tbody>
|
| 216 | </table>
|
| 217 | </div>
|
| 218 | <div style={{ height: 32 }} />
|
| 219 | <Pagination />
|
| 220 | </div>
|
| 221 | );
|
| 222 | }
|
| 223 |
|
| 224 | function Pagination() {
|
| 225 | const [page, setPage] = React.useState(3);
|
| 226 | const total = 5;
|
| 227 | return (
|
| 228 | <div className="pagination">
|
| 229 | <button
|
| 230 | onClick={() => setPage((p) => Math.max(1, p - 1))}
|
| 231 | disabled={page === 1}
|
| 232 | >
|
| 233 | 上一页
|
| 234 | </button>
|
| 235 | <span className="page-num">
|
| 236 | {page}/{total}
|
| 237 | </span>
|
| 238 | <button
|
| 239 | onClick={() => setPage((p) => Math.min(total, p + 1))}
|
| 240 | disabled={page === total}
|
| 241 | >
|
| 242 | 下一页
|
| 243 | </button>
|
| 244 | <span className="page-info">
|
| 245 | 第 <b>{page}</b> 页
|
| 246 | </span>
|
| 247 | </div>
|
| 248 | );
|
| 249 | }
|