refactor: 完成项目目录重构与代码迁移

本次提交完成了整体项目的目录梳理与代码迁移:
1.  将根级controlplane、webhost等目录的代码迁移至desktop/对应子目录,统一桌面端架构
2.  移动并整理了插件目录结构,将插件统一放入根级plugins/
3.  调整了前端项目的路径与配置,统一前后端开发构建流程
4.  清理了废弃的旧版app/目录与冗余的构建中间文件
5.  更新了.gitignore与README.md,适配新的项目结构
This commit is contained in:
2026-09-14 17:46:09 +08:00
parent cb04790d28
commit 1e533dd1b3
131 changed files with 4071 additions and 38034 deletions
+12 -6
View File
@@ -13,15 +13,18 @@ sdist/
wheels/
*.manifest
*.spec
# 桌面版打包产物(desktop 专属目录,不落根目录)
# 前端依赖与构建产物(desktop 桌面端)
desktop/*/frontend/node_modules
desktop/*/frontend/dist/
# 桌面版打包产物(PyInstaller 中间/输出、安装包、插件构建包,不入库)
desktop/**/build-exe/
desktop/**/dist-exe/
desktop/releases/
desktop/build/
dist-plugin/
pip-log.txt
pip-delete-this-directory.txt
webhost/frontend/node_modules
webhost/frontend/dist/
controlplane/frontend/node_modules
controlplane/frontend/dist/
# ---------- 虚拟环境 ----------
.venv/
@@ -37,7 +40,10 @@ ENV/
.admin_secret
.webhost.pid
*.pid
controlplane/packages/
desktop/**/keys/
desktop/**/packages/
desktop/**/controlplane.db
desktop/**/_cp_sessions.json
# 各平台会话 cookies / 缓存目录(统一移入 %LOCALAPPDATA%\37duAutomation,禁止入库)
**/.sessions/
@@ -0,0 +1,93 @@
# sb_person_change 社保增减员插件开发计划
## Context
需求8(XQ0008 重庆社保增减员导入名单制作)与需求14(XQ0014 社保系统增减员办理)业务上是一条链路:名单制作 → 平台导入办理 → 核查回盘。此前已确认合并为一个 webhost 插件(sb_person_change),本次落地实现,包含 4 个执行模式(用户已确认全闭环):
1. 增员名单制作(源:generate_add.py)
2. 减员名单制作(源:generate_stop.py)
3. 增员办理(源:import_add.py,DrissionPage 浏览器自动化)
4. 核查回盘(源:check_review.py)
workflows/ 影刀版保留不动,插件代码全部内聚在插件包内(自包含约束:只引插件内模块 + 标准库/第三方 + base 注入接口)。执行机与浏览器、D:\资料、台账同机,凭证以「社保户头管理台账」为准,共享 .env(%LOCALAPPDATA%\37duAutomation\.env)仅作登录自测兜底。
## 已确认的框架事实
- 插件位置:`webhost/backend/plugins/sb_person_change/`,动态包扫描加载([plugins/__init__.py](file:///d:/work/code/37duAutomation/webhost/backend/plugins/__init__.py))
- 插件契约:继承 `ScenePlugin`([base.py](file:///d:/work/code/37duAutomation/webhost/backend/plugins/base.py)),`run(fields, ctx) -> dict`,`ctx.log/ctx.progress`,`PLUGINS.append()` 注册;plugin.json 为元数据权威
- 子进程隔离:[plugin_runner.py](file:///d:/work/code/37duAutomation/webhost/backend/core/plugin_runner.py),fields 从 stdin JSON 传入,log/progress 经 stdout JSON 行回传,print 已改道 stderr(前端看不到,必须换 ctx.log),启动后 chdir 项目根
- 前端表单([PluginPage.vue](file:///d:/work/code/37duAutomation/webhost/frontend/src/components/PluginPage.vue#L51-L68)):支持 `int`/`text`/其它类型走 `el-select`(用 `f.options` 数组)——mode 用 select 可行
- 中心机包格式([pkgutil.py](file:///d:/work/code/37duAutomation/controlplane/core/pkgutil.py#L17)):zip 包根必含 `plugin.json` / `main.py` / `requirements.txt`
- 依赖已在 .venv:DrissionPage 4.1.1.4、ddddocr 1.6.1、xlrd 2.0.2、xlutils 2.0.0、openpyxl 3.1.5;缺口:ddddocr 未写入根 requirements.txt
## 插件目录结构
```
webhost/backend/plugins/sb_person_change/
├── plugin.json # manifest + fields JSON-Schema
├── __init__.py # ScenePlugin 子类 + run() 分发 4 模式 + PLUGINS.append
├── main.py # 发布 shim:re-export 插件类并触发注册(中心机包要求)
├── requirements.txt # DrissionPage / ddddocr / xlrd / xlutils / openpyxl / python-dotenv
├── config.py # 路径常量(源表目录/台账/回盘目录/模版名)、列映射、区域=重庆、重试次数
├── login.py # sb_login.py 迁移:SSO 法人登录、ddddocr 验证码、清 cookies 会话
├── source.py # 源表数据层:定位最新 *社保*.xlsx、增员/停保/待审核筛选与分组
├── ledger.py # 户头台账读取(按参保单位取账号密码)
├── excelio.py # openpyxl 源表读/批量回写(占用检测+3次重试)+ xlrd/xlutils 模版生成名单
├── webops.py # 网页操作:导入上传、回盘打印下载、分页取数、弹窗/菜单不可见处理
├── mode_make_add.py / mode_make_stop.py / mode_do_add.py / mode_check.py # 4 模式主流程
└── debug/ # 截图/验证码调试落盘目录(debug_mode 开启时)
```
## fields schema(plugin.json 与 __init__.py 类字段一致)
| key | 类型 | 说明 |
|---|---|---|
| `mode` | select,options=`["增员名单制作","减员名单制作","增员办理","核查回盘","预检"]` | 预检=只读源表+取号+校验,不开浏览器,用于低成本验证数据链路 |
| `limit` | int,默认 0=不限 | 分批条数,仅「增员办理」「核查回盘」生效(对应原 RUN_LIMIT/CHECK_LIMIT) |
| `debug_mode` | select,options=`["关闭","开启"]` | 截图/验证码/HTML 落盘(原 DEBUG_MODE / sb_captcha_debug) |
设计取舍:单 select 而非 4 个子按钮(前端是通用表单,改动最小);limit 统一一个字段(名单制作无分批概念,4 个独立 limit 会撑爆表单)。
## run() 分发骨架与进度打点
```
run(fields, ctx):
mode → 分发到 mode_*.py 的模式函数(fields, ctx)
预检:5 读源表 → 40 筛选分组 → 70 台账取号校验 → 100 汇总(缺账号/缺文件即抛异常终止)
名单制作:5 读源表 → 30 筛选分组 → 60 逐单位生成 xls(每单位 ctx.log)→ 100 汇总
增员办理/核查回盘:5 读表+取号 → 15 预检 → 单位循环 progress=20+70*i/n(单位粒度线性推进,
单位内子步骤走 ctx.log)→ 95 统一批量回写 → 100
return {summary, path(产出文件), rows(明细), notes}
```
## 迁移策略
- **原样复制**:login.py 登录全流程与验证码重试(5×3)、webops 页面操作(含「菜单不可见先后退/重开业务页」修复、aab001 处理)、xlrd/xlutils 模版复制保下拉字典逻辑、COLUMN_MAP 等映射表、回盘核对规则(参保缴费最多记录/个人编号备注/未查询到回盘记录)
- **改造点**:
1. `print` → `ctx.log`(模式函数接收 ctx,向下传 log 回调)
2. 剥离影刀 `glv` 全局变量与 `if __name__ == "__main__"` 段
3. `sys.exit` → `raise` 异常(plugin_runner 顶层兜底捕获并回传 result)
4. RUN_LIMIT / CHECK_LIMIT / DEBUG_MODE 等模块常量 → fields 传入
5. checkpoint JSON、验证码 debug 目录 → 插件包内 `debug/`
6. .env 定位:保留 sb_login 现有 `%LOCALAPPDATA%\37duAutomation\.env` 绝对路径逻辑(chdir 无影响)
- **Excel 安全**:运行前检测源表/台账/回写目标是否被占用,占用则明确报错提示先关闭 Excel(沿用用户既有习惯);回写统一结束时批量执行
## 收尾工作
1. 根 requirements.txt 补 `ddddocr`(含 onnxruntime 依赖说明)
2. 打包:zip 插件包根含 plugin.json / main.py / requirements.txt,命名 `sb_person_change_v1.0.0.zip`,经中心机管理页上传(RBAC 配权限后 webhost 按白名单加载)
3. webhost `.env` 核对该插件执行所需的 RUN_TIMEOUT 上限(多单位办理耗时长,靠 limit 分批)
## 验证方案
1. 语法/加载验证:py_compile 全部插件文件;重启 webhost 确认插件被发现、fields 正确渲染(select/int)
2. 预检模式:验证读表、筛选分组、台账取号链路(不开浏览器)
3. 名单制作模式:用源表副本离线验证产出 xls 与影刀版产出一致
4. 增员办理/核查回盘:`limit=1` 跑一家单位全链路,观察 WebSocket 日志/进度、Excel 回写、回盘文件命名
5. 通过后逐步放大 limit 全量
## 风险
- 有头浏览器需桌面会话(当前同机手动运行形态可行;若 webhost 未来以服务方式无桌面运行需另行处理)
- 底座超时 kill 长任务 → limit 分批 + 调大该场景 RUN_TIMEOUT
- 验证码识别失败 → 沿用既有刷新重试机制
+19 -8
View File
@@ -12,16 +12,20 @@ AI 智能体开发约束 & 项目执行规范
- 单文件需具备完整性:依赖声明、核心逻辑、异常处理、入口执行全部内聚在当前文件。
3. 项目通用架构规范
- 代码组织:不同业务、不同流程独立模块化运行,互不侵入、互不影响。
- 四方向零依赖:项目同时存在四个独立演进方向,各自目录(controlplane/ 中心机、webhost/ 部署机底座、app/ 蓝图版、workflows/ 影刀版)之间【绝不跨目录 import】,登录/数据导出等数据层各自内置(允许少量重复换取完全解耦),任一方向可单独拷贝、单独演进、独享依赖与启动。
- 各方向零依赖:项目并存多个独立演进方向,彼此【绝不跨目录 import】,登录/数据导出等数据层各自内置(允许少量重复换取完全解耦),任一方向可单独拷贝、单独演进、独享依赖与启动:
- 桌面端 desktop/:中心机 desktop/controlplane/ + 执行机 desktop/webhost/,两者互不 import、独立演进、可单独拷贝(模块搜索根 = desktop/,运行均以 desktop/ 为 cwd)。
- 插件 plugins/:根级独立目录,被执行机按账号权限自下载加载,不随 webhost 发布。
- 影刀版 workflows/:单文件自包含。
- app/ 蓝图版:已弃用,保留归档、不再维护。
- 代码形态分三类,按各方向性质采用不同组织方式(【单文件自包含】仅适用于影刀版,其它一律按正常项目开发):
- workflows/(影刀版):沿用单文件自包含架构(见第 2 节,仅影刀适用)。
- 各后端(controlplane/ 中心机、webhost/ 执行机底座、app/ 蓝图版):按正常 Python 模块化项目开发,允许按包/模块/多文件拆分(如 main.py/app.py 分割逻辑与路由),不做单文件约束。
- 插件(webhost 加载的执行单元,如 plugins/seal_check/):内部按正常项目组织,可拆 config/data/logic/report 等多文件;但强调【插件自包含】——插件内模块只能互相引用、依赖 Python 标准库/第三方依赖/底座注入的插件接口,严禁 import 插件包之外的任何代码(根目录、webhost 底座业务、controlplane、app 一律禁止),保证插件完整交付物=插件包本身,可单独拷贝发布、独立演进。
- 桌面端各后端(desktop/controlplane/ 中心机、desktop/webhost/ 执行机底座):按正常 Python 模块化项目开发,允许按包/模块/多文件拆分(如 main.py/app.py 分割逻辑与路由),不做单文件约束。
- 插件(执行机加载的执行单元,源码位于根级 plugins/<id>/,如 plugins/seal_check/):内部按正常项目组织,可拆 config/data/logic/report 等多文件;但强调【插件自包含】——插件内模块只能互相引用、依赖 Python 标准库/第三方依赖/底座注入的插件接口(webhost.backend.plugins.base),严禁 import 插件包之外的任何代码(根目录、desktop 底座业务、app 一律禁止),保证插件完整交付物=插件包本身,可单独拷贝发布、独立演进。
- 环境变量按模块隔离,各自使用自己目录下的 .env,互不覆盖、互不依赖:
- 根目录 .env:仅供 workflows/(影刀) 脚本使用,承载各 XQ 业务路径/账号等配置;禁止向根 .env 写入 webhost/app/controlplane 的变量。
- app/ → app/.env(app 版业务配置)
- webhost/ → webhost/ 下 webhost/.env(底座部署配置,含 CONTROLPLANE_*、RUN_TIMEOUT 等)
- controlplane/ → controlplane/.env(中心机配置,含 CONTROLPLANE_PORT、CONTROLPLANE_TOKEN)
- 根目录 .env:仅供 workflows/(影刀) 脚本使用,承载各 XQ 业务路径/账号等配置;禁止向根 .env 写入桌面端/app 的变量。
- desktop/controlplane/ → desktop/controlplane/.env(中心机配置,含 CONTROLPLANE_PORT、CONTROLPLANE_TOKEN)
- desktop/webhost/ → desktop/webhost/.env(执行机底座配置,含 CONTROLPLANE_*、RUN_TIMEOUT 等)
- app/ → app/.env(app 版业务配置,已弃用)
- workflows/ 影刀不再单独建 .env,所需配置统一放在根 .env。
- 各模块加载器只允许读取本模块目录下的 .env,禁止读取/改写其它模块或根 .env。
- 错误处理:全局项目级重试机制,最大重试 3 次,三次失败后再记录错误日志。
@@ -30,4 +34,11 @@ AI 智能体开发约束 & 项目执行规范
- 所有代码生成、修改、重构必须贴合 Python 模块化编程思想。
- 不主动创建冗余文件、不随意变更项目结构、不混用沙箱环境。
- 输出代码优先保证:可运行、结构清晰、符合项目统一规范、按代码形态适配(单文件自包含仅影刀版需要;后端与插件按正常模块化项目开发)。
- 变量配置规范:禁止使用命令行传入变量的方式实现参数配置,所有参数、变量、配置项均在代码/配置文件内部定义、固化或读取本地配置,保证运行无外部参数依赖。
- 变量配置规范:禁止使用命令行传入变量的方式实现参数配置,所有参数、变量、配置项均在代码/配置文件内部定义、固化或读取本地配置,保证运行无外部参数依赖。
5. 发版与自动更新操作规范
- 自动更新:插件由执行机按账号权限自下载(plugin_sync.py);壳子由执行机自动下载安装包 + 用户点击升级重启(shell_updater.py)。版本源都在中心机控制面。
- 发版统一走 agent CLI(在 desktop/ 目录下执行:.venv\Scripts\python.exe -m controlplane.tools.agent_cli,中心机本机 + 管理密钥,即控制面 /api/admin/pkg 与 shell 源):
- 壳子发版:改 desktop/webhost/tools/shell.version 与 install.iss 的 MyAppVersion → desktop/webhost/frontend 执行 npm run build → PyInstaller 依次打 desktop/webhost/tools/37du-host.spec、37du-host-runner.spec、37du-host-console.spec → ISCC.exe desktop/webhost/tools/install.iss 出安装包;然后 agent_cli shell-release <安装包> --version <新版本> [--notes "说明"]。
- 插件发版:根级 plugins/<id>/ 目录打成 zip(根目录含 plugin.json)后 agent_cli publish <插件.zip> --id <id> --version <v>;权限用 agent_cli grant / revoke 管理。
- 中心机发版:改过 controlplane 后端后 PyInstaller desktop/controlplane/tools/37du-center.spec --distpath desktop/controlplane/dist-exe --workpath desktop/controlplane/build-exe --noconfirm。
- 发布后:执行机下次启动自动检测下载、前端提示后点击升级;插件登录后按权限自动下载更新。
+19 -2
View File
@@ -16,7 +16,24 @@ HR 业务流程自动化(37duAutomation):覆盖 HRBP OA 审批、EHR 数
```
Process-Automation/
├── app/
├── desktop/ # 桌面端:中心机 + 执行机,两方向独立演进
│ ├── controlplane/ # 中心机:插件发布 / 账号权限 / 壳子分发控制面
│ │ ├── app.py # FastAPI 服务入口(在 desktop/ 下 python -m controlplane.app)
│ │ ├── core/ # 配置、存储、鉴权
│ │ ├── apis/ # REST 接口
│ │ ├── tools/ # agent_cli 发布 CLI、PyInstaller spec、前端
│ │ └── frontend/ # 中心机管理前端
│ └── webhost/ # 执行机:本地服务 + 前端工作台 + 插件运行底座
│ ├── launch.py # 启动器(uvicorn + PyWebView 窗口)
│ ├── backend/ # FastAPI 服务与插件加载器(backend/plugins)
│ ├── frontend/ # 工作台前端
│ └── tools/ # 壳子打包 spec / install.iss / 版本管理
├── plugins/ # 插件源码(独立于桌面端,执行机按权限动态加载)
│ ├── seal_check/ # 印章核对插件(目录包,含 __init__.py)
│ ├── sb_person_change/ # 人员变更插件
│ ├── demo.py
│ └── platform_check.py
├── app/ # *已弃用归档,不再维护*(早期模块化蓝图,仅留作参考)
│ ├── service/hrbp/
│ │ ├── common/ # HR 平台公共层:会话、登录、配置、验证码调试
│ │ ├── oa/ # OA 系统
@@ -148,5 +165,5 @@ python workflows/share/roster_export.py
3. OA/HR 需在登录态有效期内运行,脚本会自动重登或提示重新登录;
4. 影刀版本为单文件自包含,直接导入影刀平台运行;业务脚本不 import 共享指令模块,仅读 cookies 文件、写全局变量,消息生成与发送解耦(详见 `workflows/README.md`)。
> **影刀版与 app 版**:开发流程为「先 app 版(`app/`,模块化蓝图)测试通过 → 影刀版(`workflows/`,单文件自包含)落地部署」;后续更新与维护均以**影刀版为部署/维护真源**,正式上线时全量同步回 app 版,使蓝图与真源保持一致(如排班异常识别、雇主险增减操作)。
> **桌面端与影刀版**:开发流程为「桌面端(`desktop/`,中心机 + 执行机)测试通过 → 影刀版(`workflows/`,单文件自包含)落地部署」;`app/` 为早期模块化蓝图,已**弃用归档、不再维护**,仅留作参考。桌面端各方向互不 import、独立演进,插件源码统一放根级 `plugins/`。
+80 -44
View File
@@ -1,44 +1,80 @@
登录成功之后,在大厅页面https://ggfw.rlsbj.cq.gov.cn/onlinehall/nethall/pc/cqzhrs/onlineoffice/index
<div class="ant-col ant-col-19"><button type="button" class="ant-btn ant-btn-link"><span>首页</span></button><button type="button" class="ant-btn ant-btn-link"><span>个人办事</span></button><button type="button" class="ant-btn ant-btn-link"><span>单位办事</span></button><button type="button" class="ant-btn ant-btn-link"><span>服务清单</span></button><button type="button" class="ant-btn ant-btn-link"><span>门户集成</span></button><button type="button" class="ant-btn ant-btn-link" style="color: rgb(255, 255, 255);"><span>我的人社</span></button></div>
点击单位办事
<li class="ant-list-item"><div class="ant-list-item-meta"><div class="ant-list-item-meta-avatar"><div><text class="top2___2Ks5-">TOP2</text> <div class="ant-divider ant-divider-vertical ant-divider-dashed" role="separator"></div><span class="icontj___2iHqP"><span role="img" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#icon-jilu1"></use></svg></span></span></div></div><div class="ant-list-item-meta-content"><h4 class="ant-list-item-meta-title"><span>城保参保单位人员增加</span></h4><div class="ant-list-item-meta-description"><span>城保参保单位人员增加</span></div></div></div><ul class="ant-list-item-action"><li><div><span><span role="img" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#icon-shoucang"></use></svg></span></span><br>收藏</div><em class="ant-list-item-action-split"></em></li><li><div><span class="iconzx___1CMzc"><span role="img" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#icon-zaixian"></use></svg></span></span><br>在线办理</div></li></ul></li>
点击城保参保单位人员增加的在线办理按钮
<div class="ant-upload ant-upload-select ant-upload-select-text"><span tabindex="0" class="ant-upload" role="button"><input aria-required="true" id="customized_form_controls_data" type="file" accept="" style="display: none;"><div class="upBox___1HjlP">浏览</div></span></div>
导入对应的文件
<div class="ant-space ant-space-horizontal ant-space-align-center" style="gap: 8px;"><div class="ant-space-item" style=""><div class="dianBox___3LF74" style=""></div></div><div class="ant-space-item" style=""><button type="submit" class="ant-btn ant-btn-primary"><span>导 入</span></button></div><div class="ant-space-item" style=""><button type="button" class="ant-btn ant-btn-default"><span>取 消</span></button></div><div class="ant-space-item" style=""><button type="button" class="ant-btn ant-btn-primary"><span>预申报</span></button></div><div class="ant-space-item"><button type="button" class="ant-btn ant-btn-primary" ant-click-animating-without-extra-node="false"><span>模板下载</span></button></div></div>
点击导入按钮,会提示导入状态
<div class="ant-modal-content"><button type="button" aria-label="Close" class="ant-modal-close"><span class="ant-modal-close-x"><span role="img" aria-label="close" class="anticon anticon-close ant-modal-close-icon"><svg viewBox="64 64 896 896" focusable="false" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></span></span></button><div class="ant-modal-header"><div class="ant-modal-title" id="rc_unique_1">系统提示</div></div><div class="ant-modal-body"><div class="modelSuccess___1gz2e"><p>导入完成,成功:1人,失败:0人</p><p><button type="button" class="ant-btn ant-btn-primary"><span>确 定</span></button></p></div></div></div>
校验名单导入情况
下面会显示校验通过人员和校验未通过人员
<div role="tablist" class="ant-tabs-nav"><div class="ant-tabs-nav-wrap"><div class="ant-tabs-nav-list" style="transform: translate(0px, 0px);"><div class="ant-tabs-tab ant-tabs-tab-active"><div role="tab" aria-selected="true" class="ant-tabs-tab-btn" tabindex="0" id="rc-tabs-0-tab-1" aria-controls="rc-tabs-0-panel-1"><span>校验通过人员</span></div></div><div class="ant-tabs-tab"><div role="tab" aria-selected="false" class="ant-tabs-tab-btn" tabindex="0" id="rc-tabs-0-tab-0" aria-controls="rc-tabs-0-panel-0"><span>校验未通过人员</span></div></div><div class="ant-tabs-ink-bar ant-tabs-ink-bar-animated" style="left: 0px; width: 84px;"></div></div></div><div class="ant-tabs-nav-operations ant-tabs-nav-operations-hidden"><button type="button" class="ant-tabs-nav-more" tabindex="-1" aria-hidden="true" aria-haspopup="listbox" aria-controls="rc-tabs-0-more-popup" id="rc-tabs-0-more" aria-expanded="false" style="visibility: hidden; order: 1;"><span role="img" aria-label="ellipsis" class="anticon anticon-ellipsis"><svg viewBox="64 64 896 896" focusable="false" data-icon="ellipsis" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"></path></svg></span></button></div></div>
<div class="ant-table-container"><div class="ant-table-content"><table style="table-layout: auto;"><colgroup><col><col><col><col><col style="width: 120px;"></colgroup><thead class="ant-table-thead"><tr><th class="ant-table-cell">序号</th><th class="ant-table-cell">姓名</th><th class="ant-table-cell">证件号码</th><th class="ant-table-cell">筛选结果</th><th class="ant-table-cell">操作</th></tr></thead><tbody class="ant-table-tbody"><tr class="ant-table-placeholder"><td colspan="5" class="ant-table-cell"><div class="ant-empty ant-empty-normal"><div class="ant-empty-image"><svg class="ant-empty-img-simple" width="64" height="41" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse class="ant-empty-img-simple-ellipse" cx="32" cy="33" rx="32" ry="7"></ellipse><g class="ant-empty-img-simple-g" fill-rule="nonzero"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" class="ant-empty-img-simple-path"></path></g></g></svg></div><div class="ant-empty-description">暂无数据</div></div></td></tr></tbody></table></div></div>
<div class="ant-table-content"><table style="table-layout: auto;"><colgroup></colgroup><thead class="ant-table-thead"><tr><th class="ant-table-cell">序号</th><th class="ant-table-cell">姓名</th><th class="ant-table-cell">证件号码</th><th class="ant-table-cell">详细信息</th></tr></thead><tbody class="ant-table-tbody"><tr class="ant-table-placeholder"><td colspan="4" class="ant-table-cell"><div class="ant-empty ant-empty-normal"><div class="ant-empty-image"><svg class="ant-empty-img-simple" width="64" height="41" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse class="ant-empty-img-simple-ellipse" cx="32" cy="33" rx="32" ry="7"></ellipse><g class="ant-empty-img-simple-g" fill-rule="nonzero"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" class="ant-empty-img-simple-path"></path></g></g></svg></div><div class="ant-empty-description">暂无数据</div></div></td></tr></tbody></table></div>
这个时候未通过人员需要回写台账,根据证件号码匹配社保变更及增减名单及人数统计表中身份证号码,将未通过人员的详细信息填写到备注列对应行中,办理状态回写参保失败
校验通过人员点击预申报按钮
<div class="ant-modal-content"><button type="button" aria-label="Close" class="ant-modal-close"><span class="ant-modal-close-x"><span role="img" aria-label="close" class="anticon anticon-close ant-modal-close-icon"><svg viewBox="64 64 896 896" focusable="false" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></span></span></button><div class="ant-modal-body"><div class="modelSuccess___1gz2e"><p class="tuSuccess___LMERo"><span role="img" aria-label="check-circle" class="anticon anticon-check-circle"><svg viewBox="64 64 896 896" focusable="false" data-icon="check-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M699 353h-46.9c-10.2 0-19.9 4.9-25.9 13.3L469 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H325c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8a31.8 31.8 0 0051.7 0l210.6-292c3.9-5.3.1-12.7-6.4-12.7z"></path><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path></svg></span></p><p>提交成功</p><p>预申报成功,您可以在【申报】功能中提交正式申报!</p><p><button type="button" class="ant-btn ant-btn-default"><span>暂不申报</span></button><button type="button" class="ant-btn ant-btn-primary"><span>去申报</span></button></p></div></div></div>
点击去申报按钮
这个时候会出现两个弹窗,需要关闭,
<div class="ant-modal-content"><div class="ant-modal-header"><div class="ant-modal-title" id="rc_unique_0">系统提示</div></div><div class="ant-modal-body"><p>社保经办机构统一受理单位申报的职工参加社会保险人员增加、减少业务。若申报险种包含医疗保险、生育保险,社保经办机构审核通过后,将医疗保险、生育保险申报信息同步推送医保部门,最终以医保部门审核结果为准。</p></div><div class="ant-modal-footer"><button type="button" class="ant-btn ant-btn-default"><span>我已知晓</span></button></div></div>
<div class="ant-popover-inner" role="tooltip"><div class="ant-popover-inner-content"><div class="ant-popover-message"><span role="img" aria-label="exclamation-circle" class="anticon anticon-exclamation-circle"><svg viewBox="64 64 896 896" focusable="false" data-icon="exclamation-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"></path></svg></span><div class="ant-popover-message-title">1、点击结果列表中【查看】可检查预申报信息是否正确;
2、若需要修改预申报数据,可勾选相应数据并点击【删除预申报】,然后重新操作预申报流程;
3、确定信息无误后,可勾选数据点击【提交确认】进行批量提交,也可点击【全部提交】进行全部数据提交;
4、点击【提交确认】或【全部提交】以后,进入提交界面(文件预览—证明材料上传—提交)。</div></div><div class="ant-popover-buttons"><button type="button" class="ant-btn ant-btn-primary ant-btn-sm"><span>我知道了</span></button></div></div></div>
弹窗关闭完成点击全部提交按钮
<div class="ant-space ant-space-horizontal ant-space-align-center" style="gap: 8px;"><div class="ant-space-item" style=""><span><button type="button" class="ant-btn ant-btn-primary"><span>提交确认</span></button></span></div><div class="ant-space-item" style=""><span><button type="button" class="ant-btn ant-btn-primary"><span>全部提交</span></button></span></div><div class="ant-space-item"><span><button type="button" class="ant-btn ant-btn-primary"><span>删除预申报</span></button></span></div></div>
这个时候要等待这个pdf绘制完成
<div id="div_show_pdf" style="width: 100%; min-height: 100px; margin: 5px;"><div class="react-pdf__Document"><div class="react-pdf__Page" data-page-number="1" style="position: relative;"><canvas class="react-pdf__Page__canvas" dir="ltr" width="1080" height="763" style="display: block; user-select: none; width: 1080px; height: 763px;"></canvas><div class="react-pdf__Page__textContent" style="position: absolute; top: 50%; left: 50%; width: 1080px; height: 763.183px; color: transparent; transform: translate(-50%, -50%) rotate(0deg); pointer-events: none;"><span style="height: 1em; font-family: STSong, sans-serif; font-size: 25.6532px; position: absolute; top: 59.0024px; left: 334.774px; transform-origin: left bottom; white-space: pre; pointer-events: all;">重庆市参加社会保险人员基本情况表</span><span style="height: 1em; font-family: STSong, sans-serif; font-size: 15.3919px; position: absolute; top: 151.354px; left: 127.394px; transform-origin: left bottom; white-space: pre; pointer-events: all;">
然后点击下一步按钮
<div class="ant-col ant-col-24" style="padding-left: 5px; padding-right: 5px;"><div class="moblieBtn___2FryC"><button type="button" class="ant-btn ant-btn-default"><span>上一步</span></button><button type="button" class="ant-btn ant-btn-primary"><span>下一步</span></button></div></div>
点击提交按钮
<div class="ant-form-item-control-input"><div class="ant-form-item-control-input-content"><button type="button" class="ant-btn ant-btn-default"><span>上一步</span></button><button type="button" class="ant-btn ant-btn-primary"><span>提 交</span></button></div></div>
关闭弹窗
<div class="ant-modal-content"><button type="button" aria-label="Close" class="ant-modal-close"><span class="ant-modal-close-x"><span role="img" aria-label="close" class="anticon anticon-close ant-modal-close-icon"><svg viewBox="64 64 896 896" focusable="false" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></span></span></button><div class="ant-modal-body"><div class="modelSuccess___1UWPT"><p>1.提交申报信息后,后续将反馈审核结果,请及时查看:</p><p>2.人员新增成功后,请在本月底前向税务部门申报缴费,逾期将影响社会保险待遇。(参保单位点击“已知晓”后,方可进行正式提交)。</p><p><button type="button" class="ant-btn ant-btn-default"><span>取 消</span></button><button type="button" class="ant-btn ant-btn-primary"><span>已知晓</span></button></p><div class="mobanbgAuto2" style="display: none;"><div class="ant-spin ant-spin-spinning ant-spin-show-text" aria-live="polite" aria-busy="true"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span><div class="ant-spin-text">提交中...</div></div></div></div></div></div>
这个时候需要等待弹窗出现
<div class="ant-modal-content"><button type="button" aria-label="Close" class="ant-modal-close"><span class="ant-modal-close-x"><span role="img" aria-label="close" class="anticon anticon-close ant-modal-close-icon"><svg viewBox="64 64 896 896" focusable="false" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></span></span></button><div class="ant-modal-body"><div class="modelSuccess___1UWPT"><p class="tuSuccess___1fhnD"><span role="img" aria-label="check-circle" class="anticon anticon-check-circle"><svg viewBox="64 64 896 896" focusable="false" data-icon="check-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M699 353h-46.9c-10.2 0-19.9 4.9-25.9 13.3L469 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H325c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8a31.8 31.8 0 0051.7 0l210.6-292c3.9-5.3.1-12.7-6.4-12.7z"></path><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path></svg></span></p><p>1、您已成功提交职工新参保批量申报,待社保经办机构审核!</p><p>2、您可以通过【已申报查询】功能查看审核结果,请耐心等待!</p><p><button type="button" class="ant-btn ant-btn-default"><span>确 定</span></button><button type="button" class="ant-btn ant-btn-primary"><span>去查看</span></button></p></div></div></div>
点击去查看按钮
读取序号1的记录,点击查看按钮
<div class="ant-table-wrapper"><div class="ant-spin-nested-loading"><div class="ant-spin-container"><div class="ant-table ant-table-middle"><div class="ant-table-container"><div class="ant-table-content"><table style="table-layout: auto;"><colgroup><col><col><col><col><col><col style="width: 100px;"><col style="width: 120px;"></colgroup><thead class="ant-table-thead"><tr><th class="ant-table-cell">序号</th><th class="ant-table-cell">受理编号</th><th class="ant-table-cell">结算所属期</th><th class="ant-table-cell">业务类型</th><th class="ant-table-cell">申请时间</th><th class="ant-table-cell">当前状态</th><th class="ant-table-cell">操作</th></tr></thead><tbody class="ant-table-tbody"><tr class="ant-table-row ant-table-row-level-0"><td class="ant-table-cell">1</td><td class="ant-table-cell">10049449709786</td><td class="ant-table-cell">202609</td><td class="ant-table-cell">企业职工人员增加</td><td class="ant-table-cell">2026-09-11</td><td class="ant-table-cell">待审核</td><td class="ant-table-cell"><div class="ant-space ant-space-horizontal ant-space-align-center" style="gap: 16px;"><div class="ant-space-item"><a>查看</a></div></div></td></tr></tbody></table></div></div></div><ul class="ant-pagination ant-pagination-mini ant-table-pagination ant-table-pagination-right" unselectable="unselectable"><li class="ant-pagination-total-text">第 1-9 条/总共 9 条</li><li title="上一页" class="ant-pagination-prev ant-pagination-disabled" aria-disabled="true"><button class="ant-pagination-item-link" type="button" tabindex="-1" disabled=""><span role="img" aria-label="left" class="anticon anticon-left"><svg viewBox="64 64 896 896" focusable="false" data-icon="left" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"></path></svg></span></button></li><li title="1" class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active" tabindex="0"><a rel="nofollow">1</a></li><li title="下一页" class="ant-pagination-next ant-pagination-disabled" aria-disabled="true"><button class="ant-pagination-item-link" type="button" tabindex="-1" disabled=""><span role="img" aria-label="right" class="anticon anticon-right"><svg viewBox="64 64 896 896" focusable="false" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg></span></button></li><li class="ant-pagination-options"><div class="ant-select ant-select-sm ant-pagination-options-size-changer ant-select-single ant-select-show-arrow" aria-label="页码"><div class="ant-select-selector"><span class="ant-select-selection-search"><input type="search" autocomplete="off" class="ant-select-selection-search-input" role="combobox" aria-expanded="false" aria-haspopup="listbox" aria-owns="rc_select_12_list" aria-autocomplete="list" aria-controls="rc_select_12_list" aria-activedescendant="rc_select_12_list_0" aria-label="页码" readonly="" unselectable="on" value="" id="rc_select_12" style="opacity: 0;"></span><span class="ant-select-selection-item" title="10 条/页">10 条/页</span></div><span class="ant-select-arrow" unselectable="on" aria-hidden="true" style="user-select: none;"><span role="img" aria-label="down" class="anticon anticon-down ant-select-suffix"><svg viewBox="64 64 896 896" focusable="false" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></span></span></div></li></ul></div></div></div>
会出现完整的记录表
<table style="table-layout: auto;"><colgroup><col><col><col><col><col><col><col style="width: 120px;"></colgroup><thead class="ant-table-thead"><tr><th class="ant-table-cell">业务流水号</th><th class="ant-table-cell">业务类型</th><th class="ant-table-cell">姓名</th><th class="ant-table-cell">证件号码</th><th class="ant-table-cell">审核结论</th><th class="ant-table-cell">审核意见</th><th class="ant-table-cell">操作</th></tr></thead><tbody class="ant-table-tbody"><tr class="ant-table-row ant-table-row-level-0"><td class="ant-table-cell">2098251612312584192</td><td class="ant-table-cell">企业职工人员增加</td><td class="ant-table-cell">许光伟</td><td class="ant-table-cell">513030198204065218</td><td class="ant-table-cell"><p class="colorSize">待审核</p></td><td class="ant-table-cell">--</td><td class="ant-table-cell"><div class="ant-space ant-space-horizontal ant-space-align-center" style="gap: 16px;"><div class="ant-space-item"><a>申报查看</a></div></div></td></tr></tbody></table>
根据审核结论,回写台账状态
回写台账,根据证件号码匹配社保变更及增减名单及人数统计表中身份证号码,办理状态回写真实审核结论到办理状态
保持系统原生标题栏
这是让标题栏看起来像正常桌面软件的第一步。
在 webview.create_window() 中,不要设置 frameless=True。保持默认值 frameless=False,pywebview 就会使用 Windows 系统原生的标题栏和最小化/最大化/关闭按钮。
python
window = webview.create_window(
title='我的应用',
url='...',
frameless=False, # 关键:使用系统原生标题栏
easy_drag=False # 原生标题栏无需 easy_drag
)
📄 嵌入正确的 Manifest
这是解决标题栏样式“不对劲”最关键的一步。创建 app.manifest 文件,声明启用 Common Controls 6.0 和 DPI 感知。
xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*"
name="MyCompany.MyApp" type="win32"/>
<description>MyApp</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</windowsSettings>
</application>
</assembly>
打包时通过 --manifest 参数嵌入:
bash
pyinstaller --noconfirm --clean --windowed --name MyApp ^
--icon app.ico ^
--manifest app.manifest ^
main.py
🖼️ 设置窗口图标
--icon app.ico 只改变 exe 文件本身的图标。运行时窗口标题栏左上角的图标,不会自动跟着变,默认还是 Python 的图标。
对于 Windows,pywebview 官方推荐的方式是通过打包工具嵌入图标,而不是用 webview.start(icon=...)。所以 --icon app.ico 配合 PyInstaller 打包,是 Windows 下的正确做法。有 PR 已经为 WinForms 后端添加了 webview.start(icon=...) 的支持,但最稳妥的方式仍然是打包时嵌入。
📌 设置 AppUserModelID
这一步解决任务栏图标分组和固定的问题。在程序入口最前面调用:
python
import ctypes
try:
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("MyCompany.MyApp")
except Exception:
pass
字符串可以自定义,但如果你做了安装包和快捷方式,快捷方式的 AppUserModelID 也要保持一致。
📦 完整入口代码示例
python
import ctypes
import webview
try:
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("MyCompany.MyApp")
except Exception:
pass
if __name__ == "__main__":
window = webview.create_window(
title="我的应用",
url="http://127.0.0.1:8000", # 或 file:// 加载 Vue dist
width=1200,
height=800,
frameless=False
)
webview.start(debug=False)
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -1,108 +0,0 @@
This file lists modules PyInstaller was not able to find. This does not
necessarily mean these modules are required for running your program. Both
Python's standard library and 3rd-party Python packages often conditionally
import optional modules, some of which may be available only on certain
platforms.
Types of import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported within a function
* optional: imported within a try-except-statement
IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
tracking down the missing module yourself. Thanks!
missing module named pwd - imported by posixpath (delayed, conditional, optional), shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional), webbrowser (delayed), getpass (delayed), netrc (delayed, conditional)
missing module named grp - imported by shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional)
missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed)
missing module named fcntl - imported by subprocess (optional)
missing module named _posixshmem - imported by multiprocessing.resource_tracker (conditional), multiprocessing.shared_memory (conditional)
missing module named 'org.python' - imported by copy (optional), xml.sax (delayed, conditional)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named termios - imported by click._termui_impl (conditional), tty (top-level), getpass (optional)
missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional)
missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named posix - imported by posixpath (optional), shutil (conditional), importlib._bootstrap_external (conditional), os (conditional, optional)
missing module named resource - imported by posix (top-level)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named org - imported by pickle (optional)
missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.Pipe - imported by multiprocessing (top-level), uvicorn.supervisors.multiprocess (top-level)
missing module named pyimod02_importers - imported by D:\work\code\37duAutomation\.venv\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py (delayed)
missing module named 'gunicorn.workers' - imported by uvicorn.workers (top-level)
missing module named gunicorn - imported by uvicorn.workers (top-level)
missing module named asyncio.DefaultEventLoopPolicy - imported by asyncio (delayed, conditional), asyncio.events (delayed, conditional)
missing module named watchfiles - imported by uvicorn.supervisors.watchfilesreload (top-level)
missing module named vms_lib - imported by platform (delayed, optional)
missing module named java - imported by platform (delayed)
missing module named _winreg - imported by platform (delayed, optional)
missing module named 'wsproto.utilities' - imported by uvicorn.protocols.websockets.wsproto_impl (top-level)
missing module named 'wsproto.extensions' - imported by uvicorn.protocols.websockets.wsproto_impl (top-level)
missing module named 'wsproto.connection' - imported by uvicorn.protocols.websockets.wsproto_impl (top-level)
missing module named wsproto - imported by uvicorn.protocols.websockets.wsproto_impl (top-level), uvicorn.protocols.websockets.auto (optional)
missing module named annotationlib - imported by typing_extensions (conditional), pydantic._internal._typing_extra (delayed, conditional), pydantic._internal._model_construction (delayed, conditional), pydantic.v1.main (delayed, conditional), fastapi.dependencies.utils (delayed, conditional, optional)
missing module named trio - imported by anyio._backends._trio (top-level), websockets.trio.client (top-level), websockets.trio.connection (top-level), websockets.trio.messages (top-level), websockets.trio.utils (top-level), websockets.trio.router (top-level), websockets.trio.server (top-level)
missing module named 'trio.abc' - imported by websockets.trio.connection (top-level), websockets.trio.server (top-level)
missing module named 'werkzeug.routing' - imported by websockets.asyncio.router (optional), websockets.sync.router (optional), websockets.trio.router (optional)
missing module named 'werkzeug.exceptions' - imported by websockets.sync.router (optional), websockets.trio.router (optional)
missing module named 'python_socks.async_' - imported by websockets.asyncio.client (optional), websockets.trio.client (optional)
missing module named python_socks - imported by websockets.asyncio.client (optional), websockets.sync.client (optional), websockets.trio.client (optional)
missing module named 'python_socks.sync' - imported by websockets.sync.client (optional)
missing module named readline - imported by websockets.cli (delayed, optional)
missing module named werkzeug - imported by websockets.asyncio.router (optional)
missing module named zttp - imported by uvicorn.protocols.http.zttp_impl (top-level)
missing module named httptools - imported by uvicorn.protocols.http.httptools_impl (top-level), uvicorn.protocols.http.auto (optional)
missing module named a2wsgi - imported by uvicorn.middleware.wsgi (optional)
missing module named uvloop - imported by anyio._backends._asyncio (delayed, conditional), uvicorn.loops.auto (delayed, optional), uvicorn.loops.uvloop (top-level)
missing module named 'IPython.core' - imported by dotenv.ipython (top-level)
missing module named IPython - imported by dotenv.ipython (top-level)
missing module named bcrypt - imported by cryptography.hazmat.primitives.serialization.ssh (optional)
missing module named pydantic.BaseModel - imported by pydantic (conditional), pydantic._internal._typing_extra (conditional), pydantic._internal._core_utils (delayed), pydantic._internal._import_utils (delayed, conditional), pydantic.deprecated.copy_internals (delayed, conditional), fastapi.exceptions (top-level), fastapi.types (top-level), fastapi._compat.shared (top-level), fastapi._compat.v2 (top-level), fastapi.openapi.models (top-level), fastapi.security.http (top-level), fastapi.dependencies.utils (top-level), fastapi.encoders (top-level), fastapi.sse (top-level), fastapi.openapi.utils (top-level), D:\work\code\37duAutomation\controlplane\app.py (top-level)
missing module named cython - imported by pydantic.v1.version (optional)
missing module named email_validator - imported by pydantic.networks (delayed, conditional, optional), pydantic.v1.networks (delayed, conditional, optional), fastapi.openapi.models (optional), pydantic.v1._hypothesis_plugin (optional)
missing module named toml - imported by pydantic.v1.mypy (delayed, conditional, optional)
missing module named tomli - imported by pydantic.mypy (delayed, conditional, optional), pydantic.v1.mypy (delayed, conditional, optional)
missing module named 'mypy.version' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.util' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.typevars' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.types' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.server' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.semanal' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.plugins' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.plugin' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.options' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.nodes' - imported by pydantic.mypy (top-level), pydantic.v1.mypy (top-level)
missing module named 'mypy.errorcodes' - imported by pydantic.v1.mypy (top-level)
missing module named hypothesis - imported by pydantic.v1._hypothesis_plugin (top-level)
missing module named 'mypy.typeops' - imported by pydantic.mypy (top-level)
missing module named 'mypy.type_visitor' - imported by pydantic.mypy (top-level)
missing module named 'mypy.state' - imported by pydantic.mypy (top-level)
missing module named 'mypy.expandtype' - imported by pydantic.mypy (top-level)
missing module named mypy - imported by pydantic.mypy (top-level)
missing module named eval_type_backport - imported by pydantic._internal._typing_extra (delayed, optional)
missing module named _typeshed - imported by anyio.abc._eventloop (conditional), anyio._core._sockets (conditional), anyio._core._fileio (conditional), anyio._core._tempfile (conditional), pydantic_core._pydantic_core (top-level), pydantic._internal._dataclasses (conditional), anyio._backends._asyncio (conditional), anyio._core._asyncio_selector_thread (conditional), anyio._backends._trio (conditional)
missing module named 'rich.pretty' - imported by pydantic._internal._core_utils (delayed)
missing module named rich - imported by pydantic._internal._core_utils (conditional)
missing module named pydantic.PydanticSchemaGenerationError - imported by pydantic (delayed), pydantic.functional_validators (delayed), fastapi._compat.v2 (top-level)
missing module named pydantic.PydanticUserError - imported by pydantic (top-level), pydantic.root_model (top-level)
missing module named 'itsdangerous.exc' - imported by starlette.middleware.sessions (top-level)
missing module named itsdangerous - imported by starlette.middleware.sessions (top-level)
missing module named exceptiongroup - imported by anyio._core._exceptions (conditional), anyio._core._sockets (conditional), starlette._utils (conditional, optional), anyio._backends._asyncio (conditional), anyio._backends._trio (conditional)
missing module named sniffio - imported by anyio._core._eventloop (optional)
missing module named 'trio.testing' - imported by anyio._backends._trio (delayed)
missing module named 'trio.to_thread' - imported by anyio._backends._trio (top-level)
missing module named 'trio.socket' - imported by anyio._backends._trio (top-level)
missing module named outcome - imported by anyio._backends._trio (top-level)
missing module named 'trio.lowlevel' - imported by anyio._backends._trio (top-level)
missing module named '_pytest.outcomes' - imported by anyio._backends._asyncio (delayed)
missing module named _pytest - imported by anyio._backends._asyncio (delayed)
missing module named winloop - imported by anyio._backends._asyncio (delayed, conditional)
missing module named 'pathlib.types' - imported by anyio._core._fileio (conditional)
missing module named pydantic_extra_types - imported by fastapi.encoders (optional)
File diff suppressed because it is too large Load Diff
Binary file not shown.
-3
View File
@@ -1,3 +0,0 @@
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEINebsZBPVReZkreG8WzWLbqQ1YCfQixhfvbDhAg8NUM7
-----END PRIVATE KEY-----
-3
View File
@@ -1,3 +0,0 @@
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAixXXpXRAdY3HDgNzmP5wETRTCwGpcBV8NRVy79RylTU=
-----END PUBLIC KEY-----
Binary file not shown.
-3
View File
@@ -1,3 +0,0 @@
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIMsL5NSDmTeZ3xyxeQ9/XO58CMTSgkfRgtG+W3OOfyPS
-----END PRIVATE KEY-----
-3
View File
@@ -1,3 +0,0 @@
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAVLjHamfNRcKyUwFWD3S36poIyeHuRToO2Ib/zK8JLgA=
-----END PUBLIC KEY-----
@@ -505,4 +505,37 @@ def admin_reports(limit: int = Query(default=200, ge=1, le=1000),
"FROM runtime_reports ORDER BY id DESC LIMIT ?", (limit,))]
for r in rows:
r["nickname"] = nick.get(r["account"], "")
return {"reports": rows}
return {"reports": rows}
@router.post("/api/admin/shell-release")
async def admin_shell_release(upload: UploadFile = File(...),
version: str = Query(...),
notes: str = Query(default=""),
sha256: str = Query(default=""),
x_admin_token: str = Header(default="", alias="X-Admin-Token"),
x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
"""发布执行机壳子新版安装包:存到 shell/ + 写 version.json(管理员)。
供 agent CLI / 管理端从任意机器上传壳子安装包,执行机据此自动下载升级。
"""
_require_admin(x_admin_token, x_api_token)
version = version.strip()
if not version:
raise HTTPException(400, "version 不能为空")
if not _SAFE_NAME_RE.match(version):
raise HTTPException(400, "version 仅允许字母数字及 . _ -")
config.SHELL_DIR.mkdir(parents=True, exist_ok=True)
filename = f"setup-37du-host-{version}.exe"
content = await upload.read()
if not content:
raise HTTPException(400, "上传内容为空")
if not sha256:
sha256 = hashlib.sha256(content).hexdigest()
(config.SHELL_DIR / filename).write_bytes(content)
(config.SHELL_DIR / "version.json").write_text(
json.dumps({"version": version, "filename": filename,
"sha256": sha256, "notes": notes},
ensure_ascii=False, indent=2), encoding="utf-8")
_audit("", "shell-release", filename)
return {"ok": True, "version": version, "filename": filename, "sha256": sha256}
@@ -5,6 +5,7 @@
"""
from __future__ import annotations
import json
import secrets
from fastapi import APIRouter, Header, HTTPException, Query
@@ -232,4 +233,45 @@ def runtime_report(b: schemas.RuntimeReportIn,
"VALUES (?,?,?,?,?,?,?,?)",
(b.account, b.device_id, b.plugin_id, b.version, b.status, b.msg, b.duration_sec, _now()))
conn.commit()
return {"ok": True}
return {"ok": True}
# ==================== 壳子(执行机主程序)自动更新 ====================
# shell/version.json 约定:{"version": "1.0.0", "filename": "setup-37du-host-1.0.0.exe",
# "sha256": "<可选,安装包校验值>", "notes": "<可选,更新说明>"}
def _shell_meta() -> dict:
"""读 shell/version.json;缺失/非法返回空 dict。"""
vf = config.SHELL_DIR / "version.json"
if not vf.is_file():
return {}
try:
d = json.loads(vf.read_text(encoding="utf-8"))
return d if isinstance(d, dict) else {}
except Exception: # noqa: BLE001
return {}
@router.get("/api/shell/version")
def shell_version(x_api_token: str = Header(default="", alias="X-API-Token")) -> dict:
"""壳子版本清单:执行端启动时比对,判断是否需要自动下载升级包。"""
_check_token(x_api_token)
m = _shell_meta()
if not m.get("version"):
return {"available": False, "version": ""}
return {"available": True, "version": str(m["version"]),
"filename": m.get("filename", ""), "sha256": m.get("sha256", ""),
"notes": m.get("notes", "")}
@router.get("/api/shell/pkg")
def shell_pkg(x_api_token: str = Header(default="", alias="X-API-Token")):
"""下载壳子安装包(setup.exe),供执行端静默升级。"""
_check_token(x_api_token)
m = _shell_meta()
fn = m.get("filename", "")
path = config.SHELL_DIR / fn if fn else None
if not path or not path.exists():
raise HTTPException(404, "壳子安装包缺失,请联系管理员")
return FileResponse(path, filename=path.name, media_type="application/octet-stream")
@@ -11,8 +11,8 @@
DB:controlplane.db(同目录)。包文件:packages/。可选:CONTROLPLANE_TOKEN 非空时客户端须带
X-API-Token 请求头。
运行(本地 .venv):
python controlplane/app.py # 首次自动建表 + 种子 + 生成示例包
运行(本地 .venv,需在 desktop/ 目录下执行,模块搜索根 = desktop/):
python -m controlplane.app # 首次自动建表 + 种子 + 生成示例包
uvicorn controlplane.app:app --port 8800
"""
from __future__ import annotations
@@ -24,6 +24,8 @@ def _app_base() -> Path:
APP_DIR = _app_base()
DB_PATH = APP_DIR / "controlplane.db"
PKG_DIR = APP_DIR / "packages"
# 壳子(执行机主程序)更新源:version.json + setup 安装包,供执行端自动下载升级
SHELL_DIR = APP_DIR / "shell"
def _load_dotenv() -> None:
@@ -14,7 +14,9 @@ from fastapi import HTTPException
# 插件包约束:大小上限 / 必含文件 / 保留版本数 / 安全文件名
_PKG_MAX_BYTES = 200 * 1024 * 1024
_PKG_REQUIRED_FILES = ("plugin.json", "main.py", "requirements.txt")
# webhost 执行端插件为 __init__.py 注册风格,故仅强制 plugin.json(manifest 契约);
# main.py 仅作为通用入口可选,不再必含。
_PKG_REQUIRED_FILES = ("plugin.json",)
_KEEP_VERSIONS = 3
_SAFE_NAME_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]*$")
@@ -0,0 +1,6 @@
{
"version": "1.0.0",
"filename": "setup-37du-host-1.0.0.exe",
"sha256": "57ee9cb4d10b25914276a277bfe42b0751f4c26c3c408af1293f723c7b4488a0",
"notes": "初始版本"
}
@@ -6,11 +6,12 @@
- 变更插件状态(published / disabled / revoked)与强制更新阈值
- 建号 / 重置密码 / 改部门昵称 / 授撤销管理员 / 删除账号
- 按账号授予 / 撤销插件与平台权限
- 发布执行机壳子(主程序)新版安装包(shell-release,上传到中心机 shell 源)
- 查看插件 / 账号 / 运行统计
鉴权:
管理接口同时需要 内部凭证(X-API-Token) + 管理票据(X-Admin-Token)。
本脚本运行在中心机本机,直接复用 controlplane/.env 与 .admin_secret:
本脚本运行在中心机本机,直接复用 desktop/controlplane/.env 与 .admin_secret:
- X-API-Token 取自 CONTROLPLANE_TOKEN(.env);为空则该接口不强制,无需携带。
- X-Admin-Token 用 CONTROLPLANE_ADMIN_SECRET > CONTROLPLANE_TOKEN > .admin_secret
对指定管理员账号临时签发短期票据(与 app.py 完全一致,签名不可伪造)。
@@ -18,7 +19,7 @@
管理员账号:需用 --admin 显式指定(或设环境变量 AGENT_ADMIN_ACCOUNT),该账号须 is_admin=1。
运行(项目 .venv):
运行(项目 .venv,需在 desktop/ 目录下执行,模块搜索根 = desktop/):
python -m controlplane.tools.agent_cli publish plugin.zip --id report --version 1.2.0
python -m controlplane.tools.agent_cli plugins
python -m controlplane.tools.agent_cli grant alice report # 默认授予 download+run
@@ -141,6 +142,25 @@ class Client:
raise SystemExit(f"[x] HTTP {r.status_code}:{detail}")
return data
def shell_release(self, path: str, version: str, notes: str, sha256: str = "") -> dict:
"""上传壳子新版安装包到中心机(管理接口,缺省 sha256 由服务端计算并写 version.json)。"""
import requests
import urllib.parse
qs = urllib.parse.urlencode({"version": version, "notes": notes, "sha256": sha256})
with open(path, "rb") as fp:
r = requests.post(f"{self.base}/api/admin/shell-release?{qs}",
headers=self._headers(False),
files={"upload": (Path(path).name, fp, "application/octet-stream")},
timeout=600)
try:
data = r.json()
except ValueError:
data = {"raw": r.text[:300]}
if r.status_code >= 400:
detail = data.get("detail") if isinstance(data, dict) else data
raise SystemExit(f"[x] HTTP {r.status_code}:{detail}")
return data
# ------------------------------ 输出辅助 ------------------------------
def _plugin_rows(plugins) -> None:
@@ -233,6 +253,12 @@ def _build_parser() -> argparse.ArgumentParser:
sub.add_parser("me", help="校验当前管理身份")
p_shell = sub.add_parser("shell-release", help="发布执行机壳子新版安装包(更新 shell 源 + version.json)")
p_shell.add_argument("pkg", help="新安装包路径(setup-37du-host-<v>.exe)")
p_shell.add_argument("--version", required=True, help="壳子版本号(须高于执行机本地 shell.version)")
p_shell.add_argument("--notes", default="", help="更新说明(可选,执行机前端提示展示)")
p_shell.add_argument("--sha256", default="", help="安装包 sha256(可选,缺省自动计算)")
return parser
@@ -245,6 +271,13 @@ def _run(args: argparse.Namespace) -> int:
c = Client(args.base, API_TOKEN, args.admin, secret)
cmd = args.command
if cmd == "shell-release":
r = c.shell_release(args.pkg, args.version, args.notes, args.sha256)
print(f"[ok] 已发布壳子 v{r.get('version')} → {r.get('filename')}")
print(f" sha256={str(r.get('sha256') or '')[:16]}… notes={args.notes or '(无)'}")
print(f" 各执行机下次启动自动检测下载,前端提示后点击「重启更新」即静默升级。")
return 0
if cmd == "publish":
r = c.upload_pkg(args.pkg, args.plugin_id, args.name, args.version)
print(f"[ok] 已发布 {r.get('plugin_id')} v{r.get('version')} → {r.get('filename')}")
@@ -10,9 +10,11 @@ net session >nul 2>&1 || (echo [ERROR] Please run as Administrator. & pause & ex
set "TARGET=D:\code\controlplane"
rem locate exe: parent folder (controlplane/), or its dist\ subfolder
rem locate exe: parent folder (controlplane/), or its dist-exe\ subfolder
if exist "%~dp0..\37du-center.exe" (
set "SRC=%~dp0..\37du-center.exe"
) else if exist "%~dp0..\dist-exe\37du-center.exe" (
set "SRC=%~dp0..\dist-exe\37du-center.exe"
) else (
set "SRC=%~dp0..\dist\37du-center.exe"
)
@@ -72,6 +72,15 @@ def admin_login(b: _LoginIn, response: Response) -> dict:
except Exception as _exc: # noqa: BLE001 同步失败不影响登录本身
import logging
logging.getLogger(__name__).warning("登录后同步离线授权票据失败:%s", _exc)
# 登录成功即按账号权限自下载/更新插件并重载(离线/失败不影响登录)
try:
from webhost.backend.core.plugin_sync import sync_plugins
from webhost.backend.plugins import load_plugins
sync_plugins(b.account.strip())
load_plugins(None, reload=True)
except Exception as _exc: # noqa: BLE001
import logging
logging.getLogger(__name__).warning("登录后插件同步失败:%s", _exc)
return {**r, "account": b.account.strip()}
@@ -8,7 +8,9 @@ from webhost.backend import auth as platform_auth
from webhost.backend import config
from webhost.backend import state as _st
from webhost.backend import meta as _meta
from webhost.backend.plugins import PLUGINS
from webhost.backend.plugins import PLUGINS, load_plugins
from webhost.backend.core.plugin_sync import sync_plugins
from webhost.backend.core import shell_updater as _shell_updater
from webhost.backend.core.session import _require_login, _sess_account
router = APIRouter()
@@ -42,6 +44,37 @@ def meta(request: Request) -> dict:
}
@router.post("/api/plugins/sync")
def plugins_sync(request: Request) -> dict:
"""按当前登录账号权限自下载/更新插件,成功后重载注册表。
离线(控制面不可达)/未配置时返回空统计,前端直接沿用本地插件进入主界面。
"""
account = _require_login(request)
result = sync_plugins(account)
try:
load_plugins(_st.ALLOWED, reload=True)
except Exception as _exc: # noqa: BLE001 重载失败不阻断返回
import logging
logging.getLogger(__name__).warning("插件同步后重载失败:%s", _exc)
return result
@router.get("/api/shell/update-status")
def shell_update_status(request: Request) -> dict:
"""壳子更新状态:前端据此显示"发现新版本,点击重启更新"提示。"""
_require_login(request)
return _shell_updater.pending_status()
@router.post("/api/shell/apply")
def shell_apply(request: Request) -> dict:
"""应用壳子更新:运行新版安装包静默安装并退出进程(升级完成后自动重启新版本)。"""
_require_login(request)
_shell_updater.apply_update()
return {"ok": True} # 实际不会走到这里(apply 内 os._exit)
@router.post("/api/platforms/{pid}/login")
def platform_login(pid: str, request: Request) -> dict:
"""真实登录:需先通过统一账户登录(有会话),且该账号已获中心机平台授权。"""
@@ -7,15 +7,22 @@ from __future__ import annotations
import logging
import os
import sys
from pathlib import Path
_LOGGER = logging.getLogger(__name__)
# 部署底座路径根:webhost/(__file__ 位于 webhost/backend/config.py,parents[1]=webhost)
_HOST_ROOT = Path(__file__).resolve().parents[1]
# 打包运行(frozen)时:底座根 = exe 所在目录(.env、plugins/ 与 exe 同级部署);
# 前端静态资源打包进 exe 内部,运行时从解压目录(_MEIPASS)读取
if getattr(sys, "frozen", False):
_HOST_ROOT = Path(sys.executable).resolve().parent
DIST = Path(getattr(sys, "_MEIPASS", _HOST_ROOT)) / "frontend" / "dist"
else:
_HOST_ROOT = Path(__file__).resolve().parents[1]
DIST = _HOST_ROOT / "frontend" / "dist"
PORT = 8799
DIST = _HOST_ROOT / "frontend" / "dist"
def _load_dotenv() -> None:
@@ -16,6 +16,10 @@ import sys
def _bootstrap_paths() -> str:
"""把项目根插入 sys.path 并 chdir,保证 desktop/ 与 webhost/ 可被 import。"""
if getattr(sys, "frozen", False):
root = os.path.dirname(os.path.abspath(sys.executable)) # 打包运行:exe 同级目录
os.chdir(root)
return root
root = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.dirname(os.path.abspath(__file__))))) # core/plugin_runner.py → 项目根
if root not in sys.path:
+185
View File
@@ -0,0 +1,185 @@
# -*- coding: utf-8 -*-
"""webhost 插件按账号权限自下载 + 版本更新(执行机主动拉取,非控制面分发)。
流程:联网时按「当前登录账号」从控制面拉可用插件清单 → 对比本地已装版本,
缺失/落后则走 download-ticket 一次性票据下载 zip → sha256 校验 → 解压到
plugins/<id>/ 原子替换;更新成功后由宿主重载插件注册表。
降级策略:
- 控制面不可达/未配置 → 跳过同步,沿用本地已有插件(离线可继续运行)
- 单个插件下载/校验/解压失败 → 记 ERROR 跳过,不影响其它插件与本地旧版本
"""
from __future__ import annotations
import hashlib
import io
import json
import logging
import shutil
import tempfile
import zipfile
from pathlib import Path
from webhost.backend import config
from webhost.backend.plugins import _PLUGINS_ROOT
_LOGGER = logging.getLogger(__name__)
_DL_TIMEOUT = 30 # 包下载超时(秒)
_MAX_PKG_BYTES = 200 * 1024 * 1024 # 包大小上限,与控制面一致
def _headers() -> dict:
h = {}
if config.CONTROLPLANE_TOKEN:
h["X-API-Token"] = config.CONTROLPLANE_TOKEN
return h
def _cloud_plugin_manifest(account: str) -> list | None:
"""拉取账号可用插件清单(id/name/version)。控制面不可达/未配置返回 None。"""
if not config.CONTROLPLANE_URL or not account:
return None
import requests
try:
r = requests.get(f"{config.CONTROLPLANE_URL}/api/plugins",
params={"account": account}, headers=_headers(), timeout=5)
r.raise_for_status()
return r.json().get("plugins", [])
except Exception as _exc: # noqa: BLE001 离线兜底
_LOGGER.warning("拉取插件清单失败(离线用本地插件):%s", _exc)
return None
def _local_version(plugin_id: str) -> str:
"""本地已装插件版本:读 plugins/<id>/plugin.json.version;无则空串。"""
mf = _PLUGINS_ROOT / plugin_id / "plugin.json"
if not mf.is_file():
return ""
try:
return str(json.loads(mf.read_text(encoding="utf-8")).get("version") or "")
except Exception: # noqa: BLE001
return ""
def _version_lt(a: str, b: str) -> bool:
"""简单版本比较(数字段按 int 比较)。"""
def _key(v: str):
return [int(x) if x.isdigit() else x for x in str(v).split(".")]
try:
return _key(a) < _key(b)
except Exception: # noqa: BLE001
return a != b and a < b
def _dl_ticket(plugin_id: str, version: str, account: str) -> dict | None:
"""向控制面签发一次性下载票据;失败返回 None。"""
import requests
try:
r = requests.get(
f"{config.CONTROLPLANE_URL}/api/plugins/{plugin_id}/versions/{version}/download-ticket",
params={"account": account}, headers=_headers(), timeout=5)
r.raise_for_status()
return r.json()
except Exception as _exc: # noqa: BLE001
_LOGGER.warning("获取下载票据失败 %s@%s:%s", plugin_id, version, _exc)
return None
def _fetch_pkg(ticket: str) -> bytes | None:
"""凭一次性票据下载插件包 zip;失败返回 None。"""
import requests
try:
r = requests.get(f"{config.CONTROLPLANE_URL}/api/download/{ticket}",
headers=_headers(), timeout=_DL_TIMEOUT)
r.raise_for_status()
return r.content
except Exception as _exc: # noqa: BLE001
_LOGGER.warning("下载插件包失败:%s", _exc)
return None
def _install_pkg(plugin_id: str, content: bytes) -> bool:
"""把插件包解压安装到 plugins/<id>/(临时目录 → 原子替换)。
包根目录需含 plugin.json;解压前校验非法路径防目录穿越。
"""
if len(content) > _MAX_PKG_BYTES:
_LOGGER.error("插件包 %s 超大小上限,拒绝安装", plugin_id)
return False
try:
zf = zipfile.ZipFile(io.BytesIO(content))
except zipfile.BadZipFile:
_LOGGER.error("插件包 %s 不是合法 ZIP", plugin_id)
return False
with zf:
names = zf.namelist()
if "plugin.json" not in names:
_LOGGER.error("插件包 %s 缺 plugin.json", plugin_id)
return False
for m in names:
if m.startswith("/") or ".." in m.split("/"):
_LOGGER.error("插件包 %s 含非法路径:%s", plugin_id, m)
return False
tmp = Path(tempfile.mkdtemp(prefix=f".pkg_{plugin_id}_"))
try:
zf.extractall(tmp)
except Exception as _exc: # noqa: BLE001
_LOGGER.error("解压插件包 %s 失败:%s", plugin_id, _exc)
shutil.rmtree(tmp, ignore_errors=True)
return False
# 原子替换:旧目录移除 → 新目录就位
target = _PLUGINS_ROOT / plugin_id
try:
target.parent.mkdir(parents=True, exist_ok=True)
if target.exists():
shutil.rmtree(target)
shutil.move(str(tmp), str(target))
except OSError as _exc: # noqa: BLE001
_LOGGER.error("安装插件 %s 失败:%s", plugin_id, _exc)
shutil.rmtree(tmp, ignore_errors=True)
return False
return True
def sync_plugins(account: str) -> dict:
"""按账号权限同步插件(首次下载 + 版本更新)。离线/失败静默降级,返回统计。"""
result = {"downloaded": [], "updated": [], "up_to_date": [], "failed": []}
if not config.CONTROLPLANE_URL or not account:
return result
manifest = _cloud_plugin_manifest(account)
if manifest is None:
return result
for p in manifest:
pid = p.get("id", "")
ver = p.get("version", "") or p.get("latest_version", "")
if not pid or not ver:
continue
local = _local_version(pid)
if local == ver or (local and not _version_lt(local, ver)):
result["up_to_date"].append(pid)
continue
tkt = _dl_ticket(pid, ver, account)
if not tkt:
result["failed"].append(pid)
continue
content = _fetch_pkg(tkt.get("ticket", ""))
if not content:
result["failed"].append(pid)
continue
expect = (tkt.get("sha256") or "").lower()
if expect and hashlib.sha256(content).hexdigest() != expect:
_LOGGER.error("插件包 %s@%s sha256 校验失败,拒绝安装", pid, ver)
result["failed"].append(pid)
continue
if _install_pkg(pid, content):
(result["updated"] if local else result["downloaded"]).append(pid)
else:
result["failed"].append(pid)
_LOGGER.info("插件同步完成:下载=%s 更新=%s 最新=%s 失败=%s",
result["downloaded"], result["updated"],
result["up_to_date"], result["failed"])
return result
@@ -38,12 +38,18 @@ def _run_target(plugin, fields: dict, run_id: str) -> None:
插件在此子进程内 `run()`,本地崩溃(死循环/sys.exit/内存爬升)不会拖垮底座;
登录态由子进程直接读取共享 cookie 文件重建,无需主进程中转。
"""
runner = Path(__file__).with_name("plugin_runner.py")
root = Path(__file__).resolve().parents[3] # core/runner.py → 项目根
timeout = int(os.getenv("RUN_TIMEOUT", "1800")) # 秒;浏览器类插件默认 30min
max_mem_mb = int(os.getenv("RUN_MAX_MEM_MB", "2048")) # 子进程作业内存上限(MB)
cmd = [sys.executable, "-u", str(runner), "--plugin", plugin.id, "--run", run_id]
# 打包运行(frozen):拉起同级 37du-host-runner.exe(console 壳,内置同一套执行代码)
if getattr(sys, "frozen", False):
runner_exe = Path(sys.executable).with_name("37du-host-runner.exe")
cmd = [str(runner_exe), "--plugin", plugin.id, "--run", run_id]
root = Path(sys.executable).resolve().parent
else:
runner = Path(__file__).with_name("plugin_runner.py")
root = Path(__file__).resolve().parents[3] # core/runner.py → 项目根
cmd = [sys.executable, "-u", str(runner), "--plugin", plugin.id, "--run", run_id]
if _st.ALLOWED is not None: # 子进程加载与宿主一致的白名单,杜绝越权 import
cmd += ["--allowed", ",".join(sorted(_st.ALLOWED))]
@@ -7,6 +7,7 @@ from __future__ import annotations
import json
import logging
import sys
import threading
import time
from pathlib import Path
@@ -23,7 +24,9 @@ _SESS_TTL = 7 * 24 * 3600
_SESS: dict[str, tuple] = {}
_SESS_LOCK = threading.Lock()
# 本机会话落盘文件:重启后端不丢会话(兑现"双击壳直接进插件页、不必每次重登")
_SESS_FILE = Path(__file__).resolve().parents[1] / "_cp_sessions.json"
# 打包运行(frozen)时落盘到 exe 同级目录
_SESS_FILE = (Path(sys.executable).resolve().parent if getattr(sys, "frozen", False)
else Path(__file__).resolve().parents[1]) / "_cp_sessions.json"
# account -> 最近云端会话 token(7 天,供壳后续调 /api/plugins 用 Bearer,见 §2.2)
_ACCT_CLOUD_TOKEN: dict[str, str] = {}
@@ -0,0 +1,135 @@
# -*- coding: utf-8 -*-
"""执行机壳子(主程序)自动更新:自动下载新版安装包,由用户点击触发静默升级重启。
流程(对应前端交互):
1. 检查+下载:启动时后台检查控制面 /api/shell/version,版本落后则自动把新版安装包
下载到 %LOCALAPPDATA%\\37duAutomation\\shell\\(本地缓存,不打断用户)。
2. 应用:前端提示"发现新版本"后用户点击 → apply_update() 运行安装包
/VERYSILENT 静默覆盖安装,随后本进程退出,Inno CloseApplications 收尾,
安装完成由 [Run] 自动重启新版本主程序。
3. 离线/控制面不可达/校验失败:静默跳过,不影响使用。
"""
from __future__ import annotations
import hashlib
import logging
import os
import subprocess
import sys
import time
from pathlib import Path
from webhost.backend import config
_LOGGER = logging.getLogger(__name__)
# 下载缓存的安装包目录:独立于程序目录(升级时不被覆盖/清理)
_SHELL_CACHE = Path(os.environ.get("LOCALAPPDATA", str(Path.home()))) / "37duAutomation" / "shell"
# 已下载待应用的新版本(模块内状态,供 update-status 查询)
_PENDING: dict = {}
def local_shell_version() -> str:
"""本机壳子版本:frozen 时读 exe 同级 shell.version;源码运行返回空(不参与自更新)。"""
if not getattr(sys, "frozen", False):
return ""
vf = Path(sys.executable).resolve().parent / "shell.version"
try:
return vf.read_text(encoding="utf-8").strip() if vf.is_file() else ""
except OSError:
return ""
def _headers() -> dict:
h = {}
if config.CONTROLPLANE_TOKEN:
h["X-API-Token"] = config.CONTROLPLANE_TOKEN
return h
def _version_lt(a: str, b: str) -> bool:
def _key(v: str):
return [int(x) if x.isdigit() else x for x in str(v).split(".")]
try:
return _key(a) < _key(b)
except Exception: # noqa: BLE001
return a != b and a < b
def check_and_download() -> dict | None:
"""检查壳子更新并自动下载安装包到本地缓存。有可用更新返回 {version, notes};否则 None。"""
cur = local_shell_version()
if not cur or not config.CONTROLPLANE_URL:
return None
import requests
try:
r = requests.get(f"{config.CONTROLPLANE_URL}/api/shell/version",
headers=_headers(), timeout=5)
r.raise_for_status()
info = r.json()
except Exception as _exc: # noqa: BLE001 离线/不可达
_LOGGER.info("检查壳子更新失败(离线跳过):%s", _exc)
return None
if not info.get("available") or not info.get("version"):
return None
cloud = str(info["version"])
if not _version_lt(cur, cloud):
return None
try:
r = requests.get(f"{config.CONTROLPLANE_URL}/api/shell/pkg",
headers=_headers(), timeout=300)
r.raise_for_status()
data = r.content
except Exception as _exc: # noqa: BLE001
_LOGGER.warning("下载壳子安装包失败:%s", _exc)
return None
expect = (info.get("sha256") or "").lower()
if expect and hashlib.sha256(data).hexdigest() != expect:
_LOGGER.error("壳子安装包 sha256 校验失败,放弃更新")
return None
try:
_SHELL_CACHE.mkdir(parents=True, exist_ok=True)
pkg = _SHELL_CACHE / f"setup-37du-host-{cloud}.exe"
pkg.write_bytes(data)
except OSError as _exc: # noqa: BLE001
_LOGGER.warning("壳子安装包落盘失败:%s", _exc)
return None
_PENDING["version"] = cloud
_PENDING["notes"] = info.get("notes", "")
_LOGGER.info("壳子新版本已下载待应用:%s → %s(%d 字节)", cur, cloud, len(data))
return {"version": cloud, "notes": _PENDING["notes"]}
def cached_pkg(version: str) -> Path | None:
"""本地缓存的指定版本安装包路径;不存在返回 None。"""
p = _SHELL_CACHE / f"setup-37du-host-{version}.exe"
return p if p.is_file() else None
def pending_status() -> dict:
"""当前更新状态(供前端提示):当前版本 / 待应用新版本 / 是否已下载。"""
return {
"current": local_shell_version(),
"new": _PENDING.get("version", ""),
"notes": _PENDING.get("notes", ""),
"downloaded": bool(_PENDING.get("version"))
and cached_pkg(_PENDING.get("version", "")) is not None,
}
def apply_update() -> None:
"""运行新版安装包静默覆盖安装并退出本进程(升级完成后由 Inno 重启新版本)。
注意:本函数在返回前 os._exit(0) 退出整个进程,调用方无需继续处理。
"""
version = _PENDING.get("version", "")
pkg = cached_pkg(version)
if not pkg:
raise FileNotFoundError(f"未找到已下载的安装包:setup-37du-host-{version}.exe")
_LOGGER.info("开始静默升级到 %s:%s", version, pkg)
subprocess.Popen(
[str(pkg), "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART"],
cwd=str(pkg.parent), creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0))
time.sleep(1) # 给安装器接管进程,随后退出让 Inno CloseApplications 收尾
os._exit(0)
@@ -49,6 +49,34 @@ async def lifespan(app: FastAPI):
_LOGGER.info("启动同步离线授权票据成功(账号 %s)", config.CONTROLPLANE_ACCOUNT)
except Exception as _exc: # noqa: BLE001 首启/断网时同步失败不阻断,离线用缓存兜底
_LOGGER.warning("启动同步离线授权票据失败:%s", _exc)
# 启动即检查插件更新:有恢复的会话账号时后台同步(每次启动确定是否更新,不阻塞启动)
try:
from webhost.backend.core.session import _SESS
_accts = {_a for _, (_a, _t) in _SESS.items()}
except Exception: # noqa: BLE001
_accts = set()
if _accts:
_acct = next(iter(_accts))
def _boot_sync() -> None:
try:
from webhost.backend.core.plugin_sync import sync_plugins
sync_plugins(_acct)
load_plugins(_st.ALLOWED, reload=True)
_LOGGER.info("启动插件更新完成(账号 %s)", _acct)
except Exception as _exc: # noqa: BLE001 更新失败不阻断启动
_LOGGER.warning("启动插件更新失败:%s", _exc)
threading.Thread(target=_boot_sync, daemon=True).start()
# 启动即检查壳子(主程序)更新:有新版本自动下载,前端提示后由用户点击重启升级
def _boot_shell_check() -> None:
try:
from webhost.backend.core.shell_updater import check_and_download
check_and_download()
except Exception as _exc: # noqa: BLE001 检查失败不阻断启动
_LOGGER.warning("启动壳子更新检查失败:%s", _exc)
threading.Thread(target=_boot_shell_check, daemon=True).start()
yield
@@ -20,11 +20,22 @@ from __future__ import annotations
import importlib
import logging
import pathlib
import sys
import traceback
from webhost.backend.plugins.base import PLUGINS # noqa: F401 由 base 构造空注册表
_PLUGINS_ROOT = pathlib.Path(__file__).resolve().parent
# 插件目录(源码/打包统一的"单一真源"位置):
# - 打包运行(frozen)时:exe 同级 plugins/(中心机下发插件包解压到这里)
# - 源码运行:仓库根 plugins/(插件源码独立于底座,不随 webhost 发布)
# 两种形态都扩展本包搜索路径,使其可按 webhost.backend.plugins.<name> 被 import
if getattr(sys, "frozen", False):
_PLUGINS_ROOT = pathlib.Path(sys.executable).resolve().parent / "plugins"
else:
# __file__ = desktop/webhost/backend/plugins/__init__.py → parents[4] = 仓库根
_PLUGINS_ROOT = pathlib.Path(__file__).resolve().parents[4] / "plugins"
if _PLUGINS_ROOT.is_dir() and str(_PLUGINS_ROOT) not in __path__:
__path__.append(str(_PLUGINS_ROOT))
_PKG_NAME = __name__
_LOGGER = logging.getLogger(__name__)
@@ -47,11 +58,17 @@ def _discover_modules() -> list:
return names
def load_plugins(allowed: set = None) -> None:
def load_plugins(allowed: set = None, reload: bool = False) -> None:
"""动态加载插件。allowed 为 None = 全量;否则为严格白名单(空集 = 零权限,全不加载)。
reload=True 时先清空注册表与已加载模块缓存(用于插件自下载/更新后的重载,使新代码生效)。
单插件加载失败记 ERROR(含堆栈首行)后跳过,不拖垮整体启动。
"""
if reload:
PLUGINS.clear()
for _m in [m for m in sys.modules
if m.startswith(_PKG_NAME + ".") and m != _PKG_NAME]:
del sys.modules[_m]
for _mod in _discover_modules():
if allowed is not None and _mod not in allowed:
_LOGGER.info("插件 %s 不在权限白名单,跳过加载", _mod)
@@ -1,11 +1,16 @@
<template>
<div v-if="booting" class="boot">
<span class="boot-logo">37</span>
<span class="boot-txt">{{ store.appName || '自动化工作台' }}</span>
<span class="boot-txt">{{ syncing ? '正在同步插件,请稍候…' : (store.appName || '自动化工作台') }}</span>
<span class="boot-dots"><i></i><i></i><i></i></span>
</div>
<LoginPage v-else-if="!store.current" :app-name="store.appName" @ok="onLogin" />
<div class="__app" v-else>
<!-- 壳子更新提示:控制面有新版本且已自动下载,点击重启升级 -->
<div v-if="shellUpdate.downloaded" class="update-bar">
<span class="upd-txt">发现新版本 <b>v{{ shellUpdate.new }}</b><em v-if="shellUpdate.notes">{{ shellUpdate.notes }}</em></span>
<el-button size="small" type="primary" round :loading="updating" @click="doShellUpdate">重启更新</el-button>
</div>
<!-- 顶部:品牌 + 平台登录态 + 当前账号/登出 + 进度 -->
<header class="topbar panel">
<div class="brand">
@@ -59,10 +64,9 @@
<div class="acct">
<button class="acct-btn" title="个人中心" @click="profileOpen = true">
<el-avatar :size="26" class="acct-avatar" :src="store.avatarUrl" :key="store.avatarUrl" @error="onAvatarError">
<span class="acct-avatar-fb">{{ store.current.slice(0, 1).toUpperCase() }}</span>
<span class="acct-avatar-fb">{{ (store.nickname || store.current).slice(0, 1).toUpperCase() }}</span>
</el-avatar>
<span class="acct-name">{{ store.nickname ? store.nickname : store.current }}</span>
<span v-if="store.nickname" class="acct-sub">{{ store.current }}</span>
<span class="acct-name">{{ store.nickname || store.current }}</span>
<el-tag v-if="store.isAdmin" size="small" type="primary" effect="light" round>管理员</el-tag>
</button>
<el-button
@@ -123,7 +127,7 @@ import LogPanel from './components/LogPanel.vue'
import LoginPage from './components/LoginPage.vue'
import ProfilePanel from './components/ProfilePanel.vue'
import { store, handleEvent, clearLogs, log, loadAvatar, clearAvatarCache } from './store'
import { connectWS, fetchMeta, loginPlatform, adminLogout, adminMe, adminPassword } from './api'
import { connectWS, fetchMeta, loginPlatform, adminLogout, adminMe, adminPassword, syncPlugins, getShellStatus, applyShellUpdate } from './api'
function openConsole() {
if (!store.controlplane) return
@@ -169,11 +173,29 @@ onMounted(async () => {
await checkSession()
booting.value = false // 会话判定完成(登录/未登录/后端不可达均已定),再渲染首屏
loadAvatar()
loadShellStatus()
})
const profileOpen = ref(false)
const busyLogin = ref('')
const booting = ref(true) // 鉴权判定中:未确定会话前先显示加载骨架,避免「闪一下登录页再进首页」
const syncing = ref(false) // 首次启动/启动时:按账号权限自下载/更新插件(等待下载界面)
// ===== 壳子自动更新:控制面有新版本且已自动下载 → 提示用户点击重启升级 =====
const shellUpdate = ref({})
const updating = ref(false)
async function loadShellStatus() {
try { shellUpdate.value = await getShellStatus() } catch (_) {}
}
async function doShellUpdate() {
updating.value = true
try {
await applyShellUpdate() // 后端运行静默安装并退出进程,升级后自动重启
} catch (e) {
updating.value = false
ElMessage.error('更新失败:' + (e.message || e))
}
}
// 平台登录等轻量操作反馈:统一走 element-plus 全局消息
function showToast(msg, type = 'info') {
@@ -195,6 +217,10 @@ async function checkSession() {
store.dept = me.dept || ''
store.nickname = me.nickname || ''
try { localStorage.setItem('cp_account', me.account) } catch (_) {}
// 会话确认后:按账号权限自下载/更新插件(首次启动等待下载完成;离线/失败直接跳过)
syncing.value = true
try { await syncPlugins() } catch (_) {}
syncing.value = false
// 会话有效:补拉插件清单(未登录时 meta 不返回插件)
await refreshMeta()
} catch (_) { /* 后端 down:无法校验,保持现状(可能为登录页或本地态) */ }
@@ -303,6 +329,16 @@ async function login(id) {
padding: 12px 18px;
flex-shrink: 0;
}
.update-bar {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
padding: 8px 14px; margin-bottom: 12px; flex-shrink: 0;
background: var(--primary-weak);
border: 1px solid rgba(59, 108, 255, .35);
border-radius: var(--radius-sm);
font-size: 13px; color: var(--text-sub);
}
.update-bar b { color: var(--primary); }
.update-bar em { font-style: normal; color: var(--text-faint); margin-left: 6px; }
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
width: 36px; height: 36px; border-radius: 10px;
@@ -345,7 +381,6 @@ async function login(id) {
.acct-avatar { flex-shrink: 0; }
.acct-avatar-fb { font-size: 12px; font-weight: 700; }
.acct-name { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.acct-sub { font-size: 11px; color: var(--text-faint); margin-left: 1px; font-weight: 400; }
.body { flex: 1; display: flex; gap: 14px; min-height: 0; margin-top: 14px; }
@@ -15,6 +15,18 @@ export async function fetchMeta() {
return j('/api/meta')
}
export async function syncPlugins() {
return j('/api/plugins/sync', { method: 'POST' })
}
export async function getShellStatus() {
return j('/api/shell/update-status')
}
export async function applyShellUpdate() {
return j('/api/shell/apply', { method: 'POST' })
}
export async function loginPlatform(id) {
return j(`/api/platforms/${id}/login`, { method: 'POST' })
}
@@ -12,8 +12,10 @@
<el-radio-group v-model="level" size="small">
<el-radio-button v-for="l in LEVELS" :key="l" :value="l">{{ l }}</el-radio-button>
</el-radio-group>
<el-button size="small" :icon="CopyDocument" circle title="复制日志" :disabled="!visibleLogs.length" @click="copy" />
<el-button size="small" :icon="pause ? VideoPlay : VideoPause" circle :title="pause ? '继续滚动' : '暂停滚动'" @click="pause = !pause" />
<el-button size="small" :icon="CopyDocument" circle title="复制日志" :disabled="!visibleLogs.length"
@click="copy" />
<el-button size="small" :icon="pause ? VideoPlay : VideoPause" circle :title="pause ? '继续滚动' : '暂停滚动'"
@click="pause = !pause" />
<el-button size="small" plain :disabled="!store.logs.length" @click="confirmClear">清空</el-button>
</div>
</div>
@@ -65,7 +67,7 @@ function confirmClear() {
type: 'warning',
})
.then(() => { clearLogs(); ElMessage.success('日志已清空') })
.catch(() => {})
.catch(() => { })
}
async function copy() {
@@ -80,19 +82,82 @@ async function copy() {
</script>
<style scoped>
.log-wrap { display: flex; flex-direction: column; height: 216px; flex-shrink: 0; overflow: hidden; position: relative; }
.log-wrap {
display: flex;
flex-direction: column;
height: 216px;
flex-shrink: 0;
overflow: hidden;
position: relative;
}
.log-head {
display: flex; align-items: center; justify-content: space-between;
padding: 8px 12px 8px 14px; border-bottom: 1px solid var(--border); gap: 10px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px 8px 14px;
border-bottom: 1px solid var(--border);
gap: 10px;
}
.log-title {
display: flex;
align-items: center;
gap: 8px;
font-weight: 600;
color: var(--text);
white-space: nowrap;
}
.log-tools {
display: flex;
align-items: center;
gap: 6px;
}
.log-tools .el-button+.el-button {
margin-left: 0;
}
.status {
width: 9px;
height: 9px;
border-radius: 50%;
flex-shrink: 0;
}
.status.on {
background: var(--ok);
box-shadow: 0 0 0 3px var(--ok-weak);
}
.status.off {
background: #c6ccdc;
}
.live {
color: var(--ok);
font-size: 10px;
animation: blink 1s infinite;
letter-spacing: .04em;
}
.count {
font-size: 11px;
color: var(--text-faint);
font-weight: 500;
}
@keyframes blink {
50% {
opacity: .2;
}
}
.log-empty {
color: var(--text-faint);
padding: 14px;
font-family: var(--mono);
font-size: 12px;
}
.log-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); white-space: nowrap; }
.log-tools { display: flex; align-items: center; gap: 6px; }
.log-tools .el-button + .el-button { margin-left: 0; }
.status { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-weak); }
.status.off { background: #c6ccdc; }
.live { color: var(--ok); font-size: 10px; animation: blink 1s infinite; letter-spacing: .04em; }
.count { font-size: 11px; color: var(--text-faint); font-weight: 500; }
@keyframes blink { 50% { opacity: .2; } }
.log-empty { color: var(--text-faint); padding: 14px; font-family: var(--mono); font-size: 12px; }
</style>
@@ -28,46 +28,21 @@
<el-form label-position="top" class="form" @submit.prevent="doLogin">
<el-form-item label="员工账号">
<el-input
v-model="account"
placeholder="请输入账号"
autocomplete="username"
size="large"
clearable
@keyup.enter="doLogin"
/>
<el-input v-model="account" placeholder="请输入账号" autocomplete="username" size="large" clearable
@keyup.enter="doLogin" />
</el-form-item>
<el-form-item label="密码">
<el-input
v-model="password"
type="password"
placeholder="请输入密码"
autocomplete="current-password"
size="large"
show-password
@keyup.enter="doLogin"
/>
<el-input v-model="password" type="password" placeholder="请输入密码" autocomplete="current-password" size="large"
show-password @keyup.enter="doLogin" />
</el-form-item>
<el-button
type="primary"
size="large"
class="primary"
:loading="busy"
@click="doLogin"
>
<el-button type="primary" size="large" class="primary" :loading="busy" @click="doLogin">
{{ busy ? '进 入 中 …' : '进 入 工 作 台' }}
</el-button>
</el-form>
<div class="divider"><span>或</span></div>
<el-button
size="large"
class="dingtalk"
:loading="dingBusy"
:icon="ChatDotRound"
@click="openDing"
>
<el-button size="large" class="dingtalk" :loading="dingBusy" :icon="ChatDotRound" @click="openDing">
钉钉扫码接入
</el-button>
</main>
@@ -141,8 +116,10 @@ async function promptChangePwd(acc, r) {
const { value: np } = await ElMessageBox.prompt(
'当前为系统默认密码,请立即设置新密码(至少 6 位)',
'首次登录 · 修改密码',
{ inputType: 'password', inputPattern: /^.{6,}$/, inputErrorMessage: '密码至少 6 位',
confirmButtonText: '设置新密码', cancelButtonText: '稍后再说' })
{
inputType: 'password', inputPattern: /^.{6,}$/, inputErrorMessage: '密码至少 6 位',
confirmButtonText: '设置新密码', cancelButtonText: '稍后再说'
})
try {
await adminPassword({ account: acc, old_password: '', new_password: np })
ElMessage.success('密码已更新')
@@ -188,9 +165,10 @@ async function promptChangePwd(acc, r) {
linear-gradient(90deg, rgba(28, 23, 18, .045) 1px, transparent 1px);
background-size: 44px 44px;
-webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 78%);
mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 78%);
mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 78%);
pointer-events: none;
}
/* 顶部暖辉光 */
.login::after {
content: '';
@@ -216,21 +194,31 @@ async function promptChangePwd(acc, r) {
pointer-events: none;
user-select: none;
z-index: 1;
color: rgba(28, 23, 18, .05); /* 兜底 */
color: rgba(28, 23, 18, .05);
/* 兜底 */
animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe {
0%, 100% { opacity: .8; }
50% { opacity: 1; }
0%,
100% {
opacity: .8;
}
50% {
opacity: 1;
}
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
.ghost {
color: transparent;
background-image: radial-gradient(circle at 1px 1px,
rgba(28, 23, 18, .16) 1px, transparent 1.9px);
rgba(28, 23, 18, .16) 1px, transparent 1.9px);
background-size: 9px 9px;
-webkit-background-clip: text;
background-clip: text;
background-clip: text;
}
}
@@ -243,11 +231,12 @@ async function promptChangePwd(acc, r) {
width: min(920px, 92vw);
height: 1px;
background: linear-gradient(90deg,
transparent, rgba(28, 23, 18, .14) 18%,
rgba(28, 23, 18, .14) 82%, transparent);
transparent, rgba(28, 23, 18, .14) 18%,
rgba(28, 23, 18, .14) 82%, transparent);
z-index: 1;
pointer-events: none;
}
.pipeline i {
position: absolute;
top: -2px;
@@ -257,12 +246,32 @@ async function promptChangePwd(acc, r) {
background: #D14A2B;
box-shadow: 0 0 0 3px rgba(209, 74, 43, .10);
}
.pipeline i:nth-child(1) { left: 22%; }
.pipeline i:nth-child(2) { left: 50%; animation: blip 3.6s ease-in-out infinite; }
.pipeline i:nth-child(3) { left: 78%; }
.pipeline i:nth-child(1) {
left: 22%;
}
.pipeline i:nth-child(2) {
left: 50%;
animation: blip 3.6s ease-in-out infinite;
}
.pipeline i:nth-child(3) {
left: 78%;
}
@keyframes blip {
0%, 100% { opacity: .35; transform: scale(.85); }
50% { opacity: 1; transform: scale(1.1); }
0%,
100% {
opacity: .35;
transform: scale(.85);
}
50% {
opacity: 1;
transform: scale(1.1);
}
}
/* ---------- 顶部栏 ---------- */
@@ -276,7 +285,13 @@ async function promptChangePwd(acc, r) {
justify-content: space-between;
z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand {
display: flex;
align-items: center;
gap: 10px;
}
.mark {
width: 28px;
height: 28px;
@@ -291,12 +306,14 @@ async function promptChangePwd(acc, r) {
letter-spacing: .01em;
font-family: 'Helvetica Neue', Arial, sans-serif;
}
.name {
font-size: 12.5px;
font-weight: 500;
letter-spacing: .04em;
color: #6B6155;
}
.sys {
display: flex;
align-items: center;
@@ -305,6 +322,7 @@ async function promptChangePwd(acc, r) {
letter-spacing: .12em;
color: #6F6659;
}
.dot {
width: 6px;
height: 6px;
@@ -312,12 +330,24 @@ async function promptChangePwd(acc, r) {
background: #D14A2B;
animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(209, 74, 43, .4); }
70% { box-shadow: 0 0 0 7px rgba(209, 74, 43, 0); }
100% { box-shadow: 0 0 0 0 rgba(209, 74, 43, 0); }
0% {
box-shadow: 0 0 0 0 rgba(209, 74, 43, .4);
}
70% {
box-shadow: 0 0 0 7px rgba(209, 74, 43, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(209, 74, 43, 0);
}
}
.sep {
color: #C4BBA8;
}
.sep { color: #C4BBA8; }
/* ---------- 中央:接入终端 ---------- */
.panel {
@@ -334,21 +364,56 @@ async function promptChangePwd(acc, r) {
0 24px 48px -28px rgba(28, 23, 18, .30);
animation: rise .45s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes rise {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: none; }
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: none;
}
}
/* 卡片内元素依次点亮:终端端口逐个上电 */
@keyframes seq {
from { opacity: 0; transform: translateY(7px); }
to { opacity: 1; transform: none; }
from {
opacity: 0;
transform: translateY(7px);
}
to {
opacity: 1;
transform: none;
}
}
.core-mark { animation: seq .5s .05s both; }
.panel h1 { animation: seq .5s .10s both; }
.panel .sub{ animation: seq .5s .15s both; }
.form { animation: seq .55s .20s both; }
.divider { animation: seq .5s .26s both; }
.dingtalk { animation: seq .5s .32s both; }
.core-mark {
animation: seq .5s .05s both;
}
.panel h1 {
animation: seq .5s .10s both;
}
.panel .sub {
animation: seq .5s .15s both;
}
.form {
animation: seq .55s .20s both;
}
.divider {
animation: seq .5s .26s both;
}
.dingtalk {
animation: seq .5s .32s both;
}
/* 底部金手指纹理 */
.panel::after {
content: '';
@@ -357,11 +422,9 @@ async function promptChangePwd(acc, r) {
right: 36px;
bottom: 0;
height: 3px;
background-image: repeating-linear-gradient(
to right,
rgba(201, 191, 171, .65) 0 8px,
transparent 8px 12px
);
background-image: repeating-linear-gradient(to right,
rgba(201, 191, 171, .65) 0 8px,
transparent 8px 12px);
pointer-events: none;
}
@@ -374,6 +437,7 @@ async function promptChangePwd(acc, r) {
letter-spacing: .18em;
color: #D14A2B;
}
.panel h1 {
margin: 0 0 8px;
font-size: 26px;
@@ -382,6 +446,7 @@ async function promptChangePwd(acc, r) {
letter-spacing: -.01em;
color: #1C1712;
}
.panel .sub {
margin: 0 0 34px;
font-size: 13px;
@@ -395,10 +460,12 @@ async function promptChangePwd(acc, r) {
padding-left: 16px;
margin-bottom: 26px;
}
.form :deep(.el-form-item__content) {
position: relative;
line-height: normal;
}
/* 左侧接口指示灯 */
.form :deep(.el-form-item__content)::before {
content: '';
@@ -412,10 +479,12 @@ async function promptChangePwd(acc, r) {
background: #C9BFAB;
transition: background .2s, box-shadow .2s;
}
.form :deep(.el-form-item:focus-within .el-form-item__content)::before {
background: #D14A2B;
box-shadow: 0 0 0 3px rgba(209, 74, 43, .12);
}
.form :deep(.el-form-item__label) {
padding-bottom: 6px;
font-size: 12px;
@@ -424,6 +493,7 @@ async function promptChangePwd(acc, r) {
line-height: 1.4;
color: #635A4D;
}
/* 底线式输入 */
.form :deep(.el-input__wrapper) {
padding: 0;
@@ -433,12 +503,15 @@ async function promptChangePwd(acc, r) {
border-bottom: 1px solid #D8D0BC;
transition: border-color .2s;
}
.form :deep(.el-input__wrapper:hover) {
border-bottom-color: #BCB29A;
}
.form :deep(.el-input__wrapper.is-focus) {
border-bottom-color: #D14A2B;
}
.form :deep(.el-input__inner) {
height: 44px;
padding: 0;
@@ -446,14 +519,17 @@ async function promptChangePwd(acc, r) {
color: #1C1712;
caret-color: #D14A2B;
}
.form :deep(.el-input__inner::placeholder) {
color: #9A8F7A;
}
.form :deep(.el-input__suffix),
.form :deep(.el-input__prefix),
.form :deep(.el-input__suffix-inner) {
color: #9A8F7A;
}
.form :deep(.el-input__suffix-inner .el-input__icon:hover) {
color: #635A4D;
}
@@ -473,6 +549,7 @@ async function promptChangePwd(acc, r) {
box-shadow: 0 12px 28px -14px rgba(209, 74, 43, .7);
transition: background-color .15s, opacity .15s, transform .12s ease, box-shadow .15s ease;
}
.primary.el-button:hover,
.primary.el-button:focus {
background: #BB3F21;
@@ -480,11 +557,13 @@ async function promptChangePwd(acc, r) {
transform: translateY(-1px);
box-shadow: 0 15px 30px -14px rgba(209, 74, 43, .78);
}
.primary.el-button:active {
background: #A53517;
transform: translateY(1px) scale(.99);
box-shadow: 0 6px 16px -12px rgba(209, 74, 43, .8);
}
.primary.el-button.is-disabled,
.primary.el-button.is-loading {
background: #D14A2B;
@@ -501,6 +580,7 @@ async function promptChangePwd(acc, r) {
letter-spacing: .04em;
color: #8D8476;
}
.divider::before,
.divider::after {
content: '';
@@ -522,6 +602,7 @@ async function promptChangePwd(acc, r) {
letter-spacing: .02em;
transition: border-color .15s, background-color .15s, transform .12s ease, box-shadow .15s ease;
}
.dingtalk.el-button:hover,
.dingtalk.el-button:focus {
border-color: #C4BBA8;
@@ -530,9 +611,11 @@ async function promptChangePwd(acc, r) {
transform: translateY(-1px);
box-shadow: 0 8px 20px -14px rgba(28, 23, 18, .28);
}
.dingtalk.el-button:active {
transform: translateY(0) scale(.99);
}
.dingtalk.el-button :deep(.el-icon) {
color: #1491F0;
}
@@ -555,6 +638,7 @@ async function promptChangePwd(acc, r) {
justify-content: space-between;
z-index: 3;
}
.flows {
display: flex;
align-items: center;
@@ -563,13 +647,19 @@ async function promptChangePwd(acc, r) {
letter-spacing: .12em;
color: #6F6659;
}
.f-blocks { display: flex; gap: 3px; }
.f-blocks {
display: flex;
gap: 3px;
}
.f-blocks i {
width: 12px;
height: 4px;
border-radius: 1px;
background: #C9BEAA;
}
.copyright {
font-size: 10.5px;
letter-spacing: .1em;
@@ -578,14 +668,40 @@ async function promptChangePwd(acc, r) {
/* ---------- 自适应 ---------- */
@media (max-width: 720px) {
.login { padding: 96px 20px 140px; }
.topbar { top: 24px; left: 24px; right: 24px; }
.footbar { bottom: 24px; left: 24px; right: 24px; }
.panel { padding: 32px 24px 30px; }
.panel h1 { font-size: 23px; }
.panel::after { left: 24px; right: 24px; }
.copyright { display: none; }
.login {
padding: 96px 20px 140px;
}
.topbar {
top: 24px;
left: 24px;
right: 24px;
}
.footbar {
bottom: 24px;
left: 24px;
right: 24px;
}
.panel {
padding: 32px 24px 30px;
}
.panel h1 {
font-size: 23px;
}
.panel::after {
left: 24px;
right: 24px;
}
.copyright {
display: none;
}
}
@media (max-height: 680px) {
.login {
align-items: flex-start;
@@ -593,12 +709,35 @@ async function promptChangePwd(acc, r) {
overflow-y: auto;
padding: 80px 24px 120px;
}
.footbar { display: none; }
.footbar {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.dot, .pipeline i, .ghost { animation: none; }
.panel { animation: none; }
.core-mark, .panel h1, .panel .sub, .form, .divider, .dingtalk { animation: none; }
* { transition-duration: .01ms !important; }
.dot,
.pipeline i,
.ghost {
animation: none;
}
.panel {
animation: none;
}
.core-mark,
.panel h1,
.panel .sub,
.form,
.divider,
.dingtalk {
animation: none;
}
* {
transition-duration: .01ms !important;
}
}
</style>
@@ -18,15 +18,8 @@
</div>
<!-- 结果横幅 -->
<el-alert
v-if="store.lastResult"
:type="store.lastResult.ok ? 'success' : 'error'"
:closable="true"
:close-text="null"
class="banner"
@close="closeBanner"
show-icon
>
<el-alert v-if="store.lastResult" :type="store.lastResult.ok ? 'success' : 'error'" :closable="true"
:close-text="null" class="banner" @close="closeBanner" show-icon>
<template #title>
<span>
{{ store.lastResult.ok ? (store.lastSummary || '执行完成') : '执行失败:' + store.lastResult.error }}
@@ -37,14 +30,8 @@
<!-- 参数 -->
<div class="sec-head">
<span class="sec-title">参数配置</span>
<el-button
v-if="Object.keys(form).length"
size="small"
text
:disabled="store.running"
:icon="RefreshLeft"
@click="resetForm"
>恢复默认</el-button>
<el-button v-if="Object.keys(form).length" size="small" text :disabled="store.running" :icon="RefreshLeft"
@click="resetForm">恢复默认</el-button>
</div>
<el-form label-width="auto" class="form-card">
<div class="fields">
@@ -52,14 +39,12 @@
<template v-if="f.type === 'int'">
<el-input-number v-model="form[f.key]" :controls="false" placeholder="0" :disabled="store.running" />
</template>
<el-input
v-else-if="f.type === 'text'"
v-model="form[f.key]"
:placeholder="String(f.default ?? '')"
:disabled="store.running"
>
<el-input v-else-if="f.type === 'text'" v-model="form[f.key]" :placeholder="String(f.default ?? '')"
:disabled="store.running">
<template v-if="f.help" #suffix>
<el-tooltip :content="f.help" placement="bottom"><el-icon class="help-ic"><QuestionFilled /></el-icon></el-tooltip>
<el-tooltip :content="f.help" placement="bottom"><el-icon class="help-ic">
<QuestionFilled />
</el-icon></el-tooltip>
</template>
</el-input>
<el-select v-else v-model="form[f.key]" :disabled="store.running">
@@ -157,7 +142,7 @@ watch(
try {
const run = await getRun(store.lastRunId)
store.lastSummary = run.result?.summary || ''
} catch (e) {}
} catch (e) { }
}
}
)
@@ -168,28 +153,127 @@ function closeBanner() {
</script>
<style scoped>
.plugin-page { display: flex; flex-direction: column; gap: 18px; min-height: 100%; }
.plugin-page {
display: flex;
flex-direction: column;
gap: 18px;
min-height: 100%;
}
.head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
}
.ident {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.ident { display: flex; align-items: center; gap: 14px; min-width: 0; }
.avatar {
width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
display: grid; place-items: center; color: #fff; font-size: 18px; font-weight: 700;
width: 44px;
height: 44px;
border-radius: 13px;
flex-shrink: 0;
display: grid;
place-items: center;
color: #fff;
font-size: 18px;
font-weight: 700;
box-shadow: var(--shadow-md);
}
.ident-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ident-meta h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.ident-meta p { margin: 0; font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px; }
.ver-tag { font-size: 11px; font-weight: 500; color: var(--text-faint); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 7px; border-radius: 999px; }
.month { display: flex; align-items: center; gap: 8px; }
.month-sel { width: 120px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.fields { display: flex; gap: 24px; flex-wrap: wrap; }
.form-card .el-form-item { margin-bottom: 0; }
.help-ic { color: var(--text-faint); cursor: help; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 6px; }
.run-ind { flex: 1; max-width: 220px; }
.ident-meta {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.hint { font-size: 12px; color: var(--text-faint); margin: 0; padding-left: 2px; }
.ident-meta h2 {
margin: 0;
font-size: 17px;
display: flex;
align-items: center;
gap: 8px;
}
.ident-meta p {
margin: 0;
font-size: 12px;
color: var(--text-sub);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 520px;
}
.ver-tag {
font-size: 11px;
font-weight: 500;
color: var(--text-faint);
background: var(--surface-2);
border: 1px solid var(--border);
padding: 1px 7px;
border-radius: 999px;
}
.month {
display: flex;
align-items: center;
gap: 8px;
}
.month-sel {
width: 120px;
}
.sec-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 2px;
}
.fields {
display: flex;
gap: 24px;
flex-wrap: wrap;
}
.form-card .el-form-item {
margin-bottom: 0;
}
.help-ic {
color: var(--text-faint);
cursor: help;
}
.actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 14px;
border-top: 1px dashed var(--border);
padding-top: 14px;
margin-top: 6px;
}
.run-ind {
flex: 1;
max-width: 220px;
}
.hint {
font-size: 12px;
color: var(--text-faint);
margin: 0;
padding-left: 2px;
}
</style>
@@ -9,14 +9,14 @@
>
<!-- 个人信息 -->
<section class="pcard">
<div class="cover"><span class="cover-id mono">ID · {{ store.current }}</span></div>
<div class="cover"></div>
<div class="pcard-main">
<el-avatar :size="60" :src="store.avatarUrl" @error="onAvatarError" class="avatar">
<span>{{ store.current.slice(0, 1).toUpperCase() }}</span>
<span>{{ displayName.slice(0, 1).toUpperCase() }}</span>
</el-avatar>
<div class="pcard-id">
<div class="name-line">
<strong>{{ store.current }}</strong>
<strong>{{ displayName }}</strong>
<em v-if="store.isAdmin" class="admin">管理员</em>
</div>
<span class="dept">{{ store.dept || '未设置部门' }}</span>
@@ -97,7 +97,7 @@
</template>
<script setup>
import { ref, reactive } from 'vue'
import { ref, reactive, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { Connection, Box } from '@element-plus/icons-vue'
import { store, log, clearAvatarCache } from '../store'
@@ -107,6 +107,9 @@ const emit = defineEmits(['close'])
// 由父组件 v-if 控制挂载,挂载即展开;关闭经 @close 通知父组件卸载
const visible = ref(true)
// 展示名:优先真实姓名(钉钉登录带入),无姓名时回退账号(工号)
const displayName = computed(() => store.nickname || store.current)
// 头像:复用全局 store 的在线头像(带 localStorage 缓存);加载失败时清除缓存并回退首字符色块
function onAvatarError() {
clearAvatarCache()
@@ -219,13 +222,6 @@ async function changePwd() {
#1a1c1f;
position: relative;
}
.cover-id {
position: absolute;
right: 14px; bottom: 12px;
font-size: 11px;
color: rgba(236, 234, 223, .55);
letter-spacing: .1em;
}
.pcard-main {
display: flex; align-items: center; gap: 14px;
padding: 0 18px 16px;

Some files were not shown because too many files have changed in this diff Show More