mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-01 15:02:53 +00:00
feat: screensue 默认 5s 超时,agent 可指定时长或永不超时
- 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永不超时)
This commit is contained in:
@ -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: {},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user