From 0394d8edee57fc43d27dd84afd63aa34971e89cd Mon Sep 17 00:00:00 2001 From: chen fan <1490040662@qq.com> Date: Wed, 30 Oct 2024 14:22:53 +0800 Subject: [PATCH] fix: ts error --- src/main/download-dep/index.ts | 116 ++++++++++++++++----------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/src/main/download-dep/index.ts b/src/main/download-dep/index.ts index 590b65e..8f6bb21 100644 --- a/src/main/download-dep/index.ts +++ b/src/main/download-dep/index.ts @@ -24,10 +24,10 @@ const isArm = ['arm64', 'arm'].includes(os.arch()) const ffmpegMacUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/ffmpeg-mac.zip' const ffmpegWinUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/ffmpeg-win.zip' -const frpMacArmUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-mac-arm64.zip' -const frpMacAmdUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-mac-amd64.zip' -const frpWinArmUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-win-arm64.zip' -const frpWinAmdUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-win-amd64.zip' +// const frpMacArmUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-mac-arm64.zip' +// const frpMacAmdUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-mac-amd64.zip' +// const frpWinArmUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-win-arm64.zip' +// const frpWinAmdUrl = 'https://gitlab.com/chenfan0/ffmpeg-resource/-/raw/main/frp-win-amd64.zip' async function checkFileExist(filepath: string) { return fsp @@ -112,60 +112,60 @@ async function makeSureFfmpegDependenciesExist(dirname: string) { return p } -async function makeSureFrpDependenciesExist(dirname: string) { - const frpExist = await checkFrpcExist(dirname) - if (frpExist) { - return true - } - - let _resolve: (value: unknown) => void, _reject: (reason?: any) => void - const p = new Promise((resolve, reject) => { - _resolve = resolve - _reject = reject - }) - - const downloadUrl = isMac - ? isArm - ? frpMacArmUrl - : frpMacAmdUrl - : isArm - ? frpWinArmUrl - : frpWinAmdUrl - - downloadDepProgressInfo.downloading = true - download(downloadUrl, dirname, { extract: true }) - .on('request', (req) => { - downloadReq = req - }) - .on('downloadProgress', ({ percent }) => { - downloadDepProgressInfo.title = 'FRPC' - downloadDepProgressInfo.progress = percent - log(`frpc download progress: ${percent}`) - }) - .on('error', (error) => { - downloadDepProgressInfo.showRetry = true - downloadDepProgressInfo.downloading = false - downloadDepProgressInfo.progress = 0 - log(error.message) - _reject() - }) - .then(() => { - downloadDepProgressInfo.title = '' - downloadDepProgressInfo.downloading = false - downloadDepProgressInfo.progress = 0 - - _resolve(true) - }) - .catch(() => { - downloadDepProgressInfo.title = '' - downloadDepProgressInfo.showRetry = true - downloadDepProgressInfo.downloading = false - downloadDepProgressInfo.progress = 0 - _reject() - }) - - return p -} +// async function makeSureFrpDependenciesExist(dirname: string) { +// const frpExist = await checkFrpcExist(dirname) +// if (frpExist) { +// return true +// } + +// let _resolve: (value: unknown) => void, _reject: (reason?: any) => void +// const p = new Promise((resolve, reject) => { +// _resolve = resolve +// _reject = reject +// }) + +// const downloadUrl = isMac +// ? isArm +// ? frpMacArmUrl +// : frpMacAmdUrl +// : isArm +// ? frpWinArmUrl +// : frpWinAmdUrl + +// downloadDepProgressInfo.downloading = true +// download(downloadUrl, dirname, { extract: true }) +// .on('request', (req) => { +// downloadReq = req +// }) +// .on('downloadProgress', ({ percent }) => { +// downloadDepProgressInfo.title = 'FRPC' +// downloadDepProgressInfo.progress = percent +// log(`frpc download progress: ${percent}`) +// }) +// .on('error', (error) => { +// downloadDepProgressInfo.showRetry = true +// downloadDepProgressInfo.downloading = false +// downloadDepProgressInfo.progress = 0 +// log(error.message) +// _reject() +// }) +// .then(() => { +// downloadDepProgressInfo.title = '' +// downloadDepProgressInfo.downloading = false +// downloadDepProgressInfo.progress = 0 + +// _resolve(true) +// }) +// .catch(() => { +// downloadDepProgressInfo.title = '' +// downloadDepProgressInfo.showRetry = true +// downloadDepProgressInfo.downloading = false +// downloadDepProgressInfo.progress = 0 +// _reject() +// }) + +// return p +// } export async function makeSureDependenciesExist(dirname: string) { await makeSureFfmpegDependenciesExist(dirname)