blob: c84797b7b9ef292952f16386a431f9d7fb57d296 [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 { useNavigate } from "react-router-dom";
11import "./App.css";
12
13const navItems = [
14 { label: "电影", icon: <MovieIcon />, path: "/movie" },
15 { label: "剧集", icon: <EmailIcon />, path: "/tv" },
16 { label: "音乐", icon: <MusicNoteIcon />, path: "/music" },
17 { label: "动漫", icon: <EmojiPeopleIcon />, path: "/anime" },
18 { label: "游戏", icon: <SportsEsportsIcon />, path: "/game" },
19 { label: "体育", icon: <SportsMartialArtsIcon />, path: "/sport" },
20 { label: "资料", icon: <PersonIcon />, path: "/info" },
9563036699e95ae32025-06-02 21:42:11 +080021 { label: "发布", icon: <AccountCircleIcon />, path: "/publish" }, // Added Publish option
956303669a32fc2c2025-06-02 19:45:53 +080022];
23
24const areaTabs = [
25 { label: "大陆", icon: <MovieIcon fontSize="small" /> },
26 { label: "港台", icon: <EmailIcon fontSize="small" /> },
27 { label: "欧美", icon: <PersonIcon fontSize="small" /> },
28 { label: "日韩", icon: <EmojiPeopleIcon fontSize="small" /> },
rhjc6a4ee02025-06-06 00:45:18 +080029 // { label: "其他", icon: <PersonIcon fontSize="small" /> },
956303669a32fc2c2025-06-02 19:45:53 +080030];
31
9563036699e95ae32025-06-02 21:42:11 +080032const exampleTorrents = [
33 { type: "Action", title: "实例1", id: 1 },
34 { type: "Drama", title: "实例2", id: 2 },
35 { type: "Comedy", title: "实例3", id: 3 },
36];
37
956303669a32fc2c2025-06-02 19:45:53 +080038export default function MoviePage() {
39 const navigate = useNavigate();
40 const [activeTab, setActiveTab] = React.useState(0);
rhjc6a4ee02025-06-06 00:45:18 +080041 const [movieList, setMovieList] = React.useState([]);
956303669a32fc2c2025-06-02 19:45:53 +080042
43 // 每个tab对应的电影类型
44 const movieTypesList = [
45 ["华语电影(大陆)", "欧美电影", "日韩电影", "港台电影", "其他"], // 大陆
46 ["港台动作", "港台爱情", "港台喜剧", "港台其他"], // 港台
47 ["欧美动作", "欧美科幻", "欧美剧情", "欧美其他"], // 欧美
48 ["日韩动画", "日韩爱情", "日韩其他"], // 日韩
49 ["其他类型1", "其他类型2"] // 其他
50 ];
51 const movieTypes = movieTypesList[activeTab] || [];
52
rhjc6a4ee02025-06-06 00:45:18 +080053 React.useEffect(() => {
54 // 这里假设后端接口为 /api/get-seed-list-by-tag?tag=大陆
55 const area = areaTabs[activeTab].label;
56 fetch(`http://192.168.5.9:8080/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
57 .then(res => res.json())
58 .then(data => {
59 console.log('电影区返回数据:', data);
60 setMovieList(data);
61 })
62 .catch(() => setMovieList([]));
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 card">
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">
113 <table className="movie-table">
114 <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 {movieList.length > 0 ? (
123 movieList.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 movieTypes.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}