- Electron + React + TypeScript 桌面宠物外壳 - xterm.js + node-pty 直接对接 Claude CLI 进程 - 宠物 orb(80x80)可拖拽,点击展开终端面板 - CRT 复古终端主题(扫描线、文字发光) - 全局快捷键 Cmd+Shift+C 显隐 - 窗口位置自动保存 - 中华田园犬吉祥物 icon(AI 生成) - Makefile 新增 `make app` 打包命令
25 lines
872 B
JavaScript
25 lines
872 B
JavaScript
const { contextBridge, ipcRenderer } = require('electron')
|
|
|
|
const api = {
|
|
pty: {
|
|
write: (data) => ipcRenderer.send('pty:write', data),
|
|
resize: (cols, rows) => ipcRenderer.send('pty:resize', cols, rows),
|
|
onData: (callback) => {
|
|
ipcRenderer.on('pty:data', (_event, data) => callback(data))
|
|
},
|
|
onExit: (callback) => {
|
|
ipcRenderer.on('pty:exit', (_event, code) => callback(code))
|
|
},
|
|
},
|
|
window: {
|
|
expand: () => ipcRenderer.send('window:expand'),
|
|
collapse: () => ipcRenderer.send('window:collapse'),
|
|
setPosition: (x, y) => ipcRenderer.send('window:set-position', x, y),
|
|
setIgnoreMouseEvents: (ignore) => ipcRenderer.send('window:set-ignore-mouse', ignore),
|
|
close: () => ipcRenderer.send('window:close'),
|
|
minimize: () => ipcRenderer.send('window:minimize'),
|
|
},
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('petAPI', api)
|