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