feat(electron-shell): 启动链路修复与执行/配置收口插件侧
- 启动链路 P1-P7 修复:预算对齐、完成事件推送、端口占用提示、前端阶段文案接管 - 静态缓存按 IS_FROZEN 区分开发/打包态,bootPhaseOwned 竞态修复 - 一键执行与参数配置统一收口到插件界面,定时任务引用 config_id - 环境包迁移到 %LOCALAPPDATA%\37duAutomation\python-env,重装零解压 - shell-updater:缓存包 sha256 校验、静默升级后自动拉起新版、自动清理旧安装包 - after-pack 钩子生成 shell.version 修复打包态版本识别 - 插件 xq0031/xq0045 迁移至 plugins/XQ0001-0100/ 号段分桶中文目录
This commit is contained in:
@@ -23,20 +23,25 @@ const DESKTOP_ROOT = path.resolve(SHELL_ROOT, "..");
|
||||
|
||||
// ==================== 轻量 .env 加载(仅本模块目录,变量已存在则不覆盖) ====================
|
||||
function loadDotEnv() {
|
||||
const envPath = path.join(SHELL_ROOT, ".env");
|
||||
if (!fs.existsSync(envPath)) return;
|
||||
try {
|
||||
const text = fs.readFileSync(envPath, "utf-8");
|
||||
for (const rawLine of text.split(/\r?\n/)) {
|
||||
const line = rawLine.trim();
|
||||
if (!line || line.startsWith("#") || !line.includes("=")) continue;
|
||||
const idx = line.indexOf("=");
|
||||
const key = line.slice(0, idx).trim();
|
||||
const value = line.slice(idx + 1).trim();
|
||||
if (key && process.env[key] === undefined) process.env[key] = value;
|
||||
// 开发/CLI:读本模块 .env;打包态额外读 resources/.env(electron-builder extraResources 带入,
|
||||
// 位于 asar 外的真实文件,可随包分发或按机器覆盖)
|
||||
const candidates = [path.join(SHELL_ROOT, ".env")];
|
||||
if (IS_FROZEN) candidates.push(path.join(process.resourcesPath, ".env"));
|
||||
for (const envPath of candidates) {
|
||||
if (!fs.existsSync(envPath)) continue;
|
||||
try {
|
||||
const text = fs.readFileSync(envPath, "utf-8");
|
||||
for (const rawLine of text.split(/\r?\n/)) {
|
||||
const line = rawLine.trim();
|
||||
if (!line || line.startsWith("#") || !line.includes("=")) continue;
|
||||
const idx = line.indexOf("=");
|
||||
const key = line.slice(0, idx).trim();
|
||||
const value = line.slice(idx + 1).trim();
|
||||
if (key && process.env[key] === undefined) process.env[key] = value;
|
||||
}
|
||||
} catch (e) {
|
||||
// 读取失败静默(与 Python 实现一致)
|
||||
}
|
||||
} catch (e) {
|
||||
// 读取失败静默(与 Python 实现一致)
|
||||
}
|
||||
}
|
||||
loadDotEnv();
|
||||
@@ -93,10 +98,12 @@ const RUN_MAX_MEM_MB = parseInt(process.env.RUN_MAX_MEM_MB || "2048", 10);
|
||||
|
||||
// ==================== 便携 Python 环境包(python-env) ====================
|
||||
// 版本化目录(python-env/<version>/)+ current.json 指向当前版本,保留上一版供回滚。
|
||||
// 目录位置:打包态 = exe 同级 python-env/;开发态 = electron-shell/python-env/(可本地构建联调)。
|
||||
// 目录位置:打包态 = %LOCALAPPDATA%\37duAutomation\python-env——NSIS 重装/升级会清空安装目录,
|
||||
// 放 exe 同级会导致环境包每次陪葬重新下载解压(其余持久化数据本就都在 APP_DATA);
|
||||
// 开发态 = electron-shell/python-env/(可本地构建联调)。
|
||||
function envRootDir() {
|
||||
if (process.env.SHELL_PYTHON_ENV_ROOT) return path.resolve(process.env.SHELL_PYTHON_ENV_ROOT);
|
||||
if (IS_FROZEN) return path.join(path.dirname(process.execPath), "python-env");
|
||||
if (IS_FROZEN) return path.join(APP_DATA, "python-env");
|
||||
return path.join(SHELL_ROOT, "python-env");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user