chore: 清除所有 console.log,主进程日志接入执行日志面板

This commit is contained in:
thzxx
2026-04-07 19:49:30 +08:00
parent d524339634
commit 34a6b9fd0b
5 changed files with 26 additions and 6 deletions
+7 -1
View File
@@ -7,8 +7,14 @@ import { spawn, ChildProcess } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import { app } from 'electron';
import { mainWindow } from './main.js';
import { checkPathAllowed, checkCommandAllowed } from './tool-security.js';
/** 发送日志到渲染进程日志面板 */
function sendLog(level: 'info' | 'success' | 'warn' | 'error' | 'debug', message: string, detail?: string): void {
mainWindow?.webContents.send('main:log', { level, message, detail });
}
export const DEFAULT_WORKSPACE_DIR = path.join(app.getPath('userData'), 'workspace');
/** 活跃进程 Map */
@@ -18,7 +24,7 @@ const activeProcesses = new Map<string, ChildProcess>();
export function ensureWorkspaceDir(): void {
if (!fs.existsSync(DEFAULT_WORKSPACE_DIR)) {
fs.mkdirSync(DEFAULT_WORKSPACE_DIR, { recursive: true });
console.log('[Workspace] 创建默认工作空间目录:', DEFAULT_WORKSPACE_DIR);
sendLog('info', `📁 创建默认工作空间目录`, DEFAULT_WORKSPACE_DIR);
}
}