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