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:
@@ -16,6 +16,7 @@ const tasks = require("./tasks");
|
||||
const shellUpdater = require("./shell-updater");
|
||||
const chromeManager = require("./chrome-manager");
|
||||
const envSync = require("./env-sync");
|
||||
const { HUB } = require("./hub");
|
||||
const { makeLogger, setLogFile } = require("./logger");
|
||||
|
||||
const logger = makeLogger("app");
|
||||
@@ -72,6 +73,7 @@ async function init(options = {}) {
|
||||
setLogFile(path.join(config.APP_DATA, "logs", "shell.log"));
|
||||
}
|
||||
|
||||
state.setBootStep("加载配置与本地服务");
|
||||
scheduler.initActive();
|
||||
|
||||
// 账号:优先 .env,其次最近活跃本机会话
|
||||
@@ -79,6 +81,7 @@ async function init(options = {}) {
|
||||
if (config.CONTROLPLANE_URL) {
|
||||
// 权限白名单(fail-closed)
|
||||
try {
|
||||
state.setBootStep("同步权限白名单");
|
||||
const allowed = await pluginSync.resolveAllowed(account);
|
||||
state.setAllowed(allowed);
|
||||
} catch (e) {
|
||||
@@ -87,6 +90,7 @@ async function init(options = {}) {
|
||||
|
||||
// 敏感凭证中心化下发(在线拉取 RSA 解密 / 本地缓存兜底;失败不阻断启动)
|
||||
try {
|
||||
state.setBootStep("下发敏感凭证");
|
||||
const creds = await require("./creds-sync").load(account);
|
||||
if (creds && Object.keys(creds).length) {
|
||||
config.applyCreds(creds);
|
||||
@@ -99,6 +103,7 @@ async function init(options = {}) {
|
||||
// 启动同步离线授权票据
|
||||
if (account) {
|
||||
try {
|
||||
state.setBootStep("同步授权票据");
|
||||
await licensing.syncLicensing(account);
|
||||
logger.info(`启动同步离线授权票据成功(账号 ${account})`);
|
||||
} catch (e) {
|
||||
@@ -116,12 +121,15 @@ async function init(options = {}) {
|
||||
const manifest = await pluginSync.cloudPluginManifest(firstAcct);
|
||||
if (manifest !== null) state.setAllowed(new Set(manifest.map((p) => p.id)));
|
||||
logger.info(`启动插件更新完成(账号 ${firstAcct})`);
|
||||
try { HUB.publish({ t: "plugins_synced" }); } catch (e) { /* 忽略 */ }
|
||||
})
|
||||
.catch((e) => logger.warning(`启动插件更新失败:${e.message}`));
|
||||
}
|
||||
|
||||
// 环境包(便携 Python 运行时):启动即检查(异步不阻塞),缺失/有新版本自动下载;
|
||||
// 插件执行/平台登录在环境包就绪前会报"环境包未就绪",由设置页提供状态与手动更新
|
||||
state.setBootStep("检查便携环境包");
|
||||
envSync.migrateLegacyEnvRoot(); // 一次性:把旧版装在安装目录的环境包迁到 APP_DATA(重装不丢)
|
||||
void envSync
|
||||
.checkAndSync()
|
||||
.then((r) => logger.info(`环境包检查:${r.ok ? `就绪 v${r.version || ""}` : `未就绪(${r.reason})`}`))
|
||||
@@ -131,7 +139,8 @@ async function init(options = {}) {
|
||||
void envSync.checkAndSync().catch((e) => logger.warning(`环境包周期检查异常:${e.message}`));
|
||||
}, 30 * 60 * 1000);
|
||||
|
||||
// 壳子更新:启动检查 + 常驻周期检查
|
||||
// 壳子更新:启动检查 + 常驻周期检查(顺带清扫升级遗留的安装包/批处理)
|
||||
shellUpdater.cleanupStalePackages();
|
||||
shellUpdater.startCheck();
|
||||
shellUpdater.startPeriodicCheck();
|
||||
|
||||
@@ -151,6 +160,8 @@ async function init(options = {}) {
|
||||
|
||||
logger.info(`插件根目录:${registry.pluginRoot()}`);
|
||||
logger.info(`数据根目录:${config.APP_DATA}`);
|
||||
state.setBootStep("启动就绪", "本地服务已就绪");
|
||||
state.setBootDone();
|
||||
return { deviceId: deviceId(), account };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user