mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-18 19:47:29 +08:00
feat: 优化音源逻辑
This commit is contained in:
@@ -146,6 +146,7 @@ const getUnblockMusicAudio = (id: number, data: SongResult, sources: any[]) => {
|
|||||||
* @returns 解析结果
|
* @returns 解析结果
|
||||||
*/
|
*/
|
||||||
export const getParsingMusicUrl = async (id: number, data: SongResult) => {
|
export const getParsingMusicUrl = async (id: number, data: SongResult) => {
|
||||||
|
if(isElectron){
|
||||||
const settingStore = useSettingsStore();
|
const settingStore = useSettingsStore();
|
||||||
|
|
||||||
// 如果禁用了音乐解析功能,则直接返回空结果
|
// 如果禁用了音乐解析功能,则直接返回空结果
|
||||||
@@ -167,7 +168,7 @@ export const getParsingMusicUrl = async (id: number, data: SongResult) => {
|
|||||||
// 使用全局音源设置
|
// 使用全局音源设置
|
||||||
musicSources = settingStore.setData.enabledMusicSources || [];
|
musicSources = settingStore.setData.enabledMusicSources || [];
|
||||||
console.log(`使用全局音源设置:`, musicSources);
|
console.log(`使用全局音源设置:`, musicSources);
|
||||||
if (isElectron && musicSources.length > 0) {
|
if (musicSources.length > 0) {
|
||||||
return getUnblockMusicAudio(id, data, musicSources);
|
return getUnblockMusicAudio(id, data, musicSources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,9 +193,10 @@ export const getParsingMusicUrl = async (id: number, data: SongResult) => {
|
|||||||
}
|
}
|
||||||
console.log('musicSources', musicSources);
|
console.log('musicSources', musicSources);
|
||||||
// 2.3 使用unblockMusic解析其他音源
|
// 2.3 使用unblockMusic解析其他音源
|
||||||
if (isElectron && musicSources.length > 0) {
|
if (musicSources.length > 0) {
|
||||||
return getUnblockMusicAudio(id, data, musicSources);
|
return getUnblockMusicAudio(id, data, musicSources);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 后备方案:使用API请求
|
// 3. 后备方案:使用API请求
|
||||||
console.log('无可用音源或不在Electron环境中,使用API请求');
|
console.log('无可用音源或不在Electron环境中,使用API请求');
|
||||||
|
|||||||
Reference in New Issue
Block a user