build(desktop): 升级 electron-shell 版本至 1.6.3 并调整插件执行超时配置

- 插件执行超时默认延长至 6 小时,支持插件单独配置超时时间
- 新增插件根目录迁移逻辑,解决旧版权限问题
- 新增多个服务端实体、DTO、配置模块等基础代码
- 新增插件 UI 模板及相关静态资源
This commit is contained in:
2026-10-15 11:38:45 +08:00
parent 872d3dc5c8
commit f0a94bf523
717 changed files with 88647 additions and 17543 deletions
+23 -5
View File
@@ -56,12 +56,12 @@ const APP_DATA = path.join(localAppData(), "37duAutomation");
// 插件本地配置目录:per-plugin JSON 持久化
const PLUGIN_CONFIG_DIR = path.join(APP_DATA, "plugin_configs");
// 插件源码/安装根:dev = 仓库根 plugins/;打包 = exe 同级 plugins/
// 插件源码/安装根:dev = 仓库根 plugins/;打包 = %LOCALAPPDATA%\37duAutomation\plugins。
// 不能放 exe 同级:装到 C:\Program Files 时普通权限进程连 mkdir 都被拒(EPERM,插件全部装不上),
// 且 NSIS 重装会清空安装目录、插件陪葬(与环境包同因,见 envRootDir 注释)。
function pluginRoot() {
if (process.env.SHELL_PLUGIN_ROOT) return process.env.SHELL_PLUGIN_ROOT;
if (IS_FROZEN) {
return path.join(path.dirname(process.execPath), "plugins");
}
if (IS_FROZEN) return path.join(APP_DATA, "plugins");
return path.join(REPO_ROOT, "plugins");
}
@@ -91,9 +91,26 @@ const CONTROLPLANE_TOKEN = process.env.CONTROLPLANE_TOKEN || "";
// ==================== 插件执行子进程配置 ====================
// Python 解释器:优先 env,默认 python(PATH 中的 venv/系统 Python)
const PYTHON_EXE = process.env.PYTHON_EXE || "python";
const RUN_TIMEOUT = parseInt(process.env.RUN_TIMEOUT || "1800", 10);
// 插件执行超时(秒,默认 21600=6 小时):长流程(耗时数小时)不再被 1800s 默认强杀。
// 可整体覆盖(.env / 环境变量 RUN_TIMEOUT,0=全局不限时);单个插件可用 plugin.json 的
// runTimeoutSeconds 覆盖(见 runTimeoutFor)。两处都按 0=不限时、缺省回退壳默认处理。
const RUN_TIMEOUT = parseInt(process.env.RUN_TIMEOUT || "21600", 10);
const RUN_MAX_MEM_MB = parseInt(process.env.RUN_MAX_MEM_MB || "2048", 10);
// 插件执行超时(秒):插件 plugin.json 声明 runTimeoutSeconds 优先(0=不限时),
// 否则回退壳默认 RUN_TIMEOUT。传入 registry.find() 产出的插件对象。
function runTimeoutFor(plugin) {
if (plugin && typeof plugin === "object") {
const raw = plugin.timeout_seconds;
// 注意不能用 Number(raw) 直接判:null/undefined 会被转成 0(=不限时),必须显式排除
if (raw !== undefined && raw !== null) {
const v = Number(raw);
if (Number.isFinite(v) && v >= 0) return v;
}
}
return RUN_TIMEOUT;
}
// ==================== 便携 Python 环境包(python-env) ====================
// 版本化目录(python-env/<version>/)+ current.json 指向当前版本,保留上一版供回滚。
// 目录位置:打包态 = %LOCALAPPDATA%\37duAutomation\python-env——NSIS 重装/升级会清空安装目录,
@@ -183,6 +200,7 @@ module.exports = {
PYTHON_EXE,
RUN_TIMEOUT,
RUN_MAX_MEM_MB,
runTimeoutFor,
IS_FROZEN,
pluginRoot,
runnerScript,