blob: fb03fe15aa591cd57484f8e5c64ce1289b3de838 [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 "./App.css";
11import { useNavigate } from "react-router-dom";
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 = [
rhjc6a4ee02025-06-06 00:45:18 +080026 { label: "古典音乐", icon: <MovieIcon fontSize="small" /> },
27 { label: "流行音乐", icon: <EmailIcon fontSize="small" /> },
28 { label: "摇滚", icon: <PersonIcon fontSize="small" /> },
29 { label: "电子音乐", icon: <EmojiPeopleIcon fontSize="small" /> },
30 { label: "说唱", icon: <PersonIcon fontSize="small" /> },
956303669a32fc2c2025-06-02 19:45:53 +080031];
32
9563036699e95ae32025-06-02 21:42:11 +080033const exampleTorrents = [
34 { type: "Pop", title: "实例1", id: 1 },
35 { type: "Rock", title: "实例2", id: 2 },
36 { type: "Jazz", title: "实例3", id: 3 },
37];
38
956303669a32fc2c2025-06-02 19:45:53 +080039export default function MusicPage() {
40 const navigate = useNavigate();
41 const [activeTab, setActiveTab] = React.useState(0);
rhjc6a4ee02025-06-06 00:45:18 +080042 const [musicList, setMusicList] = React.useState([]);
956303669a32fc2c2025-06-02 19:45:53 +080043
44 // 每个tab对应的音乐类型
45 const musicTypesList = [
46 ["华语音乐(大陆)", "欧美音乐", "日韩音乐", "港台音乐", "其他"], // 大陆
47 ["港台流行", "港台摇滚", "港台其他"], // 港台
48 ["欧美流行", "欧美摇滚", "欧美其他"], // 欧美
49 ["日韩流行", "日韩其他"], // 日韩
50 ["其他类型1", "其他类型2"] // 其他
51 ];
52 const musicTypes = musicTypesList[activeTab] || [];
53
rhjc6a4ee02025-06-06 00:45:18 +080054 React.useEffect(() => {
55 // 假设后端接口为 /api/musics?area=大陆
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 => setMusicList(data))
60 .catch(() => setMusicList([]));
61 }, [activeTab]);
62
956303669a32fc2c2025-06-02 19:45:53 +080063 return (
64 <div className="container music-bg">
65 {/* 顶部空白与音乐界面一致,用户栏绝对定位在页面右上角 */}
66 <div style={{ height: 80 }} />
67 <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 }}>
68 <div style={{ cursor: 'pointer', marginRight: 16 }} onClick={() => navigate('/user')}>
69 <AccountCircleIcon style={{ fontSize: 38, color: '#1a237e', background: '#e0f3ff', borderRadius: '50%' }} />
70 </div>
71 <div style={{ color: '#222', fontWeight: 500, marginRight: 24 }}>用户栏</div>
72 <div style={{ display: 'flex', gap: 28, flex: 1, justifyContent: 'flex-end', alignItems: 'center' }}>
73 <span style={{ color: '#1976d2', fontWeight: 500 }}>魔力值: <b>12345</b></span>
74 <span style={{ color: '#1976d2', fontWeight: 500 }}>分享率: <b>2.56</b></span>
75 <span style={{ color: '#1976d2', fontWeight: 500 }}>上传量: <b>100GB</b></span>
76 <span style={{ color: '#1976d2', fontWeight: 500 }}>下载量: <b>50GB</b></span>
77 </div>
78 </div>
79 {/* 下方内容整体下移,留出与其他页面一致的间距 */}
80 <div style={{ height: 32 }} />
81 <nav className="nav-bar card">
82 {navItems.map((item) => (
83 <div
84 key={item.label}
85 className={item.label === "音乐" ? "nav-item active" : "nav-item"}
86 onClick={() => navigate(item.path)}
87 >
88 {item.icon}
89 <span>{item.label}</span>
90 </div>
91 ))}
92 </nav>
93 <div className="search-section card">
94 <input className="search-input" placeholder="输入搜索关键词" />
95 <button className="search-btn">
96 <span role="img" aria-label="search">🔍</span>
97 </button>
98 </div>
99 <div className="area-tabs card" style={{ display: 'flex', justifyContent: 'center', gap: 24, margin: '18px 0' }}>
100 {areaTabs.map((tab, idx) => (
101 <div
102 key={tab.label}
103 className={activeTab === idx ? "area-tab active" : "area-tab"}
104 onClick={() => setActiveTab(idx)}
105 >
106 {tab.icon} <span>{tab.label}</span>
107 </div>
108 ))}
109 </div>
9563036699e95ae32025-06-02 21:42:11 +0800110 <div className="table-section">
111 <table className="music-table">
956303669a32fc2c2025-06-02 19:45:53 +0800112 <thead>
113 <tr>
114 <th>音乐类型</th>
115 <th>标题</th>
116 <th>发布者</th>
117 </tr>
118 </thead>
119 <tbody>
rhjc6a4ee02025-06-06 00:45:18 +0800120 {musicList.length > 0 ? (
121 musicList.map((item, index) => (
122 <tr key={item.id || index}>
123 <td>
124 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
125 {item.seedtag}
126 </a>
127 </td>
128 <td>
129 <a href={`/torrent/${item.seedid}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
130 {item.title}
131 </a>
132 </td>
133 <td>{item.user.username}</td>
134 </tr>
135 ))
136 ) : (
137 musicTypes.map((type, index) => (
138 <tr key={type}>
139 <td>
140 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
141 {type}
142 </a>
143 </td>
144 <td>
145 <a href={`/torrent/${type}`} style={{ color: '#1a237e', textDecoration: 'none' }}>
146 种子{index + 1}
147 </a>
148 </td>
149 <td>发布者{index + 1}</td>
150 </tr>
151 ))
152 )}
956303669a32fc2c2025-06-02 19:45:53 +0800153 </tbody>
154 </table>
155 </div>
156 <div style={{ height: 32 }} />
157 <Pagination />
158 </div>
159 );
160}
161
162function Pagination() {
163 const [page, setPage] = React.useState(3);
164 const total = 5;
165 return (
166 <div className="pagination">
167 <button onClick={() => setPage(p => Math.max(1, p - 1))} disabled={page === 1}>上一页</button>
168 <span className="page-num">{page}/{total}</span>
169 <button onClick={() => setPage(p => Math.min(total, p + 1))} disabled={page === total}>下一页</button>
170 <span className="page-info">第 <b>{page}</b> 页</span>
171 </div>
172 );
173}