mirror of
https://github.com/HiMeditator/auto-caption.git
synced 2026-02-14 03:24:44 +08:00
feat(engine): 添加字幕窗口宽度记忆功能并优化字幕引擎关闭逻辑
- 添加 captionWindowWidth 属性,用于保存字幕窗口宽度 - 修改 CaptionEngine 中的 stop 和 kill 方法,优化字幕引擎关闭逻辑 - 更新 README,添加预备模型列表
This commit is contained in:
@@ -15,6 +15,7 @@ export class CaptionEngine {
|
||||
client: net.Socket | undefined
|
||||
port: number = 8080
|
||||
status: 'running' | 'starting' | 'stopping' | 'stopped' = 'stopped'
|
||||
timerID: NodeJS.Timeout | undefined
|
||||
|
||||
private getApp(): boolean {
|
||||
if (allConfig.controls.customized) {
|
||||
@@ -160,6 +161,7 @@ export class CaptionEngine {
|
||||
controlWindow.window.webContents.send('control.engine.stopped')
|
||||
}
|
||||
this.status = 'stopped'
|
||||
clearInterval(this.timerID)
|
||||
Log.info(`Engine exited with code ${code}`)
|
||||
});
|
||||
}
|
||||
@@ -176,9 +178,15 @@ export class CaptionEngine {
|
||||
}
|
||||
this.status = 'stopping'
|
||||
Log.info('Caption engine process stopping...')
|
||||
this.timerID = setTimeout(() => {
|
||||
if(this.status !== 'stopping') return
|
||||
Log.warn('Engine process still not stopped, trying to kill...')
|
||||
this.kill()
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
public kill(){
|
||||
if(!this.process || !this.process.pid) return
|
||||
if(this.status !== 'running'){
|
||||
Log.warn('Trying to kill engine which is not running, current status:', this.status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user