mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-22 01:48:11 +00:00
设备命令执行对齐服务端 cmd_type 契约: - onDeviceMsg 解析 msg.cmd_type: homeagent->能力分发 / shell->白名单执行 - 统一回执 sendCmdResult(兼容双参), 全链路回执修复 - 修复 pi-lens auto-fix 把 trayLastCmd 改 const 导致的 TypeError(命令未执行/无回执根因) homeagent 能力: - screensue: 独立窗口显示文字/HTML, 可配默认屏幕(displays:list IPC), 支持时长参数 "screensue [秒] 内容", 默认常驻 - camerasue: 抓拍单张 jpeg(base64文本); camerasue <N秒>=录像 mp4(libx264), 二进制分块经设备通道回传 - speakeruse: 接收服务端二进制音频(WS 0x2), 聚合后播放(aplay/paplay/ffplay/afplay/SoundPlayer) 二进制分块协议(设备<->网关): - 录像(设备->网关): cmd_data_start/0x2帧/cmd_data_end - 音频(网关->设备): cmd_speech_start/0x2帧/cmd_speech_end - 设备端 WS 读写侧都支持 0x2 帧; N/A 服务端 readFrame 需配套(已发群) 消息重放/交互: - sendChat 带 client_msg_id 唯一ID(服务端可去重), 超时明确提示勿重复发送 - 托盘菜单: 信息项 enabled(不再灰字)+200ms防抖+连接缓存, 首建立即弹出 - 托盘显示连接/设备桥/远控活动状态 UI: - 设备页本机卡片: 设备通道配置(网关/ws_token/screensue屏幕/cmdrun目录/沙箱) - 设备列表经 webui 反代 /api/v1/device/online 拉取 - 连接管理移除 device 类型(设备独立为 GUI 组件), toggleConnType/saveConnForm 清理 - 字体对比度提升(text-muted/secondary重调色), 内联小字 10/11px->12/13px preload: 新增 displays.list IPC
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
const { contextBridge, ipcRenderer } = require("electron");
|
|
|
|
contextBridge.exposeInMainWorld("homeagent", {
|
|
win: {
|
|
minimize: () => ipcRenderer.invoke("window:minimize"),
|
|
toggleMaximize: () => ipcRenderer.invoke("window:toggleMaximize"),
|
|
close: () => ipcRenderer.invoke("window:close"),
|
|
},
|
|
connections: {
|
|
list: () => ipcRenderer.invoke("connections:list"),
|
|
add: (conn) => ipcRenderer.invoke("connections:add", conn),
|
|
update: (id, updates) =>
|
|
ipcRenderer.invoke("connections:update", { id, updates }),
|
|
delete: (id) => ipcRenderer.invoke("connections:delete", id),
|
|
setCurrent: (id) => ipcRenderer.invoke("connections:setCurrent", id),
|
|
},
|
|
cli: {
|
|
request: (socketPath, apiKey, line) =>
|
|
ipcRenderer.invoke("cli:request", { socketPath, apiKey, line }),
|
|
},
|
|
webui: {
|
|
setAuth: (url, cookie, headers, username, password) =>
|
|
ipcRenderer.invoke("webui:setAuth", {
|
|
url,
|
|
cookie,
|
|
headers,
|
|
username,
|
|
password,
|
|
}),
|
|
openLogin: (url, username, password) =>
|
|
ipcRenderer.invoke("webui:openLogin", { url, username, password }),
|
|
onLoginResult: (cb) =>
|
|
ipcRenderer.on("webui:login-result", (_e, d) => cb(d)),
|
|
},
|
|
cacheBg: (src) => ipcRenderer.invoke("bg:cache", { src }),
|
|
log: (m) => ipcRenderer.invoke("log:r", m),
|
|
prefs: {
|
|
get: () => ipcRenderer.invoke("prefs:get"),
|
|
set: (p) => ipcRenderer.invoke("prefs:set", p),
|
|
},
|
|
device: {
|
|
identity: () => ipcRenderer.invoke("device:identity"),
|
|
},
|
|
deviceBridge: {
|
|
get: () => ipcRenderer.invoke("device-bridge:get"),
|
|
set: (cfg) => ipcRenderer.invoke("device-bridge:set", cfg),
|
|
},
|
|
displays: {
|
|
list: () => ipcRenderer.invoke("displays:list"),
|
|
},
|
|
});
|