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