feat: 添加工作空间面板 - 右侧终端/文件浏览器
- 新增主进程 workspace.ts:spawn 进程管理,流式输出,安全检查 - IPC 双向通信:workspace:exec(on/send 模式,无超时限制) - preload 暴露 workspace API - 渲染进程 workspace-panel.ts:多终端 Tab、ANSI 颜色渲染、文件浏览器 - 设置面板添加工作空间目录配置 - 启动时自动创建 workspace 目录 - 窗口关闭时自动清理所有子进程 - 帮助文档更新
This commit is contained in:
@@ -38,5 +38,23 @@ contextBridge.exposeInMainWorld('metonaDesktop', {
|
||||
},
|
||||
removeAllListeners: (channel: string) => {
|
||||
ipcRenderer.removeAllListeners(channel);
|
||||
},
|
||||
workspace: {
|
||||
getDir: () => ipcRenderer.invoke('workspace:getDir'),
|
||||
setDir: (dir: string) => ipcRenderer.invoke('workspace:setDir', dir),
|
||||
listDir: (dirPath?: string) => ipcRenderer.invoke('workspace:listDir', dirPath),
|
||||
readFile: (filePath: string) => ipcRenderer.invoke('workspace:readFile', filePath),
|
||||
exec: (params: { id: string; command: string; cwd?: string }) => {
|
||||
ipcRenderer.send('workspace:exec', params);
|
||||
},
|
||||
kill: (id: string) => {
|
||||
ipcRenderer.send('workspace:kill', id);
|
||||
},
|
||||
onOutput: (callback: (data: { id: string; type: 'stdout' | 'stderr'; data: string }) => void) => {
|
||||
ipcRenderer.on('workspace:output', (_: unknown, data: { id: string; type: 'stdout' | 'stderr'; data: string }) => callback(data));
|
||||
},
|
||||
onExit: (callback: (data: { id: string; code: number | null }) => void) => {
|
||||
ipcRenderer.on('workspace:exit', (_: unknown, data: { id: string; code: number | null }) => callback(data));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user