feat(engine): 添加字幕窗口宽度记忆功能并优化字幕引擎关闭逻辑

- 添加 captionWindowWidth 属性,用于保存字幕窗口宽度
- 修改 CaptionEngine 中的 stop 和 kill 方法,优化字幕引擎关闭逻辑
- 更新 README,添加预备模型列表
This commit is contained in:
himeditator
2025-08-02 15:57:07 +08:00
parent 64ea2f0daf
commit 38b4b15cec
10 changed files with 63 additions and 131 deletions

View File

@@ -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)
}