This commit is contained in:
吴璨
2026-08-04 09:40:15 +08:00
parent 536685e327
commit 839ec8eb2e
8 changed files with 68 additions and 31 deletions
+5 -1
View File
@@ -1,5 +1,6 @@
const { API } = require('./config');
const { fetchJSON } = require('./network');
const { formatPersonNames } = require('./utils');
async function searchSongs(keyword, limit = 10) {
const res = await fetchJSON(`${API.search}?keyword=${encodeURIComponent(keyword)}&limit=${limit}`);
@@ -9,7 +10,10 @@ async function searchSongs(keyword, limit = 10) {
}
const songs = Array.isArray(res.data) ? res.data : (res.data?.songs || []);
if (!songs.length) console.log('❌ 搜索无结果');
return songs;
return songs.map(song => ({
...song,
artists: formatPersonNames(song.artists),
}));
}
async function interactiveSearch(rl, ask) {