diff --git a/docs/api-docs/electron-ipc.md b/docs/api-docs/electron-ipc.md
index 07aa240..f6965dd 100644
--- a/docs/api-docs/electron-ipc.md
+++ b/docs/api-docs/electron-ipc.md
@@ -284,6 +284,16 @@
**数据类型:** `Controls`
+### `control.softwareLog.add`
+
+**介绍:** 添加一条新的日志数据
+
+**发起方:** 后端
+
+**接收方:** 前端控制窗口
+
+**数据类型:** `SoftwareLog`
+
### `both.styles.set`
**介绍:** 后端将最新字幕样式发送给前端,前端进行设置
diff --git a/engine/main.py b/engine/main.py
index 063ed71..23f9a09 100644
--- a/engine/main.py
+++ b/engine/main.py
@@ -76,7 +76,7 @@ if __name__ == "__main__":
# vosk only
parser.add_argument('-m', '--model_path', default='', help='The path to the vosk model.')
- args = parser.parse_args()
+ args = parser.parse_args()
if int(args.port) == 0:
thread_data.status = "running"
else:
diff --git a/src/main/ControlWindow.ts b/src/main/ControlWindow.ts
index db3b236..524170a 100644
--- a/src/main/ControlWindow.ts
+++ b/src/main/ControlWindow.ts
@@ -7,8 +7,10 @@ import icon from '../../build/icon.png?asset'
import { captionWindow } from './CaptionWindow'
import { allConfig } from './utils/AllConfig'
import { captionEngine } from './utils/CaptionEngine'
+import { Log } from './utils/Log'
class ControlWindow {
+ mounted: boolean = false;
window: BrowserWindow | undefined;
public createWindow(): void {
@@ -34,6 +36,7 @@ class ControlWindow {
})
this.window.on('closed', () => {
+ this.mounted = false
this.window = undefined
allConfig.writeConfig()
})
@@ -63,7 +66,8 @@ class ControlWindow {
})
ipcMain.handle('both.window.mounted', () => {
- return allConfig.getFullConfig()
+ this.mounted = true
+ return allConfig.getFullConfig(Log.getAndClearLogQueue())
})
ipcMain.handle('control.nativeTheme.get', () => {
diff --git a/src/main/types/index.ts b/src/main/types/index.ts
index 241725d..dc93991 100644
--- a/src/main/types/index.ts
+++ b/src/main/types/index.ts
@@ -45,6 +45,13 @@ export interface CaptionItem {
translation: string
}
+export interface SoftwareLogItem {
+ type: "INFO" | "WARN" | "ERROR",
+ index: number,
+ time: string,
+ text: string
+}
+
export interface FullConfig {
platform: string,
uiLanguage: UILanguage,
@@ -53,7 +60,8 @@ export interface FullConfig {
leftBarWidth: number,
styles: Styles,
controls: Controls,
- captionLog: CaptionItem[]
+ captionLog: CaptionItem[],
+ softwareLog: SoftwareLogItem[]
}
export interface EngineInfo {
diff --git a/src/main/utils/AllConfig.ts b/src/main/utils/AllConfig.ts
index ffb97bf..78ace77 100644
--- a/src/main/utils/AllConfig.ts
+++ b/src/main/utils/AllConfig.ts
@@ -1,6 +1,6 @@
import {
UILanguage, UITheme, Styles, Controls,
- CaptionItem, FullConfig
+ CaptionItem, FullConfig, SoftwareLogItem
} from '../types'
import { Log } from './Log'
import { app, BrowserWindow } from 'electron'
@@ -88,7 +88,7 @@ class AllConfig {
Log.info('Write Config to:', configPath)
}
- public getFullConfig(): FullConfig {
+ public getFullConfig(softwareLog: SoftwareLogItem[]): FullConfig {
return {
platform: process.platform,
uiLanguage: this.uiLanguage,
@@ -97,7 +97,8 @@ class AllConfig {
leftBarWidth: this.leftBarWidth,
styles: this.styles,
controls: this.controls,
- captionLog: this.captionLog
+ captionLog: this.captionLog,
+ softwareLog: softwareLog
}
}
diff --git a/src/main/utils/CaptionEngine.ts b/src/main/utils/CaptionEngine.ts
index 2ea1a8a..f199833 100644
--- a/src/main/utils/CaptionEngine.ts
+++ b/src/main/utils/CaptionEngine.ts
@@ -85,12 +85,16 @@ export class CaptionEngine {
}
}
Log.info('Engine Path:', this.appPath)
- Log.info('Engine Command:', this.command)
+ if(this.command.length > 2 && this.command.at(-2) === '-k') {
+ const _command = [...this.command]
+ _command[_command.length -1] = _command[_command.length -1].replace(/./g, '*')
+ Log.info('Engine Command:', _command)
+ }
+ else Log.info('Engine Command:', this.command)
return true
}
public connect() {
- Log.info('Connecting to caption engine server...')
if(this.client) { Log.warn('Client already exists, ignoring...') }
this.client = net.createConnection({ port: this.port }, () => {
Log.info('Connected to caption engine server');
@@ -177,7 +181,6 @@ export class CaptionEngine {
this.client = undefined
}
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...')
@@ -226,7 +229,7 @@ function handleEngineData(data: any) {
Log.info('Engine Info:', data.content)
}
else if(data.command === 'usage') {
- Log.info('Engine Usage: ', data.content)
+ Log.info('Engine Token Usage: ', data.content)
}
else {
Log.warn('Unknown command:', data)
diff --git a/src/main/utils/Log.ts b/src/main/utils/Log.ts
index c226c08..7a36842 100644
--- a/src/main/utils/Log.ts
+++ b/src/main/utils/Log.ts
@@ -1,3 +1,9 @@
+import { controlWindow } from "../ControlWindow"
+import { type SoftwareLogItem } from "../types"
+
+let logIndex = 0
+const logQueue: SoftwareLogItem[] = []
+
function getTimeString() {
const now = new Date()
const HH = String(now.getHours()).padStart(2, '0')
@@ -8,15 +14,45 @@ function getTimeString() {
}
export class Log {
+ static getAndClearLogQueue() {
+ const copiedQueue = structuredClone(logQueue)
+ logQueue.length = 0
+ return copiedQueue
+ }
+
+ static handleLog(logType: "INFO" | "WARN" | "ERROR", ...msg: any[]) {
+ const timeStr = getTimeString()
+ const logPre = `[${logType} ${timeStr}]`
+ let logStr = ""
+ for(let i = 0; i < msg.length; i++) {
+ logStr += i ? " " : ""
+ if(typeof msg[i] === "string") logStr += msg[i]
+ else logStr += JSON.stringify(msg[i], undefined, 2)
+ }
+ console.log(logPre, logStr)
+ const logItem: SoftwareLogItem = {
+ type: logType,
+ index: ++logIndex,
+ time: timeStr,
+ text: logStr
+ }
+ if(controlWindow.mounted && controlWindow.window) {
+ controlWindow.window.webContents.send('control.softwareLog.add', logItem)
+ }
+ else {
+ logQueue.push(logItem)
+ }
+ }
+
static info(...msg: any[]){
- console.log(`[INFO ${getTimeString()}]`, ...msg)
+ this.handleLog("INFO", ...msg)
}
static warn(...msg: any[]){
- console.warn(`[WARN ${getTimeString()}]`, ...msg)
+ this.handleLog("WARN", ...msg)
}
static error(...msg: any[]){
- console.error(`[ERROR ${getTimeString()}]`, ...msg)
+ this.handleLog("ERROR", ...msg)
}
}
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 2c8b1d7..4d642df 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -2,7 +2,7 @@
- Auto Caption
+ Auto Caption v0.7.0
{
useEngineControlStore().platform = data.platform
useEngineControlStore().setControls(data.controls)
useCaptionLogStore().captionData = data.captionLog
+ useSoftwareLogStore().softwareLogs = data.softwareLog
})
})
diff --git a/src/renderer/src/components/CaptionLog.vue b/src/renderer/src/components/CaptionLog.vue
index 5dace1d..e56a881 100644
--- a/src/renderer/src/components/CaptionLog.vue
+++ b/src/renderer/src/components/CaptionLog.vue
@@ -1,141 +1,139 @@
-
-
-
- {{ $t('log.title') }}
-
-
-
-
-
-
-
{{ $t('log.hour') }}
-
-
:
-
-
-
-
{{ $t('log.min') }}
-
-
:
-
-
-
-
{{ $t('log.sec') }}
-
-
.
-
-
- {{ $t('log.changeTime') }}
-
-
-
-
-
-
- {{ $t('log.export') }}
-
-
-
-
-
-
-
- {{ $t('log.copy') }}
-
-
{{ $t('log.clear') }}
+
+
+ {{ $t('log.title') }}
-
-
-
-
- {{ record.index }}
-
-
-
-
{{ record.time_s }}
-
{{ record.time_t }}
+
+
+
+
-
-
-
-
{{ record.text }}
-
{{ record.translation }}
+
:
+ :
+
+
+
+
{{ $t('log.sec') }}
+
+
.
+
-
+
{{ $t('log.changeTime') }}
+
+
+
+
+
+
+ {{ $t('log.export') }}
+
+
+
+
+
+
+
+ {{ $t('log.copy') }}
+
+
{{ $t('log.clear') }}
+
+
+
+
+ {{ record.index }}
+
+
+
+
{{ record.time_s }}
+
{{ record.time_t }}
+
+
+
+
+
{{ record.text }}
+
{{ record.translation }}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/renderer/src/i18n/config/logMenu.ts b/src/renderer/src/i18n/config/logMenu.ts
new file mode 100644
index 0000000..13eb84f
--- /dev/null
+++ b/src/renderer/src/i18n/config/logMenu.ts
@@ -0,0 +1,41 @@
+import { h } from 'vue';
+import { OrderedListOutlined, FileTextOutlined } from '@ant-design/icons-vue'
+
+export const logMenu = {
+ zh: [
+ {
+ key: 'captionLog',
+ icon: () => h(OrderedListOutlined),
+ label: '字幕记录',
+ },
+ {
+ key: 'projLog',
+ icon: () => h(FileTextOutlined),
+ label: '日志记录',
+ },
+ ],
+ en: [
+ {
+ key: 'captionLog',
+ icon: () => h(OrderedListOutlined),
+ label: 'Caption Log',
+ },
+ {
+ key: 'projLog',
+ icon: () => h(FileTextOutlined),
+ label: 'Software Log',
+ },
+ ],
+ ja: [
+ {
+ key: 'captionLog',
+ icon: () => h(OrderedListOutlined),
+ label: '字幕記録',
+ },
+ {
+ key: 'projLog',
+ icon: () => h(FileTextOutlined),
+ label: 'ログ記録',
+ },
+ ]
+}
\ No newline at end of file
diff --git a/src/renderer/src/i18n/index.ts b/src/renderer/src/i18n/index.ts
index 60bc6c2..8e02a6c 100644
--- a/src/renderer/src/i18n/index.ts
+++ b/src/renderer/src/i18n/index.ts
@@ -18,3 +18,4 @@ export * from './config/engine'
export * from './config/audio'
export * from './config/theme'
export * from './config/linebreak'
+export * from './config/logMenu'
\ No newline at end of file
diff --git a/src/renderer/src/i18n/lang/en.ts b/src/renderer/src/i18n/lang/en.ts
index 14e4608..2d6889c 100644
--- a/src/renderer/src/i18n/lang/en.ts
+++ b/src/renderer/src/i18n/lang/en.ts
@@ -106,6 +106,7 @@ export default {
"started": "Started",
"stopped": "Not Started",
"logNumber": "Caption Count",
+ "logNumber2": "Log Count",
"aboutProj": "About Project",
"openCaption": "Open Caption Window",
"startEngine": "Start Caption Engine",
@@ -146,6 +147,7 @@ export default {
"copyNum": "Copy Count",
"all": "All",
"copySuccess": "Subtitle copied to clipboard",
- "clear": "Clear Log"
+ "clear": "Clear Log",
+ "title2": "Software Log"
}
}
diff --git a/src/renderer/src/i18n/lang/ja.ts b/src/renderer/src/i18n/lang/ja.ts
index 4864161..984f747 100644
--- a/src/renderer/src/i18n/lang/ja.ts
+++ b/src/renderer/src/i18n/lang/ja.ts
@@ -106,6 +106,7 @@ export default {
"started": "開始済み",
"stopped": "未開始",
"logNumber": "字幕数",
+ "logNumber2": "ログ数",
"aboutProj": "プロジェクト情報",
"openCaption": "字幕ウィンドウを開く",
"startEngine": "字幕エンジンを開始",
@@ -124,7 +125,7 @@ export default {
}
},
log: {
- "title": "字幕ログ",
+ "title": "字幕記録",
"changeTime": "時間を変更",
"baseTime": "最初の字幕開始時間",
"hour": "時",
@@ -132,7 +133,7 @@ export default {
"sec": "秒",
"ms": "ミリ秒",
"export": "エクスポート",
- "copy": "ログをコピー",
+ "copy": "記録をコピー",
"exportOptions": "エクスポートオプション",
"exportFormat": "形式",
"exportContent": "内容",
@@ -146,6 +147,7 @@ export default {
"copyNum": "コピー数",
"all": "すべて",
"copySuccess": "字幕がクリップボードにコピーされました",
- "clear": "ログをクリア"
+ "clear": "記録をクリア",
+ "title2": "ログ記録"
}
}
diff --git a/src/renderer/src/i18n/lang/zh.ts b/src/renderer/src/i18n/lang/zh.ts
index 011f842..d6c96e9 100644
--- a/src/renderer/src/i18n/lang/zh.ts
+++ b/src/renderer/src/i18n/lang/zh.ts
@@ -106,6 +106,7 @@ export default {
"started": "已启动",
"stopped": "未启动",
"logNumber": "字幕数量",
+ "logNumber2": "日志数量",
"aboutProj": "项目关于",
"openCaption": "打开字幕窗口",
"startEngine": "启动字幕引擎",
@@ -146,6 +147,7 @@ export default {
"copyNum": "复制数量",
"all": "全部",
"copySuccess": "字幕已复制到剪贴板",
- "clear": "清空记录"
+ "clear": "清空记录",
+ "title2": "日志记录"
}
}
diff --git a/src/renderer/src/stores/softwareLog.ts b/src/renderer/src/stores/softwareLog.ts
new file mode 100644
index 0000000..5e172ec
--- /dev/null
+++ b/src/renderer/src/stores/softwareLog.ts
@@ -0,0 +1,21 @@
+import { ref } from 'vue'
+import { defineStore } from 'pinia'
+import { type SoftwareLogItem } from '../types'
+
+export const useSoftwareLogStore = defineStore('softwareLog', () => {
+ const softwareLogs = ref([])
+
+ function clear() {
+ softwareLogs.value = []
+ }
+
+ window.electron.ipcRenderer.on('control.softwareLog.add', (_, log) => {
+ softwareLogs.value.push(log)
+ console.log(log)
+ })
+
+ return {
+ softwareLogs,
+ clear
+ }
+})
diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts
index 241725d..dc93991 100644
--- a/src/renderer/src/types/index.ts
+++ b/src/renderer/src/types/index.ts
@@ -45,6 +45,13 @@ export interface CaptionItem {
translation: string
}
+export interface SoftwareLogItem {
+ type: "INFO" | "WARN" | "ERROR",
+ index: number,
+ time: string,
+ text: string
+}
+
export interface FullConfig {
platform: string,
uiLanguage: UILanguage,
@@ -53,7 +60,8 @@ export interface FullConfig {
leftBarWidth: number,
styles: Styles,
controls: Controls,
- captionLog: CaptionItem[]
+ captionLog: CaptionItem[],
+ softwareLog: SoftwareLogItem[]
}
export interface EngineInfo {
diff --git a/src/renderer/src/views/ControlPage.vue b/src/renderer/src/views/ControlPage.vue
index aa22fde..34a6ba7 100644
--- a/src/renderer/src/views/ControlPage.vue
+++ b/src/renderer/src/views/ControlPage.vue
@@ -11,7 +11,13 @@
@@ -24,11 +30,22 @@ import CaptionStyle from '../components/CaptionStyle.vue'
import EngineControl from '../components/EngineControl.vue'
import EngineStatus from '@renderer/components/EngineStatus.vue'
import CaptionLog from '../components/CaptionLog.vue'
+import SoftwareLog from '@renderer/components/SoftwareLog.vue'
import { storeToRefs } from 'pinia'
import { useGeneralSettingStore } from '@renderer/stores/generalSetting'
+import { ref, watch } from 'vue'
+import { MenuProps } from 'ant-design-vue'
+import { logMenu } from '@renderer/i18n'
const generalSettingStore = useGeneralSettingStore()
-const { leftBarWidth, antdTheme } = storeToRefs(generalSettingStore)
+const { leftBarWidth, antdTheme, uiLanguage } = storeToRefs(generalSettingStore)
+
+const current = ref(['captionLog'])
+const items = ref(logMenu[uiLanguage.value])
+
+watch(uiLanguage, (val) => {
+ items.value = logMenu[val]
+})