feat(fileserver): 新增内网文件服务器服务与管理页面

新增 FastAPI 文件服务器核心模块(配置、鉴权、存储、心跳上报),新增 HTTP 路由接口(健康检查、文件上传/下载/删除、管理登录/密码修改/统计),新增 Vue3 管理页面源码;新增 MySQL 元数据存储支持,新增 PyMySQL 依赖;新增 .gitignore 忽略 IDE 与备份文件;新增文件服务器工具脚本;删除旧的 build/ 脚本与 exe 构建产物,优化 Electron 平台登录逻辑为纯接口模式,新增平台账号环境变量注入,优化试用期异常检查逻辑,拆分服务岗转正流程为独立脚本。
This commit is contained in:
2026-10-12 09:45:04 +08:00
parent 68f29d0a14
commit eeb951f9f6
56 changed files with 6499 additions and 39922 deletions
+29 -17
View File
@@ -14,6 +14,7 @@ const scheduler = require("./scheduler");
const licensing = require("./licensing");
const runHistory = require("./run-history");
const platformAuth = require("./platform-auth");
const platformCreds = require("./platform-creds");
const { HUB } = require("./hub");
const { makeLogger } = require("./logger");
@@ -67,26 +68,33 @@ function nsKey(account, platform) {
return `${account || "anon"}:${platform || "local"}`;
}
// 平台登录态预检(HR/OA):插件执行前检测该账号的平台登录态,
// 失效时自动拉起自动登录(platform-auth.login,Python 子进程滑块自动化;
// cookies 实际有效时不会弹浏览器)。登录成功继续执行,失败则本次运行报错,
// 提示用户去个人中心手动登录(手动登录入口保留,不冲突)。
// 在(账号, 平台)命名空间锁内调用,天然避免并发双开登录浏览器。
// 平台登录态预检(HR/OA):点击执行后、拉起插件前,按插件声明(plugin.json 的 platforms
// 数组,缺省回退 platform 单字段)逐个校验登录态(真实轻量 API 探测),失效时自动调
// platform-auth.login 纯接口补登(无浏览器,凭据来自平台账号配置)。任一平台补登失败
// 则本次运行直接报错中止,不进入插件执行。在(账号, 平台)命名空间锁内调用,天然避免
// 并发双开登录。
const PLATFORM_LABELS = { hr: "HR 系统", oa: "OA 系统" };
function pluginPlatforms(plugin) {
if (Array.isArray(plugin.platforms) && plugin.platforms.length) {
return plugin.platforms.filter((p) => PLATFORM_LABELS[p]);
}
const pid = plugin.platform;
return pid && PLATFORM_LABELS[pid] ? [pid] : [];
}
async function ensurePlatformSession(plugin, runId, account) {
const pid = plugin.platform;
if (!pid || !PLATFORM_LABELS[pid]) return; // 无平台要求(或未知平台)直接执行
if (await platformAuth.isOnline(pid, account)) return; // 登录态有效,直接执行
if (isUserStopped(runId)) throw new Error("用户已取消该排队任务");
const label = PLATFORM_LABELS[pid];
emitLog(runId, plugin.id, "INFO", `检测到${label}登录态失效,正在自动登录…(如需人工介入请观察弹出的浏览器窗口)`);
const r = await platformAuth.login(pid, account);
if (isUserStopped(runId)) throw new Error("用户已取消该排队任务"); // 登录期间用户点了停止
if (!r || !r.online) {
const msg = (r && r.message) || "登录未生效";
throw new Error(`${label}自动登录失败:${msg}。请在「个人中心 → 平台账号」手动登录后重试`);
for (const pid of pluginPlatforms(plugin)) {
if (await platformAuth.isOnline(pid, account)) continue; // 登录态有效,无需处理
if (isUserStopped(runId)) throw new Error("用户已取消该排队任务");
const label = PLATFORM_LABELS[pid];
emitLog(runId, plugin.id, "INFO", `检测到${label}登录态失效,正在自动登录…`);
const r = await platformAuth.login(pid, account);
if (isUserStopped(runId)) throw new Error("用户已取消该排队任务"); // 登录期间用户点了停止
if (!r || !r.online) {
const msg = (r && r.message) || "登录未生效";
throw new Error(`${label}自动登录失败:${msg}。请在「个人中心 → 平台账号」检查账号密码配置后重试`);
}
emitLog(runId, plugin.id, "INFO", `${label}自动登录成功,开始执行插件`);
}
emitLog(runId, plugin.id, "INFO", `${label}自动登录成功,开始执行插件`);
}
// 发布日志事件,并同步累积到"这一次运行"的记录里(结束后随运行历史落盘,供点击回放)
@@ -287,6 +295,10 @@ function startChild(plugin, fields, runId, account) {
PYTHONIOENCODING: "utf-8",
PYTHONUTF8: "1",
PLATFORM_ACCOUNT: account || "",
// 平台凭据:供插件内登录态失效时自动补登录(未配置的平台/账号不注入,
// 此时登录模块回退读共享 .env)
...(platformCreds.envFor(account, "hr") || {}),
...(platformCreds.envFor(account, "oa") || {}),
// 环境包插件加载器据此定位插件根(dev 直拉模式传了也无害)
PLUGINS_ROOT: config.pluginRoot(),
},