refactor: 重构执行机架构为 Electron 壳内置 Python 运行时子集
将原 webhost 底座的后端、前端、工具等代码迁移至 electron-shell 目录,构建自包含的 Python 环境包,移除冗余的前端代码、旧的后端模块及相关依赖,更新版本号至 1.0.6,优化平台登录态预检逻辑,统一代码结构为单一真源,避免多副本维护问题。
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
// 37du Electron 壳:配置固化(.env 加载 + 路径 + 常量)
|
||||
// 对齐 Python webhost backend/core/config.py 的语义与路径约定。
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
@@ -17,9 +16,8 @@ const IS_FROZEN =
|
||||
// 本模块目录:desktop/electron-shell/electron → parents
|
||||
const SHELL_ROOT = path.resolve(__dirname, "..");
|
||||
|
||||
// 仓库根:electron/../.. = 37duAutomation(dev 模式定位 plugins/ 与 webhost 参考实现)
|
||||
// 仓库根:electron/../.. = 37duAutomation(dev 模式定位 plugins/)
|
||||
const REPO_ROOT = path.resolve(SHELL_ROOT, "..", "..");
|
||||
const DESKTOP_ROOT = path.resolve(SHELL_ROOT, "..");
|
||||
|
||||
// ==================== 轻量 .env 加载(仅本模块目录,变量已存在则不覆盖) ====================
|
||||
function loadDotEnv() {
|
||||
@@ -129,14 +127,14 @@ function pythonExe() {
|
||||
return "python";
|
||||
}
|
||||
|
||||
// 运行时根(webhost 包所在目录):环境包模式 = 环境包根;否则 = desktop/(dev,webhost 在仓库内)
|
||||
// 运行时根(webhost 包所在目录):环境包模式 = 环境包根;否则 = 壳内置 python/(vendor 子集)
|
||||
function runtimeRoot() {
|
||||
const envRoot = pythonEnvRoot();
|
||||
if (envRoot) return envRoot;
|
||||
return DESKTOP_ROOT;
|
||||
return path.join(SHELL_ROOT, "python");
|
||||
}
|
||||
|
||||
// 插件执行入口:环境包模式 = 环境包内 plugin_runner.py;打包态 = exe 同级;dev = 仓库 webhost
|
||||
// 插件执行入口:环境包模式 = 环境包内 plugin_runner.py;打包态 = exe 同级;dev = 壳内置 python/
|
||||
function runnerScript() {
|
||||
if (process.env.SHELL_RUNNER_SCRIPT) return process.env.SHELL_RUNNER_SCRIPT;
|
||||
const envRoot = pythonEnvRoot();
|
||||
@@ -144,7 +142,7 @@ function runnerScript() {
|
||||
if (IS_FROZEN) {
|
||||
return path.join(path.dirname(process.execPath), "plugin_runner.py");
|
||||
}
|
||||
return path.join(DESKTOP_ROOT, "webhost", "backend", "core", "plugin_runner.py");
|
||||
return path.join(SHELL_ROOT, "python", "webhost", "backend", "core", "plugin_runner.py");
|
||||
}
|
||||
|
||||
// Job Object 守护(环境包模式启用内存上限 + 整树托管):无环境包返回 ""
|
||||
@@ -154,18 +152,9 @@ function jobGuardScript() {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 前端静态资源:壳自带 renderer/dist(可单独拷贝);dev 兜底复用 webhost 构建产物
|
||||
// 前端静态资源:壳自带 renderer/dist(自包含;缺失时先跑 scripts/copy-renderer.ps1 构建)
|
||||
function frontendDist() {
|
||||
const own = path.join(SHELL_ROOT, "renderer", "dist");
|
||||
if (fs.existsSync(path.join(own, "index.html"))) return own;
|
||||
const legacy = path.join(DESKTOP_ROOT, "webhost", "frontend", "dist");
|
||||
if (fs.existsSync(path.join(legacy, "index.html"))) return legacy;
|
||||
return own;
|
||||
}
|
||||
|
||||
// 平台登录子进程:spawn python <shared 模块>(webhost.backend.shared.hr_login/oa_login)
|
||||
function sharedModule(moduleName) {
|
||||
return path.join(DESKTOP_ROOT, "webhost", "backend", "shared", `${moduleName}.py`);
|
||||
return path.join(SHELL_ROOT, "renderer", "dist");
|
||||
}
|
||||
|
||||
// 敏感凭证中心化下发:进程级覆盖存储(唯一来源:中心机下发 / 本地加密缓存)
|
||||
@@ -185,7 +174,6 @@ function getCred(name) {
|
||||
module.exports = {
|
||||
SHELL_ROOT,
|
||||
REPO_ROOT,
|
||||
DESKTOP_ROOT,
|
||||
PORT,
|
||||
APP_DATA,
|
||||
PLUGIN_CONFIG_DIR,
|
||||
@@ -199,7 +187,6 @@ module.exports = {
|
||||
pluginRoot,
|
||||
runnerScript,
|
||||
frontendDist,
|
||||
sharedModule,
|
||||
runtimeVersion,
|
||||
applyCreds,
|
||||
getCred,
|
||||
|
||||
Reference in New Issue
Block a user