feat(shell): 插件密码加密、失败熔断与客户端自动更新(v1.11.3)
- 插件配置中 format=password 字段改为 AES-256-GCM 密文落盘(本机密钥,历史明文自动迁移) - 同一插件连续失败 3 次自动禁用(仅统计进程启动后失败),升级自动解除 - 检测到新版本后台下载,空闲窗口提前提示并自动重启升级,设置页可配安全窗口
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// 设置中心持久化:用户级可调项(关闭行为 / 执行超时与内存 / 日志保留)。
|
||||
// 设置中心持久化:用户级可调项(关闭行为 / 执行超时与内存 / 日志保留 / 自动更新)。
|
||||
// 明文 JSON:%LOCALAPPDATA%\37duAutomation\shell-settings.json(与插件配置同根,重装不丢)。
|
||||
// 只做「存取 + 校验」,不碰 HTTP、不碰 Electron API(开机自启由调用方读写系统设置)。
|
||||
// 取值语义:null = 跟随默认(.env / 内置常量);数字 = 用户覆盖值。
|
||||
@@ -12,6 +12,8 @@ const FILE_NAME = "shell-settings.json";
|
||||
// 可写入的键与合法范围(范围外一律拒绝,避免手改坏文件/前端传错把设备跑废)
|
||||
const RULES = {
|
||||
close_behavior: { type: "enum", values: ["tray", "quit"] },
|
||||
auto_shell_update: { type: "enum", values: ["on", "off"] },
|
||||
auto_update_safe_min: { type: "num", min: 1, max: 60, nullable: false, integer: true },
|
||||
run_timeout_sec: { type: "num", min: 0, max: 7 * 24 * 3600, nullable: true, integer: true },
|
||||
run_max_mem_mb: { type: "num", min: 0, max: 32768, nullable: true, integer: true },
|
||||
log_max_mb: { type: "num", min: 1, max: 512, nullable: true, integer: true },
|
||||
@@ -36,6 +38,8 @@ function filePath() {
|
||||
function defaults() {
|
||||
return {
|
||||
close_behavior: "tray", // tray = 关闭窗口收托盘继续跑;quit = 关闭即退出程序
|
||||
auto_shell_update: "on", // on = 检测到新版后台自动下载、空闲窗口自动升级重启(Windows Update 式)
|
||||
auto_update_safe_min: 10,// 未来 N 分钟内有定时任务就不触发自动升级,避免任务被跳过不补跑
|
||||
run_timeout_sec: null, // 空 = 用 .env 的 RUN_TIMEOUT(默认 21600 = 6 小时;0 = 不限时)
|
||||
run_max_mem_mb: null, // 空 = 用 .env / 内置默认(物理内存 70%,4GB~16GB;0 = 不限)
|
||||
log_max_mb: null, // 空 = 内置默认 10MB 单文件
|
||||
@@ -133,6 +137,17 @@ function closeBehavior() {
|
||||
return get().close_behavior || "tray";
|
||||
}
|
||||
|
||||
/** 自动更新开关(on = 开,off = 关);默认开 */
|
||||
function autoShellUpdate() {
|
||||
return get().auto_shell_update !== "off";
|
||||
}
|
||||
|
||||
/** 自动升级前需预留的安全窗口(分钟):未来这段时间有定时任务就不触发 */
|
||||
function autoUpdateSafeMin() {
|
||||
const n = get().auto_update_safe_min;
|
||||
return Number.isFinite(n) && n > 0 ? n : 10;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
filePath,
|
||||
defaults,
|
||||
@@ -142,4 +157,6 @@ module.exports = {
|
||||
runMaxMemMb,
|
||||
logRotation,
|
||||
closeBehavior,
|
||||
autoShellUpdate,
|
||||
autoUpdateSafeMin,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user