Skip to content

Commit

Permalink
fix: check dep when activate in mac
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfan0 committed Aug 23, 2024
1 parent 15761c2 commit 60ec359
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
appId: com.electron.app
appId: site.fideo.app
productName: fideo
directories:
buildResources: build
Expand Down
7 changes: 7 additions & 0 deletions src/main/ffmpeg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export const downloadDepProgressInfo: IDownloadDepProgressInfo = {
showRetry: false
}

export let downloadReq = {
destroy: () => {}
}

const setFfmpegAndFfprobePath = (dirname: string) => {
const ffmpegPath = isMac
? path.resolve(dirname, 'ffmpeg-mac/ffmpeg')
Expand Down Expand Up @@ -80,6 +84,9 @@ export async function makeSureDependenciesExist(

downloadDepProgressInfo.downloading = true
download(downloadUrl, dirname, { extract: true })
.on('request', (req) => {
downloadReq = req
})
.on('downloadProgress', ({ percent }) => {
downloadDepProgressInfo.progress = percent
log(`ffmpeg download progress: ${percent}`)
Expand Down
2 changes: 0 additions & 2 deletions src/main/ffmpeg/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ export async function recordStream(

ffmpegProcess.inputOptions(['-re'])

console.log(ffmpegProcess, '=============================')

setRecordStreamFfmpegProcessMap(title, ffmpegProcess)

ffmpegProcess.inputOption(
Expand Down
19 changes: 11 additions & 8 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import {
makeSureDependenciesExist,
downloadDepProgressInfo,
checkFfmpegExist,
checkFfprobeExist
checkFfprobeExist,
downloadReq
} from './ffmpeg'

async function checkUpdate() {
Expand Down Expand Up @@ -100,7 +101,7 @@ const stopDownloadDepTimerWhenAllDownloadDepEnd = () => {
}

let win: BrowserWindow | null
function createWindow(): void {
async function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 900,
Expand Down Expand Up @@ -138,6 +139,7 @@ function createWindow(): void {
} else {
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
}
await handleMakeSureDependenciesExist()
}

function showNotification(title: string, body: string) {
Expand Down Expand Up @@ -173,9 +175,7 @@ async function handleMakeSureDependenciesExist() {
// Some APIs can only be used after this event occurs.
app.whenReady().then(async () => {
// Set app user model id for windows
electronApp.setAppUserModelId('com.electron')

await handleMakeSureDependenciesExist()
electronApp.setAppUserModelId('site.fideo.app')

// Default open or close DevTools by F12 in development
// and ignore CommandOrControl + R in production.
Expand Down Expand Up @@ -288,21 +288,24 @@ app.whenReady().then(async () => {
stillRecordStreamKeys.forEach((key) => {
killRecordStreamFfmpegProcess(key)
})
downloadReq.destroy()
clearTimerWhenAllFfmpegProcessEnd()
stopDownloadDepTimerWhenAllDownloadDepEnd()
win?.destroy()
})

createWindow()
await createWindow()

setTimeout(() => {
checkUpdate()
}, 1000)

app.on('activate', function () {
app.on('activate', async function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
if (BrowserWindow.getAllWindows().length === 0) {
await createWindow()
}
})
})

Expand Down

0 comments on commit 60ec359

Please sign in to comment.