Skip to content

Commit

Permalink
fix: ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfan0 committed Oct 30, 2024
1 parent fc97640 commit 0394d8e
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions src/main/download-dep/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0394d8e

Please sign in to comment.