现在如果在设置或者启动参数配置了代理服务,那么应用内的图片、音频加载,歌曲下载也将走代理
This commit is contained in:
@@ -15,6 +15,7 @@ import { qualityList } from '..'
|
||||
import { proxyCallback } from '@renderer/worker/utils'
|
||||
import { arrPush, arrUnshift, joinPath } from '@renderer/utils'
|
||||
import { DOWNLOAD_STATUS } from '@common/constants'
|
||||
import { proxy } from '../index'
|
||||
|
||||
const waitingUpdateTasks = new Map<string, LX.Download.ListItem>()
|
||||
let timer: NodeJS.Timeout | null = null
|
||||
@@ -131,6 +132,15 @@ const setStatus = (downloadInfo: LX.Download.ListItem, status: LX.Download.Downl
|
||||
// 修复 1.1.x版本 酷狗源歌词格式
|
||||
const fixKgLyric = (lrc: string) => /\[00:\d\d:\d\d.\d+\]/.test(lrc) ? lrc.replace(/(?:\[00:(\d\d:\d\d.\d+\]))/gm, '[$1') : lrc
|
||||
|
||||
const getProxy = () => {
|
||||
return proxy.enable && proxy.host ? {
|
||||
host: proxy.host,
|
||||
port: parseInt(proxy.port || '80'),
|
||||
} : proxy.envProxy ? {
|
||||
host: proxy.envProxy.host,
|
||||
port: parseInt(proxy.envProxy.port || '80'),
|
||||
} : undefined
|
||||
}
|
||||
/**
|
||||
* 设置歌曲meta信息
|
||||
* @param downloadInfo 下载任务信息
|
||||
@@ -170,7 +180,7 @@ const saveMeta = (downloadInfo: LX.Download.ListItem) => {
|
||||
artist: downloadInfo.metadata.musicInfo.singer,
|
||||
album: downloadInfo.metadata.musicInfo.meta.albumName,
|
||||
APIC: imgUrl,
|
||||
}, lrcData)
|
||||
}, lrcData, getProxy())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -282,7 +292,7 @@ const handleStartTask = async(downloadInfo: LX.Download.ListItem) => {
|
||||
default:
|
||||
break
|
||||
}
|
||||
}))
|
||||
}), getProxy())
|
||||
}
|
||||
const startTask = async(downloadInfo: LX.Download.ListItem) => {
|
||||
setStatus(downloadInfo, DOWNLOAD_STATUS.RUN)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { setMeta } from '@common/utils/musicMeta'
|
||||
import { mergeLyrics } from './lrcTool'
|
||||
|
||||
export const writeMeta = (filePath: string, meta: Omit<LX.Music.MusicFileMeta, 'lyrics'>, lyricData: { lrc: string, tlrc: string | null, rlrc: string | null }) => {
|
||||
setMeta(filePath, { ...meta, lyrics: mergeLyrics(lyricData.lrc, lyricData.tlrc, lyricData.rlrc) || null })
|
||||
export const writeMeta = (filePath: string, meta: Omit<LX.Music.MusicFileMeta, 'lyrics'>, lyricData: { lrc: string, tlrc: string | null, rlrc: string | null }, proxy?: { host: string, port: number }) => {
|
||||
setMeta(filePath, { ...meta, lyrics: mergeLyrics(lyricData.lrc, lyricData.tlrc, lyricData.rlrc) || null }, proxy)
|
||||
}
|
||||
|
||||
export { saveLrc } from './utils'
|
||||
|
||||
@@ -55,7 +55,7 @@ export const createDownloadTasks = (
|
||||
// }
|
||||
}
|
||||
|
||||
const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, skipExistFile: boolean) => {
|
||||
const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, skipExistFile: boolean, proxy?: { host: string, port: number }) => {
|
||||
// console.log('createTask', downloadInfo, savePath)
|
||||
// 开始任务
|
||||
/* commit('onStart', downloadInfo)
|
||||
@@ -103,6 +103,7 @@ const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, s
|
||||
path: savePath,
|
||||
fileName: downloadInfo.metadata.fileName,
|
||||
method: 'get',
|
||||
proxy,
|
||||
onCompleted() {
|
||||
// if (downloadInfo.progress.progress != '100.00') {
|
||||
// delete.get(downloadInfo.id)?
|
||||
@@ -241,7 +242,7 @@ export const updateUrl = (id: string, url: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const startTask = async(downloadInfo: LX.Download.ListItem, savePath: string, skipExistFile: boolean, callback: (action: LX.Download.DownloadTaskActions) => void) => {
|
||||
export const startTask = async(downloadInfo: LX.Download.ListItem, savePath: string, skipExistFile: boolean, callback: (action: LX.Download.DownloadTaskActions) => void, proxy?: { host: string, port: number }) => {
|
||||
await pauseTask(downloadInfo.id)
|
||||
|
||||
tasks.set(downloadInfo.id, downloadInfo)
|
||||
@@ -276,7 +277,7 @@ export const startTask = async(downloadInfo: LX.Download.ListItem, savePath: str
|
||||
// await dispatch('startTask')
|
||||
}
|
||||
} else {
|
||||
await createTask(downloadInfo, savePath, skipExistFile)
|
||||
await createTask(downloadInfo, savePath, skipExistFile, proxy)
|
||||
// await dispatch('handleStartTask', downloadInfo)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user