mirror of
https://github.com/HiMeditator/auto-caption.git
synced 2026-02-14 11:34:43 +08:00
feat(engine): 优化字幕引擎通信和控制逻辑,优化窗口信息展示
- 优化错误处理和引擎重启逻辑 - 添加字幕引擎强制终止功能 - 调整通知和错误提示的显示位置 - 优化日志记录精度到毫秒级
This commit is contained in:
@@ -282,7 +282,8 @@ function applyStyle(){
|
||||
|
||||
captionStyle.sendStylesChange();
|
||||
|
||||
notification.open({
|
||||
notification.open({
|
||||
placement: 'topLeft',
|
||||
message: t('noti.styleChange'),
|
||||
description: t('noti.styleInfo')
|
||||
});
|
||||
|
||||
@@ -164,6 +164,7 @@ function applyChange(){
|
||||
engineControl.sendControlsChange()
|
||||
|
||||
notification.open({
|
||||
placement: 'topLeft',
|
||||
message: t('noti.engineChange'),
|
||||
description: t('noti.changeInfo')
|
||||
});
|
||||
|
||||
@@ -61,12 +61,14 @@
|
||||
>{{ $t('status.openCaption') }}</a-button>
|
||||
<a-button
|
||||
class="control-button"
|
||||
:disabled="engineEnabled"
|
||||
:loading="pending && !engineEnabled"
|
||||
:disabled="pending || engineEnabled"
|
||||
@click="startEngine"
|
||||
>{{ $t('status.startEngine') }}</a-button>
|
||||
<a-button
|
||||
danger class="control-button"
|
||||
:disabled="!engineEnabled"
|
||||
:loading="pending && engineEnabled"
|
||||
:disabled="pending || !engineEnabled"
|
||||
@click="stopEngine"
|
||||
>{{ $t('status.stopEngine') }}</a-button>
|
||||
</div>
|
||||
@@ -119,13 +121,14 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { EngineInfo } from '@renderer/types'
|
||||
import { ref } from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useCaptionLogStore } from '@renderer/stores/captionLog'
|
||||
import { useEngineControlStore } from '@renderer/stores/engineControl'
|
||||
import { GithubOutlined, InfoCircleOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
const showAbout = ref(false)
|
||||
const pending = ref(false)
|
||||
|
||||
const captionLog = useCaptionLogStore()
|
||||
const { captionData } = storeToRefs(captionLog)
|
||||
@@ -143,6 +146,7 @@ function openCaptionWindow() {
|
||||
}
|
||||
|
||||
function startEngine() {
|
||||
pending.value = true
|
||||
if(engineControl.engine === 'vosk' && engineControl.modelPath.trim() === '') {
|
||||
engineControl.emptyModelPathErr()
|
||||
return
|
||||
@@ -151,6 +155,7 @@ function startEngine() {
|
||||
}
|
||||
|
||||
function stopEngine() {
|
||||
pending.value = true
|
||||
window.electron.ipcRenderer.send('control.engine.stop')
|
||||
}
|
||||
|
||||
@@ -164,6 +169,9 @@ function getEngineInfo() {
|
||||
})
|
||||
}
|
||||
|
||||
watch(engineEnabled, () => {
|
||||
pending.value = false
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -64,6 +64,7 @@ export const useEngineControlStore = defineStore('engineControl', () => {
|
||||
|
||||
function emptyModelPathErr() {
|
||||
notification.open({
|
||||
placement: 'topLeft',
|
||||
message: t('noti.empty'),
|
||||
description: t('noti.emptyInfo')
|
||||
});
|
||||
@@ -80,6 +81,7 @@ export const useEngineControlStore = defineStore('engineControl', () => {
|
||||
(translation.value ? `${t('noti.tLang')}${targetLang.value}` : '');
|
||||
const str1 = `${t('noti.custom')}${customizedApp.value}${t('noti.args')}${customizedCommand.value}`;
|
||||
notification.open({
|
||||
placement: 'topLeft',
|
||||
message: t('noti.started'),
|
||||
description:
|
||||
(customized.value ? str1 : str0) +
|
||||
@@ -89,6 +91,7 @@ export const useEngineControlStore = defineStore('engineControl', () => {
|
||||
|
||||
window.electron.ipcRenderer.on('control.engine.stopped', () => {
|
||||
notification.open({
|
||||
placement: 'topLeft',
|
||||
message: t('noti.stopped'),
|
||||
description: t('noti.stoppedInfo')
|
||||
});
|
||||
@@ -99,7 +102,6 @@ export const useEngineControlStore = defineStore('engineControl', () => {
|
||||
message: t('noti.error'),
|
||||
description: message,
|
||||
duration: null,
|
||||
placement: 'topLeft',
|
||||
icon: () => h(ExclamationCircleOutlined, { style: 'color: #ff4d4f' })
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user