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