feat: 新增xq0031_xq0032 ERP报表导出插件,完成功能与基建更新

1. 新增xq0031_xq0032插件:包含前后端源码、打包脚本、配置文件与插件元数据
2. 新增内网文件服务器组件:exe、启停脚本、打包脚本与配置
3. 新增敏感凭证RSA加密下发能力与存储结构
4. 新增大文件源管理表与相关API
5. 优化登录流程与会话管理,新增Chrome自动化安装工具链
6. 清理废弃插件与示例代码
7. 更新版本号至1.1.3,完善安装包与.gitignore配置
This commit is contained in:
2026-09-17 12:42:44 +08:00
parent 84d3e103ec
commit b32f8e8fe2
105 changed files with 7819 additions and 4276 deletions
+61 -5
View File
@@ -5,6 +5,9 @@
缺失/落后则走 download-ticket 一次性票据下载 zip → sha256 校验 → 解压到
plugins/<id>/ 原子替换;更新成功后由宿主重载插件注册表。
本地清理:云端清单可达时,本地存在但不在清单中的插件(中心机已删除/已收回
授权)同步移除本地目录;清单不可达(离线)时不动本地,保证离线可继续运行。
降级策略:
- 控制面不可达/未配置 → 跳过同步,沿用本地已有插件(离线可继续运行)
- 单个插件下载/校验/解压失败 → 记 ERROR 跳过,不影响其它插件与本地旧版本
@@ -17,6 +20,7 @@ import json
import logging
import shutil
import tempfile
import threading
import zipfile
from pathlib import Path
@@ -25,9 +29,13 @@ from webhost.backend.plugins import _PLUGINS_ROOT
_LOGGER = logging.getLogger(__name__)
_DL_TIMEOUT = 30 # 包下载超时(秒)
_DL_TIMEOUT = 300 # 包下载超时(秒);插件包含 ui 资源可达数 MB,留足弱网余量
_MAX_PKG_BYTES = 200 * 1024 * 1024 # 包大小上限,与控制面一致
# 同步串行锁:启动后台同步 / 登录后同步 / 手动刷新共用,防止并发同步互相覆盖
# (后完成的旧账号白名单 set_allowed+reload 会清掉刚同步好的插件清单)
SYNC_LOCK = threading.Lock()
def _headers() -> dict:
h = {}
@@ -145,14 +153,62 @@ def _install_pkg(plugin_id: str, content: bytes) -> bool:
return True
def _local_plugin_entries() -> list:
"""本地已落盘的插件条目(目录包 + 旧式单文件),发现规则与 plugins._discover_modules 对齐。
目录包:含 __init__.py 或 plugin.json(后者兜底覆盖下载中断的残缺目录);
单文件:排除 __init__/base 与 `_` 前缀私有文件。
"""
out = []
for entry in _PLUGINS_ROOT.iterdir():
if entry.name.startswith("_") or entry.name == "__pycache__":
continue
if entry.is_dir():
if (entry / "__init__.py").is_file() or (entry / "plugin.json").is_file():
out.append(entry)
elif entry.suffix == ".py" and entry.name not in ("__init__.py", "base.py"):
out.append(entry)
return out
def _prune_stale(keep_ids: set) -> list:
"""清理中心机已删除/已收回授权的本地插件(仅在云端清单成功拉取后调用)。
设备正有任务执行时整轮跳过(避免动到运行中插件的文件),留待下次同步补删;
单个目录删除失败记 WARNING 跳过,不影响其它清理与本次同步。
"""
from webhost.backend.core import scheduler
if not _PLUGINS_ROOT.is_dir() or scheduler._is_busy():
return []
removed = []
for entry in _local_plugin_entries():
pid = entry.stem if entry.is_file() else entry.name
if pid in keep_ids:
continue
try:
if entry.is_dir():
shutil.rmtree(entry)
else:
entry.unlink()
except OSError as _exc: # noqa: BLE001
_LOGGER.warning("清理本地插件 %s 失败:%s", pid, _exc)
continue
removed.append(pid)
_LOGGER.info("插件 %s 已在中心机删除/收回授权,本地目录同步移除", pid)
return removed
def sync_plugins(account: str) -> dict:
"""按账号权限同步插件(首次下载 + 版本更新)。离线/失败静默降级,返回统计。"""
result = {"downloaded": [], "updated": [], "up_to_date": [], "failed": []}
"""按账号权限同步插件(首次下载 + 版本更新 + 清理已删除)。离线/失败静默降级,返回统计。"""
result = {"downloaded": [], "updated": [], "up_to_date": [], "failed": [], "removed": []}
if not config.CONTROLPLANE_URL or not account:
return result
manifest = _cloud_plugin_manifest(account)
if manifest is None:
return result
# 中心机已删除/收回授权的插件:本地同步清理(云端清单不可达时不动本地)
result["removed"] = _prune_stale({p.get("id", "") for p in manifest})
for p in manifest:
pid = p.get("id", "")
ver = p.get("version", "") or p.get("latest_version", "")
@@ -179,7 +235,7 @@ def sync_plugins(account: str) -> dict:
(result["updated"] if local else result["downloaded"]).append(pid)
else:
result["failed"].append(pid)
_LOGGER.info("插件同步完成:下载=%s 更新=%s 最新=%s 失败=%s",
_LOGGER.info("插件同步完成:下载=%s 更新=%s 最新=%s 清理=%s 失败=%s",
result["downloaded"], result["updated"],
result["up_to_date"], result["failed"])
result["up_to_date"], result["removed"], result["failed"])
return result