Skip to content

Commit

Permalink
feat:修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yangliu0109 committed Apr 21, 2024
1 parent cea7814 commit 3d1dbc2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ target/
!**/src/main/**/target/
!**/src/test/**/target/
**/*.mp4
out/
/out
node_modules/
pnpm-lock.yaml

### STS ###
.apt_generated
.classpath
Expand Down
12 changes: 6 additions & 6 deletions src/main/ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import ffprobePath from '@ffprobe-installer/ffprobe';
import path from "path";
import {CompressOptions} from '../renderer/src/types'
import { existsSync } from "fs";
ffmpeg.setFfmpegPath(ffmpegPath.path);
ffmpeg.setFfprobePath(ffprobePath.path);
ffmpeg.setFfmpegPath(ffmpegPath.path.replace('app.asar', 'app.asar.unpacked'))
ffmpeg.setFfprobePath(ffprobePath.path.replace('app.asar', 'app.asar.unpacked'))

export default class Ffmpeg {
ffmpeg: ffmpeg.FfmpegCommand
Expand All @@ -20,22 +20,22 @@ export default class Ffmpeg {
}

processEvent(progress){
this.window.webContents.send('mainProcessNotice', 'progress', progress.percent)
// console.log('Processing: ' + progress.percent + '% done');
this.window.webContents.send('mainProcessNotice', 'progress', progress.percent, this.options.file.path)
console.log(progress);
}
error(err){

console.log('An error occurred: ' + err.message);
}
end(){
this.window.webContents.send('mainProcessNotice', 'end')
this.window.webContents.send('mainProcessNotice', 'end','' ,this.options!.file.path)
console.log('Processing finished !');
}

stop(){
try {
this.ffmpeg.kill('SIGKILL')
this.window.webContents.send('mainProcessNotice', 'stop')
this.window.webContents.send('mainProcessNotice', 'stop','' ,this.options!.file.path)
console.log('Processing stop !');
} catch (error) {

Expand Down
3 changes: 2 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function createWindow(): void {
sandbox: false
}
})

//打开调试框
mainWindow.webContents.openDevTools()
mainWindow.on('ready-to-show', () => {
mainWindow.show()
})
Expand Down
2 changes: 1 addition & 1 deletion src/preload/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare global {
selectDirectory: () => Promise<any>,
stop: () => void,
// progressNotice: (callback: (progress:numbre) => void) => void
mainProcessNotice: (callback: (type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', options: any) => void) => void
mainProcessNotice: (callback: (type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', options: any, path: string) => void) => void
}
}
}
6 changes: 3 additions & 3 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const api = {
// callback(prgress)
// })
// },
mainProcessNotice: (callback: (type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', options: any) => void) => {
ipcRenderer.on('mainProcessNotice', (_event: IpcRendererEvent, type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', options: any) => {
callback(type, options)
mainProcessNotice: (callback: (type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', options: any, path: string) => void) => {
ipcRenderer.on('mainProcessNotice', (_event: IpcRendererEvent, type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', options: any,path: string) => {
callback(type, options ,path)
})
},
stop: () => {
Expand Down
21 changes: 10 additions & 11 deletions src/renderer/src/composables/useCompress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ export default () => {
}

const progressNotice = () => {
window.api.mainProcessNotice((type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', data: any) => {
window.api.mainProcessNotice((type: 'end' | 'progress' | 'error' | 'directoryCheck' | 'stop', data: any, path: string) => {
const video = config.files.find((video) => video.path === path)
switch(type) {
case 'end':
video.value!.progress = 100
video.value!.state = VideoState.FINNISH

video!.progress = 100
video!.state = VideoState.FINNISH
isRun.value = false
compress();
break;
case 'progress':
console.log('progress!!');

video.value!.progress = data
case 'progress':
video!.progress = data
break;
case 'error':
break;
case 'directoryCheck':
video.value!.state = VideoState.READY
video!.state = VideoState.READY
ElMessage.warning({message: data, duration: 3000, grouping: true})
break;
case 'stop':
isRun.value = false
video.value!.state = VideoState.READY
video.value!.progress = 0
video!.state = VideoState.READY
video!.progress = 0
break;
}
})
Expand All @@ -61,7 +61,6 @@ export default () => {
}

const stop = () => {

window.api.stop()
}

Expand Down

0 comments on commit 3d1dbc2

Please sign in to comment.