blob: 118d8fb3e5f3e0294d9baf0e73eea239b64721e0 [file] [log] [blame]
956303669a32fc2c2025-06-02 19:45:53 +08001import React 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
25const animeTypes = [
26 "华语动漫(大陆)",
27 "欧美动漫",
28 "日韩动漫",
29 "港台动漫",
30 "其他"
31];
32
33const areaTabs = [
rhjc6a4ee02025-06-06 00:45:18 +080034 { label: "国创", icon: <EmojiPeopleIcon 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" /> },
956303669a32fc2c2025-06-02 19:45:53 +080039];
40
41export default function AnimePage() {
42 const navigate = useNavigate();
43 const [activeTab, setActiveTab] = React.useState(0);
rhjc6a4ee02025-06-06 00:45:18 +080044 const [animeList, setAnimeList] = React.useState([]);
956303669a32fc2c2025-06-02 19:45:53 +080045
46 // 每个tab对应的动漫类型
47 const animeTypesList = [
48 ["华语动漫(大陆)", "欧美动漫", "日韩动漫", "港台动漫", "其他"], // 大陆
49 ["港台热血", "港台搞笑", "港台其他"], // 港台
50 ["欧美冒险", "欧美科幻", "欧美其他"], // 欧美
51 ["日韩热血", "日韩恋爱", "日韩其他"], // 日韩
52 ["其他类型1", "其他类型2"] // 其他
53 ];
54 const animeTypes = animeTypesList[activeTab] || [];
55
rhjc6a4ee02025-06-06 00:45:18 +080056 React.useEffect(() => {
57 // 假设后端接口为 /api/animes?area=大陆
58 const area = areaTabs[activeTab].label;
223011330f9623f2025-06-06 00:22:05 +080059 fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
rhjc6a4ee02025-06-06 00:45:18 +080060 .then(res => res.json())
61 .then(data => setAnimeList(data))
62 .catch(() => setAnimeList([]));
63 }, [activeTab]);
64
956303669a32fc2c2025-06-02 19:45:53 +080065 return (
66 <div className="container">
67 {/* 顶部空白与音乐界面一致,用户栏绝对定位在页面右上角 */}
68 <div style={{ height: 80 }} />
69 <div className="user-bar" style={{ position: 'fixed', top: 18, right: 42, zIndex: 100, display: 'flex', alignItems: 'center', background: '#e0f3ff', borderRadius: 12, padding: '6px 18px', boxShadow: '0 2px 8px #b2d8ea', minWidth: 320, minHeight: 48, width: 420 }}>
70 <div style={{ cursor: 'pointer', marginRight: 16 }} onClick={() => navigate('/user')}>
71 <AccountCircleIcon style={{ fontSize: 38, color: '#1a237e', background: '#e0f3ff', borderRadius: '50%' }} />
72 </div>
73 <div style={{ color: '#222', fontWeight: 500, marginRight: 24 }}>用户栏</div>
74 <div style={{ display: 'flex', gap: 28, flex: 1, justifyContent: 'flex-end', alignItems: 'center' }}>
75 <span style={{ color: '#1976d2', fontWeight: 500 }}>魔力值: <b>12345</b></span>
76 <span style={{ color: '#1976d2', fontWeight: 500 }}>分享率: <b>2.56</b></span>
77 <span style={{ color: '#1976d2', fontWeight: 500 }}>上传量: <b>100GB</b></span>
78 <span style={{ color: '#1976d2', fontWeight: 500 }}>下载量: <b>50GB</b></span>
79 </div>
80 </div>
81 {/* 下方内容整体下移,留出与音乐界面一致的间距 */}
82 <div style={{ height: 32 }} />
83 <nav className="nav-bar">
84 {navItems.map((item) => (
85 <div
86 key={item.label}
87 className={item.label === "动漫" ? "nav-item active" : "nav-item"}
88 onClick={() => navigate(item.path)}
89 >
90 {item.icon}
91 <span>{item.label}</span>
92 </div>
93 ))}
94 </nav>
95 <div className="search-section card">
96 <input className="search-input" placeholder="输入搜索关键词" />
97 <button className="search-btn">
98 <span role="img" aria-label="search">🔍</span>
99 </button>
100 </div>
101 <div className="area-tabs" style={{ display: 'flex', justifyContent: 'center', gap: 24, margin: '18px 0' }}>
102 {areaTabs.map((tab, idx) => (
103 <div
104 key={tab.label}
105 className={activeTab === idx ? "area-tab active" : "area-tab"}
106 onClick={() => setActiveTab(idx)}
107 >
108 {tab.icon} <span>{tab.label}</span>
109 </div>
110 ))}
111 </div>
112 <div className="table-section">
9563036699e95ae32025-06-02 21:42:11 +0800113 <table className="anime-table">
956303669a32fc2c2025-06-02 19:45:53 +0800114 <thead>
115 <tr>
116 <th>动漫类型</th>
117 <th>标题</th>
118 <th>发布者</th>
119 </tr>
120 </thead>
121 <tbody>
rhjc6a4ee02025-06-06 00:45:18 +0800122 {animeList.length > 0 ? (
123 animeList.map((item, index) => (
124 <tr key={item.id || index}>
125 <td>
126 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
127 {item.seedtag}
128 </a>
129 </td>
130 <td>
131 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
132 {item.title}
133 </a>
134 </td>
135 <td>{item.user.username}</td>
136 </tr>
137 ))
138 ) : (
139 animeTypes.map((type, index) => (
140 <tr key={type}>
141 <td>
142 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
143 {type}
144 </a>
145 </td>
146 <td>
147 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
148 种子{index + 1}
149 </a>
150 </td>
151 <td>发布者{index + 1}</td>
152 </tr>
153 ))
154 )}
956303669a32fc2c2025-06-02 19:45:53 +0800155 </tbody>
156 </table>
157 </div>
158 <div style={{ height: 32 }} />
159 <Pagination />
160 </div>
161 );
162}
163
164function Pagination() {
165 const [page, setPage] = React.useState(3);
166 const total = 5;
167 return (
168 <div className="pagination">
169 <button onClick={() => setPage(p => Math.max(1, p - 1))} disabled={page === 1}>上一页</button>
170 <span className="page-num">{page}/{total}</span>
171 <button onClick={() => setPage(p => Math.min(total, p + 1))} disabled={page === total}>下一页</button>
172 <span className="page-info">第 <b>{page}</b> 页</span>
173 </div>
174 );
175}