fix: search results use pic/mPic/sPic/qualities (QZv2 format) instead of img/types/_types

This commit is contained in:
TRAE Bot
2026-07-05 11:55:58 +00:00
parent df3c6aee0e
commit aa5eeb09e7
6 changed files with 103 additions and 97 deletions

View File

@@ -83,23 +83,24 @@ function fetchAllGitMusic() {
}
function formatGitItem(item) {
var types = [];
var _types = {};
var qualities = {};
var fmt = (item.format || '').toLowerCase();
if (fmt === 'flac') { types.push({ type: 'flac', size: item.filesize || '' }); _types.flac = { size: item.filesize || '' }; }
else if (fmt === 'mp3') { types.push({ type: '320k', size: item.filesize || '' }); _types['320k'] = { size: item.filesize || '' }; }
else { types.push({ type: '128k', size: item.filesize || '' }); _types['128k'] = { size: item.filesize || '' }; }
if (fmt === 'flac' && item.filesize) qualities.lossless = String(item.filesize);
else if (fmt === 'mp3' && item.filesize) qualities.exhigh = String(item.filesize);
else if (item.filesize) qualities.standard = String(item.filesize);
var picUrl = item.img || '';
return {
artists: item.artist || '未知歌手',
id: item.relative_path || '',
name: item.title || item.filename || '',
artists: item.artist || '未知歌手',
source: 'git',
pic: picUrl,
mPic: picUrl,
sPic: picUrl,
albumName: item.album || '未知专辑',
albumId: '',
id: item.relative_path || '',
source: 'git',
interval: '',
img: item.img || '',
lrc: item.lyrics || null,
types: types, _types: _types, typeUrl: {},
qualities: qualities,
_gitcodeData: item
};
}
@@ -152,13 +153,13 @@ function getUrl(songInfo, type) {
// ===== 封面图 =====
function getPic(songInfo) {
if (songInfo.img) return Promise.resolve(songInfo.img);
if (songInfo.pic) return Promise.resolve(songInfo.pic);
return Promise.resolve('');
}
// ===== 歌词 =====
function getLyric(songInfo) {
if (songInfo.lrc) return Promise.resolve(songInfo.lrc);
if (songInfo._gitcodeData && songInfo._gitcodeData.lyrics) return Promise.resolve(songInfo._gitcodeData.lyrics);
return Promise.resolve('');
}