feat: 歌曲下载内置封面歌词歌曲信息等,添加无限制下载功能,优化下载管理,支持清空下载记录

This commit is contained in:
alger
2025-04-10 00:26:58 +08:00
parent 5f4b53c167
commit 3b1488f147
14 changed files with 370 additions and 34 deletions
+13 -2
View File
@@ -95,6 +95,7 @@ import { getSongUrl } from '@/hooks/MusicListHook';
import { useArtist } from '@/hooks/useArtist';
import { audioService } from '@/services/audioService';
import { usePlayerStore } from '@/store';
import { useSettingsStore } from '@/store/modules/settings';
import type { SongResult } from '@/type/music';
import { getImgUrl, isElectron } from '@/utils';
import { getImageBackground } from '@/utils/linearColor';
@@ -285,7 +286,14 @@ const downloadMusic = async () => {
try {
isDownloading.value = true;
const data = (await getSongUrl(props.item.id as number, cloneDeep(props.item), true)) as any;
const settingsStore = useSettingsStore();
const { unlimitedDownload } = settingsStore.setData;
const data = (await getSongUrl(
props.item.id as number,
cloneDeep(props.item),
unlimitedDownload
)) as any;
if (!data || !data.url) {
throw new Error(t('songItem.message.getUrlFailed'));
}
@@ -293,14 +301,17 @@ const downloadMusic = async () => {
// 构建文件名
const artistNames = (props.item.ar || props.item.song?.artists)?.map((a) => a.name).join(',');
const filename = `${props.item.name} - ${artistNames}`;
console.log('props.item', props.item);
const songData = cloneDeep(props.item);
songData.ar = songData.ar || songData.song?.artists;
// 发送下载请求
window.electron.ipcRenderer.send('download-music', {
url: data.url,
type: data.type,
filename,
songInfo: {
...cloneDeep(props.item),
...songData,
downloadTime: Date.now()
}
});