新增功能: - OpenClaw Gateway 配置支持修改保存(地址和 Token) - 新增测试消息通信功能,可发送测试消息验证 Gateway 连接 - 添加 URL 清理按钮(移除末尾斜杠) - 界面显示版本号 v1.0.0-fix7 修复: - OpenClaw WebSocket 握手协议(等待 challenge 响应) - 关闭窗口时事件处理器访问已销毁窗口的错误 - SSL/TLS 错误诊断和提示 - 连接状态管理优化 技术改进: - 使用 challenge-response 握手机制连接 OpenClaw Gateway - 添加窗口销毁检查避免事件发送失败 - 改进错误日志和诊断信息 - 优化连接状态更新逻辑
44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
// 暴露安全的 API 给渲染进程
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
|
// 配置管理
|
|
getConfig: () => ipcRenderer.invoke('get-config'),
|
|
saveConfig: (config) => ipcRenderer.invoke('save-config', config),
|
|
|
|
// 企业微信连接
|
|
connectWeCom: (botConfig) => ipcRenderer.invoke('connect-wecom', botConfig),
|
|
disconnectWeCom: (botId) => ipcRenderer.invoke('disconnect-wecom', botId),
|
|
|
|
// OpenClaw 连接
|
|
connectOpenClaw: (config) => ipcRenderer.invoke('connect-openclaw', config),
|
|
disconnectOpenClaw: () => ipcRenderer.invoke('disconnect-openclaw'),
|
|
|
|
// 连接状态
|
|
getConnectionStatus: () => ipcRenderer.invoke('get-connection-status'),
|
|
|
|
// 消息发送
|
|
sendWeComMessage: (botId, message) => ipcRenderer.invoke('send-wecom-message', botId, message),
|
|
|
|
// 文件选择
|
|
selectFile: (options) => ipcRenderer.invoke('select-file', options),
|
|
|
|
// 测试消息
|
|
sendTestMessage: (botId, chatId, text) => ipcRenderer.invoke('send-test-message', botId, chatId, text),
|
|
sendTestOpenClawMessage: (text) => ipcRenderer.invoke('send-test-openclaw-message', text),
|
|
|
|
// 事件监听
|
|
onWeComEvent: (callback) => {
|
|
ipcRenderer.on('wecom-event', (event, data) => callback(data));
|
|
},
|
|
|
|
onOpenClawEvent: (callback) => {
|
|
ipcRenderer.on('openclaw-event', (event, data) => callback(data));
|
|
},
|
|
|
|
// 移除事件监听
|
|
removeAllListeners: (channel) => {
|
|
ipcRenderer.removeAllListeners(channel);
|
|
}
|
|
});
|