blob: faef3bd768b05ecbcb465076bb9556429f351d2f [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";
2230113338fd3882025-06-06 23:33:57 +080010import ForumIcon from "@mui/icons-material/Forum";
956303669a32fc2c2025-06-02 19:45:53 +080011import { useNavigate } from "react-router-dom";
12import "./App.css";
223011330f9623f2025-06-06 00:22:05 +080013import { API_BASE_URL } from "./config";
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 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" /> },
rhjc6a4ee02025-06-06 00:45:18 +080032 // { label: "其他", icon: <PersonIcon fontSize="small" /> },
956303669a32fc2c2025-06-02 19:45:53 +080033];
34
9563036699e95ae32025-06-02 21:42:11 +080035const exampleTorrents = [
36 { type: "Action", title: "实例1", id: 1 },
37 { type: "Drama", title: "实例2", id: 2 },
38 { type: "Comedy", title: "实例3", id: 3 },
39];
40
956303669a32fc2c2025-06-02 19:45:53 +080041export default function MoviePage() {
42 const navigate = useNavigate();
43 const [activeTab, setActiveTab] = React.useState(0);
rhjc6a4ee02025-06-06 00:45:18 +080044 const [movieList, setMovieList] = React.useState([]);
956303669a32fc2c2025-06-02 19:45:53 +080045
46 // 每个tab对应的电影类型
47 const movieTypesList = [
48 ["华语电影(大陆)", "欧美电影", "日韩电影", "港台电影", "其他"], // 大陆
49 ["港台动作", "港台爱情", "港台喜剧", "港台其他"], // 港台
50 ["欧美动作", "欧美科幻", "欧美剧情", "欧美其他"], // 欧美
51 ["日韩动画", "日韩爱情", "日韩其他"], // 日韩
52 ["其他类型1", "其他类型2"] // 其他
53 ];
54 const movieTypes = movieTypesList[activeTab] || [];
55
rhjc6a4ee02025-06-06 00:45:18 +080056 React.useEffect(() => {
57 // 这里假设后端接口为 /api/get-seed-list-by-tag?tag=大陆
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 => {
62 console.log('电影区返回数据:', data);
63 setMovieList(data);
64 })
65 .catch(() => setMovieList([]));
66 }, [activeTab]);
67
956303669a32fc2c2025-06-02 19:45:53 +080068 return (
69 <div className="container">
70 {/* 顶部空白与音乐界面一致,用户栏绝对定位在页面右上角 */}
71 <div style={{ height: 80 }} />
72 <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 }}>
73 <div style={{ cursor: 'pointer', marginRight: 16 }} onClick={() => navigate('/user')}>
74 <AccountCircleIcon style={{ fontSize: 38, color: '#1a237e', background: '#e0f3ff', borderRadius: '50%' }} />
75 </div>
76 <div style={{ color: '#222', fontWeight: 500, marginRight: 24 }}>用户栏</div>
77 <div style={{ display: 'flex', gap: 28, flex: 1, justifyContent: 'flex-end', alignItems: 'center' }}>
78 <span style={{ color: '#1976d2', fontWeight: 500 }}>魔力值: <b>12345</b></span>
79 <span style={{ color: '#1976d2', fontWeight: 500 }}>分享率: <b>2.56</b></span>
80 <span style={{ color: '#1976d2', fontWeight: 500 }}>上传量: <b>100GB</b></span>
81 <span style={{ color: '#1976d2', fontWeight: 500 }}>下载量: <b>50GB</b></span>
82 </div>
83 </div>
84 {/* 下方内容整体下移,留出与音乐界面一致的间距 */}
85 <div style={{ height: 32 }} />
86 <nav className="nav-bar card">
87 {navItems.map((item) => (
88 <div
89 key={item.label}
90 className={item.label === "电影" ? "nav-item active" : "nav-item"}
91 onClick={() => navigate(item.path)}
92 >
93 {item.icon}
94 <span>{item.label}</span>
95 </div>
96 ))}
97 </nav>
98 <div className="search-section card">
99 <input className="search-input" placeholder="输入搜索关键词" />
100 <button className="search-btn">
101 <span role="img" aria-label="search">🔍</span>
102 </button>
103 </div>
104 <div className="area-tabs" style={{ display: 'flex', justifyContent: 'center', gap: 24, margin: '18px 0' }}>
105 {areaTabs.map((tab, idx) => (
106 <div
107 key={tab.label}
108 className={activeTab === idx ? "area-tab active" : "area-tab"}
109 onClick={() => setActiveTab(idx)}
110 >
111 {tab.icon} <span>{tab.label}</span>
112 </div>
113 ))}
114 </div>
115 <div className="table-section">
116 <table className="movie-table">
117 <thead>
118 <tr>
119 <th>电影类型</th>
120 <th>标题</th>
121 <th>发布者</th>
122 </tr>
123 </thead>
124 <tbody>
rhjc6a4ee02025-06-06 00:45:18 +0800125 {movieList.length > 0 ? (
126 movieList.map((item, index) => (
127 <tr key={item.id || index}>
128 <td>
129 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
130 {item.seedtag}
131 </a>
132 </td>
133 <td>
134 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
135 {item.title}
136 </a>
137 </td>
138 <td>{item.user.username}</td>
139 </tr>
140 ))
141 ) : (
142 movieTypes.map((type, index) => (
143 <tr key={type}>
144 <td>
145 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
146 {type}
147 </a>
148 </td>
149 <td>
150 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
151 种子{index + 1}
152 </a>
153 </td>
154 <td>发布者{index + 1}</td>
155 </tr>
156 ))
157 )}
956303669a32fc2c2025-06-02 19:45:53 +0800158 </tbody>
159 </table>
160 </div>
161 <div style={{ height: 32 }} />
162 <Pagination />
163 </div>
164 );
165}
166
167function Pagination() {
168 const [page, setPage] = React.useState(3);
169 const total = 5;
170 return (
171 <div className="pagination">
172 <button onClick={() => setPage(p => Math.max(1, p - 1))} disabled={page === 1}>上一页</button>
173 <span className="page-num">{page}/{total}</span>
174 <button onClick={() => setPage(p => Math.min(total, p + 1))} disabled={page === total}>下一页</button>
175 <span className="page-info">第 <b>{page}</b> 页</span>
176 </div>
177 );
178}