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