From cfe5a1a7f1c004638d3eb26c6cd817ffe13bd941 Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Fri, 21 Aug 2026 12:10:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20screensue=20=E9=BB=98=E8=AE=A4=205s=20?= =?UTF-8?q?=E8=B6=85=E6=97=B6=EF=BC=8Cagent=20=E5=8F=AF=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E6=88=96=E6=B0=B8=E4=B8=8D=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GUI main.js: screensue 默认 duration 从 0(常驻) 改为 5 秒自动关闭 - 命令带数字 token 指定时长: "screensue 30 内容"=显示30秒 - 命令带 0 表示永不超时: "screensue 0 重要公告"=常驻直到用户手动关闭 - gui-prefs.screensueDuration 用户配置默认值(未配置时 5),命令参数优先级最高 - 设置页(app.js)新增「默认时长(秒)」输入框(placeholder 提示 0=常驻) - 回执文案区分 for Ns / persistent until closed - 服务端 device_ctl_cmdrun 工具描述同步更新(5秒默认/指定秒数/0永不超时) --- cmd/gui/main.js | 21 +++++++++++++++------ cmd/gui/renderer/app.js | 14 +++++++++++++- internal/plugins/remotedevice/device.go | 7 ++++--- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/cmd/gui/main.js b/cmd/gui/main.js index 6c845c8..d7ed354 100644 --- a/cmd/gui/main.js +++ b/cmd/gui/main.js @@ -1428,7 +1428,8 @@ function executeHomeagentCmd(capability, reqId) { } case "screensue": { // 在配置的目标屏幕上拉起独立窗口显示内容(支持文字 / HTML) - var duration = 0; // 显示时长(秒),0=常驻 + // 默认 5 秒自动关闭;命令可带 [秒] 指定时长,0 = 永不超时(常驻,用户手动关闭) + var duration = 5; var raw = String(capability || "") .replace(/^screensue/, "") .trim(); @@ -1438,9 +1439,15 @@ function executeHomeagentCmd(capability, reqId) { const prefs = loadGuiPrefs(); const db = prefs.deviceBridge || {}; dispIdx = parseInt(db.screensueDisplay || "0", 10) || 0; - duration = parseInt(db.screensueDuration || "0", 10) || 0; + const cfgDur = db.screensueDuration; + if (cfgDur === undefined || cfgDur === null || cfgDur === "") { + duration = 5; // 未配置时默认 5 秒 + } else { + duration = parseInt(cfgDur, 10); + if (!Number.isFinite(duration) || duration < 0) duration = 5; + } } catch (e) {} - // 参数支持 "screensue [时长秒] 内容":首个纯数字 token 作为时长 + // 参数支持 "screensue [时长秒] 内容":首个纯数字 token 作为时长(0=永不超时) const tokens = raw.split(/\s+/); if (tokens.length > 1 && /^\d+$/.test(tokens[0])) { duration = parseInt(tokens[0], 10); @@ -1509,7 +1516,9 @@ function executeHomeagentCmd(capability, reqId) { "ok", "screensue shown on display " + dispIdx + - (duration > 0 ? " for " + duration + "s" : "") + + (duration > 0 + ? " for " + duration + "s" + : " (persistent until closed)") + ": " + raw.slice(0, 80), "", @@ -2132,7 +2141,7 @@ function loadGuiPrefs() { gateway: db.gateway || "", token: db.token || "", screensueDisplay: db.screensueDisplay || "0", - screensueDuration: db.screensueDuration || "0", + screensueDuration: db.screensueDuration === undefined || db.screensueDuration === null || db.screensueDuration === "" ? "5" : String(db.screensueDuration), exec: db.exec || {}, authSchedule: db.authSchedule || {}, }, @@ -2148,7 +2157,7 @@ function loadGuiPrefs() { gateway: "", token: "", screensueDisplay: "0", - screensueDuration: "0", + screensueDuration: "5", exec: {}, authSchedule: {}, }, diff --git a/cmd/gui/renderer/app.js b/cmd/gui/renderer/app.js index 5279b22..e8e5cc3 100644 --- a/cmd/gui/renderer/app.js +++ b/cmd/gui/renderer/app.js @@ -4992,6 +4992,13 @@ function renderDevices() { '" + + "' + "" + '
' + "