blob: 216dfcc724cb7d875a7bffe877d05666a91b2790 [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
rhjc6a4ee02025-06-06 00:45:18 +080025const tvTypesList = [
26 ["华语剧集(大陆)", "欧美剧集", "日韩剧集", "港台剧集", "其他"], // 大陆
27 ["港台都市", "港台爱情", "港台悬疑", "港台其他"], // 港台
28 ["欧美悬疑", "欧美历史", "欧美其他"], // 欧美
29 ["日韩青春", "日韩家庭", "日韩其他"], // 日韩
30 ["其他类型1", "其他类型2"] // 其他
956303669a32fc2c2025-06-02 19:45:53 +080031];
32
33const areaTabs = [
rhjc6a4ee02025-06-06 00:45:18 +080034 { label: "国产电视剧", icon: <MovieIcon 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" /> },
9563036699e95ae32025-06-02 21:42:11 +080039];
40
956303669a32fc2c2025-06-02 19:45:53 +080041export default function TVPage() {
42 const navigate = useNavigate();
43 const [activeTab, setActiveTab] = React.useState(0);
rhjc6a4ee02025-06-06 00:45:18 +080044 const [tvList, setTvList] = React.useState([]);
45
46 React.useEffect(() => {
47 // 假设后端接口为 /api/tvs?area=大陆
48 const area = areaTabs[activeTab].label;
223011330f9623f2025-06-06 00:22:05 +080049 fetch(`${API_BASE_URL}/api/get-seed-list-by-tag?tag=${encodeURIComponent(area)}`)
rhjc6a4ee02025-06-06 00:45:18 +080050 .then(res => res.json())
51 .then(data => setTvList(data))
52 .catch(() => setTvList([]));
53 }, [activeTab]);
956303669a32fc2c2025-06-02 19:45:53 +080054
55 // 每个tab对应的剧集类型
956303669a32fc2c2025-06-02 19:45:53 +080056 const tvTypes = tvTypesList[activeTab] || [];
57
58 return (
59 <div className="container">
60 {/* 顶部空白与音乐界面一致,用户栏绝对定位在页面右上角 */}
61 <div style={{ height: 80 }} />
62 <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 }}>
63 <div style={{ cursor: 'pointer', marginRight: 16 }} onClick={() => navigate('/user')}>
64 <AccountCircleIcon style={{ fontSize: 38, color: '#1a237e', background: '#e0f3ff', borderRadius: '50%' }} />
65 </div>
66 <div style={{ color: '#222', fontWeight: 500, marginRight: 24 }}>用户栏</div>
67 <div style={{ display: 'flex', gap: 28, flex: 1, justifyContent: 'flex-end', alignItems: 'center' }}>
68 <span style={{ color: '#1976d2', fontWeight: 500 }}>魔力值: <b>12345</b></span>
69 <span style={{ color: '#1976d2', fontWeight: 500 }}>分享率: <b>2.56</b></span>
70 <span style={{ color: '#1976d2', fontWeight: 500 }}>上传量: <b>100GB</b></span>
71 <span style={{ color: '#1976d2', fontWeight: 500 }}>下载量: <b>50GB</b></span>
72 </div>
73 </div>
74 {/* 下方内容整体下移,留出与音乐界面一致的间距 */}
75 <div style={{ height: 32 }} />
76 <nav className="nav-bar card">
77 {navItems.map((item) => (
78 <div
79 key={item.label}
80 className={item.label === "剧集" ? "nav-item active" : "nav-item"}
81 onClick={() => navigate(item.path)}
82 >
83 {item.icon}
84 <span>{item.label}</span>
85 </div>
86 ))}
87 </nav>
88 <div className="search-section card">
89 <input className="search-input" placeholder="输入搜索关键词" />
90 <button className="search-btn">
91 <span role="img" aria-label="search">🔍</span>
92 </button>
93 </div>
94 <div className="area-tabs" style={{ display: 'flex', justifyContent: 'center', gap: 24, margin: '18px 0' }}>
95 {areaTabs.map((tab, idx) => (
96 <div
97 key={tab.label}
98 className={activeTab === idx ? "area-tab active" : "area-tab"}
99 onClick={() => setActiveTab(idx)}
100 >
101 {tab.icon} <span>{tab.label}</span>
102 </div>
103 ))}
104 </div>
105 <div className="table-section">
106 <table className="movie-table">
107 <thead>
108 <tr>
109 <th>剧集类型</th>
110 <th>标题</th>
111 <th>发布者</th>
112 </tr>
113 </thead>
114 <tbody>
rhjc6a4ee02025-06-06 00:45:18 +0800115 {tvList.length > 0 ? (
116 tvList.map((item, index) => (
117 <tr key={item.id || index}>
118 <td>
119 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
120 {item.seedtag}
121 </a>
122 </td>
123 <td>
124 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
125 {item.title}
126 </a>
127 </td>
128 <td>{item.user.username}</td>
129 </tr>
130 ))
131 ) : (
132 tvTypes.map((type, index) => (
133 <tr key={type}>
134 <td>
135 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
136 {type}
137 </a>
138 </td>
139 <td>
140 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
141 种子{index + 1}
142 </a>
143 </td>
144 <td>发布者{index + 1}</td>
145 </tr>
146 ))
147 )}
956303669a32fc2c2025-06-02 19:45:53 +0800148 </tbody>
149 </table>
150 </div>
151 <div style={{ height: 32 }} />
152 <Pagination />
153 </div>
154 );
155}
156
157function Pagination() {
158 const [page, setPage] = React.useState(3);
159 const total = 5;
160 return (
161 <div className="pagination">
162 <button onClick={() => setPage(p => Math.max(1, p - 1))} disabled={page === 1}>上一页</button>
163 <span className="page-num">{page}/{total}</span>
164 <button onClick={() => setPage(p => Math.min(total, p + 1))} disabled={page === total}>下一页</button>
165 <span className="page-info">第 <b>{page}</b> 页</span>
166 </div>
167 );
168}