From 65923982ac4f87ccbc9516b03826f7d388c80e3b Mon Sep 17 00:00:00 2001 From: digua Date: Tue, 14 Apr 2026 20:41:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AI=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=96=87=E4=BB=B6=E5=8E=9F=E5=A7=8B=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/ai/logger.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/electron/main/ai/logger.ts b/electron/main/ai/logger.ts index 6d0690ee..93287db3 100644 --- a/electron/main/ai/logger.ts +++ b/electron/main/ai/logger.ts @@ -22,6 +22,15 @@ let LOG_DIR: string | null = null let LOG_FILE: string | null = null let logStream: fs.WriteStream | null = null +function formatPathForLog(filePath: string): string { + return filePath.replace(/ /g, '\\ ') +} + +function writeLogFileHeader(stream: fs.WriteStream, filePath: string): void { + const localPath = formatPathForLog(filePath) + stream.write(`Local Path: ${localPath}\n\n`) +} + /** * 获取日志目录 */ @@ -75,7 +84,11 @@ function getLogStream(): fs.WriteStream { if (logStream) return logStream const filePath = getLogFilePath() + const isNewOrEmptyFile = !fs.existsSync(filePath) || fs.statSync(filePath).size === 0 logStream = fs.createWriteStream(filePath, { flags: 'a', encoding: 'utf-8' }) + if (isNewOrEmptyFile) { + writeLogFileHeader(logStream, filePath) + } return logStream }