From b6c1ef15d23a48d423d05c49423992ce42fc8d0e Mon Sep 17 00:00:00 2001 From: jianf <2198972886@qq.com> Date: Fri, 21 Aug 2026 16:43:53 +0800 Subject: [PATCH] =?UTF-8?q?gui:=20=E6=96=B0=E5=A2=9E=20clipboardsee/clipbo?= =?UTF-8?q?ardsue=20=E5=89=AA=E5=88=87=E6=9D=BF=E8=AF=BB=E5=86=99=E8=83=BD?= =?UTF-8?q?=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - clipboardsee: 读取设备剪切板文字(clipboard.readText), 回执 output 为文字, content=ok/empty - clipboardsue: 写入文字到剪切板(clipboard.writeText), 回执含写入字节数+预览 - 与服务端 c0e92cc 配对, 支持 computeruse keypress ctrl+v 自动粘贴 --- cmd/gui/main.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/cmd/gui/main.js b/cmd/gui/main.js index b06ebd4..608cda9 100644 --- a/cmd/gui/main.js +++ b/cmd/gui/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain, Menu, screen, desktopCapturer } = require("electron"); +const { app, BrowserWindow, ipcMain, Menu, screen, desktopCapturer, clipboard } = require("electron"); let screensueWin = null; // screensue 展示窗口(独立于主窗口,显示在配置的屏幕) // 设备桥直连远程网关:绕过系统代理(本机 clash 代理会导致 wss 被雷池 403) try { @@ -1944,6 +1944,45 @@ function executeHomeagentCmd(capability, reqId) { return; } } + case "clipboardsee": { + // 读取设备剪切板当前文字内容(仅文本)。隐私提示:可能含密码,仅用户明确要求时读。 + // 协议: homeagent-clipboardsee + try { + const txt = clipboard.readText(); + const has = !!(txt && txt.length); + sendCmdResult( + reqId, + Object.assign(baseResult(reqId, "ok", has ? String(txt) : "", ""), { + content: has ? "ok" : "empty", + }), + ); + } catch (e) { + sendCmdResult(reqId, baseResult(reqId, "error", "", "clipboardsee failed: " + e.message)); + } + return; + } + case "clipboardsue": { + // 写入文字到设备剪切板(用户可直接 Ctrl+V 粘贴)。 + // 协议: homeagent-clipboardsue <文字> + const txt = String(capability || "") + .replace(/^clipboardsue/, "") + .trim(); + try { + clipboard.writeText(txt); + sendCmdResult( + reqId, + baseResult( + reqId, + "ok", + "written " + Buffer.byteLength(txt) + " bytes: " + txt.slice(0, 60), + "", + ), + ); + } catch (e) { + sendCmdResult(reqId, baseResult(reqId, "error", "", "clipboardsue failed: " + e.message)); + } + return; + } default: sendCmdResult( reqId,