feat: 完善剩余功能

This commit is contained in:
ethan.chen
2025-11-05 14:24:15 +08:00
parent f67a3835fa
commit 73945c40e5
8 changed files with 105 additions and 59 deletions

View File

@@ -25,19 +25,13 @@ async function sendControlCommand(action, position = null) {
data: payload
});
if (!response.ok) {
throw new Error(`控制请求失败: ${response.status} ${response.statusText}`);
}
const result = await response.json();
// 检查结果状态如果Apple Music未运行提供明确的错误信息
if (result.status === 'error' && result.message === 'notrunning') {
if (response.status === 'error' && response.message === 'notrunning') {
console.warn('Apple Music未运行无法执行控制命令');
throw new Error('Apple Music未运行请先启动Apple Music应用');
}
return result;
return response;
} catch (error) {
console.error(`${action}控制请求错误:`, error);
throw error;

View File

@@ -50,7 +50,7 @@
>
<div class="result-info">
<div class="track-name">{{ result.name }}</div>
<div class="artist-name">{{ getArtistName(result.artists) }}</div>
<div class="artist-name">{{ result.artist }}</div>
</div>
<div class="result-actions">
<button
@@ -88,10 +88,6 @@ const hasSearched = ref(false);
const selectedIndex = ref(-1);
const searchResults = ref([]);
const getArtistName = (artists) => {
return artists.map(artist => artist.name).join(', ');
};
import request from '../utils/request';
import { useLyricsStore } from '../store';
const lyricsStore = useLyricsStore();
@@ -139,12 +135,12 @@ const returnToSearch = () => {
const selectResult = (index) => {
request({
url: '/lyrics/getLyricsFromId',
url: '/lyrics/save',
method: 'POST',
data: {
id: searchResults.value[index].id,
track_name: lyricsStore.trackName,
artist: lyricsStore.artist
artist: lyricsStore.artist,
lyrics: searchResults.value[index].lyrics
}
});
};
@@ -312,7 +308,7 @@ h2 {
height: 40px;
border-radius: 6px;
white-space: nowrap;
}
}
.results-list {
display: flex;