新增基于lxserver的音乐功能

This commit is contained in:
mtvpls
2026-04-13 23:17:57 +08:00
parent 7469cc1537
commit c82d7b3841
30 changed files with 2740 additions and 546 deletions
+9 -10
View File
@@ -9,7 +9,7 @@ interface Song {
artist: string;
album?: string;
pic?: string;
platform: 'netease' | 'qq' | 'kuwo';
platform: 'wy' | 'tx' | 'kw' | 'kg' | 'mg';
duration?: number;
}
@@ -56,10 +56,10 @@ export default function AddToPlaylistModal({
const loadPlaylists = async () => {
try {
setLoading(true);
const response = await fetch('/api/music/playlists');
const response = await fetch('/api/music/v2/playlists');
if (response.ok) {
const data = await response.json();
setPlaylists(data.playlists || []);
setPlaylists(data.data?.playlists || []);
}
} catch (error) {
console.error('加载歌单失败:', error);
@@ -76,7 +76,7 @@ export default function AddToPlaylistModal({
try {
setCreating(true);
const response = await fetch('/api/music/playlists', {
const response = await fetch('/api/music/v2/playlists', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -107,19 +107,18 @@ export default function AddToPlaylistModal({
try {
setAddingToPlaylistId(playlistId);
const response = await fetch('/api/music/playlists/songs', {
const response = await fetch(`/api/music/v2/playlists/${playlistId}/songs`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
playlistId,
song: {
platform: song.platform,
id: song.id,
source: song.platform,
songId: song.id,
name: song.name,
artist: song.artist,
album: song.album,
pic: song.pic,
duration: song.duration || 0,
cover: song.pic,
durationSec: song.duration || 0,
},
}),
});
+20 -3
View File
@@ -10,12 +10,13 @@ interface Song {
artist: string;
album?: string;
pic?: string;
platform: 'netease' | 'qq' | 'kuwo';
platform: 'wy' | 'tx' | 'kw' | 'kg' | 'mg';
}
interface LyricLine {
time: number;
text: string;
translation?: string;
}
interface LyricsPiPWindowProps {
@@ -187,7 +188,11 @@ const PiPLyricsContent = ({
}}
>
{lyrics.length > 0 && currentLyricIndex >= 0
? lyrics[currentLyricIndex]?.text || '♪'
? (
lyrics[currentLyricIndex]?.translation
? `${lyrics[currentLyricIndex]?.text || '♪'}\n${lyrics[currentLyricIndex]?.translation}`
: lyrics[currentLyricIndex]?.text || '♪'
)
: currentSong
? '暂无歌词'
: '请播放歌曲'}
@@ -220,7 +225,19 @@ const PiPLyricsContent = ({
fontWeight: index === currentLyricIndex ? 'bold' : 'normal',
}}
>
{line.text}
<div>{line.text}</div>
{line.translation && (
<div
style={{
marginTop: '4px',
fontSize: index === currentLyricIndex ? '13px' : '12px',
opacity: index === currentLyricIndex ? 0.85 : 0.55,
fontWeight: 'normal',
}}
>
{line.translation}
</div>
)}
</div>
))
) : (