mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-15 00:27:32 +08:00
refactor: 更新 eslint 和 prettier 配置 格式化代码
This commit is contained in:
+11
-12
@@ -45,33 +45,33 @@ function ensureDataStructure(data: any): any {
|
||||
album: { name: '' }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 确保name字段存在
|
||||
if (data.name === undefined || data.name === null) {
|
||||
data.name = '';
|
||||
}
|
||||
|
||||
|
||||
// 确保artists字段存在且为数组
|
||||
if (!data.artists || !Array.isArray(data.artists)) {
|
||||
data.artists = data.ar && Array.isArray(data.ar) ? data.ar : [];
|
||||
}
|
||||
|
||||
|
||||
// 确保artists中的每个元素都有name属性
|
||||
if (data.artists.length > 0) {
|
||||
data.artists = data.artists.map(artist => {
|
||||
data.artists = data.artists.map((artist) => {
|
||||
return artist ? { name: artist.name || '' } : { name: '' };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 确保album对象存在并有name属性
|
||||
if (!data.album || typeof data.album !== 'object') {
|
||||
data.album = data.al && typeof data.al === 'object' ? data.al : { name: '' };
|
||||
}
|
||||
|
||||
|
||||
if (!data.album.name) {
|
||||
data.album.name = '';
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -89,15 +89,14 @@ const unblockMusic = async (
|
||||
retryCount = 1,
|
||||
enabledPlatforms?: Platform[]
|
||||
): Promise<UnblockResult> => {
|
||||
|
||||
// 过滤 enabledPlatforms,确保只包含 ALL_PLATFORMS 中存在的平台
|
||||
const filteredPlatforms = enabledPlatforms
|
||||
? enabledPlatforms.filter(platform => ALL_PLATFORMS.includes(platform))
|
||||
const filteredPlatforms = enabledPlatforms
|
||||
? enabledPlatforms.filter((platform) => ALL_PLATFORMS.includes(platform))
|
||||
: ALL_PLATFORMS;
|
||||
|
||||
|
||||
// 处理歌曲数据,确保数据结构完整
|
||||
const processedSongData = ensureDataStructure(songData);
|
||||
|
||||
|
||||
const retry = async (attempt: number): Promise<UnblockResult> => {
|
||||
try {
|
||||
const data = await match(parseInt(String(id), 10), filteredPlatforms, processedSongData);
|
||||
|
||||
Reference in New Issue
Block a user