Compare commits

...
132 Commits
Author SHA1 Message Date
puddy c73c113721 feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
2026-10-26 15:42:50 +08:00
puddy 8bf33b65cd feat: 新增改签离职电子签OA待办对账销办脚本
新增步骤7脚本,实现OA待办对账销办逻辑:
1. 解析OA待办链路由fdId获取HR任务ID
2. 核对任务/流程状态,仅销办COMPLETED状态的待办
3. 校验账号权限,仅处理当前人资账号待办
4. 支持试算模式,避免误操作
同时更新XQ0035转正流程规则,将分支1回填条件从"到期能否考核通过=能"调整为"人员处理意见=直接离职/无需处理",并更新XQ0037合同模板逻辑,为超龄人员配置专用合同模板组合
2026-10-22 13:33:57 +08:00
puddy 8cc747b6e8 fix: 调整调动筛选天数及超龄合同分段规则
msg
feat: 优化流程实例查询逻辑避免误判

msg
docs: 更新文档说明及版本号至1.1.5

msg
refactor: 优化提醒消息逻辑隐藏不必要部门信息
2026-10-21 19:33:34 +08:00
puddy ee26409ac9 feat: 新增 CRM 数据导出插件(XQ0048)
新增 XQ0048 CRM 数据导出插件,包含储值卡余额整页截图、18 张报表自动导出功能。
支持登录态钉钉扫码一次后缓存复用(约 30 分钟免扫码),按报表日期规则自动计算导出区间,礼品卡订单因接口限制跨度 ≤31 天按月拆分。
插件包含 requirements.txt、plugin.json、打包脚本、数据层及业务逻辑代码,可直接通过 agent_cli 发布。
2026-10-21 19:02:32 +08:00
puddy a33f4b2929 feat(XQ0047): 微盟数据导出插件 v1.0.2 版本更新,拆分合并单元格并优化导出
新增合并单元格拆分逻辑,将微盟导出Excel中同一订单的纵向合并单元格值填充到区域内每一行,使每行数据自包含便于筛选统计
更新插件版本号、打包脚本及需求文档中的版本信息
2026-10-21 16:16:34 +08:00
puddy 8a1e06e94b fix(XQ0037): 修复时间解析与时区处理导致的写入错误
新增北京时间统一处理工具函数,修复带时区时间写入openpyxl报错问题
同时更新插件版本至1.1.2
2026-10-21 15:22:08 +08:00
puddy 12f8ec2bd2 feat: 新增3个EHR流程审核插件:请假、加班、离职电子签
新增XQ0003请假流程审核、XQ0004加班流程审核、XQ0020离职电子签流程审核插件
包含Python后端逻辑、Vite+Vue3前端工程、打包脚本及依赖配置
支持假期校验、加班时长核对、电子签状态核验及自动审批提交
新增rapidocr依赖及OCR附件核验逻辑
2026-10-21 11:53:39 +08:00
puddy b76e703dba feat(xq0037): 升级调动改签离职电子签流程优化数据范围与逻辑
- 调整台账导出范围为近三月、筛选时间为近4天
- 将名单表从「本月发起名单」统一改为「已发起名单」
- 新增三类人员群提醒、分页查询流程优化
- 修复单位名称匹配逻辑,新增选项集获取
- 替换COM写入为openpyxl避免时区问题
2026-10-21 08:45:55 +08:00
puddy c0fd432fc8 feat: 新增微盟数据导出和门店出勤积分更新插件 2026-10-20 18:29:04 +08:00
puddy 2bc1986e93 feat(attendance_points): add rejoin ledger support and optimize push logic
新增离职当月再入职人员台账查询与无效积分段清理逻辑
优化积分推送逻辑,统一使用官方模板格式并修正日期显示格式
更新版本至1.1.0,完善登录态处理与错误提示
2026-10-20 14:00:53 +08:00
puddy 97899b5d06 feat(XQ0008): 新增 HR 接口数据源及花名册 fallback 逻辑,修复 OA 推送附件上传 Content-Type 问题
- 新增 HR 花名册接口拉取逻辑,优先从 HR 接口获取花名册,失败回退源表/本地文件
- 新增推送人映射支持所属单位回退值,新增「水庄大鹅事业部」映射
- 修复 OA 推送附件上传时清除默认 Content-Type,避免 multipart 请求被服务端拒绝
- 优化二级部门解析逻辑,为空时用所属单位替代,避免中断流程
- 新增 store_point_api.py 和 attendance_points_push.py 积分推送模块,新增 store_login_api.py 门店登录模块
- 新增 notice_gen.py 中 HR 接口加密逻辑及多数据源 fallback 处理
2026-10-19 19:03:27 +08:00
puddy 5df05b4ebc fix(续签电子签): 修正签署状态判断逻辑及防重处理规则
移除离职电子签接口调用,改用合同行自带字段判断签署状态
调整防重逻辑,核对合同信息一致后回填推送时间
更新核验条件,仅处理续签为是且已推送的记录
2026-10-19 12:17:41 +08:00
puddy 9f9cd3e730 feat: 续签/离职/请假审批功能迭代与优化
- 续签电子签:新增电子签模板防呆校验,仅当模板配置时才提交;调整核验规则,仅签署完成(is_initiate_sign=2)算完成
- 改签离职电子签:新增后浪新天地按岗位细分签署单位逻辑,区分餐饮/非餐饮主体
- 转正不通过电子签:新增签署单位细分逻辑,与改签离职保持一致
- 通用审批:统一将审批请求的视图类型从VIEW改为WAIT,确保审批按钮正常加载;开启自动审批开关(APPROVE_ENABLED)
- 转正流程:优化结果统计,区分成功/跳过/失败状态,跳过状态不判定为运行失败
- 请假审批:重构小时假校验逻辑,按请假时段匹配排班班段(含跨天夜班),新增排班班段字段记录
2026-10-19 10:05:27 +08:00
puddy fb70082d54 feat(xq0034): 续签电子签功能迭代:前置补全+核验逻辑优化
1. 新增前置默认补全逻辑:AI表电子签接收电话为空时取花名册号码回填,期望推送日期为空时默认当天回填,补全后不再跳过流程
2. 优化核验逻辑:改为联合待生效+生效中合同取最新合同,新增调用签署状态接口判断是否发起电子签,按2026-10-16用户口径修正完成判定规则
3. 精简通知格式:与加班审批一致,仅推送成功/核验数量/失败明细,删除冗余通知内容
4. 新增合同签署状态查询接口,完善续签完成判定依据
2026-10-16 16:19:44 +08:00
puddy 32de74f103 feat: 新增续签电子签插件及多插件钉钉通知功能
- 新增 xq0034 续签电子签插件,包含核心流程与钉钉通知能力
- 为 xq0035、xq0008、xq0009、xq0010、xq0011、xq0031_xq0032、xq0037、xq0038、xq0045_xq0046 插件添加钉钉群通知配置
- 优化续签电子签执行结果日志,减少重复名单输出
- 桌面端插件列表新增分页功能,优化长列表展示
2026-10-16 13:11:30 +08:00
puddy cad685fe40 feat(frontend): 重构登录页面并新增插件强制更新功能
- 替换登录页面为极光背景玻璃拟态设计,移除注册/忘记密码页面
- 新增插件强制更新功能,支持设置最低版本和截止时间
- 修复通知账号选择占位文本和拉取失败注释
- 新增审计日志系统用户相关操作类型
- 新增用户菜单头像 fallback 逻辑
- 重构 XQ0037 工作簿写入逻辑,改用 openpyxl 直写避免时区问题
- 更新 XQ0034 脚本参数默认值和注释
2026-10-16 11:40:43 +08:00
puddy a7dbc5a77e feat: 重构控制台为37du自动化平台,新增权限授权与通知中心功能
- 更新系统名称、登录页宣传文案为37du平台相关内容
- 移除聊天功能相关代码与配置
- 新增客户端版本上报字段与设备统计接口
- 新增通知中心功能(60s轮询、localStorage已读标记)
- 新增权限授权工作台相关接口与页面
- 新增统一页头组件ArtPageHeader
- 调整快速入口配置指向真实功能页面
- 修复控制面地址为内网生产库
2026-10-15 18:01:29 +08:00
puddy f0a94bf523 build(desktop): 升级 electron-shell 版本至 1.6.3 并调整插件执行超时配置
- 插件执行超时默认延长至 6 小时,支持插件单独配置超时时间
- 新增插件根目录迁移逻辑,解决旧版权限问题
- 新增多个服务端实体、DTO、配置模块等基础代码
- 新增插件 UI 模板及相关静态资源
2026-10-15 11:38:45 +08:00
puddy 872d3dc5c8 feat: 新增通知推送功能及离线登录,优化重连逻辑
- 新增通知推送模块:支持 WebSocket 实时推送与轮询兜底,新增通知管理界面
- 新增离线登录功能:断网时凭本地 7 天授权票据自动登录或手动登录
- 优化 Electron 客户端 WebSocket 重连逻辑,避免死循环
- 调整工作流脚本,拆分重构合同相关分支逻辑
- 新增设备上报客户端版本字段,用于升级追踪与关旧依据
2026-10-13 17:46:49 +08:00
puddy 816af4b960 feat: 新增门店上月请休假异常人员名单梳理插件
新增 XQ0009 插件完整代码,包含后端业务逻辑、数据接口、报告导出、前端 UI 及打包脚本,用于梳理门店上月请休假异常人员名单,输出 Excel 名单
2026-10-13 10:26:03 +08:00
puddy 27f9054671 feat(workflows): 新增HR发起状态核查及发起日期回填逻辑
新增通过HR系统运行中流程及签署记录核查改签发起状态,未发起的保留待办;新增推送表发起日期回填功能,同时优化名单表和AI表的数据结构,完善注释说明。
2026-10-13 09:01:22 +08:00
puddy 0964245246 docs,refactor: 更新超龄用工判定逻辑及相关代码实现
更新文档aa.md,明确已达龄不再报异常、仅新签合同超龄需分段转人工;同步修改主脚本trial_period_change.py和新签脚本sign_new_contract.py,调整超龄判定规则,已达龄自动签超龄用工协议,仅未达龄且合同终止日超退休日转人工,同步更新异常类型、过滤规则及相关文案。
2026-10-12 17:57:34 +08:00
puddy e7c874537e feat(XQ0037): 新增调动改签离职电子签全流程步骤文件及相关逻辑
- 修复 cashier_login.py 登录成功判定逻辑,调整 URL 条件为同时包含 SUCCESS_KEYWORD 且不在 /login 路径,避免误判
- 调整 roster_export_api.py 默认参数,新增离职状态及时间范围,更新输出路径
- 扩展 absence_analysis.py 日期范围支持 YYYYMM 格式
- 新增 transfer_roster_export_api.py 调动改签电子签导出模板字段配置
- 新增 XQ0037 调动改签离职电子签全流程步骤文件 step1~step6,涵盖台账导出筛选、待办处理、电子签发起及跟进回写等功能
2026-10-12 17:15:58 +08:00
puddy 489748dfc1 refactor(tests): 归档旧版HRBP测试文件,新增新版测试辅助脚本和雇主险WPS可行性验证
本次提交主要包含以下内容:
1. 归档tests/hrbp目录下的旧版测试文件至tests/_app_蓝图版归档目录
2. 新增tests/_app_蓝图版归档/hrbp目录下的新版测试辅助脚本和测试用例
3. 新增雇主险场景下的WPS COM可行性验证脚本
4. 更新README.md中关于tests目录的说明,明确各子目录用途
5. 更新XQ0035工作流相关文件中的操作人UnionID,更换为人资专用号
6. 修复试用期变更脚本中日期转换的问题,确保AI表格时间戳正确转换为日期格式
7. 归档XQ0035工作流下的旧版测试脚本至测试归档目录
2026-10-12 11:31:52 +08:00
puddy eeb951f9f6 feat(fileserver): 新增内网文件服务器服务与管理页面
新增 FastAPI 文件服务器核心模块(配置、鉴权、存储、心跳上报),新增 HTTP 路由接口(健康检查、文件上传/下载/删除、管理登录/密码修改/统计),新增 Vue3 管理页面源码;新增 MySQL 元数据存储支持,新增 PyMySQL 依赖;新增 .gitignore 忽略 IDE 与备份文件;新增文件服务器工具脚本;删除旧的 build/ 脚本与 exe 构建产物,优化 Electron 平台登录逻辑为纯接口模式,新增平台账号环境变量注入,优化试用期异常检查逻辑,拆分服务岗转正流程为独立脚本。
2026-10-12 09:45:04 +08:00
puddy 68f29d0a14 fix: 优化社保增减员回盘打印的菜单跳转逻辑并更新插件版本
优化回盘打印的菜单跳转逻辑,移除冗余的当前页尝试,调整异常处理顺序以适配页面变化;同步更新插件版本至1.0.3
2026-10-08 11:52:20 +08:00
puddy 6525275a54 feat(plugin XQ0008): 支持增员按参保类型分目录存储回盘文件
更新插件版本至1.0.2,调整增员核查逻辑按参保类型分组,回盘文件按类型分目录存储,适配不同参保类型的办理需求
2026-10-08 11:46:09 +08:00
puddy 8c61a05d8a feat: 新增定性评价推送插件 v1.1.1 2026-10-08 10:44:18 +08:00
puddy 57028b8626 feat: 新增HR纯接口登录OA接口探针及试用期变更流程增强
新增3个核心文件:
1. workflows/share/oa_login_api.py:OA纯接口登录模块,与浏览器版输出兼容
2. workflows/share/hr_login_api.py:HR纯接口登录模块,支持滑块验证,与浏览器版输出兼容
3. workflows/share/_probe_we_process_todo.py:HR WeProcess待办探针,验证替代OA待办+SSO链路

同时增强试用期变更流程:
- 新增流程交叉验证逻辑,处理已被他人操作的情况
- 新增离职电子签详情链接获取逻辑
- 新增AI表格自动回填逻辑,处理无需处理的情况
- 新增流程待办查询接口,支持反查流程实例
2026-10-06 17:56:36 +08:00
puddy 5abdd91f35 docs: 更新需求单评分文档与最终评级,移除提成金额 2026-10-05 18:05:54 +08:00
puddy 008f6f5998 refactor: 重构执行机架构为 Electron 壳内置 Python 运行时子集
将原 webhost 底座的后端、前端、工具等代码迁移至 electron-shell 目录,构建自包含的 Python 环境包,移除冗余的前端代码、旧的后端模块及相关依赖,更新版本号至 1.0.6,优化平台登录态预检逻辑,统一代码结构为单一真源,避免多副本维护问题。
2026-10-05 14:13:47 +08:00
puddy 41bcb44e34 feat(xq0002): 新增钉钉群通知推送功能,优化雇主险增减操作流程 2026-10-05 09:42:56 +08:00
puddy 26d4125798 feat(雇主险): 新增钉钉群通知推送功能,版本更新至1.0.7
新增钉钉群通知配置项,支持推送调度汇总、HR导入结果及异常名单;
新增钉钉通知模块,推送失败不影响主流程;
调整雇主险调度描述,补充钉钉推送功能说明;
优化UI开关区布局,适配新增配置项显示;
同步更新相关文档,明确钉钉通知功能与口径。
2026-09-30 15:59:37 +08:00
puddy 08d26a416e docs: 更新金色印象通联数据导出需求单文档并新增插件相关文档 2026-09-30 11:44:12 +08:00
puddy ffeebf80e6 feat: 新增重庆社保增减员办理插件全流程功能
新增重庆社保增减员办理插件,包含目录预检、增/减员名单制作、系统办理、核查回盘、告知书制作与OA推送全流程功能,适配重庆社保业务需求,支持多阶段可选执行
2026-09-30 11:18:12 +08:00
puddy e115bb7113 feat: 新增社保减员核查脚本及相关配置优化
- 新增停保核查脚本 check_review_stop.py
- 优化社保增减员路径配置,合并台账目录
- 调整商户分组名称为综合门店
- 新增 Chrome 密码设置配置,关闭保存密码弹窗
- 优化源文件筛选规则,收紧为社保变更文件
- 新增 VC 运行库复制到构建脚本,解决 DLL 加载问题
- 升级通联数据导出插件版本至 1.0.12,更新描述
2026-09-30 09:39:12 +08:00
puddy 2a08338ed1 feat(xq0002): 新增HR自动导入功能,优化花名册源表新鲜度校验
```

或者更贴合中文项目习惯的表述:
```msg
feat(xq0002): 新增HR自动导入,优化花名册源表新鲜度校验
2026-09-29 13:54:32 +08:00
puddy ee46776648 feat(通联登录): 优化验证码识别与风控锁定处理,升级插件UI
- 新增双模型验证码交叉识别提升准确率
- 增加账号风控锁定检测与异常处理
- 优化登录表单字段提交适配服务端校验
- 升级两个插件的UI为卡片式分区设计
- 升级插件版本至1.0.9
2026-09-29 10:37:24 +08:00
puddy f8f108af5d feat(xq0011): 支持检查项选择并增加岗位等核心字段到异常名单 2026-09-29 08:47:27 +08:00
puddy 87f995ca47 feat(electron-shell): 启动链路修复与执行/配置收口插件侧
- 启动链路 P1-P7 修复:预算对齐、完成事件推送、端口占用提示、前端阶段文案接管
- 静态缓存按 IS_FROZEN 区分开发/打包态,bootPhaseOwned 竞态修复
- 一键执行与参数配置统一收口到插件界面,定时任务引用 config_id
- 环境包迁移到 %LOCALAPPDATA%\37duAutomation\python-env,重装零解压
- shell-updater:缓存包 sha256 校验、静默升级后自动拉起新版、自动清理旧安装包
- after-pack 钩子生成 shell.version 修复打包态版本识别
- 插件 xq0031/xq0045 迁移至 plugins/XQ0001-0100/ 号段分桶中文目录
2026-09-28 14:20:35 +08:00
puddy 3214305dea feat(electron-shell): 补录壳子源码(排除运行环境与构建产物) 2026-09-24 16:14:24 +08:00
puddy 7e0838de64 rescue: 断电事故后工作区全量备份 2026-09-24 15:59:44 +08:00
puddy be1a2899ba feat: 重构控制面安全机制与分页规范
本次提交包含多项安全加固和体验优化:
1. 分离管理密钥与传输凭证,避免持 API Token 者伪造管理员票据
2. 钉钉回调地址增加白名单校验,防止开放重定向钓鱼
3. 初始管理员密码改为随机生成并日志记录,移除硬编码 123456
4. 新增登录防爆破计数表,支持 MySQL 多 worker 共享
5. 统一分页规范,新增 usePagedList composable 和 PagerBar 组件
6. 控制面 CORS 收敛为白名单,避免公网环境下任意站点跨域
7. 插件管理、凭证管理等列表接口支持分页和搜索
8. 强制初始密码修改,未改密前禁止使用管理功能
9. 定时任务触发被拒日志节流,避免授权失效时刷屏
10. 健康检查接口移除环境信息泄露,返回固定响应
2026-09-23 15:19:54 +08:00
puddy dd546fc07b feat(xq0002): 完成雇主险增减操作插件开发并补齐配套资源
- 新增XQ0002雇主险增减操作插件完整实现,包含数据层、逻辑层、UI界面
- 新增测试用的样板数据文件与插件打包脚本
- 更新文档说明插件当前状态与使用方式
- 新增收银系统登录共享模块供业务流程复用
2026-09-22 12:41:16 +08:00
puddy a4c172bc98 feat(shift_abnormal_check): 新增生物识别登记核查功能
新增考勤平台BioData生物识别登记核查逻辑:
1. 新增AES加密登录考勤平台的完整实现,支持环境变量覆盖配置
2. 对排班异常名单查询员工生物识别登记状态,未登记单独标注提醒
3. 处理账号互踢问题,每次调用重新登录,查询失败降级不阻断主流程
4. 更新依赖包与文档说明
2026-09-22 10:06:52 +08:00
puddy c7add9574e chore: 清理废弃插件与冗余文档,重构项目目录结构
1.  删除旧版xq0031_xq0032插件的冗余UI源码与配置文件
2.  迁移并标准化XQ0001-0100系列需求的插件、文档与工作流目录
3.  清理过期的需求列表、评分文档与流程底稿
4.  更新.gitignore匹配规则,适配新的目录结构
2026-09-21 16:59:05 +08:00
puddy b034b51685 feat: 新增内网文件服务器离线监控,升级ERP报表导出插件适配新旧系统差异
1.  新增内网文件服务器心跳上报与离线监控功能:
    - 为文件服务器添加周期心跳上报到中心机的能力
    - 中心机新增文件服务器状态监控线程,超时自动判离线并钉钉告警管理员
    - 新增数据库表存储文件服务器状态,提供管理端API查看在线状态
2.  修复ERP物料收发汇总报表插件:
    - 调整插件版本到1.0.9,更新前端配置与UI适配新旧ERP系统
    - 重构组织与仓库默认值逻辑,区分新版/旧版ERP的默认配置
    - 统一所有场景下显式设置查询组织,移除旧版默认组织的兼容逻辑
    - 新增代管仓仓库编码适配旧版系统
3.  优化文件服务器打包脚本路径,更新文档示例命令
2026-09-19 14:55:22 +08:00
puddy 600379933d feat: 新增壳子内置定时任务功能,支持配置备份与恢复
本次提交新增完整的定时任务系统:
1. 后端支持cron表达式调度插件执行,与手动运行共用执行链路
2. 前端新增定时任务管理页面,支持增删改查与启停操作
3. 实现配置自动备份到中心机,启动时自动从云端恢复任务
4. 配套新增数据库表与控制面API接口
5. 同时优化了考勤异常检查的规则细节
2026-09-19 12:11:49 +08:00
puddy 530cfe38dc feat(XQ0011考勤月报封存检查): 新增5项考勤封存检查脚本及文档
新增考勤月报封存检查的完整校验逻辑:
1. 新增延时加班验证脚本,检查经营系管理岗违规领取延时加班补贴
2. 新增全勤验证脚本,校验月中晋升及异常考勤仍标记全勤的情况
3. 新增封存值最新校验脚本,对比封存数据与实时统计数据差异
4. 新增出勤排休验证脚本,校验出勤天数和休息天数是否符合排班方案
5. 更新aa.md文档,补充全部6项检查规则和接口说明
6. 删除冗余的aa.json测试文件
2026-09-18 23:33:11 +08:00
puddy 11fc3cee6a chore: 版本升级至1.1.8,新增钉钉账号通知等功能
1. 版本号更新:shell.version与install.iss同步升级到1.1.8
2. 新增钉钉账号创建通知:新用户收账号密码,管理员收权限提醒
3. 优化钉钉扫码登录逻辑:自动补全账号信息并同步昵称
4. 修复首次改密校验逻辑,统一初始密码验证规则
5. 新增AGENTS文档写入操作沙箱规避规范
6. 优化雇主险调度脚本,新增四级部门自动填充逻辑
7. 重构前端更新弹窗,将下载进度从顶部条改为独立弹窗
8. 新增EHR考勤异常检查脚本,优化打卡判定逻辑
2026-09-18 21:25:43 +08:00
puddy 78aa8c361c release: bump version to 1.1.7, update xq0031_xq0032 plugin to 1.0.8
主要变更:
1. 整体版本升级至1.1.7,更新安装包与shell版本号
2. 新增API与后端能力:
   - 新增停止运行接口,支持强制终止插件进程与浏览器子进程
   - 云端会话令牌与下载票据落库,适配多worker部署
   - 优化Chrome版本读取逻辑,避免弹窗与编码问题
3. xq0031_xq0032插件升级至1.0.8:
   - 新增仓库中文名自动筛选功能,简化用户操作
   - 优化ERP登录与报表导出流程,修复标签页残留问题
   - 新增前端强制停止按钮,支持实时终止运行
   - 修复中文编码与乱码问题,兼容Windows非UTF-8环境
4. 修复授权校验逻辑,确保账号与授权匹配
5. 更新文档与部署脚本,修正发版流程说明
2026-09-17 23:25:33 +08:00
puddy f30ab9cc29 feat: 新增xq0031_xq0032 ERP报表导出插件,完成功能与基建更新
1. 新增xq0031_xq0032插件:包含前后端源码、打包脚本、配置文件与插件元数据
2. 新增内网文件服务器组件:exe、启停脚本、打包脚本与配置
3. 新增敏感凭证RSA加密下发能力与存储结构
4. 新增大文件源管理表与相关API
5. 优化登录流程与会话管理,新增Chrome自动化安装工具链
6. 清理废弃插件与示例代码
7. 更新版本号至1.1.3,完善安装包与.gitignore配置
2026-09-17 12:42:44 +08:00
puddy 6d2dd93628 refactor: 整体迁移控制面至MySQL + 替换UI框架为Element Plus
1. 移除naive-ui依赖,迁移前端至Element Plus
2. 重构后端数据库层,切换为MySQL替代SQLite
3. 调整项目部署架构,停止exe打包改为源码部署
4. 新增设备上报接口与相关数据库模型
5. 优化配置路径与SQL语法,替换为MySQL占位符格式
6. 调整站点名称与文案,统一为「37du 插件管理平台」
7. 新增SQLite到MySQL迁移脚本
2026-09-16 15:58:45 +08:00
puddy 813bee743b feat: 新增账号状态管理、头像功能与报表工具,完善账号系统
新增账号状态字段与停用校验,支持账号头像上传管理,新增物料收发汇总表合并工具,优化银行卡检查脚本,新增ERP登录复用模块,重构账号数据库迁移与管理接口
2026-09-16 00:25:13 +08:00
puddy 0ab43d0ed8 refactor: 完成项目目录重构与代码迁移
本次提交完成了整体项目的目录梳理与代码迁移:
1.  将根级controlplane、webhost等目录的代码迁移至desktop/对应子目录,统一桌面端架构
2.  移动并整理了插件目录结构,将插件统一放入根级plugins/
3.  调整了前端项目的路径与配置,统一前后端开发构建流程
4.  清理了废弃的旧版app/目录与冗余的构建中间文件
5.  更新了.gitignore与README.md,适配新的项目结构
2026-09-14 17:46:09 +08:00
puddy a1a06504a5 refactor: 重构项目目录结构与代码组织
1.  重构controlplane与webhost后端的包结构,按领域拆分模块到core/apis子包
2.  移动并整理工具脚本到tools子目录,统一管理运维脚本
3.  重构插件运行时、调度、作业管理等核心模块到core子包
4.  更新AGENTS.md文档,明确各代码形态的组织规范
5.  清理重复的旧文件与冗余代码
2026-09-14 12:34:54 +08:00
puddy b86bc1bf97 fix: 修复多项异常问题并优化社保业务脚本
1. 修复scheduler.py异常退出残留状态导致死锁,改用原子写active.json
2. 优化import_add.py备注回写防重复追加
3. 完善generate_add.py筛选逻辑,新增办理状态为空过滤
4. 重构check_review.py,新增回盘打印核对、并行轮询加载、统一清400状态逻辑,更新测试文档
2026-09-14 11:36:46 +08:00
puddy 67bb73fa30 refactor: 项目重命名为37du自动化工作台,完成全链路更新
本次提交完成了项目从"业务场景工具集"到"自动化工作台"的全链路重命名:
1.  更新所有页面标题、应用名称配置
2.  重构前端登录页UI与交互逻辑,新增启动加载动画
3.  移除旧版钉钉登录相关API与代码
4.  优化控制面板后台统计接口的SQL查询与字段映射
5.  新增agent_cli命令行管理工具,支持插件与账号权限管理
6.  修复后端插件权限校验逻辑,新增云端权限拉取能力
7.  更新控制面登录页面样式与交互体验
2026-09-14 00:34:54 +08:00
puddy 6f248b0741 feat: 实现v3版本的中心机与部署壳拆分登录架构
此提交完成了核心架构改造:
1. 新增钉钉直连接登录链路,使用浏览器本地跳转而非云端中转
2. 实现壳本机会话持久化,重启后不丢失登录态
3. 重构后端API鉴权,支持Bearer Token身份验证
4. 重写ProfilePanel与LoginPage页面样式与交互逻辑
5. 新增文档说明完整的拆分重构方案

主要变更包括:
- 新增/auth/exchange、/api/auth/dingtalk等登录相关接口
- 重构plugins/allowed_platforms接口支持新鉴权方式
- 实现云端会话token管理与本地会话落盘
- 替换旧登录页为分屏设计,支持钉钉扫码直连登录
2026-09-13 21:31:28 +08:00
puddy 9f6deaae76 feat(XQ0014): 实现社保增减员全流程与配套工具
新增:
- 社保增减员主流程import_add.py
- 审核结果核查脚本check_review.py
- 专用登录模块sb_login.py
- 验证码/SSO调试探针
- 完整测试记录文档

修复:
- XQ0002过滤规则新增虚拟大区排除
- 启用XQ0002数据校验开关
2026-09-12 15:20:54 +08:00
puddy d605a7f9cc feat: 完成插件管理系统产品化P0闭环落地
此提交实现完整的插件管理产品化闭环:
1. 中心机新增Ed25519密钥、审计/运行上报表、插件扩展字段,实现票据/管控清单签发、鉴权下载能力
2. 部署端新增设备级单活调度器、用户私有插件库、离线/联网校验链、插件下载安装流程
3. 控制面与部署前端同步更新UI与接口适配,新增审计页、插件管理增强功能
4. 修复两个工作流脚本的过滤与Excel导出问题,优化打包依赖与日志面板
5. 新增完整架构设计与实施文档
2026-09-11 09:08:40 +08:00
puddy 42c7cf24f2 feat(controlplane): 完成多页面管理台重构与平台权限控制
1. 重构控制面前端为多页面路由架构,拆分出概览/插件/账号/权限管理页面
2. 引入Element Plus组件库优化UI样式与交互
3. 新增平台登录权限校验,支持按账号授权HR/OA平台访问
4. 新增平台登出接口与个人中心功能
5. 完善账号管理、插件授权相关API与UI交互
6. 新增防火墙、启停、自启动脚本与部署文档
2026-09-10 15:03:21 +08:00
puddy c00c4423f0 chore(controlplane): 删除过时的seal_check v1.0.0占位包
移除不再需要的占位安装包文件,清理无用的旧版本包资源
2026-09-10 15:03:01 +08:00
puddy 3f901d3882 feat: 搭建控制面管理前端并剥离底座管理功能
1. 新增controlplane/frontend Vue3管理前端,实现登录、账号CRUD、插件上传/管理、权限授权
2. 为controlplane/app.py添加CORS中间件并挂载前端静态产物
3. 重构环境变量加载,统一使用app/common/env.load_app_env()
4. 剥离webhost/的管理UI与代理接口,仅保留基础登录能力
5. 新增环境隔离规范文档与架构蓝图说明
2026-09-09 17:10:12 +08:00
puddy 65540fb121 feat: 新增控制面管理功能,优化插件加载与消息通知
- 新增内网插件控制面服务,实现统一账户、权限管理与插件分发
- 重构后端插件加载逻辑,支持按账号动态权限白名单加载
- 优化XQ0001排班异常提醒文案与推送群配置
- 新增前端管理界面与登录态会话管理
- 新增插件上传、账号管理等后台管理接口
2026-09-09 11:31:41 +08:00
puddy 9d067c0646 refactor(workflows): 统一替换 yingdao 目录引用为 workflows
1.  将所有文档、代码中对 `yingdao/` 目录的引用替换为 `workflows/`,统一影刀版代码的命名空间
2.  调整 workflows/share 模块内的路径引用与文档注释,确保一致性
3.  同步更新测试代码与配置文件中的旧目录引用
2026-09-08 16:16:35 +08:00
puddy be07de0e92 feat: 新增多个业务需求脚本与共享模块
新增内容包括:
1. 7个业务需求占位文档目录与README
2. 共享OA登录、钉钉机器人推送工具模块
3. 雇主险变更清单导出脚本
4. 考勤月报封存检查两个检查脚本
5. 重庆社保停保导入名单生成脚本
2026-09-08 16:16:15 +08:00
puddy 0354a1ca58 refactor(yingdao/XQ0011): 重构考勤月报封存检查模块,拆分统一数据层
1.  新增seal_data_export.py统一处理考勤封存数据拉取、白名单筛选与导出
2.  移除unsealed_check.py与working_days_shift_check.py的直连接口逻辑,改为复用预处理数据
3.  统一XQ0007 OA社保申请导出筛选条件为ge(包含当月1号)并更新文档
4.  新增客服评价聚合分类需求文档
5.  移除闲置的XQ0011占位文档
6.  优化排班异常检查脚本,新增汇总群聊推送功能
2026-09-08 11:22:30 +08:00
puddy 1a16b1b5b7 feat(yingdao): 新增预入职/调动台账纯接口导出共享指令
新增两个影刀共享指令文件:
1. pre_entry_roster_export_api.py:预入职台账导出纯接口版,无需浏览器依赖
2. transfer_roster_export_api.py:调动台账导出纯接口版,无需浏览器依赖

两个文件均保留与原有浏览器版一致的调用签名,通过直接调用HR后端API实现台账导出,支持自定义模板、日期范围筛选,内置重试机制与登录态校验。
2026-09-05 18:59:22 +08:00
puddy f8889cdf51 feat: 新增花名册查询导出、电子签状态补全与会话自愈能力
1. 新增OA电子签相关工具函数:补全签署状态、会话失效自愈、附件下载重试
2. 新增EHR花名册查询、导出、字典翻译全套API
3. 重构离职电子签审批流程,适配接口变更,补全电子签状态与附件源
4. 新增数据字典缓存与编码翻译能力
2026-09-05 18:35:46 +08:00
puddy 8593f0fec4 feat: 新增组织维护接口模块,更新登录配置
1. 更新影刀HR登录的测试账号密码
2. 新增common_query加密工具类,实现HR平台查询参数加密逻辑
3. 新增组织维护API接口实现与导出工具
4. 更新HR配置文件,添加组织维护接口常量与参数
5. 更新API导出模块,新增组织数据接口导出支持
2026-09-05 16:14:36 +08:00
puddy e5884bd943 feat(hrbp/ehr): 实现重庆社保增减员导入名单制作功能
新增XQ0008重庆社保增减员导入名单制作全流程:
1. 新增app服务模块app/service/hrbp/ehr/social_import,包含核心生成逻辑、配置文件
2. 新增影刀脚本版本,支持增员/停保名单自动化生成
3. 完善配套文档:需求文档、流程文档、开发文档与评分文档
4. 修复钉钉机器人推送模块默认署名与关键词
5. 优化考勤异常脚本,改为自动查询上月完整数据
2026-09-05 11:48:00 +08:00
puddy 657f444041 docs: 批量更新项目评级文档,移除200元/400元/600元金额标注
refactor: 重构钉钉推送逻辑,移除内嵌dws命令改用全局变量传递
fix: 雇主险调度逻辑,修复名额复用与增删员同步问题
style: 优化文档表格排版与代码注释格式
2026-09-03 13:33:52 +08:00
puddy 16d59e4e69 feat: 多业务模块迭代优化
1. 修复雇主险导入监听逻辑,适配HR端流程变更,补全分页拉取逻辑
2. 为雇主险增员导入添加厂区后缀适配HR侧方案列表
3. 优化电子签审批消息格式适配钉钉markdown渲染
4. 新增请假异常名单钉钉群推送功能
5. 重构银行卡检查脚本,复用共享登录态并优化推送流程
6. 扩展钉钉推送共享模块支持群聊推送
2026-09-01 18:00:55 +08:00
puddy ea92c62bb9 feat(XQ0011考勤检查): 新增2个封存检查脚本与接口文档
1. 新增unsealed_check.py:实现考勤月报未封存名单检查
2. 新增working_days_shift_check.py:实现在职天数排班校验检查
3. 更新aa.md:更新考勤封存接口的请求地址、参数与完整字段定义
2026-09-01 00:00:31 +08:00
puddy 121df38da1 docs: 更新项目文档与需求单说明
1. 补充XQ0002需求文档换行符
2. 更新XQ0001需求单说明,明确app版为开发蓝图、影刀版为部署真源
3. 重构README文档结构,优化项目结构说明与运行示例
4. 更新XQ0001开发文档,补充代码实现细节与配置项说明
5. 新增迭代规划文档,设计API调度与原子化任务编排方案
2026-08-31 21:44:31 +08:00
puddy 75d0903c0a chore: 整理归档临时测试脚本并更新相关文档
1. 删除临时测试用的 _test_push.py 脚本,该脚本为定向推送测试用后即删
2. 更新XQ0002雇主险增减操作的需求文档与流程文档,新增变更清单导出与增减员导入步骤
3. 重评并更新XQ0001排班异常识别的评分文档、流程文档、需求文档与开发文档,补充钉钉推送、部门排班集合比对等新增功能,调整评级为一般档
4. 更新雇主险项目的开发文档,补充各步骤细节与配置项
2026-08-31 16:53:58 +08:00
puddy 8375df692a feat: 新增部门排班查询接口与排班异常校验优化
1. 新增按部门查询排班集合的接口能力,替换原模糊匹配排班名的校验逻辑
2. 新增门店技师序列的排除规则,优化异常判定范围
3. 修复导入统计分页截断问题,完善全量数据抓取逻辑
4. 更新钉钉推送模板与测试账号配置
5. 补全离职电子签流程相关文档
2026-08-31 16:24:25 +08:00
puddy 3b5ce2d219 feat: 新增离职电子签流程审批功能,重构请假OCR业务逻辑
1.  新增离职电子签全流程校验:包括附件下载、PDF解析、表单与文书核验
2.  重构通用OCR模块,剥离业务逻辑到单独的请假附件检测模块
3.  新增PyMuPDF依赖用于PDF文本与扫描件OCR解析
4.  新增附件清单查询接口与离职附件检测工具类
2026-08-31 11:55:25 +08:00
puddy 9cfa096ec8 feat(排班异常识别): 新增序列过滤、离职剔除,优化推送逻辑与钉钉消息格式
1.  新增职位序列过滤,排除经营系/职能系专业序列员工异常
2.  增加离职/未入册员工过滤,按花名册工号剔除异常记录
3.  简化店长解析逻辑,不再回退部门匹配
4.  优化钉钉消息格式,使用markdown换行并添加门店问候语
5.  调整钉钉推送命令参数,适配新版dws工具
6.  新增测试脚本,推送结果定向到夏一平
7.  更新花名册导出路径与默认筛选条件
2026-08-28 17:59:28 +08:00
puddy 30218cc339 feat: 调整EHR考勤异常处理逻辑,适配整月查询+上周推送需求
1.  更新需求文档版本与查询范围规则,将默认查询改为整月(1号查上月),钉钉推送仅覆盖上周
2.  新增query_month、in_last_week工具函数重构日期逻辑
3.  调整自动确认开关默认值为启用,分级处理轻微异常整月自动确认、严重异常仅上周推送
4.  更新日志与汇总消息格式,补充本月非上周异常的统计项
5.  同步修改影刀脚本与业务服务端代码逻辑
2026-08-28 16:30:21 +08:00
puddy 1178ea37b3 feat: 新增钉钉DWS推送模块,废弃旧钉钉推送脚本并更新全流程
1. 标记dingtalk_sender.py为废弃,新增dingtalk_dws_push.py基于DWS CLI实现钉钉单聊推送
2. 为花名册导出添加TTL缓存功能,支持强制重新导出
3. 更新考勤、排班异常脚本的推送逻辑,适配新的推送模块
4. 新增钉钉推送自测脚本
5. 更新项目文档与业务说明
2026-08-28 13:38:17 +08:00
puddy 5c90747d0f docs: 更新XQ0002、XQ0009的业务评分文档
重新评估两个项目的业务复杂度,修正评级规则判定逻辑,将XQ0002评级从一般上调至困难,更新XQ0009的困难、极难判定条件与最终评级,补充详细的维度计算依据与更新说明
2026-08-27 19:06:28 +08:00
puddy be6817bafd refactor: 重构影刀脚本目录结构,按需求单归档并清理冗余文件
- 将影刀脚本从按系统分组的oa/hr/employer_insurance等目录迁移到XQ00xx命名的需求单目录,与docs/需求单一一对应
- 删除原employer_insurance目录下冗余的export_change_sheet.py,将其迁移到XQ0002目录
- 清理已废弃的XQ0020标准化门店手续相关文档与XQ0021离职电子签重复文档
- 更新需求单总索引、README文档与影刀脚本目录说明,修正路径引用
- 修复雇主险导入模板校验逻辑与增员导入异常捕获逻辑
2026-08-27 17:00:09 +08:00
puddy 7af2132b99 refactor(yingdao): 重构OA工作沟通推送模块,迁移为共享可复用模块
1. 将原yingdao/oa/work_communication.py迁移至yingdao/share/work_communication.py,更新导入路径与文档注释
2. 在yingdao/README.md中新增OA工作沟通推送模块说明,更新依赖与调用示例
3. 新增排班异常识别相关影刀脚本:
   - transfer_roster_export.py:调动台账自定义导出
   - pre_entry_roster_export.py:预入职台账自定义导出
   - shift_abnormal_check.py:排班异常识别与工作沟通消息构造
4. 全局更新项目文档结构与README,补充需求单索引与依赖说明
5. 移除原yingdao/oa/work_communication.py,调整目录结构统一共享模块位置
2026-08-27 14:47:39 +08:00
puddy acca8c5e8a feat(yingdao): 新增OA工作沟通推送单文件模块
该模块合并自app公共模块,实现完整OA工作沟通推送能力,支持按工号/姓名搜索接收人、附件上传、HTML富文本内容,兼容影刀运行环境,提供单条/批量推送入口,内置登录态校验与异常处理。
2026-08-27 14:47:13 +08:00
puddy aee37b200f docs: 批量补全各需求单的文档文件
新增了XQ0008至XQ0021共计14个需求单的开发、流程、需求以及评分文档,同时更新了总需求单列表,删除了部分重复的旧文档文件与临时监听脚本。
2026-08-27 14:19:13 +08:00
puddy 05842f36d5 refactor: 升级OCR依赖与适配rapidocr v3+,补充业务字段展示
主要变更:
1. 统一替换rapidocr-onnxruntime为rapidocr+onnxruntime依赖包
2. 适配rapidocr v3+ API变更:调整OCR结果解析逻辑
3. 补充展示员工岗位信息到OA审批通知
4. 优化OA详情链接格式为Markdown可点击样式
5. 修复OCR图片EXIF旋转问题与文件名解码
6. 新增RPA开发提成评分规则文档
7. 重构OA登录入口参数,简化调用逻辑
8. 删除临时测试脚本
2026-08-27 13:32:48 +08:00
puddy 76d7459515 feat: 新增社保告知书制作下发全流程模块
1. 新增参保/停保告知书生成模块,支持按模板批量生成Word+PDF
2. 新增社保转移告知书独立数据源处理逻辑
3. 新增OA工作沟通推送数据自动构造能力
4. 重构雇主险模块,拆分变更清单导出为独立文件
5. 新增花名册查询工具模块,支持店长/人事批量查询
6. 更新项目文档与README说明
2026-08-26 19:50:32 +08:00
puddy fc2cf49c35 feat(employer-insurance): 新增雇主险增减员导入功能与流程优化
本次提交完成雇主险增减员导入全流程升级,包括:
1.  新增姓名关键字过滤规则,自动剔除测试/人资账号数据
2.  新增变更清单独立工作簿导出功能,保留格式与公式
3.  重构增减员导入流程,监听接口捕获全量导入异常
4.  新增影刀版钉钉推送异常消息适配,支持块格式分组推送
5.  更新文档与配置项,同步维护app与影刀双版本代码
2026-08-26 14:49:33 +08:00
puddy 93795ffec0 feat(yingdao/oa): 新增影刀共享模块,OA工作沟通推送脚本
1. 新增 work_communication.py 单文件OA工作沟通推送脚本,支持多接收人、多附件、HTML内容
2. 更新工作沟通需求文档与开发文档,补充多值分隔符说明与测试验证结果
2026-08-25 17:26:25 +08:00
puddy 4b168c3982 feat: 新增OA工作沟通推送模块,优化考勤异常查询逻辑与钉钉推送能力
1. 新增OA工作沟通推送全流程模块:
   - 实现人员搜索、多附件上传、工作沟通提交完整链路
   - 提供一键推送入口send_work_communication,支持多接收人、富文本与多类型沟通
   - 补充配套配置常量与接口封装
   - 添加抓包调试脚本与完整需求/开发文档

2. 考勤异常处理模块重构:
   - 将默认查询范围从「当月」改为「上周(周一~周日)」
   - 统一app/影刀版的日期范围计算逻辑
   - 新增班段合成、请假日期修复逻辑,优化导出报表字段
   - 更新需求文档与开发文档,同步功能变更

3. 钉钉推送工具优化:
   - 修复窗口激活逻辑,避免批量推送时抢焦点导致窗口失焦
   - 新增安全点击与鼠标状态兜底,防止左键卡死
   - 优化搜索与会话打开流程,提升稳定性
2026-08-25 17:08:44 +08:00
puddy e3dc6369ee feat(ehr): add shift abnormal recognition module
1. 新增排班异常识别完整业务模块,包含调动台账、预入职台账导出及异常校验
2. 新增对应自定义导出页面配置到config.py
3. 更新aa.md文档补充台账表头说明
4. 补充验证码调试用的图片资源
2026-08-25 00:24:07 +08:00
puddy bdcc0326bf feat: 周考勤异常处理全流程优化与功能增强
1. 新增考勤异常自动确认功能:支持轻微异常(迟到/早退<30分钟)自动确认,总开关可控
2. 完善钉钉推送能力:新增推送记录持久化、会话切换缓存优化、OCR逻辑重构
3. 重构考勤异常处理业务逻辑,统一app与影刀版代码逻辑
4. 新增测试用例与调试脚本,优化文档与配置项
5. 清理废弃调试文件,更新导出字段映射与展示顺序
2026-08-24 22:21:32 +08:00
puddy 20d93187f9 feat(employer-insurance): 新增姓名核对修正、增减员导入模板与自动生成功能,优化审批推送逻辑
1.  新增姓名核对修正逻辑,比对在参名单与花名册姓名并就地修正
2.  新增增减员导入文件自动生成功能,基于官方模板生成导入素材
3.  更新审批推送规则,仅推送提交失败明细与汇总统计
4.  重构变更清单输出逻辑,合并档次替换操作并新增姓名修正记录
5.  新增导入模板配置常量,统一管理模板文件路径
2026-08-23 22:18:27 +08:00
puddy b2db418d39 refactor(yingdao/雇主险): 重构业务流程步骤拆分与模块复用
1. 调整雇主险目录脚本结构,将原roster_export移出目录并改为共享模块
2. 重构roster_filter:改为复用共享导出模块,更新参数与注释
3. 新增add_sub_import脚本作为步骤3增减员导入,统一全流程调用逻辑
4. 更新README文档,修正步骤说明与文件对应关系
2026-08-23 21:48:37 +08:00
puddy d19b783302 docs: 批量更新各脚本文档注释,补充规则文档位置与简化描述
统一优化多个HR、OA、雇主险相关脚本的文件注释:
1.  整理折叠冗长的业务描述,将具体规则指向对应docs目录下的需求文档
2.  简化登录、推送流程的说明文本,统一表述风格
3.  修正雇主险调度脚本的main函数传参类型,匹配实际调用逻辑
2026-08-23 21:30:31 +08:00
puddy 13eb46f4e1 refactor(yingdao): 重构钉钉推送逻辑,新增VC运行库自包含支持
1.  重构钉钉推送模块:改为接收元组列表参数,移除群消息推送逻辑,拆分单聊/群推送职责
2.  新增VC运行库自动加载逻辑,解决onnxruntime依赖运行库缺失问题
3.  升级依赖包版本并做兼容性降级适配,统一numpy/opencv/onnxruntime版本
4.  更新考勤异常、离职审批脚本及文档,适配新的推送参数格式
2026-08-23 21:20:03 +08:00
puddy 7a4f3590ef feat(absence-analysis): 升级异常考勤分析逻辑至v2.2.0
1.  仅统计已备案(002)的请假记录,过滤撤销/销假/申请中的假单避免误判
2.  新增当前月返岗判定逻辑,不再仅依赖请假单判断是否已归岗
3.  跨月追溯改为逐月重估策略,根据追溯人数自动切换整月缓存/单人查询模式
4.  统一使用end_date而非带时刻的end_time计算请假截止日
5.  更新文档注释与日志文案,对齐业务口径
2026-08-23 15:05:07 +08:00
puddy 9e61206be2 feat: 启用考勤异常直接推送,重构钉钉推送适配逻辑
1.  启用app版考勤异常推送:移除push_abnormal中的注释,直接调用钉钉推送接口,不再仅打印日志
2.  更新钉钉推送文档与适配逻辑:
    - 重构dingtalk_sender参数为search_keyword/verify_keyword替代target/display_name
    - 更新考勤异常推送分组与参数格式,适配新的OCR推送逻辑
3.  移除影刀审批脚本的单聊推送支持,统一使用群机器人推送
4.  优化缺勤分析缓存逻辑,移除历史月缓存限制,改用懒加载缓存
5.  为影刀考勤异常脚本新增联调测试模式,避免联调期间打扰真实员工
2026-08-23 12:50:29 +08:00
puddy e5c598e67a feat(share/): add 37du花名册导出共享指令,重构原有内联导出逻辑
1. 新增share/roster_export.py共享指令,实现标准化花名册自定义导出
2. 统一读取HR共享登录态,支持在职/离职筛选、离职时间范围、自定义模板
3. 规范输出格式:单sheet、第2行作为表头、追加「类型」列到末尾
4. 更新README文档,补充指令说明、调用方式和路径配置
5. 重构原有employer_insurance/roster_export.py为雇主险专属导出逻辑
2026-08-22 16:26:52 +08:00
puddy 39bf3e14a0 feat(ehr): 添加出勤统计报告导出并更新缺勤分析
1. 新增考勤统计报表接口与导出功能,支持全集团逐日出勤数据拉取和Excel导出
2. 重构请休假异常分析逻辑,改用考勤统计报表作为精确数据源替代排班+旷工接口
3. 新增跨月追溯缓存机制,优化大批次员工分析性能
4. 补充缺勤类型统计备注字段,提升分析准确性
2026-08-22 00:58:22 +08:00
puddy ce0422979a refactor(oa&dingtalk): 重构审批推送逻辑,改用块格式Markdown并支持分批推送
1.  统一请假、加班审批的推送实现,新增`_format_leave_block`/`_format_overtime_block`格式化审批详情为标准Markdown块
2.  重构`build_push_summary`生成分组推送数据,不再拆分单条消息,直接返回带标题和块列表的分组结构
3.  升级钉钉机器人推送模块,支持块格式分组自动分批推送,兼容原有纯文本推送逻辑
4.  临时关闭自动审批开关`APPROVE_ENABLED`,适配影刀运行环境
5.  重构影刀端钉钉推送指令入口,支持传入块格式分组数据并自动处理分批
2026-08-21 23:45:16 +08:00
puddy bfef048695 fix: 修复多个功能模块的分页、待办请求及社保统计逻辑
1.  修正OA待办接口分页参数,改用服务端支持的pageno/rowsize/pagingtype,移除无效旧参数并添加防缓存随机数
2.  调整待办默认分页大小至100,减少分页异常丢单风险
3.  优化请假候选过滤逻辑,仅统计请假天数≥1天的有效记录
4.  新增社保参保名额复用链条追踪逻辑,修复跨员工替换时的名额平衡问题
2026-08-21 20:24:26 +08:00
puddy 2f67a15083 fix(oa): 修复改签离职电子签审核脚本的状态获取与消息推送逻辑
1. 修复电子签状态恒为空的问题,新增签署状态查询接口调用补全真实状态
2. 将消息推送从多条明细改为单条汇总统计
3. 修正多处文档描述与变量名,统一"改签离职电子签"命名
2026-08-21 11:54:00 +08:00
puddy d773f783eb feat(hrbp.oa): 新增离职电子签流程审核模块
完成离职电子签全流程开发,包括:
1. 新增模块目录与基础初始化文件
2. 实现表单解析、校验逻辑、审批入口与报告生成
3. 扩展通知模块兼容离职电子签场景,新增未完成待跟进统计
4. 补充接口文档与示例代码
2026-08-20 23:28:05 +08:00
puddy dc8d038e34 refactor(oa): 将审批决策中的「驳回」统一替换为「校验不通过未处理」
1.  统一所有模块的决策状态命名,替换原「驳回」为「校验不通过未处理」
2.  调整配置注释、文档说明、报告输出文案与推送文本
3.  新增请假附件OCR详情识别函数,支持多附件校验与命中关键词记录
4.  优化多附件下载逻辑,支持逗号分隔fileId与避免文件覆盖
5.  调整请假校验逻辑,适配小时假日期区间获取与多附件处理
6.  更新测试用例与审批提交逻辑,适配新的决策状态
2026-08-20 21:46:33 +08:00
puddy 195edb8b32 feat(oa): 新增审批异常状态的统计与通知
1. 为请假、加班审批流程新增异常状态分类统计和专属报告清单
2. 完善审批提交弹窗选择兼容逻辑,适配多类型确认弹窗
3. 提交失败时自动将单据标记为异常状态并记录原始结论
4. 推送摘要中新增异常审批条目展示
2026-08-20 21:45:44 +08:00
puddy 59b2ee9acb fix: 修正排班休息日判定逻辑,移除不可靠的paiban_type依赖
本次提交全面调整了排班数据的处理逻辑:
1.  移除所有对`paiban_type`字段的依赖,改为通过`bc_name == "休息"`作为休息日判定的唯一可靠依据
2.  从`_extract_day_shift`、`_get_day_shift`等工具函数中删除`paiban_type`相关的字段获取和判断逻辑
3.  更新所有相关接口注释、文档说明,明确说明`paiban_type`不可靠,休息也可能返回-2
4.  重构了连续未出勤段的计算逻辑,将休息日纳入未出勤集合,支持跨月追溯
5.  同时更新了影刀版本和服务端版本的实现代码,保持逻辑一致
2026-08-20 19:18:01 +08:00
puddy d7f3cbfcfd refactor(leave): 重构请假审批校验逻辑,升级排班数据获取方式
1.  请假解析器新增工号、开始/结束日期字段,优化日期取值逻辑
2.  排班数据从考勤逐日接口改为HR排班接口,支持跨月和未来日期查询
3.  校验逻辑改用工号查询排班,新增HR会话缓存复用机制
4.  修复测试用例适配新的排班数据结构
5.  更新文档说明钉钉推送消息格式变更
6.  雇主险脚本优化文件选择逻辑,按文件名日期而非修改时间排序
7.  影刀登录模块移除环境变量依赖,内置默认配置
8.  加班审批脚本适配新的消息推送格式,新增超期处理类型
2026-08-20 17:11:49 +08:00
puddy d2b24051af refactor: 统一审批流程推送逻辑,优化通知与报告展示
1.  移除审批结果过滤,始终推送完整报告含明细
2.  统一驳回相关术语为「校验不通过未处理」
3.  重构OA登录态校验,改用SystemExit友好提示无堆栈
4.  更新钉钉推送样式,改用代码块避免Markdown格式冲突
5.  优化雇主险/考勤清单的紧凑化与日期格式处理
6.  拆分原「修改」操作为「删除+新增」以准确体现变更
2026-08-20 11:26:54 +08:00
puddy 0973533bab refactor(overtime-approval): 重构加班审批弹性兑换规则
1.  新增弹性扣减午餐时长配置项,优化晚到扣减逻辑
2.  统一排班开始时间作为上班时间优先级,替代硬编码09:00
3.  替换总自然时长校验为实际在岗时长计算
4.  更新文档与代码注释,对齐业务规则变更
2026-08-20 09:31:24 +08:00
puddy 61e9e123c4 refactor(employer_insurance): 重构为多类别并行处理流程
1. 拆分原单类别逻辑为四大标准类别(三十七度/水庄/湖畔/秒创),按类别独立管理文件与配置
2. 新增自动查找类别目录内最新变更记录文件的逻辑
3. 统一工号文本格式处理,避免Excel匹配失败
4. 新增增员/减员导入文件生成功能,适配HR上传流程
5. 更新文档注释与运行说明,支持单类别调用
2026-08-19 18:53:47 +08:00
puddy 60a177605a refactor: 重构雇主险业务,适配多类别拆分与影刀脚本整合
1.  重构ehr/common/config.py与employer_insurance/config.py,新增多类别配置与工具函数
2.  重写employer_insurance.py,支持按类别调度处理
3.  新增影刀共享模块与业务脚本,统一RPA开发规范
4.  移除旧版冗余的影刀脚本文件
2026-08-19 11:30:23 +08:00
puddy 60112ad367 feat: 新增打卡明细接口支持,优化加班校验逻辑
1. 新增打卡明细接口封装,支持单页查询与自动分页获取员工真实打卡记录
2. 重构加班校验逻辑,使用打卡明细接口替代原考勤逐日接口的打卡字段,解决跨天打卡归属错误问题
3. 移除过时的打卡时间解析与单条打卡修正逻辑,简化代码维护
4. 优化OA登录脚本,新增requests依赖并完善会话校验逻辑
5. 新增钉钉群机器人推送通用模块,支持多场景通知推送
2026-08-18 13:35:11 +08:00
puddy c95720514b refactor: 替换排班/打卡接口为考勤逐日接口,清理旧依赖
1. 重构考勤相关接口:将get_attendance_html、get_attendance_records替换为get_attendance_daily,使用新的ATTENDANCE_DAILY_URL接口替代旧接口
2. 更新请假校验逻辑:使用考勤逐日接口统计上班天数,替换原跨月排班HTML请求逻辑
3. 升级测试用例:同步更新test_03_attendance.py和test_06_leave_online.py适配新接口
4. 新增/完善文档:新增多份流程与需求文档,删除旧版冗余文档,整理docs目录结构
5. 清理废弃文件:删除原周考勤异常、门店请休假异常相关旧需求文档
6. 配置更新:更新config.py中的考勤相关URL常量,补充注释说明
7. 待办优化:更新aa.md内容,同步加班审批规则说明
2026-08-18 12:00:53 +08:00
puddy 2fafd9af18 refactor(dingtalk): 重构钉钉发送工具为OCR视觉方案,替换旧UI自动化实现
- 重写核心逻辑为屏幕OCR识别+键盘自动化,大幅提升稳定性
- 移除旧版UIAutomation依赖,新增psutil、rapidocr等依赖
- 拆分新增dingtalk_demo.py作为手动测试入口
- 替换tests/test.py为新的视觉方案测试示例
- 兼容保留旧版API接口(send_to_person/send_to_group等)
- 优化窗口激活策略,规避快捷键切换隐藏窗口问题
2026-08-15 19:25:47 +08:00
puddy 4d9928abf3 refactor(yingdao): 优化登录和预检逻辑,完善资源清理
1. 为OA登录添加成功标记,确保异常时正确关闭浏览器
2. 调整HR登录获取账号密码的优先级,优先使用环境变量
3. 新增OA登录态预检逻辑,自动保存有效cookie
2026-08-15 14:27:03 +08:00
puddy 28b74fce4e refactor(hrbp/yingdao): 统一社保核对逻辑,优化异常处理与会话复用
1. 重构_si_check_batch和_si_preflight,统一异常处理策略:查询失败不再内部吞错而是上抛,由调用方处理重登或标注异常
2. 为_write_annotated新增session入参,支持调用方传入预构建会话避免重复预检
3. 新增失败工号集合统计,将查询失败的工号统一标注为需人工复核状态
4. 提前在导出入口做登录态预检,避免导出完成后才发现会话失效
5. 同步更新两个业务模块的代码逻辑,保持行为一致
2026-08-15 13:08:49 +08:00
puddy d468d15032 feat: 新增轻量会话校验能力,优化登录态失效处理流程
1. 新增TODO_COUNT_URL轻量接口用于快速校验会话有效性
2. 定义OALoginExpiredError统一标识登录态失效异常
3. 重构会话校验逻辑,使用轻量接口替代拉取待办页校验
4. 为重试装饰器添加不重试异常配置,登录失效直接上抛
5. 全流程增加登录态失效自动重登机制,最多重试2次
6. 新增通用钉钉机器人推送工具类
2026-08-15 12:45:41 +08:00
puddy c1c54e61fc refactor(yingdao): 统一影刀脚本依赖校验逻辑,移除懒加载改为启动即校验
1.  所有影刀脚本改为启动时一次性校验所有依赖,不再懒加载,任一依赖缺失立即报错退出
2.  更新requirements.txt,新增requests、rapidocr-onnxruntime依赖
3.  重构多个影刀脚本的依赖导入和错误提示逻辑,统一提示话术和安装命令
4.  为请假审批脚本内置OCR实现,移除对项目目录OCR模块的依赖,实现单文件自包含
5.  优化考勤异常处理脚本,新增职能序列过滤和合并推送逻辑,减少重复通知
2026-08-14 17:14:17 +08:00
puddy 966d529551 refactor: 重构HRBP公共层与业务模块,整理废弃资源
1.  迁移并统一HR会话、配置、API等公共能力至hrbp/common层,实现ehr/oa模块复用
2.  删除captcha_debug调试用图片资源与旧session_manager文件
3.  重构考勤异常处理模块,补充分级逻辑与导出优化
4.  新增OA/HR多套API封装模块与配套文档
5.  移除旧通用接口规划文档,补充完整需求与开发文档
2026-08-14 15:48:15 +08:00
puddy 186636a8e4 refactor: 统一所有缓存/会话文件的存储路径
1.  重构会话管理模块,新增app.common.app_paths统一管理缓存路径,所有登录态与缓存统一迁移至%LOCALAPPDATA%\37duAutomation\.sessions
2.  更新所有涉及文件存储路径的代码,包括考勤、工资卡、社保、审批等模块
3.  新增银行字典缓存功能,统一管理银行编码映射
4.  添加雇主险业务模块,实现花名册筛选复制功能
5.  更新.gitignore,将所有.sessions目录纳入忽略列表
6.  删除影刀脚本旧的本地缓存文件
7.  优化加班审批校验逻辑,新增提前到岗型加班校验规则
8.  完善工资卡核对功能,补充开卡银行信息展示
2026-08-13 21:20:55 +08:00
puddy c749d951a0 fix: 修复加班校验逻辑与OA单据重复问题,新增Excel重算工具
1.  加班校验不通过时直接返回驳回结果,不再执行后续校验
2.  为OA待办查询接口添加去重逻辑,避免重复审批单据
3.  新增WPS COM调用的Excel公式重算测试工具
2026-08-12 17:47:49 +08:00
puddy 9a14f5aca6 feat(overtime): add special half-day overtime rule for functional scheduling
新增职能排班员工休息日/节假日加班的半天时长规则:上午加班按3.5小时、下午按4.5小时计算,不再统一使用4小时的默认半天标准,按加班开始时间是否早于12点区分上下午。
2026-08-12 09:31:10 +08:00
puddy 9927066abb feat: 新增考勤异常模块、银行卡校验、OCR附件检测等功能
1. 新增考勤异常查询与导出模块,支持当月异常拉取、Excel导出、钉钉推送提醒
2. 完善请假/加班流程解析与校验,新增附件下载、OCR核验能力
3. 新增银行卡信息校验模块,支持在职/离职员工工资卡数据核对与异常导出
4. 新增通用OCR工具模块,支持病假/婚假/产检假附件关键词检测与日期提取
5. 新增门店请休假异常名单、银行卡检查等需求文档
6. 重构部分现有模块代码,优化配置与接口调用逻辑
7. 新增测试文件与工具类,完善项目基础能力
2026-08-11 17:26:24 +08:00
puddy 7e46b5cc06 feat(hrbp-ehr): 新增HR薪资卡与花名册自动化模块
1.  新增hrbp.ehr业务模块目录结构与基础配置
2.  新增工资卡数据抓取、核对功能,支持在职/离职员工数据导出
3.  新增员工花名册自定义导出自动化流程
4.  添加pandas依赖到requirements.txt
5.  清理调试用的验证码图片文件
2026-08-08 23:39:04 +08:00
puddy eef5df9ce2 feat: 新增登录态过期不重试逻辑,优化社保核对流程
1. 重构重试装饰器,新增no_retry_on参数支持指定异常不重试
2. 为社保核对模块添加登录态过期检测与自动刷新逻辑
3. 统一两处社保业务代码的异常处理与会话重建流程
4. 更新版本号与默认输出目录配置
2026-08-08 19:25:42 +08:00
puddy 83d8204847 chore: 删除两个过期的员工考勤统计excel文件 2026-08-08 00:10:38 +08:00
puddy 0489fbe62c feat: 新增社保参保核对工具链,补全依赖并清理废弃文件
- 新增社保参保/停保状态核对核心逻辑,支持调用HR接口校验工号参保记录
- 新增滑块验证码改进版登录工具,支持缓存会话免重复登录
- 新增HR通用API封装模块
- 新增员工异动名单清洗、导出、核对全流程功能
- 新增依赖库xlrd、openpyxl、opencv等
- 删除旧的钉钉消息推送文档、测试用Excel、aa.md脚本文件
- 优化员工异动导出流程,自动完成去重和参保核对
2026-08-07 23:12:09 +08:00
puddy 5d339b3d0e refactor: 重构审批流程与依赖,新增社保异动模块
1. 新增社保增减名单模块,支持参保/停保名单导出
2. 重构钉钉推送逻辑,先推摘要再按需推送完整报告
3. 优化假期/加班校验的天数比对逻辑,适配半天请假场景
4. 重写排班HTML解析器,兼容新的页面结构并提取班次全称
5. 重构审批报告生成逻辑,新增全量明细展示
6. 重构影刀脚本的日志与依赖管理,新增UI自动化聚焦输入框
7. 更新依赖包,新增uiautomation库支持
2026-08-07 19:40:02 +08:00
puddy 724a4f7b77 refactor: 重构项目代码结构与依赖管理
1.  **依赖与导入路径修正
    - 移除所有本地sys.path插入,统一使用绝对包导入
    - 修复logger导入路径,统一从app.utils导入
    - 重构intelligent_retry.py移除冗余导入
    - 统一hrbp各模块的导入路径

2.  **项目配置与构建
    - 新增pyproject.toml配置文件,规范项目元数据与依赖声明
    - 更新requirements.txt新增pyautogui、pywin32、pyperclip依赖

3.  **业务模块重构
    - 重构请假/加班审批模块的导入路径与内部逻辑
    - 重命名审批结果描述(将"不通过"改为"驳回")
    - 统一代码中的箭头符号(将→改为->)
    - 新增请假表单解析模块、钉钉通知模块
    - 重构加班/请假校验模块的报告生成逻辑,统一报告格式与推送流程

4.  **测试与文档
    - 新增端到端测试脚本与统一测试运行器
    - 完善README.md文档,补充项目结构、功能说明与使用方法
    - 新增钉钉消息推送工具文档
    - 新增测试用例与辅助工具

5.  **其他优化
    - 修复common/parser.py中的正则表达式兼容单引号的HTML属性
    - 新增session_manager.py移除冗余导入与路径修正
    - 新增OA审批报告生成逻辑优化,支持分组统计与详细清单输出
2026-08-07 00:18:49 +08:00
1725 changed files with 495354 additions and 2938 deletions
+95 -51
View File
@@ -1,51 +1,95 @@
# ---------- Python ---------- # ---------- Python ----------
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
*.so *.so
.Python .Python
*.egg *.egg
*.egg-info/ *.egg-info/
dist/ dist/
build/ build/
eggs/ eggs/
sdist/ sdist/
wheels/ wheels/
*.manifest *.manifest
*.spec *.spec
pip-log.txt # 前端依赖与构建产物(desktop 桌面端)
pip-delete-this-directory.txt desktop/*/frontend/node_modules
plugins/**/ui-src/node_modules
# ---------- 虚拟环境 ---------- desktop/*/frontend/dist/
.venv/ desktop/**/frontend/*.zip # controlplane-web-dist.zip 等部署用压缩包
venv/ # Node 依赖全局兜底(含 electron-shell 根目录)
env/ node_modules/
ENV/ # Electron 壳子运行环境 / 打包产物(可再生,不入库;详细规则见 desktop/electron-shell/.gitignore)
dist-app/
# ---------- 环境变量 / 密钥 ---------- dist-env/
.env python-env/
.env.*
!.env.example # 桌面版打包产物(PyInstaller 中间/输出、安装包、插件构建包,不入库)
# 各平台会话 cookies 持久化目录(OA / 其他平台共用,按平台名分文件) # 仅执行机(壳子)/文件服务器仍走 PyInstaller 打包;中心机已改源码部署,不再产出 exe
app/service/.sessions/ desktop/*/build-exe/
desktop/*/dist-exe/
# ---------- IDE ---------- desktop/releases/
.idea/ desktop/build/
.vscode/ dist-plugin/
*.swp desktop/**/setup-*.exe
*.swo desktop/**/installer/
pip-log.txt
# ---------- 操作系统 ---------- pip-delete-this-directory.txt
.DS_Store
Thumbs.db # ---------- 虚拟环境 ----------
desktop.ini .venv/
venv/
# ---------- 日志 ---------- env/
*.log ENV/
logs/
# ---------- 环境变量 / 密钥 ----------
# ---------- 测试 / 覆盖率 ---------- .env
.pytest_cache/ .env.*
.coverage !.env.example
htmlcov/ # 控制面签名密钥 / 运行期产物(禁止入库)
.tox/ .admin_secret
.webhost.pid
*.pid
desktop/**/keys/
desktop/**/packages/
desktop/**/controlplane.db
desktop/**/_cp_sessions.json
# 各平台会话 cookies / 缓存目录(统一移入 %LOCALAPPDATA%\37duAutomation,禁止入库)
**/.sessions/
# ---------- IDE ----------
.idea/
.vscode/
*.swp
*.swo
# Trae IDE 本地配置/技能(不入库)
.trae/
# 工具 ACL 恢复备份产物
.dsh-acl-recovery/
# ---------- 操作系统 ----------
.DS_Store
Thumbs.db
desktop.ini
# ---------- 日志 ----------
*.log
logs/
# 豁免:新版服务端前端的「运行日志」视图目录(logs/ 通用规则会误伤 views/logs)
!desktop/controlplane-next/frontend/src/views/logs/
# ---------- 测试 / 覆盖率 ----------
.pytest_cache/
.coverage
htmlcov/
.tox/
aa.md
# vc运行库
vc_redist/
vc_redist_x64/
vc_redist_x86/
静态资源/
.assets/
+44
View File
@@ -0,0 +1,44 @@
AI 智能体开发约束 & 项目执行规范
本文件为项目根目录全局 Agent 行为规则,AI 编码、重构、调试、优化、答疑均需默认遵循以下配置,无需用户重复说明。
---
1. 运行环境规范
- 默认强制使用本地 .venv 虚拟环境,禁止使用任何沙箱环境、在线临时环境、容器模拟环境。
- 所有代码运行、依赖安装、调试、语法检查、模块测试,均基于项目根目录 .venv 环境执行。
- 如需安装依赖,仅操作本地虚拟环境,不污染全局 Python 环境。
- 所有需要【写入文件内容】的操作(导出落盘、覆盖目标文件、复制/移动文件、下载保存等)一律不使用沙箱:执行时触发沙箱外运行(requires_approval 申请用户批准),避免被沙箱拦截(如 D:\资料 等受保护目录只读可读、写入被拒)。
2. 影刀开发规范
- 影刀项目默认采用单文件自包含架构。
- 输出影刀脚本、逻辑代码、流程封装时,优先单文件独立实现,功能自包含、可直接导入运行,不拆分冗余子文件。
- 单文件需具备完整性:依赖声明、核心逻辑、异常处理、入口执行全部内聚在当前文件。
3. 项目通用架构规范
- 代码组织:不同业务、不同流程独立模块化运行,互不侵入、互不影响。
- 各方向零依赖:项目并存多个独立演进方向,彼此【绝不跨目录 import】,登录/数据导出等数据层各自内置(允许少量重复换取完全解耦),任一方向可单独拷贝、单独演进、独享依赖与启动:
- 桌面端 desktop/:中心机 desktop/controlplane/ + 执行机桌面壳 desktop/electron-shell/(当前宿主,Electron + Node,内置便携 python 环境 python-env/<版本>/ 跑插件)+ 老版执行机底座 desktop/webhost/(标记老版本、后续废弃、不再维护)。各自互不 import、独立演进、可单独拷贝(模块搜索根 = desktop/,运行均以 desktop/ 为 cwd)。
- 插件 plugins/:根级独立目录(按号段分桶 plugins/XQ0001-0100/),被执行机(electron-shell 壳)按账号权限自下载加载,不随底座发布。
- 影刀版 workflows/:单文件自包含,需求脚本按号段分桶(workflows/XQ0001-0100/)。
- app/ 蓝图版:已弃用,保留归档、不再维护。
- 代码形态分三类,按各方向性质采用不同组织方式(【单文件自包含】仅适用于影刀版,其它一律按正常项目开发):
- workflows/(影刀版):沿用单文件自包含架构(见第 2 节,仅影刀适用)。
- 桌面端各后端(desktop/controlplane/ 中心机、desktop/electron-shell/ 执行机壳、desktop/webhost/ 老版执行机底座[后续废弃]):按正常 Python 模块化项目开发,允许按包/模块/多文件拆分(如 main.py/app.py 分割逻辑与路由),不做单文件约束。
- 插件(执行机加载的执行单元,源码位于根级 plugins/XQ0001-0100/<中文目录>/,如 plugins/XQ0001-0100/XQ0011 考勤月报封存检查/,id 用固定规则 xq{单号},与目录名解耦):内部按正常项目组织,可拆 config/data/logic/report 等多文件;但强调【插件自包含】——插件内模块只能互相引用、依赖 Python 标准库/第三方依赖/底座注入的插件接口(webhost.backend.plugins.base),严禁 import 插件包之外的任何代码(根目录、desktop 底座业务、app 一律禁止),保证插件完整交付物=插件包本身,可单独拷贝发布、独立演进。插件目录结构、前端(ui/ 与 ui-src/)存放、打包产物位置(dist-plugin/<id>_v<版本>.zip)、发布流程等细则见 docs/插件/插件开发规范.md 与 docs/插件/发版规范.md。
- 环境变量按模块隔离,各自使用自己目录下的 .env,互不覆盖、互不依赖:
- 根目录 .env:仅供 workflows/(影刀) 脚本使用,承载各 XQ 业务路径/账号等配置;禁止向根 .env 写入桌面端/app 的变量。
- desktop/controlplane/ → desktop/controlplane/.env(中心机配置,含 CONTROLPLANE_PORT、CONTROLPLANE_TOKEN)
- desktop/webhost/ → desktop/webhost/.env(老版执行机底座配置,后续废弃);当前宿主 desktop/electron-shell/ 无独立 .env,配置在 electron/config.js,数据根 %LOCALAPPDATA%\37duAutomation
- app/ → app/.env(app 版业务配置,已弃用)
- workflows/ 影刀不再单独建 .env,所需配置统一放在根 .env。
- 各模块加载器只允许读取本模块目录下的 .env,禁止读取/改写其它模块或根 .env。
- 插件本地配置(当前宿主 electron-shell):明文 JSON,路径 %LOCALAPPDATA%\37duAutomation\plugin_configs\<插件id>.json,electron-shell/electron/runner.js 直接 JSON.parse 读取、无加密解密(登录类插件需自行清洗首尾空白防误存空格导致"密码不正确"累计触发平台锁定);旧 SQLite 场景配置(plugin_configs 表,enc:v1: AES-256-GCM 加密)是另一套,不参与插件执行参数注入。
- 错误处理:全局项目级重试机制,最大重试 3 次,三次失败后再记录错误日志。
- 日志规范:正常 INFO 级别屏蔽大体积 JSON 调试日志,保证日志整洁;仅 DEBUG 模式开启完整 JSON 调试信息输出。
4. AI 工作默认规则
- 所有代码生成、修改、重构必须贴合 Python 模块化编程思想。
- 不主动创建冗余文件、不随意变更项目结构、不混用沙箱环境。
- 输出代码优先保证:可运行、结构清晰、符合项目统一规范、按代码形态适配(单文件自包含仅影刀版需要;后端与插件按正常模块化项目开发)。
- 变量配置规范:禁止使用命令行传入变量的方式实现参数配置,所有参数、变量、配置项均在代码/配置文件内部定义、固化或读取本地配置,保证运行无外部参数依赖。
5. 发版与自动更新操作规范
- 自动更新:插件由执行机按账号权限自下载(plugin_sync.py);壳子由执行机自动下载安装包 + 用户点击升级重启(shell_updater.py)。版本源都在中心机控制面。
- 发版统一走 agent CLI(desktop/ 下执行:.venv\Scripts\python.exe -m controlplane.tools.agent_cli)。插件用 publish / grant / revoke;壳子用 file push --category shell;中心机为内网 `172.30.30.243`(controlplane-next / Midway,systemd `37du-controlplane-next.service`),改代码后按 `37du-Center-Deploy` 技能部署(SSH 凭证已固化在该技能内)。
- 鉴权:密码登录 `--admin puddy --password 123456`,**一律显式加 `--base http://172.30.30.243:8800`(内网生产控制面,执行机实际连接源)**,或中心机本机密钥自签。⚠️ 控制面有两套且数据不同步:公网 `http://117.72.191.188:8800` 是迁移前旧库(仍在线但执行机不连),发版/授权/登记发到公网库 = 执行机永远检测不到新版本;端口分工(内网 172.30.30.243):8800 控制面 / 8802 文件服务器下载 / 8899 文件服务器管理台。
- 完整流程、命令示例见 docs/插件/发版规范.md;中心机部署见技能 `.trae/skills/37du-Center-Deploy/SKILL.md`(SSH、编译、重启、验证)。⚠️ 公网 117.72.191.188 / 宝塔 已废弃停更,不再部署、不再更新,旧的宝塔部署文档仅作历史参考。
+235 -235
View File
@@ -1,235 +1,235 @@
GNU AFFERO GENERAL PUBLIC LICENSE GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007 Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble Preamble
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow. The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS TERMS AND CONDITIONS
0. Definitions. 0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License. "This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program. A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code. 1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
subprograms and other parts of the work. subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work. The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions. 2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law. 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies. 4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions. 5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date. a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms. 6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms. 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination. 8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies. 9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients. 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents. 11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom. 12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License. 13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License. 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty. 15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability. 16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16. 17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
Process-Automation Process-Automation
Copyright (C) 2026 spudding Copyright (C) 2026 spudding
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
+176
View File
@@ -1,2 +1,178 @@
# Process-Automation # Process-Automation
HR 业务流程自动化(37duAutomation):覆盖 HRBP OA 审批、EHR 数据核对/导出、社保、考勤、排班、雇主险等场景,提供桌面端插件体系(中心机 + 执行机)、影刀 RPA 单文件版本及配套的「需求单 → 评分」文档体系。
## 项目简介
基于 Python / Node 的 HR 流程自动化工具,实现形态上分两条落地路线:
* **桌面端插件体系**:中心机控制面(插件发布 / 账号权限 / 壳子分发)+ 执行机桌面壳(Electron + Node,内置便携 Python,插件以 Python 子进程运行),插件按账号权限自动同步加载,另配独立内网文件服务器承载大文件分发;
* **影刀 RPA 单文件版**:`workflows/` 下按业务隔离的单文件自包含脚本,可直接导入影刀平台运行。
业务上覆盖两大类场景:
* **OA 审批自动化**:通过 DrissionPage 浏览器自动化 + OA 接口,自动处理请假、加班、离职电子签等审批流程,内置规则校验、OCR(rapidocr 3.x)附件识别、钉钉/工作沟通推送、审批报告生成;
* **EHR 数据处理自动化**:对接 HR 平台接口与本地 Excel,完成考勤异常核对、排班异常识别、工资卡核对、社保增减名单/告知书、雇主险名额等。
## 项目结构
```
Process-Automation/
├── desktop/ # 桌面端:中心机 + 执行机 + 文件服务,各方向独立演进(模块搜索根 = desktop/,运行 cwd 均为 desktop/)
│ ├── controlplane/ # 中心机:插件发布 / 账号权限 / 壳子分发控制面
│ │ ├── app.py # FastAPI 服务入口(desktop/ 下 python -m controlplane.app)
│ │ ├── core/ / apis/ / frontend/ # 配置存储鉴权 / REST 接口 / 管理前端
│ │ ├── packages/ / shell/ # 插件包与壳子安装包仓库
│ │ └── tools/ # agent_cli 发布 CLI、运维脚本
│ ├── electron-shell/ # 执行机桌面壳(当前宿主,Electron + Node)
│ │ ├── electron/ # 主进程:本地服务、插件同步/调度/执行、壳子自动升级、Chrome 管理
│ │ ├── frontend/ / renderer/ # 工作台前端
│ │ ├── python-env/ # 内置便携 Python(插件以 Python 子进程执行)
│ │ └── dist-app/ # 打包产物(electron-builder NSIS)
│ ├── fileserver/ # 内网文件服务器(独立 FastAPI,端口 8802,存放壳子更新包/Chrome 安装包等大文件)
│ └── webhost/ # 老版执行机底座(Python + PyWebView,已废弃,不再维护)
├── plugins/ # 插件:号段桶目录为源码,扁平 id 目录为开发态运行目录
│ ├── XQ0001-0100/ # 插件源码(按号段分桶,含 ui-src/ 前端源码与 _pack.py 打包脚本)
│ │ ├── XQ0002 雇主险增减操作/
│ │ ├── XQ0010 EHR系统月考勤异常处理/
│ │ ├── XQ0011 考勤月报封存检查/
│ │ └── ... # 插件内部按 config/data/logic/report/ui 多文件组织,自包含可独立发布
│ └── xq0002/ xq0010/ xq0011/ ... # 开发态运行目录(打包产物解压得到,执行机注册表只扫一层)
├── dist-plugin/ # 插件打包产物 <id>_v<版本>.zip(经 agent_cli publish 发布到中心机)
├── workflows/ # 影刀 RPA 单文件版(需求脚本按号段分桶,对应 docs/需求单/XQ00xx)
│ ├── share/ # 共享指令:钉钉群机器人/推送、OA/HR 登录、花名册导出、工作沟通
│ ├── XQ0001-0100/ # 需求脚本(每 100 号一桶)
│ │ ├── XQ0001 排班异常识别/ # 调动/预入职台账导出 + 排班异常判定(钉钉单聊推送)
│ │ ├── XQ0002 雇主险增减操作/ # 名额调度、变更清单导出、增减员导入
│ │ ├── XQ0003 EHR系统请假流程审核/
│ │ ├── XQ0004 EHR系统加班流程审核/
│ │ ├── XQ0005 银行卡检查/
│ │ ├── XQ0006 EHR系统周考勤异常处理/
│ │ ├── XQ0007 OA系统社保增减名单梳理/
│ │ ├── XQ0008 重庆社保增减员导入名单制作/ # 增员/减员导入名单生成
│ │ ├── XQ0009 门店上月请休假异常人员名单梳理/
│ │ ├── XQ0010 EHR系统月考勤异常处理/
│ │ ├── XQ0011 考勤月报封存检查/ # 月报封存、加班补偿、休班核对等多维检查
│ │ ├── XQ0012 EHR预支及支付报酬自动发起ERP付款申请/ # *仅说明文档,未实现*
│ │ ├── XQ0013 社保费用申报导出并汇总/ # *仅说明文档,未实现*
│ │ ├── XQ0014 社保系统增减员办理/ # 社保系统登录、增员/减员导入、回盘审核结果检查回写
│ │ ├── XQ0015 参保成功及异常告知书制作与下发/ # 覆盖 XQ0016 社保转移告知书
│ │ ├── XQ0016 社保转移告知书制作与下发/ # *已由 XQ0015 覆盖*
│ │ ├── XQ0017 入职人事手续办理/ # *仅说明文档,未实现*
│ │ ├── XQ0018 调动人事手续跟进/ # *仅说明文档,未实现*
│ │ ├── XQ0019 离职人事手续跟进与检查/ # *仅说明文档,未实现*
│ │ ├── XQ0020 EHR系统离职电子签流程审核/
│ │ ├── XQ0031 物料收发汇总表导出/
│ │ └── XQ0032 ERP采购订单列表导出/
│ └── README.md # 影刀版开发指南
├── app/ # *已弃用归档,不再维护*(早期模块化蓝图,仅留作参考)
├── tests/ # 测试与试验脚本(xq0002_雇主险/ 冒烟与原型;_app_蓝图版归档/ 弃用蓝图时代的测试;汇总社保申报.py 独立工具)
├── docs/
│ ├── README.md # 文档总索引
│ ├── 需求单/ # 各 XQ 四件套(按号段分桶 XQ0001-0100/)+ 需求单索引 + 评分规则 + 实现形态登记表
│ ├── 插件/ # 插件开发规范 / 插件UI开发规范 / 发版规范
│ ├── 架构/ # 架构蓝图 / 插件管理系统设计 / 迭代规划 / 重构方案
│ ├── 部署/ # 控制面前后端部署 SOP
│ └── 桌面端/ # Node 版客户端开发交接 / 桌面端发版 SOP / 平台账号本地加密存储等
├── AGENTS.md # AI 智能体开发约束 & 项目执行规范
└── requirements.txt
```
## 核心功能
| 模块 | 说明 |
| ------- | ------------------------------------------- |
| 自动登录/会话 | OA(SSO)、HR 平台、社保系统登录,cookie 缓存,过期自动重登 |
| 审批流程引擎 | 待办获取、表单解析、规则校验、结果提交、报告生成 |
| 请假/加班审批 | 多类型(事假/病假/产假/年度福利假/加班类型等)分支校验,含附件 OCR |
| 离职电子签审核 | 离职电子签流程自动审批 |
| 考勤异常处理 | 周/月考勤异常核对,三查复核,钉钉推送 |
| 考勤月报封存检查 | 月报封存状态、加班补偿、休班核对等多维检查与封存数据导出 |
| 排班异常识别 | 调动/预入职台账导出 + 部门排班集合比对判定,序列/离职过滤,按店长分组钉钉单聊推送 |
| 工资卡核对 | 身份证/姓名/银行卡号格式与一致性校验 |
| 社保类 | 增减名单梳理、导入名单生成、社保系统增减员办理与回盘核对、参保异常处理 |
| 社保告知书 | 按模板生成 Word/PDF 告知书并合并下发 |
| 雇主险 | 名额调度、增减操作、变更名单导出 |
| 数据导出类插件 | 物料收发汇总、ERP 采购订单列表、通联交易数据导出(按商户分组拆分) |
| 重试/日志 | 项目级最大 3 次重试;INFO 屏蔽大体积 JSON 调试日志,DEBUG 全量输出 |
## 技术依赖
* `DrissionPage`:浏览器自动化
* `pandas` / `openpyxl`:Excel 读写
* `rapidocr`(3.x)/ `opencv-python`(numpy 2.x):OCR 附件识别
* `python-docx` / WPS COM:Word/PDF 生成
* `python-dotenv`、`chinese_calendar` 等
* `Electron` + `Node.js`:执行机桌面壳(当前宿主),插件以 Python 子进程运行
> 运行一律使用项目本地虚拟环境 `d:\work\code\37duAutomation\.venv`(`.venv\Scripts\python.exe`)。
## 使用方法
```bash
# 进入虚拟环境
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
# 中心机控制面 / 内网文件服务器(cwd = desktop/,用项目根 .venv)
python -m controlplane.app
python -m fileserver.main
# 执行机桌面壳开发态(desktop/electron-shell/ 下)
npm run dev
# 影刀版脚本(单文件自包含,直接运行,按号段分桶存放):
# 排班异常识别(第二步导出 + 第三步识别)
python "workflows/XQ0001-0100/XQ0001 排班异常识别/transfer_roster_export.py"
python "workflows/XQ0001-0100/XQ0001 排班异常识别/pre_entry_roster_export.py"
python "workflows/XQ0001-0100/XQ0001 排班异常识别/shift_abnormal_check.py"
# 雇主险增减操作(名额调度、增减员导入)
python "workflows/XQ0001-0100/XQ0002 雇主险增减操作/roster_filter.py"
python "workflows/XQ0001-0100/XQ0002 雇主险增减操作/employer_insurance_schedule.py"
python "workflows/XQ0001-0100/XQ0002 雇主险增减操作/add_sub_import.py"
# OA 审批流程审核(请假 / 加班 / 离职电子签)
python "workflows/XQ0001-0100/XQ0003 EHR系统请假流程审核/leave_approval.py"
python "workflows/XQ0001-0100/XQ0004 EHR系统加班流程审核/overtime_approval.py"
python "workflows/XQ0001-0100/XQ0020 EHR系统离职电子签流程审核/resign_e_sign_approval.py"
# 考勤异常处理(周 / 月)
python "workflows/XQ0001-0100/XQ0006 EHR系统周考勤异常处理/attendance_abnormal.py"
python "workflows/XQ0001-0100/XQ0010 EHR系统月考勤异常处理/attendance_abnormal_monthly.py"
# 社保增减名单梳理 / 增减员导入名单 / 社保系统增减员办理 / 告知书制作与下发
python "workflows/XQ0001-0100/XQ0007 OA系统社保增减名单梳理/social_change.py"
python "workflows/XQ0001-0100/XQ0008 重庆社保增减员导入名单制作/generate_add.py"
python "workflows/XQ0001-0100/XQ0014 社保系统增减员办理/import_add.py"
python "workflows/XQ0001-0100/XQ0015 参保成功及异常告知书制作与下发/notice_mail_merge.py"
# 先运行登录指令写入共享登录态,再执行业务脚本
python workflows/share/oa_login.py
python workflows/share/hr_login.py
python workflows/share/roster_export.py
```
## 文档体系
* 每个需求单在 `docs/需求单/XQ0001-0100/XQ00xx 名称/` 下维护 需求文档 / 流程文档 / 开发文档 / 评分文档 四件套(需求单目录按号段分桶,每 100 号一桶);
* RPA 场景分级依据 `docs/需求单/评分规则.md`(系统对接数 / 业务分支数 / 智能识别场景数 / 异常类型数,四档定级);
* 已落地场景的评分文档为初稿,需经业务方签字 + 网络信息部审批 + 人资备案。
## 注意事项
1. 确保已安装 Chrome/Edge;
2. 首次运行需手动登录一次并缓存会话/cookie(或先运行 `workflows/share/` 下的 `oa_login.py` / `hr_login.py` 写入共享登录态);
3. OA/HR 需在登录态有效期内运行,脚本会自动重登或提示重新登录;
4. 影刀版本为单文件自包含,直接导入影刀平台运行;业务脚本不 import 共享指令模块,仅读 cookies 文件、写全局变量,消息生成与发送解耦(详见 `workflows/README.md`)。
> **桌面端与影刀版**:桌面端 = 中心机 `desktop/controlplane/` + 执行机壳 `desktop/electron-shell/`(当前宿主)+ 内网文件服务 `desktop/fileserver/`,各方向互不 import、独立演进、可单独拷贝;`desktop/webhost/` 为老版执行机底座,已废弃不再维护。插件源码统一放根级 `plugins/`(按号段分桶),打包产物在 `dist-plugin/`,经 agent CLI 发布到中心机后由执行机按账号权限自下载。开发流程为「桌面端测试通过 → 影刀版(`workflows/`,单文件自包含)落地部署」;`app/` 为早期模块化蓝图,已**弃用归档、不再维护**,仅留作参考。
+367
View File
@@ -0,0 +1,367 @@
{
"code": "10000",
"msg": null,
"subCode": "200",
"subMsg": "",
"data": {
"bws071": null,
"bws072": null,
"aab003": null,
"aab001": "20445751",
"aab004": null,
"aaa121": "Z1002",
"aac002": "510222197804160909",
"aac003": "孙智慧",
"aac005": null,
"aac007": null,
"aab120": null,
"aab121": null,
"aab122": null,
"aac020": null,
"aca111": null,
"aac060": null,
"aac009": null,
"aae005": null,
"aac011": null,
"aai030": null,
"aaj030": null,
"aak030": null,
"aal030": null,
"aam034": null,
"aai031": null,
"aae013": null,
"aab020": null,
"aac014": null,
"aac001": "2061656779",
"aad030": "2026/6/29",
"aad013": "在职人员主动解除劳动合同",
"abi030": null,
"abj030": null,
"abk030": null,
"abl030": null,
"abm030": null,
"abi031": null,
"abj040": "3 劳动者自愿辞职",
"aae201": null,
"aab084": null,
"aab085": null,
"aab086": null,
"aae202": null,
"aae500": null,
"aae501": null,
"aae036": null,
"aae100": null,
"itmes": [
{
"bws071": null,
"bws072": null,
"aab003": null,
"aab001": null,
"aab004": null,
"aaa121": null,
"aac002": null,
"aac003": null,
"aac005": null,
"aac007": null,
"aab120": null,
"aab121": null,
"aab122": null,
"aac020": null,
"aca111": null,
"aac060": null,
"aac009": null,
"aae005": null,
"aac011": null,
"aai030": null,
"aaj030": null,
"aak030": null,
"aal030": null,
"aam034": null,
"aai031": null,
"aae013": null,
"aab020": null,
"aac014": null,
"aac001": "2061656779",
"aad030": "2026/6/29",
"aad013": null,
"abi030": null,
"abj030": null,
"abk030": null,
"abl030": null,
"abm030": null,
"abi031": null,
"abj040": null,
"aae201": null,
"aab084": null,
"aab085": null,
"aab086": null,
"aae202": null,
"aae500": null,
"aae501": null,
"aae036": null,
"aae100": null,
"itmes": null,
"xh": "1",
"sxjg": null,
"aae140": "养老保险",
"aae035": null,
"asl001": null,
"aac004": null,
"aac091": null,
"aae038": null,
"aae040": null,
"aae041": null
},
{
"bws071": null,
"bws072": null,
"aab003": null,
"aab001": null,
"aab004": null,
"aaa121": null,
"aac002": null,
"aac003": null,
"aac005": null,
"aac007": null,
"aab120": null,
"aab121": null,
"aab122": null,
"aac020": null,
"aca111": null,
"aac060": null,
"aac009": null,
"aae005": null,
"aac011": null,
"aai030": null,
"aaj030": null,
"aak030": null,
"aal030": null,
"aam034": null,
"aai031": null,
"aae013": null,
"aab020": null,
"aac014": null,
"aac001": "2061656779",
"aad030": "2026/6/29",
"aad013": null,
"abi030": null,
"abj030": null,
"abk030": null,
"abl030": null,
"abm030": null,
"abi031": null,
"abj040": null,
"aae201": null,
"aab084": null,
"aab085": null,
"aab086": null,
"aae202": null,
"aae500": null,
"aae501": null,
"aae036": null,
"aae100": null,
"itmes": null,
"xh": "2",
"sxjg": null,
"aae140": "失业保险",
"aae035": null,
"asl001": null,
"aac004": null,
"aac091": null,
"aae038": null,
"aae040": null,
"aae041": null
},
{
"bws071": null,
"bws072": null,
"aab003": null,
"aab001": null,
"aab004": null,
"aaa121": null,
"aac002": null,
"aac003": null,
"aac005": null,
"aac007": null,
"aab120": null,
"aab121": null,
"aab122": null,
"aac020": null,
"aca111": null,
"aac060": null,
"aac009": null,
"aae005": null,
"aac011": null,
"aai030": null,
"aaj030": null,
"aak030": null,
"aal030": null,
"aam034": null,
"aai031": null,
"aae013": null,
"aab020": null,
"aac014": null,
"aac001": "2061656779",
"aad030": "2026/6/29",
"aad013": null,
"abi030": null,
"abj030": null,
"abk030": null,
"abl030": null,
"abm030": null,
"abi031": null,
"abj040": null,
"aae201": null,
"aab084": null,
"aab085": null,
"aab086": null,
"aae202": null,
"aae500": null,
"aae501": null,
"aae036": null,
"aae100": null,
"itmes": null,
"xh": "3",
"sxjg": null,
"aae140": "医疗保险",
"aae035": null,
"asl001": null,
"aac004": null,
"aac091": null,
"aae038": null,
"aae040": null,
"aae041": null
},
{
"bws071": null,
"bws072": null,
"aab003": null,
"aab001": null,
"aab004": null,
"aaa121": null,
"aac002": null,
"aac003": null,
"aac005": null,
"aac007": null,
"aab120": null,
"aab121": null,
"aab122": null,
"aac020": null,
"aca111": null,
"aac060": null,
"aac009": null,
"aae005": null,
"aac011": null,
"aai030": null,
"aaj030": null,
"aak030": null,
"aal030": null,
"aam034": null,
"aai031": null,
"aae013": null,
"aab020": null,
"aac014": null,
"aac001": "2061656779",
"aad030": "2026/6/29",
"aad013": null,
"abi030": null,
"abj030": null,
"abk030": null,
"abl030": null,
"abm030": null,
"abi031": null,
"abj040": null,
"aae201": null,
"aab084": null,
"aab085": null,
"aab086": null,
"aae202": null,
"aae500": null,
"aae501": null,
"aae036": null,
"aae100": null,
"itmes": null,
"xh": "4",
"sxjg": null,
"aae140": "工伤保险",
"aae035": null,
"asl001": null,
"aac004": null,
"aac091": null,
"aae038": null,
"aae040": null,
"aae041": null
},
{
"bws071": null,
"bws072": null,
"aab003": null,
"aab001": null,
"aab004": null,
"aaa121": null,
"aac002": null,
"aac003": null,
"aac005": null,
"aac007": null,
"aab120": null,
"aab121": null,
"aab122": null,
"aac020": null,
"aca111": null,
"aac060": null,
"aac009": null,
"aae005": null,
"aac011": null,
"aai030": null,
"aaj030": null,
"aak030": null,
"aal030": null,
"aam034": null,
"aai031": null,
"aae013": null,
"aab020": null,
"aac014": null,
"aac001": "2061656779",
"aad030": "2026/6/29",
"aad013": null,
"abi030": null,
"abj030": null,
"abk030": null,
"abl030": null,
"abm030": null,
"abi031": null,
"abj040": null,
"aae201": null,
"aab084": null,
"aab085": null,
"aab086": null,
"aae202": null,
"aae500": null,
"aae501": null,
"aae036": null,
"aae100": null,
"itmes": null,
"xh": "5",
"sxjg": null,
"aae140": "生育保险",
"aae035": null,
"asl001": null,
"aac004": null,
"aac091": null,
"aae038": null,
"aae040": null,
"aae041": null
}
],
"xh": null,
"sxjg": null,
"aae140": null,
"aae035": null,
"asl001": "10047223466559",
"aac004": null,
"aac091": null,
"aae038": null,
"aae040": null,
"aae041": null
}
}
+11 -47
View File
@@ -1,47 +1,11 @@
一、延时加班 已完成
(一)驳回门槛(任一不满足直接驳回)
1. 日期匹配规则:加班开始时间所属日期 = 加班申请日期。当日开始、次日结束的跨天加班,按开始时间判定日期,视为符合要求。 - 销办经验已固化为 step7_oa_todo_reconcile.py ,DRY_RUN 试算通过(37 条待办中改签 7 条,全部判为活跃保留,零误销)。
2. 时长达标规则:以「申请结束时间 - 申请开始时间」计算申请加班总时长,统一执行以下计时标准: - 链路:OA fdId → view 页 unquote 取 fkId →`WeTask.mc?method=query&task_id=` →`getWeProcess` 。
◦ 不足1小时的,直接驳回; - 判据:任务/流程`COMPLETED` 才销,`WAITING/ACCEPTED` 保留,无映射跳过;只销`participantName=人资专用号` 的待办,他人待办单列不处理。
◦ 满1小时及以上的,超出1小时的部分按0.5小时为单位向下取整累加,不足0.5小时的部分不计入有效时长。 - 今日 step1/step2 已跑完:名单`202610 每日推送调动改签名单1022.xlsx` ,陈泽涛(37037922)双标志已置 1。
◦ 跨天延时加班的总时长统一套用上述取整规则,不按日期分段计算。 待办(新会话可直接说)
3. 区间合规校验:申请开始时间 ≥ 当日规定下班时间,且申请结束时间 ≤ 当日实际下班打卡时间;超出该区间的申请直接驳回。
(二)弹性到岗兑换规则(仅影响结算时长,不影响审批通过与否) 1. 整点后确认陈泽涛的「改签离职电子签」流程已生成,取`processId` 与「完善信息(操作人)」任务。
员工可使用当日加班时长等额兑换次日晚到时长,兑换额度、校验规则如下: 2. 浏览器 HR 登录态注入仍是卡点(`document.cookie` 拼接后访问`index.jsp` 返回 500 会话过期),需要解决后才能打开 goToWorkFlow 链接手动填写 + 后台抓包,验证人工提交时 HR 是否主动撤回其他 10 人的 OA 待办。
1. 弹性额度D计算规则 3. 3 个历史遗留工号(高小青 37031379、王娜娜 37033731、邹婷 37036164)标志为 0,是否从`待办工号列表.json` 清理未定。
◦ 计算基准:以当日实际下班打卡时间为准,与申请结束时间无关。
◦ 触发条件:实际下班打卡时间 < 23:00 时,弹性额度 D=0,不可兑换次日晚到。
◦ 额度计算公式:实际下班打卡时间 ≥ 23:00 时,基础兑换额度1小时;超出23:00的部分,按0.5小时为单位向下取整,每满0.5小时累加0.5小时额度。
公式:D = 1 + FLOOR( (实际下班打卡时间 - 23:00) / 0.5小时 ) × 0.5小时
2. 次日场景分支校验
对申请日的次日进行判断,符合以下任一情形的,不触发弹性兑换校验,仅校验当日申请与打卡、请假数据匹配(次日为休息且存在加班申请的,同步核实上班打卡记录):
① 次日排班为“休息”或无排班;
② 次日排班数据获取失败;
③ 次日有请假时段覆盖09:00(任意假期类型)。
不属于以上情形的正常工作日,按次日实际打卡时间P进行校验:
① 无次日打卡记录:不触发弹性兑换校验,仅校验当日数据;
② P ≤ 09:00:无晚到,无需兑换,直接通过;
③ 09:00 < P ≤ 09:00+D:实际晚到时长 = P - 09:00,不足1小时按1小时计算;
校验规则:申请加班时长 + 实际晚到时长 ≤ 申请加班时间至实际打卡的总自然时长,不符合则驳回;
④ P > 09:00+D:可兑换的晚到时长最高按D计算,超出D的晚到部分按考勤迟到规则处理,不影响本次加班审批;
校验规则:申请加班时长 + D ≤ 申请加班时间至实际打卡的总自然时长,不符合则驳回。
---
二、休息日加班
(一)适用范围
1. 周末休息日加班;
2. 除春节外的其余法定节假日加班,统一按本规则执行。
(二)审批条件(全部满足则通过,任一不满足即驳回)
1. 申请有效:申请加班时长 > 0;
2. 打卡完整:申请对应时段内有完整的上班打卡、下班打卡记录;跨次日0点的连续加班,下班打卡可在次日,只要时段连续、覆盖申请时段,即视为打卡完整;
3. 排班匹配:申请当日排班显示为休息;
4. 时长达标:上下班打卡的自然时间间隔(含午休、用餐等自然时长)满足申报档位要求:
◦ 申报0.5天:打卡间隔 ≥ 4小时
◦ 申报1天:打卡间隔 ≥ 9小时
◦ 申报1.5天:打卡间隔 ≥ 13小时
◦ 申报2天:打卡间隔 ≥ 18小时
以此类推,每增加0.5天,对应时长要求增加4小时。
---
三、法定假日加班(仅春节法定节假日适用)
1. 基础审批规则与休息日加班完全一致;
2. 额外校验:申请日期必须为春节法定节假日;春节假期内的调休休息日,不适用本规则,按休息日加班规则执行。
---
-9
View File
@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: app
@FileName: __init__.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:00
@Description: 应用主包
@Version: 1.0.0
"""
-9
View File
@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp
@FileName: __init__.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:00
@Description: HRBP 审批服务包:oa(OA 系统公共模块)+ flows(业务流程:请假/加班等)
@Version: 1.0.0
"""
-9
View File
@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa
@FileName: __init__.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:00
@Description: OA 系统模块:包含 common(公共组件)、leave(请假流程)、work_overtime(加班流程)
@Version: 1.0.0
"""
-9
View File
@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa
@FileName: __init__.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:00
@Description: OA 系统公共模块:登录、会话管理、接口调用、解析
@Version: 1.0.0
"""
-182
View File
@@ -1,182 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.approval_flow
@FileName: approval_flow.py
@Author: 小布丁
@CreateTime: 2026-08-05 23:52
@Description: 公共审批引擎:登录(复用登录态)→ 查待办 → 解析 SSO → 获取表单 → 校验 → 生成报告
加班/请假共用,业务差异通过 subject + validate_doc + generate_report 注入
@Version: 1.2.0
"""
import os
import sys
from typing import Any, Callable, Dict, List
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger, setup_logging
from utils.intelligent_retry import retry
try:
from .login import oa_login
from .session_manager import (
init_session_from_page,
refresh_session_cookies,
load_saved_session,
save_browser_cookies,
create_browser_with_saved_cookies,
is_session_valid,
)
from .oa_api import (
get_documents,
get_wf_activity_by_task_id,
extract_form_id,
get_business_data,
)
from .sso import resolve_sso_params
except ImportError:
from login import oa_login
from session_manager import (
init_session_from_page,
refresh_session_cookies,
load_saved_session,
save_browser_cookies,
create_browser_with_saved_cookies,
is_session_valid,
)
from oa_api import (
get_documents,
get_wf_activity_by_task_id,
extract_form_id,
get_business_data,
)
from sso import resolve_sso_params
logger = get_logger(__name__)
@retry(max_attempts=3)
def _login():
"""完整登录 OA(失败自动重试,最多 3 次)"""
return oa_login()
def _get_browser_and_session(subject: str):
"""
获取浏览器和会话:优先复用已保存的登录 cookies,无效或不存在时才完整登录。
Returns:
(browser, session, is_fresh_login)
"""
saved_session = load_saved_session()
if saved_session is not None and is_session_valid(saved_session, subject):
logger.info("复用已保存的登录会话,跳过登录")
browser = create_browser_with_saved_cookies()
return browser, saved_session, False
browser = _login()
session = init_session_from_page(browser)
save_browser_cookies(browser)
return browser, session, True
@retry(max_attempts=3)
def _fetch_documents(session, subject: str) -> List[Dict[str, Any]]:
"""按主题拉取待办单据(失败自动重试,最多 3 次)"""
return get_documents(session, subject=subject)
@retry(max_attempts=3)
def _fetch_doc_detail(browser, session, doc: Dict[str, Any]) -> Dict[str, Any]:
"""
解析单据详情:SSO 取 taskId/businessKey → WfActivity 取 formId → WorkformEngine 取表单数据。
Args:
browser: 已登录的 ChromiumPage 对象(用于执行 SSO 的 JS 跳转)
session: 已登录的 SessionPage 对象(用于后台 API 请求)
doc: 单据信息(包含 detail_url)
Returns:
单据信息 + taskId/businessKey/formId/formData
"""
detail_url = doc.get("detail_url", "")
if not detail_url:
raise RuntimeError(f"单据无详情链接: {doc.get('title')}")
# Step 1: 浏览器打开 SSO 链接,从重定向后的 URL 提取 taskId 和 businessKey
sso_params = resolve_sso_params(browser, detail_url)
task_id = sso_params["taskId"]
business_key = sso_params["businessKey"]
logger.info("SSO 解析完成: taskId=%s, businessKey=%s", task_id, business_key)
# SSO 的 linkLogin 在 hr 域产生了新的会话 cookie,先同步回 SessionPage
refresh_session_cookies(session, browser)
# Step 2: 通过 taskId 获取 formId
wf_activity_data = get_wf_activity_by_task_id(session, task_id)
form_id = extract_form_id(wf_activity_data)
# Step 3: 通过 businessKey + formId 获取表单数据
form_data = get_business_data(session, business_key, form_id)
return {
**doc,
"taskId": task_id,
"businessKey": business_key,
"formId": form_id,
"formData": form_data,
}
def run_flow(
subject: str,
validate_doc: Callable[[Dict[str, Any], Any], Dict[str, Any]],
generate_report: Callable[[List[Dict[str, Any]]], str],
) -> str:
"""
公共审批流程:登录(优先复用已保存会话)→ 查待办 → 逐单解析详情并校验 → 生成报告。
Args:
subject: 待办标题关键字,如 "加班" / "请假"
validate_doc: 单张单据的校验函数,签名为 (doc, session) -> result
generate_report: 校验结果报告生成函数
Returns:
报告文本
"""
setup_logging()
logger.info("%s审批流程开始", subject)
browser, session, _ = _get_browser_and_session(subject)
docs = _fetch_documents(session, subject)
logger.info("共获取%s待办 %d 条", subject, len(docs))
results = []
for doc in docs:
try:
doc_detail = _fetch_doc_detail(browser, session, doc)
result = validate_doc(doc_detail, session)
results.append(result)
logger.info(
"已校验: %s - %s -> %s",
result["creator"], result["title"], result["decision"],
)
except Exception as e:
logger.error("处理单据失败: %s, 错误: %s", doc.get("title"), str(e))
results.append({
"creator": doc.get("creator", "未知"),
"title": doc.get("title", "未知"),
"decision": "失败",
"error": str(e),
})
report = generate_report(results)
print("\n" + report)
# 保存最新 cookies(SSO 已刷新 hr 域会话,供下次运行免登录复用)
save_browser_cookies(browser)
logger.info("%s审批流程结束,共处理 %d 条", subject, len(results))
return report
-46
View File
@@ -1,46 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.config
@FileName: config.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:09
@Description: OA 系统配置,集中管理接口地址、待办类型、分页大小等常量
@Version: 1.2.0
"""
# ---------- OA 系统 ----------
# 待办列表等后台接口在 oa 域名;流程引擎/表单/考勤等 RedseaPlatform 接口在 hr 域名
BASE_URL = "https://oa.37du.co"
HR_BASE_URL = "https://hr.37du.co"
# 待办列表接口(oa 域名):按标题关键字查询当前账号的待办单据,用于抓取请假/加班等待审批流程
TODO_LIST_URL = f"{BASE_URL}/sys/notify/sys_notify_todo/sysNotifyMainIndex.do"
# 待办类型编码:"13" 对应需人工处理的审批类待办
FD_TYPE = "13"
# OA 流程接口(hr 域名)
# 通过 taskId 获取流程表单 ID(formId),用于后续拉取表单详情
WF_ACTIVITY_URL = f"{HR_BASE_URL}/RedseaPlatform/WfActivity.mc"
# 表单引擎接口:通过 businessKey + formId 获取审批单的表单数据(如加班日期、申请人等)
WORKFORM_ENGINE_URL = f"{HR_BASE_URL}/RedseaPlatform/WorkformEngine.mc"
# 排班接口(hr 域名,按员工 + 年月查询当月排班)
PAIBAN_URL = f"{HR_BASE_URL}/RedseaPlatform/KqCount.mc"
# 考勤打卡明细接口(hr 域名,按员工 + 日期范围查询原始打卡记录)
KQ_DATA_URL = f"{HR_BASE_URL}/RedseaPlatform/redmagicapi/rf_s_kq_data_queryByStaffId_all/getExecuteResult.mc"
# 请假记录接口(hr 域名,按员工 + 日期范围查询请假明细)
LEAVE_RECORD_URL = f"{HR_BASE_URL}/RedseaPlatform/redmagicapi/rf_s_kq_leave_record_SelectByStaffID/redApiExec.mc"
# ---------- 加班审批规则常量(对应 aa.md 审批规则) ----------
# 次日正常上班时间 T(固定 09:00)
WORK_START_TIME = "09:00"
# 当日规定下班时间(固定 18:00,用于区间合规校验)
WORK_END_TIME = "18:00"
# 弹性额度触发阈值:实际下班打卡时间 >= 该时刻才计算弹性额度 D
FLEX_TRIGGER_TIME = "23:00"
# 延时加班有效时长门槛:不足该小时数直接驳回
OT_MIN_HOURS = 1
# ---------- 分页 ----------
DEFAULT_PAGE_SIZE = 15
-130
View File
@@ -1,130 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.login
@FileName: login.py
@Author: 小布丁
@CreateTime: 2026-08-04 17:34
@Description: 自动登录 OA 系统
@Version: 1.1.0
"""
import os
import sys
import time
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger
try:
from DrissionPage import ChromiumPage
except ImportError:
ChromiumPage = None
try:
from dotenv import load_dotenv
except ImportError:
load_dotenv = lambda *args, **kwargs: None
logger = get_logger(__name__)
def oa_login(
username: str = None,
password: str = None,
timeout: float = 10,
wait_after_load: float = 2,
) -> ChromiumPage:
"""
自动登录 OA 系统,返回已登录的 ChromiumPage 对象。
参数:
username: 登录用户名,若不提供则从环境变量 oa_login_username 读取
password: 登录密码,若不提供则从环境变量 oa_login_password 读取
timeout: URL 跳转等待超时(秒,默认 10)
wait_after_load: 页面加载后的额外等待时间(秒,默认 2)
返回:
登录成功后的 ChromiumPage 对象
异常:
若登录失败或关键元素未找到,抛出 RuntimeError
"""
# 加载 .env 环境变量(默认读取当前工作目录下的 .env)
load_dotenv()
# 获取配置,参数优先于环境变量
login_url = os.getenv('oa_login_url')
if not login_url:
raise RuntimeError("环境变量 oa_login_url 未设置")
target_url_keyword = os.getenv('oa_target_url_keyword')
if not target_url_keyword:
raise RuntimeError("环境变量 oa_target_url_keyword 未设置")
final_username = username or os.getenv('oa_login_username')
final_password = password or os.getenv('oa_login_password')
if not final_username or not final_password:
raise RuntimeError("用户名或密码未提供,请设置环境变量或传入参数")
# 创建浏览器页面对象
page = ChromiumPage()
# page.set.window.max()
try:
# 访问登录页面
page.get(login_url)
time.sleep(wait_after_load) # 等待页面初步加载
# 定位并填写用户名
username_input = page.ele('tag:input@name=j_username')
if not username_input:
raise RuntimeError("未找到用户名输入框")
username_input.input(final_username)
page.wait(0.5)
# 定位并填写密码
password_input = page.ele('tag:input@name=j_password')
if not password_input:
raise RuntimeError("未找到密码输入框")
password_input.input(final_password)
page.wait(0.5)
# 定位并点击登录按钮
login_button = page.ele('.lui_login_button_div_c')
if not login_button:
raise RuntimeError("未找到登录按钮")
login_button.click()
page.wait(0.5)
# ---------- 轮询检测 URL ----------
start = time.time()
while time.time() - start < timeout: # timeout 默认 10 秒
if target_url_keyword in page.url:
logger.info("登录成功!当前 URL: %s", page.url)
return page
time.sleep(0.5)
# 超时处理
error_elem = page.ele('.error-msg') or page.ele('.alert-danger')
if error_elem:
logger.warning("登录失败,提示: %s", error_elem.text)
raise RuntimeError(f"登录超时,当前 URL: {page.url}")
except Exception as e:
# 若发生异常,可选择关闭浏览器并重新抛出
page.quit()
raise RuntimeError(f"登录过程出错: {e}")
# ---------- 使用示例 ----------
if __name__ == "__main__":
from utils.logger import setup_logging
setup_logging()
try:
page = oa_login()
except RuntimeError as e:
logger.error(e)
-532
View File
@@ -1,532 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.oa_api
@FileName: oa_api.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:10
@Description: OA/HR 系统 API 模块,负责调用系统接口(待办列表、流程引擎、表单、排班等)
@Version: 1.3.1
"""
import os
import sys
import time
import re
from typing import List, Dict, Any
from urllib.parse import urlencode
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger
try:
from DrissionPage import SessionPage
except ImportError:
SessionPage = None
try:
from .config import BASE_URL, HR_BASE_URL, TODO_LIST_URL, DEFAULT_PAGE_SIZE, FD_TYPE, WF_ACTIVITY_URL, WORKFORM_ENGINE_URL, KQ_DATA_URL, LEAVE_RECORD_URL, PAIBAN_URL
except ImportError:
from config import BASE_URL, HR_BASE_URL, TODO_LIST_URL, DEFAULT_PAGE_SIZE, FD_TYPE, WF_ACTIVITY_URL, WORKFORM_ENGINE_URL, KQ_DATA_URL, LEAVE_RECORD_URL, PAIBAN_URL
logger = get_logger(__name__)
# ---------- 获取待处理单据列表 ----------
def fetch_todo_page(
session: SessionPage,
subject: str,
page_no: int = 1,
page_size: int = DEFAULT_PAGE_SIZE
) -> Dict[str, Any]:
"""
请求单页待办列表数据。
Args:
session: 已登录的 SessionPage 对象
subject: 待办标题关键字,如 "请假" / "加班"
page_no: 页码(从1开始)
page_size: 每页条数
Returns:
接口返回的 JSON 字典
Raises:
RuntimeError: 请求失败或状态码异常
"""
params = {
"method": "list",
"dataType": "todo",
"fdType": FD_TYPE, # 待办类型(请假/加班)
"fdCateId": "",
"q.fdSubject": subject, # 按标题关键字过滤(请假/加班)
"orderby": "fdCreateTime",
"ordertype": "down",
"page.pageNo": page_no,
"page.pageSize": page_size,
"__seq": int(time.time() * 1000), # 防缓存
}
url = f"{TODO_LIST_URL}?{urlencode(params)}"
logger.debug("请求第 %d 页: %s", page_no, url)
session.get(url)
resp = session.response
if not resp:
raise RuntimeError("请求失败,未获取到响应")
if resp.status_code != 200:
raise RuntimeError(f"接口请求失败,状态码: {resp.status_code}")
try:
return resp.json()
except Exception:
raise RuntimeError("接口返回非 JSON 数据,请检查参数或登录状态")
def parse_todo_list(data: Dict[str, Any]) -> List[Dict[str, Any]]:
"""
解析接口返回的 JSON,提取每张单据的关键信息。
Args:
data: 接口返回的 JSON
Returns:
单据列表,每项包含:
- title: 标题(去除 HTML 标签)
- creator: 发起人
- time: 接收时间(字符串)
- detail_url: SSO 跳转链接(完整 URL)
"""
datas = data.get("datas", [])
if not datas:
return []
docs = []
for row in datas:
# 1. 标题
title_cell = next((c for c in row if c["col"] == "todo.subject4View"), {})
title_raw = title_cell.get("value", "")
# 移除 <span class="subjecthead"> 标签,仅保留内容
match = re.search(r'<span class="subjecthead"[^>]*>(.*?)</span>', title_raw, re.DOTALL)
title = match.group(1).strip() if match else re.sub(r'<[^>]+>', '', title_raw).strip()
# 2. 发起人
creator_cell = next((c for c in row if c["col"] == "docCreatorName"), {})
creator = creator_cell.get("value", "")
# 3. 接收时间
time_cell = next((c for c in row if c["col"] == "fdCreateTime"), {})
time_str = time_cell.get("value", "")
# 4. SSO 跳转链接(补全为完整 URL)
href_cell = next((c for c in row if c["col"] == "tr_href"), {})
detail_url = href_cell.get("value", "")
if detail_url and not detail_url.startswith(("http://", "https://")):
detail_url = BASE_URL + detail_url
docs.append({
"title": title,
"creator": creator,
"time": time_str,
"detail_url": detail_url,
})
return docs
def get_documents(
session: SessionPage,
subject: str,
page_size: int = DEFAULT_PAGE_SIZE
) -> List[Dict[str, Any]]:
"""
主入口:获取所有待处理单据(自动分页)。
请假与加班流程逻辑一致,仅通过 subject 关键字区分。
Args:
session: 已登录的 SessionPage 对象(已设置 cookies)
subject: 待办标题关键字,如 "请假" / "加班"
page_size: 每页条数(默认15)
Returns:
所有单据的列表
"""
all_docs = []
# 请求第一页,获取总条数
data = fetch_todo_page(session, subject, page_no=1, page_size=page_size)
total = int(data.get("page", {}).get("totalSize", 0))
logger.info("总待办[%s]条数: %d", subject, total)
# 解析第一页
docs = parse_todo_list(data)
all_docs.extend(docs)
logger.info("第 1 页获取 %d 条", len(docs))
# 若总条数超过单页,继续翻页
if total > page_size:
total_pages = (total + page_size - 1) // page_size
for p in range(2, total_pages + 1):
data = fetch_todo_page(session, subject, page_no=p, page_size=page_size)
docs = parse_todo_list(data)
all_docs.extend(docs)
logger.info("第 %d 页获取 %d 条,累计 %d 条", p, len(docs), len(all_docs))
return all_docs
# ---------- WfActivity 接口:通过 taskId 获取 formId ----------
def get_wf_activity_by_task_id(
session: SessionPage,
task_id: str
) -> Dict[str, Any]:
"""
通过 taskId 调用 WfActivity 接口获取 formId。
Args:
session: 已登录的 SessionPage 对象
task_id: SSO 解析得到的 taskId
Returns:
接口返回的 JSON 字典,包含 formId 等信息
Raises:
RuntimeError: 请求失败或响应异常
"""
url = f"{WF_ACTIVITY_URL}?method=getWfActivityByTaskId"
data = {"taskId": task_id}
logger.info("获取 formId: taskId=%s", task_id)
session.post(url, data=data)
resp = session.response
if not resp:
raise RuntimeError("WfActivity 请求失败,未获取到响应")
if resp.status_code != 200:
raise RuntimeError(f"WfActivity 接口状态码异常: {resp.status_code}")
try:
json_data = resp.json()
except Exception:
body = (resp.text or "")[:200]
raise RuntimeError(
f"WfActivity 接口返回非 JSON 数据(状态码 {resp.status_code}): {body}"
)
logger.debug("WfActivity 返回: %s", json_data)
return json_data
def extract_form_id(wf_activity_data: Dict[str, Any]) -> str:
"""
从 WfActivity 接口返回数据中提取 formId。
Args:
wf_activity_data: get_wf_activity_by_task_id 返回的 JSON
Returns:
formId 字符串
Raises:
ValueError: 未找到 formId
"""
# 常见 formId 字段路径:顶层,以及 data / result 子对象
form_id = (
wf_activity_data.get("formId")
or wf_activity_data.get("FormId")
or wf_activity_data.get("form_id")
)
if not form_id:
for key in ("data", "result"):
data_obj = wf_activity_data.get(key, {})
if isinstance(data_obj, dict):
form_id = (
data_obj.get("formId")
or data_obj.get("FormId")
or data_obj.get("form_id")
)
if form_id:
break
if not form_id:
raise ValueError(f"无法从 WfActivity 返回数据中提取 formId: {wf_activity_data}")
logger.info("提取到 formId: %s", form_id)
return form_id
# ---------- WorkformEngine 接口:获取加班申请表单数据 ----------
def get_business_data(
session: SessionPage,
business_key: str,
form_id: str
) -> Dict[str, Any]:
"""
通过 businessKey 和 formId 调用 WorkformEngine 接口获取加班申请表单数据。
Args:
session: 已登录的 SessionPage 对象
business_key: SSO 解析得到的 businessKey
form_id: 从 WfActivity 接口获取的 formId
Returns:
表单详细数据字典(接口响应的 result 字段,如 ot_date/staff_name 等)
Raises:
RuntimeError: 请求失败或响应异常
"""
url = f"{WORKFORM_ENGINE_URL}?method=getBusinessDate"
data = {
"businessKey": business_key,
"formId": form_id,
}
logger.info("获取加班表单: businessKey=%s, formId=%s", business_key, form_id)
session.post(url, data=data)
resp = session.response
if not resp:
raise RuntimeError("WorkformEngine 请求失败,未获取到响应")
if resp.status_code != 200:
raise RuntimeError(f"WorkformEngine 接口状态码异常: {resp.status_code}")
try:
json_data = resp.json()
except Exception:
body = (resp.text or "")[:200]
raise RuntimeError(
f"WorkformEngine 接口返回非 JSON 数据(状态码 {resp.status_code}): {body}"
)
# 表单详情在 result 字段中(如 ot_date / staff_name 等)
result = json_data.get("result")
if json_data.get("state") != "1" or not isinstance(result, dict):
raise RuntimeError(f"WorkformEngine 接口返回失败: {json_data}")
logger.info("WorkformEngine 返回成功")
return result
# ---------- 排班接口 ----------
def get_attendance_html(
session: SessionPage,
staff_id: str,
year: int,
month: int
) -> str:
"""
获取指定员工某月的排班 HTML。
Args:
session: 已登录的 SessionPage 对象
staff_id: 员工 UUID
year: 年份(如 2026)
month: 月份(1-12)
Returns:
排班表格的 HTML 字符串(从返回 JSON 的 caleHtml 字段提取)
Raises:
RuntimeError: 请求失败或响应异常
"""
url = f"{PAIBAN_URL}?method=geRenPaibanByMonth"
data = {
"type": "2",
"staffId": staff_id,
"year": str(year),
"month": str(month)
}
logger.info("获取排班: %s %d-%02d", staff_id, year, month)
session.post(url, data=data)
resp = session.response
if not resp:
raise RuntimeError("排班请求失败,未获取到响应")
if resp.status_code != 200:
raise RuntimeError(f"排班接口状态码异常: {resp.status_code}")
try:
json_data = resp.json()
except Exception:
raise RuntimeError("排班接口返回非 JSON 数据")
if json_data.get("success") != "true":
raise RuntimeError(f"排班接口返回失败: {json_data}")
html = json_data.get("caleHtml")
if not html:
raise RuntimeError("排班接口未返回 caleHtml 字段")
return html
# ---------- 考勤打卡明细接口 ----------
def get_attendance_records(
session: SessionPage,
staff_id: str,
start_date: str,
end_date: str
) -> List[Dict[str, Any]]:
"""
查询员工某时间段的原始打卡明细。
Args:
session: 已登录的 SessionPage 对象
staff_id: 员工 UUID
start_date: 查询起始日期 "YYYY-MM-DD"
end_date: 查询结束日期 "YYYY-MM-DD"
Returns:
打卡记录列表(接口返回的 jsonList,每条含 kq_time / status / time_order 等)
- status: "1"=上班打卡, "5"=下班打卡, "6"=重复打卡
- time_order: "1"=上班时段, "2"=下班时段
Raises:
RuntimeError: 请求失败或响应异常
"""
params = {
"staff_id": staff_id,
"rootId": "",
"countId": "",
"bc_date": start_date,
"bc_date_end": end_date,
"begin": start_date,
"end": end_date,
}
logger.info("获取打卡明细: staff_id=%s, %s 至 %s", staff_id, start_date, end_date)
session.get(KQ_DATA_URL, params=params)
resp = session.response
if not resp:
raise RuntimeError("考勤打卡请求失败,未获取到响应")
if resp.status_code != 200:
raise RuntimeError(f"考勤打卡接口状态码异常: {resp.status_code}")
try:
json_data = resp.json()
except Exception:
body = (resp.text or "")[:200]
raise RuntimeError(f"考勤打卡接口返回非 JSON 数据: {body}")
records = json_data.get("jsonList", [])
logger.info("打卡明细返回 %d 条", len(records))
return records
# ---------- 请假记录接口 ----------
def fetch_leave_record_page(
session: SessionPage,
staff_id: str,
begin_date: str,
end_date: str,
page_no: int = 1,
page_size: int = DEFAULT_PAGE_SIZE,
sub_type: str = "-1"
) -> Dict[str, Any]:
"""
请求单页员工请假记录。
Args:
session: 已登录的 SessionPage 对象
staff_id: 员工 UUID
begin_date: 查询起始日期 "YYYY-MM-DD"
end_date: 查询结束日期 "YYYY-MM-DD"
page_no: 页码(从1开始)
page_size: 每页条数
sub_type: 假期类型编码,默认 "-1" 表示全部
Returns:
接口返回的 data 字段字典,包含 total / pageCount / list
Raises:
RuntimeError: 请求失败或响应异常
"""
data = {
"sub_type": sub_type,
"staff_id": staff_id,
"begin_date": begin_date,
"end_date": end_date,
"start": str((page_no - 1) * page_size),
"pageSize": str(page_size),
"sortType": "",
"sortName": "",
"pageNo": str(page_no),
}
logger.info("获取请假记录: staff_id=%s, %s 至 %s, 第%d页", staff_id, begin_date, end_date, page_no)
session.post(LEAVE_RECORD_URL, data=data)
resp = session.response
if not resp:
raise RuntimeError("请假记录请求失败,未获取到响应")
if resp.status_code != 200:
raise RuntimeError(f"请假记录接口状态码异常: {resp.status_code}")
try:
json_data = resp.json()
except Exception:
body = (resp.text or "")[:200]
raise RuntimeError(f"请假记录接口返回非 JSON 数据: {body}")
if json_data.get("success") is not True or json_data.get("code") != 200:
raise RuntimeError(f"请假记录接口返回失败: {json_data}")
page_info = json_data.get("data")
if not isinstance(page_info, dict):
raise RuntimeError(f"请假记录接口未返回 data 字段: {json_data}")
return page_info
def get_leave_records(
session: SessionPage,
staff_id: str,
begin_date: str,
end_date: str,
page_size: int = DEFAULT_PAGE_SIZE,
sub_type: str = "-1"
) -> List[Dict[str, Any]]:
"""
查询员工某时间段内的全部请假记录(自动分页)。
Args:
session: 已登录的 SessionPage 对象
staff_id: 员工 UUID
begin_date: 查询起始日期 "YYYY-MM-DD"
end_date: 查询结束日期 "YYYY-MM-DD"
page_size: 每页条数
sub_type: 假期类型编码,默认 "-1" 表示全部
Returns:
请假记录列表,每条包含:
- staff_id: 员工ID
- staff_name: 员工姓名
- leave_businessKey: 审批单号
- sub_type: 假期类型编码
- vacation_type_name: 假期名称
- leave_reason: 请假原因
- leave_days: 请假天数
- leave_hours: 请假小时
- start_time: 开始时间
- end_time: 结束时间
Raises:
RuntimeError: 请求失败或响应异常
"""
all_records: List[Dict[str, Any]] = []
# 请求第一页,获取总条数与总页数
page_info = fetch_leave_record_page(
session, staff_id, begin_date, end_date,
page_no=1, page_size=page_size, sub_type=sub_type
)
total = int(page_info.get("total", 0))
page_total = int(page_info.get("pageCount", 1))
records = page_info.get("list", []) or []
all_records.extend(records)
logger.info("请假记录总数: %d, 第1页获取 %d 条", total, len(records))
# 若存在多页,继续翻页
if page_total > 1:
for p in range(2, page_total + 1):
page_info = fetch_leave_record_page(
session, staff_id, begin_date, end_date,
page_no=p, page_size=page_size, sub_type=sub_type
)
records = page_info.get("list", []) or []
all_records.extend(records)
logger.info("第 %d 页获取 %d 条,累计 %d 条", p, len(records), len(all_records))
return all_records
-167
View File
@@ -1,167 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.parser
@FileName: parser.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:10
@Description: 解析模块(HTML 排班表格解析,供请假校验使用)
@Version: 1.3.0
"""
import os
import sys
import re
from collections import defaultdict
from datetime import datetime
from typing import Any, Dict, List
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger
logger = get_logger(__name__)
# ---------- 排班 HTML 解析 ----------
def parse_attendance_html(html: str) -> Dict[str, str]:
"""
解析排班 HTML 表格,提取每个日期的班次名称。
示例 HTML 片段:
<a class='cale_a' ... data-temp='2026-08-01' ...>正常</a>
或 <a ...>休息</a>
Args:
html: 排班接口返回的 HTML 字符串
Returns:
字典:{日期字符串: 班次名称}
例如:{"2026-08-01": "正常", "2026-08-02": "休息"}
"""
# 正则匹配 <a> 标签中的 data-temp 和文本内容
pattern = r'<a[^>]*data-temp="([^"]+)"[^>]*>([^<]+)</a>'
matches = re.findall(pattern, html)
result = {}
for date, shift in matches:
# 去除可能的空格
date_clean = date.strip()
shift_clean = shift.strip()
result[date_clean] = shift_clean
return result
def get_work_days_in_range(
attendance_dict: Dict[str, str],
start_date: str,
end_date: str
) -> List[str]:
"""
根据排班字典和请假起止日期,返回请假区间内所有非“休息”的日期列表。
Args:
attendance_dict: 由 parse_attendance_html 返回的字典
start_date: 请假开始日期,格式 "YYYY-MM-DD"
end_date: 请假结束日期,格式 "YYYY-MM-DD"
Returns:
非休息日的日期字符串列表(格式 "YYYY-MM-DD")
"""
from datetime import datetime, timedelta
start = datetime.strptime(start_date, "%Y-%m-%d")
end = datetime.strptime(end_date, "%Y-%m-%d")
work_days = []
current = start
while current <= end:
date_str = current.strftime("%Y-%m-%d")
shift = attendance_dict.get(date_str, "")
# 如果该日期没有排班信息,或明确为“休息”,视为休息日
if shift != "休息" and shift != "":
work_days.append(date_str)
current += timedelta(days=1)
return work_days
# ---------- 打卡明细汇总 ----------
def summarize_attendance_records(records: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
"""
按日汇总员工打卡明细:每天取最早打卡和最晚打卡。
实际接口返回的打卡记录 status 多为 "6"、time_order 为 null,
无法据其区分上下班,因此直接按 bc_date 分组后取时间最早和最晚的打卡。
Args:
records: get_attendance_records 返回的原始打卡列表
Returns:
每日汇总列表,每项含:
- staff_id / staff_name / dept_name / post_name / attend_date
- first_check_in: 当日最早打卡时间(字符串,无则 None)
- last_check_out: 当日最晚打卡时间(字符串,仅1条时为 None,含跨天凌晨)
"""
time_format = "%Y-%m-%d %H:%M:%S"
# 按 (staff_id, bc_date) 分组,取每天最早和最晚的打卡
group_map: Dict[tuple, List[Dict[str, Any]]] = defaultdict(list)
for item in records:
staff_id = item.get("staff_id", "")
bc_day = item.get("bc_date", "")
if not staff_id or not bc_day:
continue
try:
kq_dt = datetime.strptime(item["kq_time"], time_format)
except (KeyError, ValueError):
continue
group_map[(staff_id, bc_day)].append({**item, "_dt": kq_dt})
summary: List[Dict[str, Any]] = []
for (sid, day), items in group_map.items():
items.sort(key=lambda x: x["_dt"])
base = items[0]
row = {
"staff_id": sid,
"staff_name": base.get("staff_name", ""),
"dept_name": base.get("DEPT_ORG_NAME", ""),
"post_name": base.get("POST_ALIAS_NAME", ""),
"attend_date": day,
"first_check_in": items[0]["kq_time"],
"last_check_out": items[-1]["kq_time"] if len(items) > 1 else None,
}
summary.append(row)
return summary
# ---------- 使用示例(测试用) ----------
if __name__ == "__main__":
from utils.logger import setup_logging
setup_logging()
# 测试 HTML 解析
sample_html = """
<a class='cale_a' data-temp="2026-08-01">休息</a>
<a class='cale_a' data-temp="2026-08-02">正常</a>
<a class='cale_a' data-temp="2026-08-03">休息</a>
"""
result = parse_attendance_html(sample_html)
logger.info("解析结果: %s", result)
work = get_work_days_in_range(result, "2026-08-01", "2026-08-03")
logger.info("工作日: %s", work)
# 测试打卡汇总
sample_records = [
{"staff_id": "S001", "staff_name": "张三", "bc_date": "2026-08-02",
"kq_time": "2026-08-02 08:50:00", "status": "1", "time_order": "1",
"DEPT_ORG_NAME": "技术部", "POST_ALIAS_NAME": "工程师"},
{"staff_id": "S001", "staff_name": "张三", "bc_date": "2026-08-02",
"kq_time": "2026-08-03 00:30:00", "status": "5", "time_order": "2",
"DEPT_ORG_NAME": "技术部", "POST_ALIAS_NAME": "工程师"},
]
summary = summarize_attendance_records(sample_records)
logger.info("打卡汇总: %s", summary)
@@ -1,157 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.session_manager
@FileName: session_manager.py
@Author: 小布丁
@CreateTime: 2026-08-05 10:30
@Description: 从 ChromiumPage 提取 Cookies,生成 SessionPage 供后台请求;支持 cookies 持久化复用
@Version: 1.3.0
"""
import json
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger
logger = get_logger(__name__)
try:
from DrissionPage import ChromiumPage, SessionPage
except ImportError:
ChromiumPage = None
SessionPage = None
# 登录 cookies 持久化目录:服务层统一管理各平台会话文件,文件名按平台区分
# 如 oa_cookies.json / xxx_cookies.json,便于后续扩展其他平台
_SESSIONS_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '.sessions')
COOKIE_FILE = os.path.join(_SESSIONS_DIR, 'oa_cookies.json')
def init_session_from_page(
browser_page: ChromiumPage,
copy_headers: bool = True
) -> SessionPage:
"""
从已登录的 ChromiumPage 中提取 cookies 和 headers,
创建并返回一个可直接发送后台请求的 SessionPage 对象。
Args:
browser_page: 已登录的 ChromiumPage 实例
copy_headers: 是否复制浏览器的 User-Agent 等头部信息(默认 True)
Returns:
已设置好 cookies 和 headers 的 SessionPage 对象
"""
session = SessionPage()
# 1. 获取浏览器 cookies(全域名:oa 域登录态 + hr 域可能已有的会话)
cookies_dict = browser_page.cookies(all_domains=True)
if cookies_dict:
session.set.cookies(cookies_dict)
logger.info("已复制 %d 个 Cookies 到 SessionPage", len(cookies_dict))
else:
logger.warning("未获取到 Cookies,请确认浏览器已登录")
# 2. 可选复制 headers(主要是 User-Agent,防止被反爬)
if copy_headers:
headers = {
"User-Agent": browser_page.run_js("return navigator.userAgent;")
}
session.set.headers(headers)
logger.info("已复制 User-Agent: %s...", headers['User-Agent'][:50])
# 3. 可额外设置默认超时、重试等
session.set.timeout(10) # 全局超时 10 秒
return session
# 便捷函数:SSO 跳转后同步浏览器 cookies 到 SessionPage
def refresh_session_cookies(session: SessionPage, browser_page: ChromiumPage) -> None:
"""
从浏览器重新同步全域名 cookies 到 SessionPage。
SSO 的 linkLogin 会在 hr 域产生新的会话 cookie,需在浏览器完成 SSO 跳转后调用。
Args:
session: 目标 SessionPage 对象
browser_page: 已登录且已完成 SSO 跳转的 ChromiumPage 实例
"""
cookies = browser_page.cookies(all_domains=True)
if cookies:
session.set.cookies(cookies)
logger.info("已同步 %d 个 Cookies 到 SessionPage(含 SSO 会话)", len(cookies))
else:
logger.warning("未获取到 Cookies,请确认浏览器登录态")
# ---------- Cookies 持久化(复用登录态,免重复登录) ----------
def save_browser_cookies(browser_page: ChromiumPage, path: str = COOKIE_FILE) -> None:
"""把浏览器全域名 cookies 保存到本地文件,下次运行可免登录复用。"""
cookies = browser_page.cookies(all_domains=True)
if not cookies:
logger.warning("未获取到 Cookies,跳过保存")
return
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, 'w', encoding='utf-8') as f:
json.dump(cookies, f, ensure_ascii=False, indent=2)
logger.info("已保存 %d 个 Cookies 到 %s", len(cookies), path)
def load_cookies(path: str = COOKIE_FILE):
"""从本地文件加载 cookies 列表;文件不存在或为空时返回 None。"""
if not os.path.exists(path):
return None
with open(path, encoding='utf-8') as f:
cookies = json.load(f)
return cookies or None
def load_saved_session(path: str = COOKIE_FILE) -> SessionPage:
"""用已保存的 cookies 构建 SessionPage;无可用 cookies 时返回 None。"""
cookies = load_cookies(path)
if not cookies:
return None
session = SessionPage()
session.set.cookies(cookies)
session.set.timeout(10)
return session
def create_browser_with_saved_cookies(path: str = COOKIE_FILE) -> ChromiumPage:
"""用已保存的 cookies 创建 ChromiumPage(免输账号密码,SSO 跳转仍需真浏览器)。"""
browser = ChromiumPage()
cookies = load_cookies(path)
if cookies:
browser.set.cookies(cookies)
return browser
def is_session_valid(session: SessionPage, subject: str = "加班") -> bool:
"""通过拉取待办第一页判断会话是否有效(无效则需重新登录)。"""
try:
from .oa_api import fetch_todo_page
except ImportError:
from oa_api import fetch_todo_page
try:
fetch_todo_page(session, subject=subject, page_no=1, page_size=1)
return True
except Exception as e:
logger.info("会话已失效,需重新登录: %s", e)
return False
# 便捷函数:直接从已登录的浏览器提取会话,一步到位
def create_session_from_login() -> SessionPage:
"""
如果希望快速测试,可直接调用 oa_login() 获取浏览器,
再提取 SessionPage。
"""
try:
from .login import oa_login
except ImportError:
from login import oa_login
browser = oa_login()
return init_session_from_page(browser)
-68
View File
@@ -1,68 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.sso
@FileName: sso.py
@Author: 小布丁
@CreateTime: 2026-08-05 23:50
@Description: SSO 链接解析模块:浏览器访问 SSO 链接,从重定向后的详情页 URL 提取 taskId/fkId 和 businessKey
@Version: 1.0.1
"""
import os
import sys
from urllib.parse import urlparse, parse_qs
from typing import Dict
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger
logger = get_logger(__name__)
try:
from DrissionPage import ChromiumPage
except ImportError:
ChromiumPage = None
def resolve_sso_params(
browser: ChromiumPage,
sso_url: str,
wait_timeout: float = 20,
) -> Dict[str, str]:
"""
用浏览器打开 SSO 链接,等待 JS 重定向到详情页,
从最终 URL 的 query 参数中提取 taskId(部分页面命名为 fkId)和 businessKey。
Args:
browser: 已登录的 ChromiumPage 对象(SSO 的 JS 跳转必须用真浏览器)
sso_url: SSO 跳转链接(完整 URL)
wait_timeout: 等待 JS 跳转完成的超时时间(秒,默认 20)
Returns:
包含 taskId 和 businessKey 的字典
Raises:
RuntimeError: 跳转失败或 URL 中缺少 taskId/businessKey
"""
logger.info("解析 SSO 重定向: %s", sso_url)
# 浏览器打开 SSO 链接,页面 JS 自动重定向到详情页。
# 跳转链: sso.mob → unifyWorkFlow.jsp(中间页,一闪而过) → goToWorkFlow 详情页。
# 因此不能等中间页(会匹配不到而超时卡 wait_timeout 秒),改为等待地址栏离开 SSO 链接。
browser.get(sso_url)
browser.wait.url_change(sso_url, exclude=True, timeout=wait_timeout, raise_err=False)
logger.info("重定向最终 URL: %s", browser.url)
# 从详情页 URL 提取 taskId(fkId 是同一字段的别名)和 businessKey
params = parse_qs(urlparse(browser.url).query)
task_id = params.get("taskId", [None])[0] or params.get("fkId", [None])[0]
business_key = params.get("businessKey", [None])[0]
if not task_id or not business_key:
raise RuntimeError(
f"无法从重定向 URL 提取 taskId 或 businessKey: {browser.url}"
)
logger.info("SSO 解析成功: taskId=%s, businessKey=%s", task_id, business_key)
return {"taskId": task_id, "businessKey": business_key}
-9
View File
@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.leave
@FileName: __init__.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:00
@Description: 请假审批流程包
@Version: 1.0.0
"""
@@ -1,33 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.leave.leave_approval
@FileName: leave_approval.py
@Author: 小布丁
@CreateTime: 2026-08-05 21:21
@Description: 请假审批流程入口(审批引擎见 common/approval_flow.py,校验规则见 validator.py,报告见 reporter.py)
@Version: 1.2.0
"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
try:
from ..common.approval_flow import run_flow
from .validator import validate_doc
from .reporter import generate_report
except ImportError:
from common.approval_flow import run_flow
from validator import validate_doc
from reporter import generate_report
def main() -> None:
"""请假审批:登录 → 查待办 → 解析SSO → 获取表单 → 校验 → 报告"""
run_flow(subject="请假", validate_doc=validate_doc, generate_report=generate_report)
if __name__ == "__main__":
main()
-29
View File
@@ -1,29 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.leave.reporter
@FileName: reporter.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:11
@Description: 请假流程报告模块,生成审批报告
@Version: 1.1.0
"""
from typing import Any, Dict, List
def generate_report(results: List[Dict[str, Any]]) -> str:
"""
根据校验结果生成请假审批报告。
TODO: 按实际报告格式完善(导出 Excel/文件等)。
Args:
results: validate_doc 返回的校验结果列表
Returns:
报告文本
"""
lines = ["请假审批报告", "=" * 30]
for r in results:
lines.append(f"{r.get('creator', '')} | {r.get('title', '')} | {r.get('decision', '')}")
return "\n".join(lines)
-34
View File
@@ -1,34 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.leave.validator
@FileName: validator.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:11
@Description: 请假流程校验模块(审批规则:驳回/人工复核/通过)
@Version: 1.1.0
"""
from typing import Any, Dict
def validate_doc(doc: Dict[str, Any], session: Any) -> Dict[str, Any]:
"""
校验单张请假单据,返回审批决策。
TODO: 请假审批规则在此实现(依据排班、假期类型、请假时长等判定通过/驳回/人工复核)。
Args:
doc: 单据信息,含基本信息(title/creator/time/detail_url)
和审批引擎已获取的 taskId/businessKey/formId/formData(表单详情)
session: 已登录的 SessionPage 对象(用于调用排班接口)
Returns:
校验结果,包含审批决策
"""
return {
"title": doc.get("title", ""),
"creator": doc.get("creator", ""),
"time": doc.get("time", ""),
"decision": "pending", # pending: 规则未实现,默认待处理
"note": "请假校验规则待补充",
}
@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.work_overtime
@FileName: __init__.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:00
@Description: 加班审批流程包
@Version: 1.0.0
"""
@@ -1,33 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.work_overtime.overtime_approval
@FileName: overtime_approval.py
@Author: 小布丁
@CreateTime: 2026-08-05 21:22
@Description: 加班审批流程入口(审批引擎见 common/approval_flow.py,校验规则见 validator.py,报告见 reporter.py)
@Version: 1.4.0
"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
try:
from ..common.approval_flow import run_flow
from .validator import validate_doc
from .reporter import generate_report
except ImportError:
from common.approval_flow import run_flow
from validator import validate_doc
from reporter import generate_report
def main() -> None:
"""加班审批:登录 → 查待办 → 解析SSO → 获取表单 → 校验 → 报告"""
run_flow(subject="加班", validate_doc=validate_doc, generate_report=generate_report)
if __name__ == "__main__":
main()
-105
View File
@@ -1,105 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.work_overtime.parser
@FileName: parser.py
@Author: 小布丁
@CreateTime: 2026-08-06 09:30
@Description: 加班表单解析模块(解析 WorkformEngine 返回的 result,提取关键字段并转换为中文描述)
@Version: 1.0.0
"""
import os
import sys
from typing import Any, Dict
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger
logger = get_logger(__name__)
# 加班类型映射
OT_TYPE_MAP = {
"1": "延时加班",
"2": "法定假日加班",
"3": "休息日加班",
}
# 补贴类型映射
SUBSIDY_TYPE_MAP = {
"1": "转调休",
"2": "转补贴",
}
def parse_overtime_form(result: Dict[str, Any]) -> Dict[str, Any]:
"""
解析加班表单数据,提取关键字段并将代码转换为中文描述。
注意:入参为 oa_api.get_business_data 返回的 result 字段(state 校验已在
get_business_data 内完成),即审批引擎 doc['formData']。
Args:
result: WorkformEngine 返回的 result 字典(含 ot_type / staff_name 等)
Returns:
包含加班关键字段的字典(中文键名);找不到映射时保留原始代码值
"""
# 获取原始类型代码
ot_type_code = result.get("ot_type")
subsidy_type_code = result.get("subsidy_type")
overtime_info = {
"加班人员ID": result.get("staff_id"),
"加班人员": result.get("staff_name"),
"所属部门": result.get("dept_org_name"),
"加班类型": OT_TYPE_MAP.get(ot_type_code, ot_type_code),
"补贴类型": SUBSIDY_TYPE_MAP.get(subsidy_type_code, subsidy_type_code),
"加班日期": result.get("ot_date"),
"加班开始时间": result.get("start_time"),
"加班结束时间": result.get("end_time"),
"加班时长(小时)": result.get("ot_hour"),
"加班天数(天)": result.get("ot_day"),
"系统判断加班时长(小时)": result.get("judge_ot_hour"),
"系统判断加班天数(天)": result.get("judge_ot_day"),
"附件": result.get("file"),
}
# 拼接系统判定的加班时间段
judge_start = result.get("judge_start_time")
judge_end = result.get("judge_end_time")
if judge_start and judge_end:
overtime_info["系统判定加班时间"] = f"{judge_start} 至 {judge_end}"
else:
overtime_info["系统判定加班时间"] = None
return overtime_info
# ---------- 使用示例(测试用) ----------
if __name__ == "__main__":
from utils.logger import setup_logging
setup_logging()
# 示例 result(WorkformEngine 返回的 result 字段)
sample_result = {
"dept_org_name": "网络项目小组",
"end_time": "2026-08-03 00:00",
"judge_end_time": "2026-08-03 00:00:00",
"judge_ot_hour": 6.0,
"judge_start_time": "2026-08-02 18:00:00",
"ot_date": "2026-08-02",
"ot_hour": 6.0,
"ot_type": "1",
"staff_id": "572e6cce-7a9f-11ec-b449-000c296f9469",
"staff_name": "黄俊林",
"start_time": "2026-08-02 18:00",
"subsidy_type": "2",
"file": "ccc1d3ef-175a-4105-a8a8-0e63ed88d7bd",
}
parsed = parse_overtime_form(sample_result)
logger.info("===== 加班信息解析结果 =====")
for key, value in parsed.items():
logger.info("%s: %s", key, value)
@@ -1,82 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.work_overtime.reporter
@FileName: reporter.py
@Author: 小布丁
@CreateTime: 2026-08-05 21:35
@Description: 加班流程报告模块,生成审批报告(详细数据版,供自测阶段人工复核)
@Version: 1.3.0
"""
from typing import Any, Dict, List
def _format_detail(idx: int, r: Dict[str, Any]) -> str:
"""
格式化单条记录的详细信息:展示全部解析数据,最后是判断结果。
所有键值对左对齐,方便人工逐项核对。
"""
info = r.get("overtime_info", {}) or {}
# 收集全部要展示的键值对:先数据,后判断结果
items: List[tuple] = list(info.items())
items.append(("审批结果", r.get("decision", "")))
if r.get("note"):
items.append(("说明", r.get("note", "")))
if r.get("error"):
items.append(("错误", r.get("error", "")))
max_key = max((len(k) for k, _ in items), default=0)
lines = [
f"#{idx} 申请人: {r.get('creator', '')} | {r.get('title', '')}",
"-" * 60,
]
for key, value in items:
lines.append(f" {key:<{max_key}} : {value}")
lines.append("-" * 60)
return "\n".join(lines)
def generate_report(results: List[Dict[str, Any]]) -> str:
"""
根据校验结果生成加班审批报告(详细数据版)。
每条记录展示全部解析数据(人员、日期、起止时间、时长、排班、打卡、
申报天数、计算结果等),最后是审批结果和说明,供自测阶段人工复核。
Args:
results: validate_doc 返回的校验结果列表
Returns:
报告文本
"""
passed = [r for r in results if r.get("decision") == "通过"]
rejected = [r for r in results if r.get("decision") == "不通过"]
failed = [r for r in results if r.get("decision") == "失败"]
lines = [
"加班审批报告",
"=" * 60,
f"共 {len(results)} 单:通过 {len(passed)},不通过 {len(rejected)},处理失败 {len(failed)}",
"",
]
if rejected:
lines.append("【审批未通过名单】")
for i, r in enumerate(rejected, 1):
lines.append(_format_detail(i, r))
lines.append("")
if passed:
lines.append("【审批通过名单】")
for i, r in enumerate(passed, 1):
lines.append(_format_detail(i, r))
lines.append("")
if failed:
lines.append("【处理失败】")
for i, r in enumerate(failed, 1):
lines.append(_format_detail(i, r))
return "\n".join(lines)
@@ -1,447 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.work_overtime.validator
@FileName: validator.py
@Author: 小布丁
@CreateTime: 2026-08-05 21:35
@Description: 加班流程校验模块(按 aa.md 审批规则:延时加班/休息日加班/法定假日加班,判定通过/不通过)
@Version: 3.0.0
"""
import math
import os
import sys
from datetime import datetime, timedelta
from typing import Any, Dict, Optional
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
from utils.logger import get_logger
logger = get_logger(__name__)
try:
from .parser import parse_overtime_form
from ..common.oa_api import (
get_attendance_html,
get_attendance_records,
get_leave_records,
)
from ..common.parser import parse_attendance_html, summarize_attendance_records
from ..common.config import (
WORK_START_TIME,
WORK_END_TIME,
FLEX_TRIGGER_TIME,
OT_MIN_HOURS,
)
except ImportError:
from parser import parse_overtime_form
from common.oa_api import (
get_attendance_html,
get_attendance_records,
get_leave_records,
)
from common.parser import parse_attendance_html, summarize_attendance_records
from common.config import (
WORK_START_TIME,
WORK_END_TIME,
FLEX_TRIGGER_TIME,
OT_MIN_HOURS,
)
# ---------- 通用工具 ----------
def _parse_dt(value: Any) -> Optional[datetime]:
"""解析 "YYYY-MM-DD HH:MM[:SS]" 格式时间,失败返回 None"""
if not value:
return None
for fmt in ("%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M"):
try:
return datetime.strptime(str(value), fmt)
except ValueError:
continue
return None
def _calc_delayed_hours(start: datetime, end: datetime) -> float:
"""
延时加班计时:1小时起算,超过1小时的部分按0.5小时累加,不足0.5小时舍去。
不足1小时返回0。
示例:1.0->1.0, 1.4->1.0, 1.5->1.5, 1.9->1.5, 2.0->2.0, 2.3->2.0, 2.5->2.5
"""
total = (end - start).total_seconds() / 3600
if total < 1:
return 0.0
return 1.0 + math.floor((total - 1) / 0.5) * 0.5
def _calc_flex_d(actual_checkout: datetime, flex_trigger: datetime) -> float:
"""
弹性额度 D 计算(基于实际下班打卡时间):
实际下班打卡 >= 23:00 时,D = 1 + floor((打卡-23:00)/0.5) * 0.5
"""
return 1.0 + math.floor((actual_checkout - flex_trigger).total_seconds() / 1800) * 0.5
def _calc_day_ot_threshold(days: float) -> float:
"""
休息日/法定假日加班打卡间隔阈值:8 * days + int(days)。
0.5天->4h, 1天->9h, 1.5天->13h, 2天->18h, 2.5天->22h
"""
return 8.0 * days + int(days)
def _next_day(date_str: str) -> str:
"""日期字符串 +1 天"""
d = datetime.strptime(date_str, "%Y-%m-%d")
return (d + timedelta(days=1)).strftime("%Y-%m-%d")
def _is_spring_festival(date_str: str) -> bool:
"""
判断日期是否为春节法定节假日(初一至初三)。
用 chinese_calendar 的 get_holiday_detail 判断 holiday_name == 'Spring Festival',
且 is_in_lieu=False(排除调休日),且非周末(排除正常周末)。
判定失败时按非春节处理(优雅降级)。
"""
try:
import chinese_calendar as cc
date = datetime.strptime(date_str, "%Y-%m-%d").date()
is_holiday, holiday_name = cc.get_holiday_detail(date)
return (is_holiday
and holiday_name == 'Spring Festival'
and not cc.is_in_lieu(date)
and date.weekday() < 5)
except Exception as e:
logger.warning("春节法定假日判定失败(%s): %s", date_str, str(e))
return False
# ---------- 排班 / 打卡 / 请假查询 ----------
def _get_shift(session: Any, staff_id: str, date_str: str) -> str:
"""获取指定日期员工的排班班次(自动处理跨月)"""
if not date_str or not staff_id:
return "未知"
try:
year = int(date_str[:4])
month = int(date_str[5:7])
html = get_attendance_html(session, staff_id, year, month)
attendance = parse_attendance_html(html)
return attendance.get(date_str, "无排班")
except Exception as e:
logger.warning("获取排班失败(%s): %s", date_str, str(e))
return "获取失败"
def _check_attendance(session: Any, staff_id: str, ot_date: str) -> Dict[str, Any]:
"""查询员工在加班日期的排班班次"""
return {"加班当天班次": _get_shift(session, staff_id, ot_date)}
def _check_punch_records(session: Any, staff_id: str, ot_date: str) -> Dict[str, Any]:
"""
查询员工在加班日及次日的打卡明细,按日汇总。
加班常跨天(如 18:00 至次日 00:00),下班打卡可能落在次日,因此查询
范围扩展到 ot_date 次日;次日最早打卡用于延时加班的弹性到岗兑换判定。
"""
if not ot_date or not staff_id:
return {"当日最早打卡": None, "当日最晚打卡": None, "次日最早打卡": None,
"打卡备注": "缺少加班日期或员工ID"}
start = datetime.strptime(ot_date, "%Y-%m-%d")
next_day = (start + timedelta(days=1)).strftime("%Y-%m-%d")
try:
records = get_attendance_records(session, staff_id, ot_date, next_day)
summary = summarize_attendance_records(records)
day_summary = next((r for r in summary if r["attend_date"] == ot_date), None)
next_summary = next((r for r in summary if r["attend_date"] == next_day), None)
if not day_summary and not next_summary:
return {"当日最早打卡": None, "当日最晚打卡": None, "次日最早打卡": None,
"打卡备注": "当天及次日无打卡记录"}
return {
"当日最早打卡": day_summary["first_check_in"] if day_summary else None,
"当日最晚打卡": day_summary["last_check_out"] if day_summary else None,
"次日最早打卡": next_summary["first_check_in"] if next_summary else None,
"打卡备注": "",
}
except Exception as e:
logger.warning("获取打卡明细失败: %s", str(e))
return {"当日最早打卡": None, "当日最晚打卡": None, "次日最早打卡": None,
"打卡备注": f"获取失败: {e}"}
def _check_leave_covers_morning(session: Any, staff_id: str, date_str: str) -> bool:
"""
判断指定日期是否有请假覆盖早上上班时间(用于弹性兑换触发判定)。
只要任意请假区间覆盖了当日 WORK_START_TIME(如 09:00),即视为早上无需到岗,
不触发弹性兑换。查询范围向前一天扩展,确保能查到跨天请假。
"""
prev_day = (datetime.strptime(date_str, "%Y-%m-%d") - timedelta(days=1)).strftime("%Y-%m-%d")
try:
records = get_leave_records(session, staff_id, prev_day, date_str)
except Exception as e:
logger.warning("获取请假记录失败: %s", str(e))
return False
morning = datetime.strptime(f"{date_str} {WORK_START_TIME}", "%Y-%m-%d %H:%M")
for r in records:
start = _parse_dt(r.get("start_time"))
end = _parse_dt(r.get("end_time"))
if start and end and start <= morning <= end:
return True
return False
# ---------- 规则一:延时加班 ----------
def _validate_delayed(
info: Dict[str, Any], punch: Dict[str, Any], session: Any, staff_id: str
) -> tuple:
"""
延时加班审批(按 aa.md 规则一):
(一)驳回门槛:
1. 日期匹配:加班开始时间所属日期 = 申请加班日期;
2. 时长达标:1小时起算,超1小时按0.5h累加,不足1h驳回;
3. 区间合规:开始时间 >= 规定下班时间(18:00),结束时间 <= 实际下班打卡时间。
(二)弹性到岗兑换(仅影响结算,校验不通过则驳回):
D 基于实际下班打卡时间计算,>= 23:00 时 D = 1 + floor((打卡-23:00)/0.5)*0.5。
次日休息/请假覆盖09:00/无打卡 -> 不触发兑换。
正常工作日按次日打卡 P 校验:P<=09:00 不扣;09:00<P<=09:00+D 扣 ceil(P-09:00);
P>09:00+D 扣 D。兑换校验:加班时长+晚到 <= 加班开始到次日打卡的总自然时长。
"""
ot_date = info.get("加班日期")
start = _parse_dt(info.get("加班开始时间"))
end = _parse_dt(info.get("加班结束时间"))
actual_checkout = _parse_dt(punch.get("当日最晚打卡"))
reasons = []
# 1. 日期校验
if start is None:
reasons.append("加班开始时间缺失")
elif start.strftime("%Y-%m-%d") != ot_date:
reasons.append(f"加班开始日期({start:%Y-%m-%d})与申请加班日期({ot_date})不一致")
# 2. 时长校验
hours = None
if end is None:
reasons.append("加班结束时间缺失")
elif start is not None:
hours = _calc_delayed_hours(start, end)
if hours < OT_MIN_HOURS:
reasons.append(f"加班时长为{hours:g}小时,不足{OT_MIN_HOURS}小时")
# 3. 区间合规校验:开始 >= 规定下班时间,结束 <= 实际下班打卡时间
work_end = datetime.strptime(f"{ot_date} {WORK_END_TIME}", "%Y-%m-%d %H:%M")
if start is not None and start < work_end:
reasons.append(f"申请开始时间({start:%H:%M})早于规定下班时间({WORK_END_TIME})")
if end is not None:
if actual_checkout is None:
reasons.append("当日无下班打卡记录,无法校验区间合规")
elif end > actual_checkout:
reasons.append(
f"申请结束时间({end:%H:%M})晚于实际下班打卡时间({actual_checkout:%H:%M:%S})"
)
info["计算加班时长(小时)"] = hours
if reasons:
info["弹性扣减(小时)"] = 0
info["有效加班时长(小时)"] = hours
info["弹性额度D(小时)"] = 0
return "不通过", ";".join(reasons)
# 4. 弹性到岗兑换(仅影响结算时长)
deduction = 0.0
flex_note = ""
d_hours = 0.0
flex_trigger = datetime.strptime(f"{ot_date} {FLEX_TRIGGER_TIME}", "%Y-%m-%d %H:%M")
if actual_checkout is not None and actual_checkout >= flex_trigger:
d_hours = _calc_flex_d(actual_checkout, flex_trigger)
next_day = _next_day(ot_date)
next_shift = _get_shift(session, staff_id, next_day)
if next_shift in ("休息", "无排班"):
flex_note = f"次日({next_day})为休息日,不触发弹性兑换"
elif next_shift in ("获取失败", "未知"):
flex_note = f"次日({next_day})排班获取失败,不触发弹性兑换"
elif _check_leave_covers_morning(session, staff_id, next_day):
flex_note = f"次日({next_day})请假覆盖早上上班时间,不触发弹性兑换"
else:
work_start = datetime.strptime(f"{next_day} {WORK_START_TIME}", "%Y-%m-%d %H:%M")
p = _parse_dt(punch.get("次日最早打卡"))
if p is None:
flex_note = f"次日({next_day})无打卡记录,不触发弹性兑换"
elif p <= work_start:
flex_note = f"次日打卡({p:%H:%M})准时或提前,无需兑换"
else:
# 有晚到,校验:加班时长 + 晚到 <= 加班开始到次日打卡的总自然时长
total_natural = (p - start).total_seconds() / 3600
if p <= work_start + timedelta(hours=d_hours):
# 09:00 < P <= 09:00+D:晚到时长 = ceil(P-09:00),不足1h按1h
late_hours = max(1, math.ceil((p - work_start).total_seconds() / 3600))
if hours + late_hours > total_natural:
info["弹性扣减(小时)"] = 0
info["有效加班时长(小时)"] = hours
info["弹性额度D(小时)"] = d_hours
return "不通过", (
f"弹性兑换校验不通过:申请加班{hours:g}h + 晚到{late_hours}h "
f"> 总自然时长{total_natural:.1f}h"
)
deduction = float(late_hours)
flex_note = f"次日打卡({p:%H:%M})晚到,兑换{late_hours}小时"
else:
# P > 09:00+D:兑换额度最高按D,超出部分交考勤处理
if hours + d_hours > total_natural:
info["弹性扣减(小时)"] = 0
info["有效加班时长(小时)"] = hours
info["弹性额度D(小时)"] = d_hours
return "不通过", (
f"弹性兑换校验不通过:申请加班{hours:g}h + 兑换额度{d_hours:g}h "
f"> 总自然时长{total_natural:.1f}h"
)
deduction = float(d_hours)
flex_note = (
f"次日打卡({p:%H:%M})超出弹性区间(D={d_hours:g}h),"
f"按D兑换,超出部分交考勤处理"
)
else:
if actual_checkout is not None:
flex_note = f"实际下班打卡({actual_checkout:%H:%M})早于{FLEX_TRIGGER_TIME},弹性额度D=0"
effective = max(0.0, float(hours) - deduction)
info["弹性扣减(小时)"] = deduction
info["有效加班时长(小时)"] = effective
info["弹性额度D(小时)"] = d_hours
note = f"审批通过,有效加班时长{effective:g}小时"
if flex_note:
note += f"({flex_note})"
return "通过", note
# ---------- 规则二/三:休息日 / 法定假日加班 ----------
def _validate_day_ot(
info: Dict[str, Any],
punch: Dict[str, Any],
session: Any,
staff_id: str,
require_holiday: bool,
) -> tuple:
"""
休息日/法定假日加班审批(任一条件不满足即不通过):
- 排班显示为休息;
- 法定假日(仅春节):申请日期必须为春节法定节假日;
- 加班时长 > 0;
- 当天有上下班打卡;
- 打卡时间间隔满足申报天数(0.5天>=4h, 1天>=9h, 1.5天>=13h, 2天>=18h...)。
"""
ot_date = info.get("加班日期")
reasons = []
# 排班须显示为休息;排班获取失败/未知时优雅降级
shift = info.get("加班当天班次", "")
if shift not in ("休息", "获取失败", "未知", "无排班"):
reasons.append(f"当天排班为'{shift}',非休息日")
if require_holiday and not _is_spring_festival(ot_date):
reasons.append(f"{ot_date}不在春节法定节假日列表中")
# 加班时长 > 0
ot_hour = info.get("加班时长(小时)") or info.get("系统判断加班时长(小时)")
try:
ot_hour = float(ot_hour)
except (TypeError, ValueError):
ot_hour = 0.0
if ot_hour <= 0:
reasons.append("加班时长为0或缺失")
# 当天有上下班打卡,且打卡时间间隔满足申报天数
first = _parse_dt(punch.get("当日最早打卡"))
last = _parse_dt(punch.get("当日最晚打卡"))
interval = None
if first is None or last is None:
reasons.append("当天缺少上班或下班打卡")
else:
interval = (last - first).total_seconds() / 3600
apply_days = info.get("加班天数(天)") or info.get("系统判断加班天数(天)")
try:
apply_days = float(apply_days)
except (TypeError, ValueError):
apply_days = 0.0
if apply_days <= 0:
reasons.append("申报天数缺失或为0")
elif interval is not None:
threshold = _calc_day_ot_threshold(apply_days)
if interval < threshold:
reasons.append(
f"打卡间隔{interval:.2f}小时不足申报{apply_days:g}天所需的{threshold:g}小时"
)
info["打卡时间间隔(小时)"] = interval
info["申报天数(天)"] = apply_days
if reasons:
return "不通过", ";".join(reasons)
return "通过", f"审批通过(申报{apply_days:g}天,打卡间隔{interval:.2f}小时)"
# ---------- 主入口 ----------
def validate_doc(doc: Dict[str, Any], session: Any) -> Dict[str, Any]:
"""
校验单张加班单据,返回审批决策(通过 / 不通过)。
按加班类型分派规则:
ot_type=1 延时加班;
ot_type=3 休息日加班;
ot_type=2 法定假日加班(仅春节法定节假日走规则三,非春节按休息日规则执行)。
Args:
doc: 单据信息,含基本信息(title/creator/time/detail_url)
和审批引擎已获取的 taskId/businessKey/formId/formData(表单详情)
session: 已登录的 SessionPage 对象(用于调用排班/打卡/请假接口)
Returns:
校验结果,包含审批决策、原因说明及解析后的加班信息
"""
form_data = doc.get("formData", {}) or {}
overtime_info = parse_overtime_form(form_data)
staff_id = overtime_info.get("加班人员ID")
ot_date = overtime_info.get("加班日期")
attendance_info = _check_attendance(session, staff_id, ot_date)
punch_info = _check_punch_records(session, staff_id, ot_date)
overtime_info.update(attendance_info)
overtime_info.update(punch_info)
ot_type_code = str(form_data.get("ot_type") or "")
if ot_type_code == "1":
decision, note = _validate_delayed(overtime_info, punch_info, session, staff_id)
elif ot_type_code == "3":
decision, note = _validate_day_ot(
overtime_info, punch_info, session, staff_id, require_holiday=False
)
elif ot_type_code == "2":
# 法定假日加班:仅春节法定节假日适用规则三,非春节按休息日规则执行
require_holiday = _is_spring_festival(ot_date)
decision, note = _validate_day_ot(
overtime_info, punch_info, session, staff_id, require_holiday=require_holiday
)
else:
decision, note = "不通过", f"无法识别加班类型: {ot_type_code}"
return {
"title": doc.get("title", ""),
"creator": doc.get("creator", ""),
"time": doc.get("time", ""),
"decision": decision,
"note": note,
"overtime_info": overtime_info,
}
-9
View File
@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: utils
@FileName: __init__.py
@Author: 小布丁
@CreateTime: 2026-08-05 17:00
@Description: 项目级通用工具包
@Version: 1.0.0
"""
-79
View File
@@ -1,79 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.utils
@FileName: utils.py
@Author: 小布丁
@CreateTime: 2026-08-05 21:30
@Description: 项目级通用工具(重试装饰器)
@Version: 1.1.0
"""
import functools
import os
import random
import sys
import time
from typing import Callable
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from logger import get_logger
logger = get_logger(__name__)
class RetryExhaustedError(Exception):
"""重试耗尽后抛出的异常,保留原始异常链。"""
pass
def retry(max_attempts: int = 3) -> Callable:
"""
重试装饰器:内置指数退避 + 随机抖动,只暴露重试次数。
Args:
max_attempts: 最大尝试次数(含首次执行),默认 3,必须 >= 1。
内部行为(对调用方透明):
- 捕获所有 Exception;
- 延迟策略:第 n 次重试等待 1.0 * 2^(n-1) 秒,并乘以 [0.5, 1.5] 随机因子;
- 全部失败后抛出 RetryExhaustedError,可通过 __cause__ 获取原始异常。
"""
if max_attempts < 1:
raise ValueError("max_attempts must be >= 1")
def decorator(func: Callable) -> Callable:
@functools.wraps(func)
def wrapper(*args, **kwargs):
last_exc = None
base_delay = 1.0
backoff = 2.0
for attempt in range(1, max_attempts + 1):
try:
return func(*args, **kwargs)
except Exception as e:
last_exc = e
if attempt >= max_attempts:
logger.error(
"%s 连续 %d 次尝试失败,放弃并记录: %s",
func.__name__, max_attempts, e,
)
break
# 计算退避 + 抖动
delay = base_delay * (backoff ** (attempt - 1))
delay *= random.uniform(0.5, 1.5)
logger.warning(
"%s 第 %d 次执行失败: %s,%.2f 秒后重试",
func.__name__, attempt, e, delay,
)
time.sleep(delay)
raise RetryExhaustedError(
f"{func.__name__} failed after {max_attempts} attempts"
) from last_exc
return wrapper
return decorator
-89
View File
@@ -1,89 +0,0 @@
# -*- coding: utf-8 -*-
"""
@Module: utils.logger
@FileName: logger.py
@Author: 小布丁
@CreateTime: 2026-08-05
@Description: 项目统一日志配置:控制台彩色输出 + 文件持久化
@Version: 1.0.0
"""
import logging
import logging.handlers
import os
import sys
from datetime import datetime
_console_fmt = "%(asctime)s | %(levelname)-7s | %(name)s | %(message)s"
_file_fmt = "%(asctime)s | %(levelname)-7s | %(name)s | %(filename)s:%(lineno)d | %(message)s"
_date_fmt = "%Y-%m-%d %H:%M:%S"
_initialized = False
class _ColoredFormatter(logging.Formatter):
"""控制台彩色日志格式,不修改 record 本身,避免污染文件输出"""
_colors = {
logging.DEBUG: "\033[36m",
logging.INFO: "\033[32m",
logging.WARNING: "\033[33m",
logging.ERROR: "\033[31m",
logging.CRITICAL: "\033[35m",
}
_reset = "\033[0m"
def format(self, record: logging.LogRecord) -> str:
color = self._colors.get(record.levelno, "")
orig_levelname = record.levelname
record.levelname = f"{color}{record.levelname}{self._reset}"
result = super().format(record)
record.levelname = orig_levelname
return result
def setup_logging(
level: int = logging.INFO,
log_dir: str = None,
log_file: bool = True,
) -> None:
"""
初始化项目统一日志配置。只需在入口调用一次。
Args:
level: 日志级别,默认 INFO
log_dir: 日志文件目录,默认 app/logs/
log_file: 是否同时输出到文件,默认 True
"""
global _initialized
if _initialized:
return
logger = logging.getLogger()
logger.setLevel(level)
logger.handlers.clear()
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(level)
console_handler.setFormatter(_ColoredFormatter(_console_fmt, datefmt=_date_fmt))
logger.addHandler(console_handler)
if log_file:
if log_dir is None:
log_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "logs")
os.makedirs(log_dir, exist_ok=True)
log_path = os.path.join(log_dir, f"app_{datetime.now().strftime('%Y%m%d')}.log")
file_handler = logging.handlers.RotatingFileHandler(
log_path, maxBytes=5 * 1024 * 1024, backupCount=5, encoding="utf-8"
)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(logging.Formatter(_file_fmt, datefmt=_date_fmt))
logger.addHandler(file_handler)
_initialized = True
def get_logger(name: str) -> logging.Logger:
"""获取模块级 logger,用法:logger = get_logger(__name__)"""
return logging.getLogger(name)
+8
View File
@@ -0,0 +1,8 @@
# 37du 新中心机控制面(cool-admin-midway + art-design-pro)本地开发忽略
node_modules/
dist/
*.log
.cache/
# MySQL/Redis 便携运行环境(含数据)不入库,实际安装位置 D:\work\env\(Windows 服务 37duMySQL / redis37du)
/mysql/
/redis/
@@ -0,0 +1,2 @@
*.html linguist-detectable=false
*.vue linguist-detectable=true
@@ -0,0 +1,11 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
.cursorrules
# Auto-generated files
src/types/import/auto-imports.d.ts
src/types/import/components.d.ts
.auto-import.json
@@ -0,0 +1 @@
pnpm dlx commitlint --edit $1
@@ -0,0 +1 @@
pnpm run lint:lint-staged
@@ -0,0 +1,3 @@
/node_modules/*
/dist/*
/src/main.ts
@@ -0,0 +1,20 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"vueIndentScriptAndStyle": true,
"singleQuote": true,
"quoteProps": "as-needed",
"bracketSpacing": true,
"trailingComma": "none",
"bracketSameLine": false,
"jsxSingleQuote": false,
"arrowParens": "always",
"insertPragma": false,
"requirePragma": false,
"proseWrap": "never",
"htmlWhitespaceSensitivity": "strict",
"endOfLine": "auto",
"rangeStart": 0
}
@@ -0,0 +1,9 @@
dist
node_modules
public
.husky
.vscode
src/components/Layout/MenuLeft/index.vue
src/assets
stats.html
@@ -0,0 +1,82 @@
module.exports = {
// 继承推荐规范配置
extends: [
'stylelint-config-standard',
'stylelint-config-recommended-scss',
'stylelint-config-recommended-vue/scss',
'stylelint-config-html/vue',
'stylelint-config-recess-order'
],
// 指定不同文件对应的解析器
overrides: [
{
files: ['**/*.{vue,html}'],
customSyntax: 'postcss-html'
},
{
files: ['**/*.{css,scss}'],
customSyntax: 'postcss-scss'
}
],
// 自定义规则
rules: {
'import-notation': 'string', // 指定导入CSS文件的方式("string"|"url")
'selector-class-pattern': null, // 选择器类名命名规则
'custom-property-pattern': null, // 自定义属性命名规则
'keyframes-name-pattern': null, // 动画帧节点样式命名规则
'no-descending-specificity': null, // 允许无降序特异性
'no-empty-source': null, // 允许空样式
'property-no-vendor-prefix': null, // 允许属性前缀
// 允许 global 、export 、deep伪类
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: ['global', 'export', 'deep']
}
],
// 允许未知属性
'property-no-unknown': [
true,
{
ignoreProperties: []
}
],
// 允许未知规则
'at-rule-no-unknown': [
true,
{
ignoreAtRules: [
'apply',
'use',
'mixin',
'include',
'extend',
'each',
'if',
'else',
'for',
'while',
'reference'
]
}
],
'scss/at-rule-no-unknown': [
true,
{
ignoreAtRules: [
'apply',
'use',
'mixin',
'include',
'extend',
'each',
'if',
'else',
'for',
'while',
'reference'
]
}
]
}
}
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 SuperManTT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,97 @@
/**
* commitlint 配置文件
* 文档
* https://commitlint.js.org/#/reference-rules
* https://cz-git.qbb.sh/zh/guide/
*/
module.exports = {
// 继承的规则
extends: ['@commitlint/config-conventional'],
// 自定义规则
rules: {
// 提交类型枚举,git提交type必须是以下类型
'type-enum': [
2,
'always',
[
'feat', // 新增功能
'fix', // 修复缺陷
'docs', // 文档变更
'style', // 代码格式(不影响功能,例如空格、分号等格式修正)
'refactor', // 代码重构(不包括 bug 修复、功能新增)
'perf', // 性能优化
'test', // 添加疏漏测试或已有测试改动
'build', // 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等)
'ci', // 修改 CI 配置、脚本
'revert', // 回滚 commit
'chore', // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
'wip' // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
]
],
'subject-case': [0] // subject大小写不做校验
},
prompt: {
messages: {
type: '选择你要提交的类型 :',
scope: '选择一个提交范围(可选):',
customScope: '请输入自定义的提交范围 :',
subject: '填写简短精炼的变更描述 :\n',
body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n',
footerPrefixesSelect: '选择关联issue前缀(可选):',
customFooterPrefix: '输入自定义issue前缀 :',
footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
generatingByAI: '正在通过 AI 生成你的提交简短描述...',
generatedSelectByAI: '选择一个 AI 生成的简短描述:',
confirmCommit: '是否提交或修改commit ?'
},
// prettier-ignore
types: [
{ value: "feat", name: "feat: 新增功能" },
{ value: "fix", name: "fix: 修复缺陷" },
{ value: "docs", name: "docs: 文档变更" },
{ value: "style", name: "style: 代码格式(不影响功能,例如空格、分号等格式修正)" },
{ value: "refactor", name: "refactor: 代码重构(不包括 bug 修复、功能新增)" },
{ value: "perf", name: "perf: 性能优化" },
{ value: "test", name: "test: 添加疏漏测试或已有测试改动" },
{ value: "build", name: "build: 构建流程、外部依赖变更(如升级 npm 包、修改 vite 配置等)" },
{ value: "ci", name: "ci: 修改 CI 配置、脚本" },
{ value: "revert", name: "revert: 回滚 commit" },
{ value: "chore", name: "chore: 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)" },
],
useEmoji: true,
emojiAlign: 'center',
useAI: false,
aiNumber: 1,
themeColorCode: '',
scopes: [],
allowCustomScopes: true,
allowEmptyScopes: true,
customScopesAlign: 'bottom',
customScopesAlias: 'custom',
emptyScopesAlias: 'empty',
upperCaseSubject: false,
markBreakingChangeMode: false,
allowBreakingChanges: ['feat', 'fix'],
breaklineNumber: 100,
breaklineChar: '|',
skipQuestions: ['breaking', 'footerPrefix', 'footer'], // 跳过的步骤
issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }],
customIssuePrefixAlign: 'top',
emptyIssuePrefixAlias: 'skip',
customIssuePrefixAlias: 'custom',
allowCustomIssuePrefix: true,
allowEmptyIssuePrefix: true,
confirmColorize: true,
maxHeaderLength: Infinity,
maxSubjectLength: Infinity,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: '',
defaultIssues: '',
defaultScope: '',
defaultSubject: ''
}
}
@@ -0,0 +1,83 @@
// 从 URL 和路径模块中导入必要的功能
import fs from 'fs'
import path, { dirname } from 'path'
import { fileURLToPath } from 'url'
// 从 ESLint 插件中导入推荐配置
import pluginJs from '@eslint/js'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import pluginVue from 'eslint-plugin-vue'
import globals from 'globals'
import tseslint from 'typescript-eslint'
// 使用 import.meta.url 获取当前模块的路径
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
// 读取 .auto-import.json 文件的内容,并将其解析为 JSON 对象
const autoImportConfig = JSON.parse(
fs.readFileSync(path.resolve(__dirname, '.auto-import.json'), 'utf-8')
)
export default [
// 指定文件匹配规则
{
files: ['**/*.{js,mjs,cjs,ts,tsx,vue}']
},
// 指定全局变量和环境
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
// 扩展配置
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...pluginVue.configs['flat/essential'],
// 自定义规则
{
// 针对所有 JavaScript、TypeScript 和 Vue 文件应用以下配置
files: ['**/*.{js,mjs,cjs,ts,tsx,vue}'],
languageOptions: {
globals: {
// 合并从 autoImportConfig 中读取的全局变量配置
...autoImportConfig.globals,
// TypeScript 全局命名空间
Api: 'readonly'
}
},
rules: {
quotes: ['error', 'single'], // 使用单引号
semi: ['error', 'never'], // 语句末尾不加分号
'no-var': 'error', // 要求使用 let 或 const 而不是 var
'@typescript-eslint/no-explicit-any': 'off', // 禁用 any 检查
'vue/multi-word-component-names': 'off', // 禁用对 Vue 组件名称的多词要求检查
'no-multiple-empty-lines': ['warn', { max: 1 }], // 不允许多个空行
'no-unexpected-multiline': 'error' // 禁止空余的多行
}
},
// vue 规则
{
files: ['**/*.vue'],
languageOptions: {
parserOptions: { parser: tseslint.parser }
}
},
// 忽略文件
{
ignores: [
'node_modules',
'dist',
'public',
'.vscode/**',
'src/assets/**',
'src/utils/console.ts'
]
},
// prettier 配置
eslintPluginPrettierRecommended
]
@@ -0,0 +1,47 @@
<!doctype html>
<html>
<head>
<title>37du 控制台</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="37du 自动化平台控制台:插件分发、账号授权与运行监控"
/>
<link rel="shortcut icon" type="image/x-icon" href="src/assets/images/favicon.ico" />
<style>
/* 防止页面刷新时白屏的初始样式 */
html {
background-color: #fafbfc;
}
html.dark {
background-color: #070707;
}
</style>
<script>
// 初始化 html class 主题属性
;(function () {
try {
if (typeof Storage === 'undefined' || !window.localStorage) {
return
}
const themeType = localStorage.getItem('sys-theme')
if (themeType === 'dark') {
document.documentElement.classList.add('dark')
}
} catch (e) {
console.warn('Failed to apply initial theme:', e)
}
})()
</script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
@@ -0,0 +1,123 @@
{
"name": "art-design-pro",
"version": "0.0.0",
"type": "module",
"engines": {
"node": ">=20.19.0",
"pnpm": ">=8.8.0"
},
"scripts": {
"dev": "vite --open",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview",
"lint": "eslint",
"fix": "eslint --fix",
"lint:prettier": "prettier --write \"**/*.{js,cjs,ts,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint \"**/*.{css,scss,vue}\" --fix",
"lint:lint-staged": "lint-staged",
"prepare": "husky",
"commit": "git-cz",
"clean:dev": "tsx scripts/clean-dev.ts"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
},
"lint-staged": {
"*.{js,ts,mjs,mts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{cjs,json,jsonc}": [
"prettier --write"
],
"*.vue": [
"eslint --fix",
"stylelint --fix --allow-empty-input",
"prettier --write"
],
"*.{html,htm}": [
"prettier --write"
],
"*.{scss,css,less}": [
"stylelint --fix --allow-empty-input",
"prettier --write"
],
"*.{md,mdx}": [
"prettier --write"
],
"*.{yaml,yml}": [
"prettier --write"
]
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.2",
"@iconify/vue": "^5.0.0",
"@tailwindcss/vite": "^4.1.14",
"@vue/reactivity": "^3.5.21",
"@vueuse/core": "^13.9.0",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "next",
"axios": "^1.12.2",
"crypto-js": "^4.2.0",
"echarts": "^6.0.0",
"element-plus": "^2.11.2",
"file-saver": "^2.0.5",
"highlight.js": "^11.10.0",
"mitt": "^3.0.1",
"nprogress": "^0.2.0",
"ohash": "^2.0.11",
"pinia": "^3.0.3",
"pinia-plugin-persistedstate": "^4.3.0",
"qrcode.vue": "^3.6.0",
"tailwindcss": "^4.1.14",
"vue": "^3.5.21",
"vue-draggable-plus": "^0.6.0",
"vue-i18n": "^9.14.0",
"vue-router": "^4.5.1",
"xgplayer": "^3.0.20",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@commitlint/cli": "^19.4.1",
"@commitlint/config-conventional": "^19.4.1",
"@eslint/js": "^9.9.1",
"@types/node": "^24.0.5",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"@vitejs/plugin-vue": "^6.0.1",
"@vue/compiler-sfc": "^3.0.5",
"commitizen": "^4.3.0",
"cz-git": "^1.11.1",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "^9.27.0",
"globals": "^15.9.0",
"husky": "^9.1.5",
"lint-staged": "^15.5.2",
"prettier": "^3.5.3",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.81.0",
"stylelint": "^16.20.0",
"stylelint-config-html": "^1.1.0",
"stylelint-config-recess-order": "^4.6.0",
"stylelint-config-recommended-scss": "^14.1.0",
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^36.0.1",
"terser": "^5.36.0",
"tsx": "^4.20.3",
"typescript": "~5.6.3",
"typescript-eslint": "^8.9.0",
"unplugin-auto-import": "^20.2.0",
"unplugin-element-plus": "^0.10.0",
"unplugin-vue-components": "^29.1.0",
"vite": "^7.1.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-vue-devtools": "^7.7.6",
"vue-demi": "^0.14.9",
"vue-img-cutter": "^3.0.5",
"vue-tsc": "~2.1.6"
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,8 @@
allowBuilds:
'@parcel/watcher': true
'@tailwindcss/oxide': true
core-js: true
es5-ext: true
esbuild: true
vue-demi: true
# pnpm 12 设置(onlyBuiltDependencies 从 package.json 移到这里)
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

@@ -0,0 +1,838 @@
// scripts/clean-dev.ts
import fs from 'fs/promises'
import path from 'path'
// 现代化颜色主题
const theme = {
// 基础颜色
reset: '\x1b[0m',
bold: '\x1b[1m',
dim: '\x1b[2m',
// 前景色
primary: '\x1b[38;5;75m', // 亮蓝色
success: '\x1b[38;5;82m', // 亮绿色
warning: '\x1b[38;5;220m', // 亮黄色
error: '\x1b[38;5;196m', // 亮红色
info: '\x1b[38;5;159m', // 青色
purple: '\x1b[38;5;141m', // 紫色
orange: '\x1b[38;5;208m', // 橙色
gray: '\x1b[38;5;245m', // 灰色
white: '\x1b[38;5;255m', // 白色
// 背景色
bgDark: '\x1b[48;5;235m', // 深灰背景
bgBlue: '\x1b[48;5;24m', // 蓝色背景
bgGreen: '\x1b[48;5;22m', // 绿色背景
bgRed: '\x1b[48;5;52m' // 红色背景
}
// 现代化图标集
const icons = {
rocket: '🚀',
fire: '🔥',
star: '⭐',
gem: '💎',
crown: '👑',
magic: '✨',
warning: '⚠️',
success: '✅',
error: '❌',
info: 'ℹ️',
folder: '📁',
file: '📄',
image: '🖼️',
code: '💻',
data: '📊',
globe: '🌐',
map: '🗺️',
chat: '💬',
bolt: '⚡',
shield: '🛡️',
key: '🔑',
link: '🔗',
clean: '🧹',
trash: '🗑️',
check: '✓',
cross: '✗',
arrow: '→',
loading: '⏳'
}
// 格式化工具
const fmt = {
title: (text: string) => `${theme.bold}${theme.primary}${text}${theme.reset}`,
subtitle: (text: string) => `${theme.purple}${text}${theme.reset}`,
success: (text: string) => `${theme.success}${text}${theme.reset}`,
error: (text: string) => `${theme.error}${text}${theme.reset}`,
warning: (text: string) => `${theme.warning}${text}${theme.reset}`,
info: (text: string) => `${theme.info}${text}${theme.reset}`,
highlight: (text: string) => `${theme.bold}${theme.white}${text}${theme.reset}`,
dim: (text: string) => `${theme.dim}${theme.gray}${text}${theme.reset}`,
orange: (text: string) => `${theme.orange}${text}${theme.reset}`,
// 带背景的文本
badge: (text: string, bg: string = theme.bgBlue) =>
`${bg}${theme.white}${theme.bold} ${text} ${theme.reset}`,
// 渐变效果模拟
gradient: (text: string) => {
const colors = ['\x1b[38;5;75m', '\x1b[38;5;81m', '\x1b[38;5;87m', '\x1b[38;5;159m']
const chars = text.split('')
return chars.map((char, i) => `${colors[i % colors.length]}${char}`).join('') + theme.reset
}
}
// 创建现代化标题横幅
function createModernBanner() {
console.log()
console.log(
fmt.gradient(' ╔══════════════════════════════════════════════════════════════════╗')
)
console.log(
fmt.gradient(' ║ ║')
)
console.log(
` ║ ${icons.rocket} ${fmt.title('ART DESIGN PRO')} ${fmt.subtitle('· 代码精简程序')} ${icons.magic} ║`
)
console.log(
` ║ ${fmt.dim('为项目移除演示数据,快速切换至开发模式')} ║`
)
console.log(
fmt.gradient(' ║ ║')
)
console.log(
fmt.gradient(' ╚══════════════════════════════════════════════════════════════════╝')
)
console.log()
}
// 创建分割线
function createDivider(char = '─', color = theme.primary) {
console.log(`${color}${' ' + char.repeat(66)}${theme.reset}`)
}
// 创建卡片样式容器
function createCard(title: string, content: string[]) {
console.log(` ${fmt.badge('', theme.bgBlue)} ${fmt.title(title)}`)
console.log()
content.forEach((line) => {
console.log(` ${line}`)
})
console.log()
}
// 进度条动画
function createProgressBar(current: number, total: number, text: string, width = 40) {
const percentage = Math.round((current / total) * 100)
const filled = Math.round((current / total) * width)
const empty = width - filled
const filledBar = '█'.repeat(filled)
const emptyBar = '░'.repeat(empty)
process.stdout.write(
`\r ${fmt.info('进度')} [${theme.success}${filledBar}${theme.gray}${emptyBar}${theme.reset}] ${fmt.highlight(percentage + '%')})}`
)
if (current === total) {
console.log()
}
}
// 统计信息
const stats = {
deletedFiles: 0,
deletedPaths: 0,
failedPaths: 0,
startTime: Date.now(),
totalFiles: 0
}
// 清理目标
const targets = [
'README.md',
'README.zh-CN.md',
'CHANGELOG.md',
'CHANGELOG.zh-CN.md',
'src/views/change',
'src/views/safeguard',
'src/views/article',
'src/views/examples',
'src/views/system/nested',
'src/views/widgets',
'src/views/template',
'src/views/dashboard/analysis',
'src/views/dashboard/ecommerce',
'src/mock/json',
'src/mock/temp/articleList.ts',
'src/mock/temp/commentDetail.ts',
'src/mock/temp/commentList.ts',
'src/assets/images/cover',
'src/assets/images/safeguard',
'src/assets/images/3d',
'src/components/core/charts/art-map-chart',
'src/components/business/comment-widget'
]
// 递归统计文件数量
async function countFiles(targetPath: string): Promise<number> {
const fullPath = path.resolve(process.cwd(), targetPath)
try {
const stat = await fs.stat(fullPath)
if (stat.isFile()) {
return 1
} else if (stat.isDirectory()) {
const entries = await fs.readdir(fullPath)
let count = 0
for (const entry of entries) {
const entryPath = path.join(targetPath, entry)
count += await countFiles(entryPath)
}
return count
}
} catch {
return 0
}
return 0
}
// 统计所有目标的文件数量
async function countAllFiles(): Promise<number> {
let totalCount = 0
for (const target of targets) {
const count = await countFiles(target)
totalCount += count
}
return totalCount
}
// 删除文件和目录
async function remove(targetPath: string, index: number) {
const fullPath = path.resolve(process.cwd(), targetPath)
createProgressBar(index + 1, targets.length, targetPath)
try {
const fileCount = await countFiles(targetPath)
await fs.rm(fullPath, { recursive: true, force: true })
stats.deletedFiles += fileCount
stats.deletedPaths++
await new Promise((resolve) => setTimeout(resolve, 50))
} catch (err) {
stats.failedPaths++
console.log()
console.log(` ${icons.error} ${fmt.error('删除失败')}: ${fmt.highlight(targetPath)}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
}
}
// 清理路由模块
async function cleanRouteModules() {
const modulesPath = path.resolve(process.cwd(), 'src/router/modules')
try {
// 删除演示相关的路由模块
const modulesToRemove = [
'template.ts',
'widgets.ts',
'examples.ts',
'article.ts',
'safeguard.ts',
'help.ts'
]
for (const module of modulesToRemove) {
const modulePath = path.join(modulesPath, module)
try {
await fs.rm(modulePath, { force: true })
} catch {
// 文件不存在时忽略错误
}
}
// 重写 dashboard.ts - 只保留 console
const dashboardContent = `import { AppRouteRecord } from '@/types/router'
export const dashboardRoutes: AppRouteRecord = {
name: 'Dashboard',
path: '/dashboard',
component: '/index/index',
meta: {
title: 'menus.dashboard.title',
icon: 'ri:pie-chart-line',
roles: ['R_SUPER', 'R_ADMIN']
},
children: [
{
path: 'console',
name: 'Console',
component: '/dashboard/console',
meta: {
title: 'menus.dashboard.console',
keepAlive: false,
fixedTab: true
}
}
]
}
`
await fs.writeFile(path.join(modulesPath, 'dashboard.ts'), dashboardContent, 'utf-8')
// 重写 system.ts - 移除 nested 嵌套菜单
const systemContent = `import { AppRouteRecord } from '@/types/router'
export const systemRoutes: AppRouteRecord = {
path: '/system',
name: 'System',
component: '/index/index',
meta: {
title: 'menus.system.title',
icon: 'ri:user-3-line',
roles: ['R_SUPER', 'R_ADMIN']
},
children: [
{
path: 'user',
name: 'User',
component: '/system/user',
meta: {
title: 'menus.system.user',
keepAlive: true,
roles: ['R_SUPER', 'R_ADMIN']
}
},
{
path: 'role',
name: 'Role',
component: '/system/role',
meta: {
title: 'menus.system.role',
keepAlive: true,
roles: ['R_SUPER']
}
},
{
path: 'user-center',
name: 'UserCenter',
component: '/system/user-center',
meta: {
title: 'menus.system.userCenter',
isHide: true,
keepAlive: true,
isHideTab: true
}
},
{
path: 'menu',
name: 'Menus',
component: '/system/menu',
meta: {
title: 'menus.system.menu',
keepAlive: true,
roles: ['R_SUPER'],
authList: [
{ title: '新增', authMark: 'add' },
{ title: '编辑', authMark: 'edit' },
{ title: '删除', authMark: 'delete' }
]
}
}
]
}
`
await fs.writeFile(path.join(modulesPath, 'system.ts'), systemContent, 'utf-8')
// 重写 index.ts - 只导入保留的模块
const indexContent = `import { AppRouteRecord } from '@/types/router'
import { dashboardRoutes } from './dashboard'
import { systemRoutes } from './system'
import { resultRoutes } from './result'
import { exceptionRoutes } from './exception'
/**
* 导出所有模块化路由
*/
export const routeModules: AppRouteRecord[] = [
dashboardRoutes,
systemRoutes,
resultRoutes,
exceptionRoutes
]
`
await fs.writeFile(path.join(modulesPath, 'index.ts'), indexContent, 'utf-8')
console.log(` ${icons.success} ${fmt.success('清理路由模块完成')}`)
} catch (err) {
console.log(` ${icons.error} ${fmt.error('清理路由模块失败')}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
}
}
// 清理路由别名
async function cleanRoutesAlias() {
const routesAliasPath = path.resolve(process.cwd(), 'src/router/routesAlias.ts')
try {
const cleanedAlias = `/**
* 公共路由别名
# 存放系统级公共路由路径,如布局容器、登录页等
*/
export enum RoutesAlias {
Layout = '/index/index', // 布局容器
Login = '/auth/login' // 登录页
}
`
await fs.writeFile(routesAliasPath, cleanedAlias, 'utf-8')
console.log(` ${icons.success} ${fmt.success('重写路由别名配置完成')}`)
} catch (err) {
console.log(` ${icons.error} ${fmt.error('清理路由别名失败')}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
}
}
// 清理变更日志
async function cleanChangeLog() {
const changeLogPath = path.resolve(process.cwd(), 'src/mock/upgrade/changeLog.ts')
try {
const cleanedChangeLog = `import { ref } from 'vue'
interface UpgradeLog {
version: string // 版本号
title: string // 更新标题
date: string // 更新日期
detail?: string[] // 更新内容
requireReLogin?: boolean // 是否需要重新登录
remark?: string // 备注
}
export const upgradeLogList = ref<UpgradeLog[]>([])
`
await fs.writeFile(changeLogPath, cleanedChangeLog, 'utf-8')
console.log(` ${icons.success} ${fmt.success('清空变更日志数据完成')}`)
} catch (err) {
console.log(` ${icons.error} ${fmt.error('清理变更日志失败')}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
}
}
// 清理语言文件
async function cleanLanguageFiles() {
const languageFiles = [
{ path: 'src/locales/langs/zh.json', name: '中文语言文件' },
{ path: 'src/locales/langs/en.json', name: '英文语言文件' }
]
for (const { path: langPath, name } of languageFiles) {
try {
const fullPath = path.resolve(process.cwd(), langPath)
const content = await fs.readFile(fullPath, 'utf-8')
const langData = JSON.parse(content)
const menusToRemove = [
'widgets',
'template',
'article',
'examples',
'safeguard',
'plan',
'help'
]
if (langData.menus) {
menusToRemove.forEach((menuKey) => {
if (langData.menus[menuKey]) {
delete langData.menus[menuKey]
}
})
if (langData.menus.dashboard) {
if (langData.menus.dashboard.analysis) {
delete langData.menus.dashboard.analysis
}
if (langData.menus.dashboard.ecommerce) {
delete langData.menus.dashboard.ecommerce
}
}
if (langData.menus.system) {
const systemKeysToRemove = [
'nested',
'menu1',
'menu2',
'menu21',
'menu3',
'menu31',
'menu32',
'menu321'
]
systemKeysToRemove.forEach((key) => {
if (langData.menus.system[key]) {
delete langData.menus.system[key]
}
})
}
}
await fs.writeFile(fullPath, JSON.stringify(langData, null, 2), 'utf-8')
console.log(` ${icons.success} ${fmt.success(`清理${name}完成`)}`)
} catch (err) {
console.log(` ${icons.error} ${fmt.error(`清理${name}失败`)}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
}
}
}
// 清理快速入口组件
async function cleanFastEnterComponent() {
const fastEnterPath = path.resolve(process.cwd(), 'src/config/fastEnter.ts')
try {
const cleanedFastEnter = `/**
* 快速入口配置
* 包含:应用列表、快速链接等配置
*/
import { WEB_LINKS } from '@/utils/constants'
import type { FastEnterConfig } from '@/types/config'
const fastEnterConfig: FastEnterConfig = {
// 显示条件(屏幕宽度)
minWidth: 1200,
// 应用列表
applications: [
{
name: '工作台',
description: '系统概览与数据统计',
icon: 'ri:pie-chart-line',
iconColor: '#377dff',
enabled: true,
order: 1,
routeName: 'Console'
},
{
name: '官方文档',
description: '使用指南与开发文档',
icon: 'ri:bill-line',
iconColor: '#ffb100',
enabled: true,
order: 2,
link: WEB_LINKS.DOCS
},
{
name: '技术支持',
description: '技术支持与问题反馈',
icon: 'ri:user-location-line',
iconColor: '#ff6b6b',
enabled: true,
order: 3,
link: WEB_LINKS.COMMUNITY
},
{
name: '哔哩哔哩',
description: '技术分享与交流',
icon: 'ri:bilibili-line',
iconColor: '#FB7299',
enabled: true,
order: 4,
link: WEB_LINKS.BILIBILI
}
],
// 快速链接
quickLinks: [
{
name: '登录',
enabled: true,
order: 1,
routeName: 'Login'
},
{
name: '注册',
enabled: true,
order: 2,
routeName: 'Register'
},
{
name: '忘记密码',
enabled: true,
order: 3,
routeName: 'ForgetPassword'
},
{
name: '个人中心',
enabled: true,
order: 4,
routeName: 'UserCenter'
}
]
}
export default Object.freeze(fastEnterConfig)
`
await fs.writeFile(fastEnterPath, cleanedFastEnter, 'utf-8')
console.log(` ${icons.success} ${fmt.success('清理快速入口配置完成')}`)
} catch (err) {
console.log(` ${icons.error} ${fmt.error('清理快速入口配置失败')}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
}
}
// 更新菜单接口
async function updateMenuApi() {
const apiPath = path.resolve(process.cwd(), 'src/api/system-manage.ts')
try {
const content = await fs.readFile(apiPath, 'utf-8')
const updatedContent = content.replace(
"url: '/api/v3/system/menus'",
"url: '/api/v3/system/menus/simple'"
)
await fs.writeFile(apiPath, updatedContent, 'utf-8')
console.log(` ${icons.success} ${fmt.success('更新菜单接口完成')}`)
} catch (err) {
console.log(` ${icons.error} ${fmt.error('更新菜单接口失败')}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
}
}
// 用户确认函数
async function getUserConfirmation(): Promise<boolean> {
const { createInterface } = await import('readline')
return new Promise((resolve) => {
const rl = createInterface({
input: process.stdin,
output: process.stdout
})
console.log(
` ${fmt.highlight('请输入')} ${fmt.success('yes')} ${fmt.highlight('确认执行清理操作,或按 Enter 取消')}`
)
console.log()
process.stdout.write(` ${icons.arrow} `)
rl.question('', (answer: string) => {
rl.close()
resolve(answer.toLowerCase().trim() === 'yes')
})
})
}
// 显示清理警告
async function showCleanupWarning() {
createCard('安全警告', [
`${fmt.warning('此操作将永久删除以下演示内容,且无法恢复!')}`,
`${fmt.dim('请仔细阅读清理列表,确认后再继续操作')}`
])
const cleanupItems = [
{
icon: icons.image,
name: '图片资源',
desc: '演示用的封面图片、3D图片、运维图片等',
color: theme.orange
},
{
icon: icons.file,
name: '演示页面',
desc: 'widgets、template、article、examples、safeguard等页面',
color: theme.purple
},
{
icon: icons.code,
name: '路由模块文件',
desc: '删除演示路由模块,只保留核心模块(dashboard、system、result、exception)',
color: theme.primary
},
{
icon: icons.link,
name: '路由别名',
desc: '重写routesAlias.ts,移除演示路由别名',
color: theme.info
},
{
icon: icons.data,
name: 'Mock数据',
desc: '演示用的JSON数据、文章列表、评论数据等',
color: theme.success
},
{
icon: icons.globe,
name: '多语言文件',
desc: '清理中英文语言包中的演示菜单项',
color: theme.warning
},
{ icon: icons.map, name: '地图组件', desc: '移除art-map-chart地图组件', color: theme.error },
{ icon: icons.chat, name: '评论组件', desc: '移除comment-widget评论组件', color: theme.orange },
{
icon: icons.bolt,
name: '快速入口',
desc: '移除分析页、礼花效果、聊天、更新日志、定价、留言管理等无效项目',
color: theme.purple
}
]
console.log(` ${fmt.badge('', theme.bgRed)} ${fmt.title('将要清理的内容')}`)
console.log()
cleanupItems.forEach((item, index) => {
console.log(` ${item.color}${theme.reset} ${fmt.highlight(`${index + 1}. ${item.name}`)}`)
console.log(` ${fmt.dim(item.desc)}`)
})
console.log()
console.log(` ${fmt.badge('', theme.bgGreen)} ${fmt.title('保留的功能模块')}`)
console.log()
const preservedModules = [
{ name: 'Dashboard', desc: '工作台页面' },
{ name: 'System', desc: '系统管理模块' },
{ name: 'Result', desc: '结果页面' },
{ name: 'Exception', desc: '异常页面' },
{ name: 'Auth', desc: '登录注册功能' },
{ name: 'Core Components', desc: '核心组件库' }
]
preservedModules.forEach((module) => {
console.log(` ${icons.check} ${fmt.success(module.name)} ${fmt.dim(`- ${module.desc}`)}`)
})
console.log()
createDivider()
console.log()
}
// 显示统计信息
async function showStats() {
const duration = Date.now() - stats.startTime
const seconds = (duration / 1000).toFixed(2)
console.log()
createCard('清理统计', [
`${fmt.success('成功删除')}: ${fmt.highlight(stats.deletedFiles.toString())} 个文件`,
`${fmt.info('涉及路径')}: ${fmt.highlight(stats.deletedPaths.toString())} 个目录/文件`,
...(stats.failedPaths > 0
? [
`${icons.error} ${fmt.error('删除失败')}: ${fmt.highlight(stats.failedPaths.toString())} 个路径`
]
: []),
`${fmt.info('耗时')}: ${fmt.highlight(seconds)} 秒`
])
}
// 创建成功横幅
function createSuccessBanner() {
console.log()
console.log(
fmt.gradient(' ╔══════════════════════════════════════════════════════════════════╗')
)
console.log(
fmt.gradient(' ║ ║')
)
console.log(
` ║ ${icons.star} ${fmt.success('清理完成!项目已准备就绪')} ${icons.rocket} ║`
)
console.log(
` ║ ${fmt.dim('现在可以开始您的开发之旅了!')} ║`
)
console.log(
fmt.gradient(' ║ ║')
)
console.log(
fmt.gradient(' ╚══════════════════════════════════════════════════════════════════╝')
)
console.log()
}
// 主函数
async function main() {
// 清屏并显示横幅
console.clear()
createModernBanner()
// 显示清理警告
await showCleanupWarning()
// 统计文件数量
console.log(` ${fmt.info('正在统计文件数量...')}`)
stats.totalFiles = await countAllFiles()
console.log(` ${fmt.info('即将清理')}: ${fmt.highlight(stats.totalFiles.toString())} 个文件`)
console.log(` ${fmt.dim(`涉及 ${targets.length} 个目录/文件路径`)}`)
console.log()
// 用户确认
const confirmed = await getUserConfirmation()
if (!confirmed) {
console.log(` ${fmt.warning('操作已取消,清理中止')}`)
console.log()
return
}
console.log()
console.log(` ${icons.check} ${fmt.success('确认成功,开始清理...')}`)
console.log()
// 开始清理过程
console.log(` ${fmt.badge('步骤 1/6', theme.bgBlue)} ${fmt.title('删除演示文件')}`)
console.log()
for (let i = 0; i < targets.length; i++) {
await remove(targets[i], i)
}
console.log()
console.log(` ${fmt.badge('步骤 2/6', theme.bgBlue)} ${fmt.title('清理路由模块')}`)
console.log()
await cleanRouteModules()
console.log()
console.log(` ${fmt.badge('步骤 3/6', theme.bgBlue)} ${fmt.title('重写路由别名')}`)
console.log()
await cleanRoutesAlias()
console.log()
console.log(` ${fmt.badge('步骤 4/6', theme.bgBlue)} ${fmt.title('清空变更日志')}`)
console.log()
await cleanChangeLog()
console.log()
console.log(` ${fmt.badge('步骤 5/6', theme.bgBlue)} ${fmt.title('清理语言文件')}`)
console.log()
await cleanLanguageFiles()
console.log()
console.log(` ${fmt.badge('步骤 6/7', theme.bgBlue)} ${fmt.title('清理快速入口')}`)
console.log()
await cleanFastEnterComponent()
console.log()
console.log(` ${fmt.badge('步骤 7/7', theme.bgBlue)} ${fmt.title('更新菜单接口')}`)
console.log()
await updateMenuApi()
// 显示统计信息
await showStats()
// 显示成功横幅
createSuccessBanner()
}
main().catch((err) => {
console.log()
console.log(` ${icons.error} ${fmt.error('清理脚本执行出错')}`)
console.log(` ${fmt.dim('错误详情: ' + err)}`)
console.log()
process.exit(1)
})
@@ -0,0 +1,41 @@
<template>
<ElConfigProvider
size="default"
:locale="locales[language]"
:z-index="3000"
:card="{
shadow: 'never'
}"
>
<RouterView></RouterView>
</ElConfigProvider>
</template>
<script setup lang="ts">
import { useUserStore } from './store/modules/user'
import zh from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
import { systemUpgrade } from './utils/sys'
import { toggleTransition } from './utils/ui/animation'
import { checkStorageCompatibility } from './utils/storage'
import { initializeTheme } from './hooks/core/useTheme'
const userStore = useUserStore()
const { language } = storeToRefs(userStore)
const locales = {
zh: zh,
en: en
}
onBeforeMount(() => {
toggleTransition(true)
initializeTheme()
})
onMounted(() => {
checkStorageCompatibility()
toggleTransition(false)
systemUpgrade()
})
</script>
@@ -0,0 +1,27 @@
import request from '@/utils/http'
/**
* 认证 API(37du 重构版,对接 cool-admin 后端 /api/admin/*)
*/
/** 登录(统一账户,POST /api/admin/auth) */
export function fetchLogin(params: Api.Auth.LoginParams) {
return request.post<Api.Auth.LoginResponse>({
url: '/api/admin/auth',
data: { account: params.account, password: params.password }
})
}
/** 获取当前账号信息(GET /api/admin/me) */
export function fetchGetUserInfo() {
return request.get<Api.Auth.UserInfo>({
url: '/api/admin/me'
})
}
/** 获取当前账号的业务菜单树 + 权限标识(GET /api/admin/me/menus) */
export function fetchUserMenus() {
return request.get<Api.Auth.MenuData>({
url: '/api/admin/me/menus'
})
}
@@ -0,0 +1,266 @@
import request from '@/utils/http'
/**
* 37du 控制台业务 API(对接 cool-admin 后端 /api/admin/*)
* 响应统一由请求层归一:cool-admin 信封 / 裸数据均返回业务数据本体
*/
/** 概览 */
export function fetchOverview() {
return request.get<any>({ url: '/api/admin/overview' })
}
/** 数据看板 */
export function fetchStats() {
return request.get<any>({ url: '/api/admin/stats' })
}
/** 插件列表 */
export function fetchPlugins(params: { page?: number; page_size?: number; q?: string }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/plugins', params })
}
/** 上传发布插件包(multipart) */
export function uploadPlugin(file: File, params: { plugin_id: string; name?: string; version: string }) {
const fd = new FormData()
fd.append('file', file)
return request.post<any>({ url: '/api/admin/pkg', data: fd, params, timeout: 300000 })
}
/** 删除插件 */
export function deletePlugin(plugin_id: string) {
return request.post<any>({ url: '/api/admin/plugin/delete', data: { plugin_id } })
}
/** 更新插件元信息/状态/强制更新 */
export function patchPlugin(plugin_id: string, body: any) {
return request.post<any>({ url: '/api/admin/plugin/patch', params: { plugin_id }, data: body })
}
// ==================== 字典(可维护枚举,如场景分类 plugin_category) ====================
/** 字典项列表(sort,id 升序) */
export function fetchDictItems(key: string) {
return request.get<{ items: { id: number; label: string; sort: number }[] }>({ url: `/api/admin/dict/${key}/items` })
}
/** 新增字典项 */
export function addDictItem(key: string, label: string) {
return request.post<any>({ url: `/api/admin/dict/${key}/items`, data: { label } })
}
/** 改名 / 上移下移 */
export function updateDictItem(key: string, id: number, body: { label?: string; move?: 'up' | 'down' }) {
return request.put<any>({ url: `/api/admin/dict/${key}/items/${id}`, data: body })
}
/** 删除字典项(不影响已引用该值的业务数据) */
export function deleteDictItem(key: string, id: number) {
return request.del<any>({ url: `/api/admin/dict/${key}/items/${id}` })
}
/** 账号列表 */
export function fetchAccounts(params: { page?: number; page_size?: number; q?: string }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/accounts', params })
}
/** 新建账号 */
export function createAccount(body: any) {
return request.post<any>({ url: '/api/admin/account', data: body })
}
/** 更新账号 */
export function updateAccount(body: any) {
return request.post<any>({ url: '/api/admin/account/update', data: body })
}
/** 重置密码 */
export function resetAccountPwd(body: { account: string; new_password: string }) {
return request.post<any>({ url: '/api/admin/account/reset_pwd', data: body })
}
/** 删除账号 */
export function deleteAccount(account: string) {
return request.post<any>({ url: '/api/admin/account/delete', data: { account } })
}
/** 授权页数据(插件 + 账号) */
export function fetchGrantData() {
return request.get<{ plugins: any[]; accounts: any[] }>({ url: '/api/admin/grant_data' })
}
/** 某账号授权明细 */
export function fetchAccountGrants(account: string) {
return request.get<any>({ url: '/api/admin/account_grants', params: { account } })
}
/** 授予/撤销插件(granted=false 即撤销整行) */
export function grantPlugin(body: any) {
return request.post<any>({ url: '/api/admin/account_plugins', data: body })
}
/** 授予/撤销平台 */
export function grantPlatform(body: any) {
return request.post<any>({ url: '/api/admin/account_platforms', data: body })
}
// ==================== 双向批量授权(新授权工作台) ====================
/** 授权矩阵总览(账号 × 插件 + 平台白名单,一次拉全量) */
export function fetchGrantsMatrix() {
return request.get<any>({ url: '/api/admin/grants/matrix' })
}
/** 插件维度:该插件已授权账号列表 */
export function fetchPluginGrants(pluginId: string) {
return request.get<any>({ url: '/api/admin/plugin_grants', params: { plugin_id: pluginId } })
}
/** 批量授权/更新(事务 upsert) */
export function batchPluginGrants(body: { plugin_id: string; items: { account: string; can_download: boolean; can_run: boolean }[] }) {
return request.post<any>({ url: '/api/admin/plugin_grants/batch', data: body, timeout: 60000 })
}
/** 批量撤销 */
export function revokePluginGrants(body: { plugin_id: string; accounts: string[] }) {
return request.post<any>({ url: '/api/admin/plugin_grants/revoke', data: body, timeout: 60000 })
}
/** 审计日志 */
export function fetchAudit(params: { page?: number; page_size?: number; action?: string; q?: string }) {
return request.get<{ items: any[]; total: number; today: number }>({ url: '/api/admin/audit', params })
}
/** 运行记录 */
export function fetchReports(params: { page?: number; page_size?: number; status?: string; q?: string }) {
return request.get<{ items: any[]; total: number; today: number; failed: number }>({ url: '/api/admin/reports', params })
}
/** 设备列表 */
export function fetchDevices(params: { page?: number; page_size?: number }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/devices', params })
}
/** 设备汇总(升级进度) */
export function fetchDevicesSummary() {
return request.get<any>({ url: '/api/admin/devices/summary' })
}
/** 通知列表(管理) */
export function fetchNotifications(params: { page?: number; page_size?: number; q?: string }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/notifications', params })
}
/** 最新有效通知(页眉通知中心,active 且未过期) */
export function fetchLatestNotifications(limit: number = 30) {
return request.get<{ items: any[] }>({ url: '/api/admin/notifications/latest', params: { limit } })
}
/** 创建通知 */
export function createNotification(body: any) {
return request.post<any>({ url: '/api/admin/notifications', data: body })
}
/** 启停通知 */
export function toggleNotification(id: number, active: boolean) {
return request.put<any>({ url: `/api/admin/notifications/${id}`, params: { active } })
}
/** 删除通知 */
export function deleteNotification(id: number) {
return request.del<any>({ url: `/api/admin/notifications/${id}` })
}
/** 凭证管理列表 */
export function fetchCredsManage(params: { page?: number; page_size?: number }) {
return request.get<any>({ url: '/api/admin/creds/manage', params })
}
/** 录入凭证明文源 */
export function seedCreds(body: any) {
return request.post<any>({ url: '/api/admin/creds/seed', data: body })
}
/** 大文件源列表 */
export function fetchFileSources(params: { category?: string; page?: number; page_size?: number }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/file-sources', params })
}
/** 登记/覆盖大文件源 */
export function upsertFileSource(body: any) {
return request.post<any>({ url: '/api/admin/file-sources', data: body })
}
/** 启停/改说明 */
export function patchFileSource(id: number, body: any) {
return request.put<any>({ url: `/api/admin/file-sources/${id}`, data: body })
}
/** 删除大文件源 */
export function deleteFileSource(id: number) {
return request.del<any>({ url: `/api/admin/file-sources/${id}` })
}
// ==================== 个人中心(自助) ====================
/** 自助修改密码(旧密码校验,新密码≥8位,成功后 must_change_pwd 清零) */
export function changePassword(body: { account: string; old_password: string; new_password: string }) {
return request.post<any>({ url: '/api/admin/password', data: body })
}
/** 上传头像(multipart,file 字段) */
export function uploadAvatar(file: File, account: string) {
const fd = new FormData()
fd.append('file', file)
return request.post<any>({ url: '/api/admin/avatar', data: fd, params: { account }, timeout: 30000 })
}
// ==================== 集中日志(运行日志 / 客户端壳日志) ====================
/** 运行日志列表(分页 + 账号/设备/插件/状态/关键字/近N天筛选) */
export function fetchRunLogs(params: {
page?: number; page_size?: number; account?: string; device?: string;
plugin?: string; status?: string; q?: string; days?: number;
}) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/run-logs', params })
}
/** 单次运行日志详情(含日志正文) */
export function fetchRunLogDetail(runId: string) {
return request.get<any>({ url: `/api/admin/run-logs/${encodeURIComponent(runId)}` })
}
/** 客户端壳日志设备列表 */
export function fetchDeviceLogs(params: { page?: number; page_size?: number; account?: string; q?: string }) {
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/device-logs', params })
}
/** 设备壳日志尾部内容 */
export function fetchDeviceLogDetail(deviceId: string) {
return request.get<any>({ url: `/api/admin/device-logs/${encodeURIComponent(deviceId)}` })
}
/** 壳日志全文下载(需鉴权头,用 fetch 取 blob 触发浏览器下载) */
export async function downloadDeviceLog(deviceId: string, filename?: string) {
const { useUserStore } = await import('@/store/modules/user')
const token = useUserStore().accessToken
const base = (import.meta.env.VITE_API_URL as string) || ''
const res = await fetch(`${base}/api/admin/device-logs/${encodeURIComponent(deviceId)}/download`, {
headers: { 'X-Admin-Token': token || '' },
})
if (!res.ok) throw new Error(`下载失败 HTTP ${res.status}`)
const blob = await res.blob()
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = filename || `shell-${deviceId}.log`
document.body.appendChild(a)
a.click()
a.remove()
setTimeout(() => URL.revokeObjectURL(url), 5000)
}
/** 手动触发一次保留期清理 */
export function cleanupLogs() {
return request.post<any>({ url: '/api/admin/logs/cleanup' })
}
@@ -0,0 +1,162 @@
import request from '@/utils/http'
/**
* 系统管理 API(37du 控制台侧封装,走 /api/admin/sys/*)
* 身份统一为控制台管理员票据(requireAdmin),管理 cool-admin RBAC 表(base_sys_*)
*/
/** 控制台用户(base_sys_user,含部门名/角色) */
export function sysUsers() {
return request.get<{ items: any[] }>({ url: '/api/admin/sys/users' })
}
/** 角色 */
export function sysRoles() {
return request.get<{ items: any[] }>({ url: '/api/admin/sys/roles' })
}
/** 菜单(树) */
export function sysMenus() {
return request.get<{ items: any[] }>({ url: '/api/admin/sys/menus' })
}
/** 部门(树) */
export function sysDepartments() {
return request.get<{ items: any[] }>({ url: '/api/admin/sys/departments' })
}
// ==================== 用户管理 ====================
/** 用户详情(含 roleIdList,不含密码) */
export function sysUserInfo(id: number) {
return request.get<any>({ url: '/api/admin/sys/user/info', params: { id } })
}
/** 新增用户 */
export function sysUserAdd(body: {
username: string
password: string
nickName?: string
name?: string
phone?: string
departmentId?: number | null
status?: number
roleIdList?: number[]
remark?: string
}) {
return request.post<any>({ url: '/api/admin/sys/user/add', data: body })
}
/** 编辑用户(username 不可改;password 留空不改) */
export function sysUserEdit(body: {
id: number
nickName?: string
name?: string
phone?: string
departmentId?: number | null
status?: number
roleIdList?: number[]
remark?: string
password?: string
}) {
return request.post<any>({ url: '/api/admin/sys/user/edit', data: body })
}
/** 删除用户(内置 admin 保护) */
export function sysUserDel(id: number) {
return request.post<any>({ url: '/api/admin/sys/user/del', data: { id } })
}
// ==================== 角色管理 ====================
/** 角色详情(含 menuIdList/departmentIdList) */
export function sysRoleInfo(id: number) {
return request.get<any>({ url: '/api/admin/sys/role/info', params: { id } })
}
/** 新增角色(可带授权) */
export function sysRoleAdd(body: {
name: string
label?: string
remark?: string
relevance?: boolean
menuIdList?: number[]
departmentIdList?: number[]
}) {
return request.post<any>({ url: '/api/admin/sys/role/add', data: body })
}
/** 编辑角色(含授权) */
export function sysRoleEdit(body: {
id: number
name?: string
label?: string
remark?: string
relevance?: boolean
menuIdList?: number[]
departmentIdList?: number[]
}) {
return request.post<any>({ url: '/api/admin/sys/role/edit', data: body })
}
/** 删除角色(内置超管保护) */
export function sysRoleDel(id: number) {
return request.post<any>({ url: '/api/admin/sys/role/del', data: { id } })
}
// ==================== 菜单管理 ====================
/** 新增菜单(type: 0目录 1菜单 2按钮) */
export function sysMenuAdd(body: {
parentId?: number | null
name: string
router?: string
perms?: string
icon?: string
type: number
orderNum?: number
viewPath?: string
keepAlive?: boolean
isShow?: boolean
}) {
return request.post<any>({ url: '/api/admin/sys/menu/add', data: body })
}
/** 编辑菜单 */
export function sysMenuEdit(body: {
id: number
parentId?: number | null
name?: string
router?: string
perms?: string
icon?: string
type?: number
orderNum?: number
viewPath?: string
keepAlive?: boolean
isShow?: boolean
}) {
return request.post<any>({ url: '/api/admin/sys/menu/edit', data: body })
}
/** 删除菜单(有子级拒绝) */
export function sysMenuDel(id: number) {
return request.post<any>({ url: '/api/admin/sys/menu/del', data: { id } })
}
// ==================== 部门管理 ====================
/** 新增部门 */
export function sysDeptAdd(body: { parentId?: number | null; name: string; orderNum?: number }) {
return request.post<any>({ url: '/api/admin/sys/dept/add', data: body })
}
/** 编辑部门 */
export function sysDeptEdit(body: { id: number; parentId?: number | null; name?: string; orderNum?: number }) {
return request.post<any>({ url: '/api/admin/sys/dept/edit', data: body })
}
/** 删除部门(有子级或在用用户拒绝) */
export function sysDeptDel(id: number) {
return request.post<any>({ url: '/api/admin/sys/dept/del', data: { id } })
}
@@ -0,0 +1,25 @@
import request from '@/utils/http'
import { AppRouteRecord } from '@/types/router'
// 获取用户列表
export function fetchGetUserList(params: Api.SystemManage.UserSearchParams) {
return request.get<Api.SystemManage.UserList>({
url: '/api/user/list',
params
})
}
// 获取角色列表
export function fetchGetRoleList(params: Api.SystemManage.RoleSearchParams) {
return request.get<Api.SystemManage.RoleList>({
url: '/api/role/list',
params
})
}
// 获取菜单列表
export function fetchGetMenuList() {
return request.get<AppRouteRecord[]>({
url: '/api/v3/system/menus/simple'
})
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

@@ -0,0 +1 @@
<svg viewBox="0 0 400 300" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="a" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="94" y="34" width="212" height="233"><path d="M306 34H94v233h212V34Z" fill="#fff"/></mask><g mask="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M234.427 155.64h38.36V69.6h-38.36v86.04ZM113.326 155.64h121.1V69.6h-121.1v86.04Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M130.126 155.354h104.2v-72.95h-104.2v72.95ZM236.369 71.05s0 3.3 1.65 5.05c2.33 2.52 7.38-.2 7.38-.2s-1.75 5.15-1.55 10.19c.29 8.24 6.99 9.51 10 4.75 4.56 4.85 8.94-.29 9.52-2.62 4.27 4.76 9.32-.87 9.32-.87v-6.3l-23.99-12.13-12.33 2.13Z" fill="#C7DEFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="M234.429 155.641h-121.1l-15.93 32.11h121.1l15.93-32.11Z" fill="#fff"/><path d="M234.427 69.6h38.46v86.04M113.326 146.52V69.6h121.1M234.429 155.641l-15.93 32.11h-121.1l15.93-32.11h111.39" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M226.37 159.715H116.82l-12.04 23.86H215l11.37-23.86Z" fill="#006EFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="m288.807 187.751-15.92-32.11h-38.46l16.02 32.11h38.36Z" fill="#fff"/><path d="m238.607 163.981 11.84 23.77h38.36l-15.92-32.11h-38.46" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M207.336 223.734c-3.69-13.77-15.44-23.86-29.33-23.86h-8.65s-27.09 14.94-27.09 33.27c0 18.34 25.44 33.18 25.44 33.18h10.4c13.79-.1 25.44-10.19 29.13-23.87 1.75-12.51 0-18.62.1-18.72Z" fill="#C7DEFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="M243.459 240.421c3.98 0 7.28-3.3 7.28-7.27 0-3.98-3.3-7.28-7.28-7.28h-31.08c-3.98 0-7.28 3.3-7.28 7.28 0 3.97 3.3 7.27 7.28 7.27h31.08Z" fill="#C7DEFF"/><path d="M210.342 223.737c-4.08-13.87-16.9-23.96-32.05-23.96H168.972s-29.62 14.94-29.62 33.37 27.87 33.37 27.87 33.37h11.27c15.05-.1 27.77-10.19 31.75-23.96" stroke="#071F4D"/><path d="M212.379 240.421c-3.98 0-7.28-3.3-7.28-7.27m0 0c0-3.98 3.3-7.28 7.28-7.28" stroke="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M168.781 199.777c-18.45 0-33.41 14.94-33.41 33.37s14.96 33.37 33.41 33.37c18.45 0 33.4-14.94 33.4-33.37s-14.95-33.37-33.4-33.37Z" fill="#006EFF"/><path d="M168.781 199.777c-18.45 0-33.41 14.94-33.41 33.37s14.96 33.37 33.41 33.37c18.45 0 33.4-14.94 33.4-33.37s-14.95-33.37-33.4-33.37Z" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M168.775 209.38c-13.14 0-23.79 10.64-23.79 23.77 0 13.12 10.65 23.76 23.79 23.76 13.14 0 23.8-10.64 23.8-23.76 0-13.13-10.66-23.77-23.8-23.77Z" fill="#00E4E5"/><path d="M162.174 223.736a17.48 17.48 0 0 1 14.76-8.05M159.455 231.982c.1-1.36.29-2.62.68-3.88" stroke="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M173.535 209.87c-1.55-.3-3.11-.49-4.76-.49-13.11 0-23.79 10.67-23.79 23.77 0 13.09 10.68 23.76 23.79 23.76 1.65 0 3.21-.19 4.76-.48-10.88-2.23-19.03-11.84-19.03-23.28 0-11.45 8.15-21.05 19.03-23.28Z" fill="#071F4D"/><path d="M219.957 225.774h23.6c4.08 0 7.38 3.3 7.38 7.37m0 0c0 4.08-3.3 7.37-7.38 7.37h-20.1M212.091 225.774h3.3" stroke="#071F4D"/><path d="m248.894 34.485-.19 18.24c0 4.07-.39 5.23-2.14 6.79-8.15 6.88-10.97 9.02-9.22 12.9 1.45 3.2 6.79 2.23 9.61-1.55-.39 4.56-5.24 15.32-.58 18.04 4.37 2.52 6.89-3.49 6.89-3.49s.49 3.49 4.47 3.49c3.69 0 5.24-4.75 5.24-4.75s2.14 3.49 6.22 1.35c3.11-1.55 5.44-7.08 5.44-26.67v-24.35" fill="#fff"/><path d="m248.894 34.485-.19 18.24c0 4.07-.39 5.23-2.14 6.79-8.15 6.88-10.97 9.02-9.22 12.9 1.45 3.2 6.79 2.23 9.61-1.55-.39 4.56-5.24 15.32-.58 18.04 4.37 2.52 6.89-3.49 6.89-3.49s.49 3.49 4.47 3.49c3.69 0 5.24-4.75 5.24-4.75s2.14 3.49 6.22 1.35c3.11-1.55 5.44-7.08 5.44-26.67v-24.35" stroke="#071F4D"/><path d="M255.307 75.71s-.39 5.43-2.04 9.6l2.04-9.6Z" fill="#fff"/><path d="M255.307 75.71s-.39 5.43-2.04 9.6" stroke="#071F4D"/><path d="M264.921 75.323s-.68 5.24-2.04 8.63l2.04-8.63Z" fill="#fff"/><path d="M264.921 75.323s-.68 5.24-2.04 8.63M147.801 34.485v34.92M121.775 34.485v34.92M102.546 204.724v13.97M102.546 222.379v.87M102.546 197.934v3.49M115.268 206.955v26.29M115.268 239.451v5.34M244.43 197.643v11.93M244.43 213.939v3.49M270.359 201.232v33.76M115.369 47.774h-13.6M94.486 47.774h3.4M241.516 47.774h-84.1M280.168 47.774h25.35" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="m282.497 183.575-12.04-23.86h-27.29l11.36 23.86h27.97Z" fill="#00E4E5"/><path d="M234.427 134.88V69.6M234.427 140.412v7.66" stroke="#071F4D"/><path d="M220.831 228.684h16.99M240.934 228.684h2.43" stroke="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="m223.842 187.462 21.46-.2-10.97-20.66-10.49 20.86Z" fill="#071F4D"/></g></svg>

After

Width:  |  Height:  |  Size: 4.5 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.0 KiB

@@ -0,0 +1,5 @@
<svg
viewBox="0 0 400 300"
fill="none"
xmlns="http://www.w3.org/2000/svg"
><mask id="a" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="47" y="38" width="307" height="224"><path d="M353.3 38H47.5v223.8h305.8V38Z" fill="#fff"/></mask><g mask="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M299.2 200.6H61.6v5.1h240.3l-2.7-5.1Z" fill="#C7DEFF"/><path d="m308.9 185.8-6.5 20H183.7M332.3 127.6h10.6l-5 16.7-14.8-.1-7.2 21.1M328.8 127.4l13.6-39.6M307.6 166 337 84.7H180.6l-9.8 26.9h-10.5M296.6 196l4.3-11.8M157.2 149.2l6.4-17.7" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M324.8 93.1H188.5l-34.8 95.8h136.4l34.7-95.8ZM169.9 166.2l5-13.6-5 13.6Z" fill="#fff"/><path d="m169.9 166.2 5-13.6" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M324.8 93.1H188.5l-4 11.7h135.8l4.5-11.7Z" fill="#006EFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="M102.6 159.5h38.3l2.7 36.6h-38.4c-10.1 0-20.9-8.2-20.9-18.3 0-10.1 8.2-18.3 18.3-18.3Z" fill="#DEEBFC"/><path fill-rule="evenodd" clip-rule="evenodd" d="M84.3 174.102c2.5 3.4 10 5 17.9 2.8 16.6-6.5 23.8-3.9 23.8-3.9s.5-3.4 1.3-5c-5.8-3-15.4.3-26.1 3.1-10.7 2.8-15.8-2.5-15.8-2.5-.4 0-1.1 2.8-1.1 5.5Z" fill="#fff"/><path d="M96.5 194.2c-7.2-3.3-12.2-10.5-12.2-19m0 0c0-11.5 9.3-20.8 20.8-20.8h29.4" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M140.3 195.1c-8.4-2.7-14.5-10.6-14.5-19.8l14.5 19.8Zm-14.5-19.8c0-11.5 9.3-20.8 20.8-20.8l-20.8 20.8Zm20.8-20.8c11.5 0 20.8 9.3 20.8 20.8l-20.8-20.8Zm20.8 20.8c0 8.4-5 15.6-12.1 18.9l12.1-18.9Z" fill="#fff"/><path d="M140.3 195.1c-8.4-2.7-14.5-10.6-14.5-19.8m0 0c0-11.5 9.3-20.8 20.8-20.8m0 0c11.5 0 20.8 9.3 20.8 20.8m0 0c0 8.4-5 15.6-12.1 18.9" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M161.5 177.2c0-7.7-6.3-14-14-14s-14 6.3-14 14c0 5.8 3.5 10.8 8.6 12.9.1 0 5.8 1.6 10.7 0 5.3-1.7 8.7-7.1 8.7-12.9Z" fill="#00E4E5"/><path d="M140.5 190.1c-5.8-2.4-9.9-8.2-9.9-14.9 0-8.9 7.2-16.1 16.1-16.1 8.9 0 16.1 7.2 16.1 16.1 0 6.8-4.2 12.5-10.1 14.9M88.4 170.604c2.9 1.3 7.7 2.6 13.6.3 14.7-5.7 22.3-4.3 24.6-3.5M84.5 174.599s5.9 6.5 19 1.7c9.2-3.4 15.3-3.9 18.8-3.8" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M340.6 112.3h-55.2l-2.7 6.2H338l2.6-6.2Z" fill="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M236.8 117.9c-16.13 0-29.2 13.07-29.2 29.2s13.07 29.2 29.2 29.2 29.2-13.07 29.2-29.2-13.07-29.2-29.2-29.2Z" fill="#00E4E5"/><path d="M265 123.3c13.1 13.1 13.1 34.4 0 47.6M306 205.9h19.2M61.7 205.9h32.9M181.2 196.2h115.2M47.5 205.9h10v-9.7h73.8" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M146.7 179.2c-2.49 0-4.5 2.01-4.5 4.5s2.01 4.5 4.5 4.5 4.5-2.01 4.5-4.5-2.01-4.5-4.5-4.5Z" fill="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M169.5 196.2c3.9 0 7.1 3.2 7.1 7.1 0 3.9-3.2 7.1-7.1 7.1H144c-2.1 0-3.9 1.7-3.9 3.9v1c0 2.1 1.7 3.9 3.9 3.9h48c5.1 0 9.2 4.1 9.2 9.2s-4.1 9.3-9.2 9.2h-33.8c-2.3 0-4.1 1.8-4.1 4.1s1.8 4.1 4.1 4.1h4.2c4.4 0 8 3.6 8 8s-3.6 8-8 8H111c-3.7 0-6.8-3-6.8-6.8 0-3.7 3-6.8 6.8-6.8h.3c2.3 0 4.1-1.8 4.1-4.1s-1.8-4.1-4.1-4.1H79c-4.5 0-8.1-3.6-8.1-8.1s3.6-8.1 8.1-8.1h37.7c2.1 0 3.9-1.7 3.9-3.9 0-2.1-1.7-3.9-3.9-3.9h-7.9c-4.4 0-7.9-3.5-7.9-7.9s3.5-7.9 7.9-7.9h30.4c2.2 0 3.9-1.8 3.9-3.9V187c0-1.9 1.6-3.5 3.5-3.5s3.5 1.6 3.5 3.5v5.3c0 2.2 1.8 3.9 3.9 3.9h15.5Z" fill="#006EFF"/><path d="m227.8 138.5 18.7 18.7M227.8 157.2l18.7-18.7" stroke="#fff" stroke-width="6"/><path fill-rule="evenodd" clip-rule="evenodd" d="M194.8 96.9c-.99 0-1.8.81-1.8 1.8s.81 1.8 1.8 1.8 1.8-.81 1.8-1.8-.81-1.8-1.8-1.8ZM202.9 96.9c-.99 0-1.8.81-1.8 1.8s.81 1.8 1.8 1.8 1.8-.81 1.8-1.8-.81-1.8-1.8-1.8Z" fill="#fff"/><path d="m291.7 184.3-1.6 4.6h-121M298.1 166.7l22.5-61.9" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="m193 134.1 2.2-5.1h-19.4l-2.3 5.1H193ZM313.2 123.5l2.2-5.1h-24.5l-2.3 5.1h24.6Z" fill="#DEEBFC"/><path d="m164.5 159.2 19.8-54.6" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M199.6 119.8h-53.2l-4.4 9.3h53.2l4.4-9.3Z" fill="#00E4E5"/><path d="M151.3 129.1H142l4.4-9.3h16.9" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M353.3 169.4h-67.4l-4.8 12.2h67.3l4.9-12.2Z" fill="#006EFF"/><path d="M332.4 169.4h20.9l-4.9 12.2h-39.7M242.7 235.5v-4.8c0-3.8 3.1-7 7-7h20.2c3.8 0 7 3.1 7 7" stroke="#071F4D"/><path d="M261.1 235.5v-4.8c0-3.8 3.1-7 7-7h13.7c3.8 0 7 3.1 7 7v4.8M242.6 230.7h13.7M235.2 237.7h63.3M224 237.7h6.7" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M324.1 141.3H335l3.3-10.7h-10.2l-4 10.7Z" fill="#C7DEFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="M288.3 230.4c0-3.6-2.9-6.5-6.5-6.5h-14.2c-3.6 0-6.5 2.9-6.5 6.5v5.3h27.2v-5.3Z" fill="#071F4D"/><path d="M80.4 228.5H83M87.7 228.5h19.2M146.3 195.8v2c0 3.6-2.9 6.6-6.6 6.6H138M133.4 204.3h1.5M154 249.9h9.4" stroke="#DEEBFC"/><path d="m299.4 141.9 5.1-13.9" stroke="#071F4D"/></g></svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

@@ -0,0 +1 @@
<svg viewBox="0 0 400 300" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="a" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="44" y="42" width="312" height="217"><path d="M355.3 42H44v216.9h311.3V42Z" fill="#fff"/></mask><g mask="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M288.2 248.4h25.1v-30h-25.1v30Z" fill="#C7DEFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="M304.498 238.199c-1.5-3.9-5.9-15.4-4-21.6-2.9.8-3.3.1-5-.1-1.7-.1 0 10.7 2.2 16.4 1.7 4.5 2.1 11.1 2.1 13.6h5.4c.2-1.9.3-5.5-.7-8.3Z" fill="#fff"/><path d="M311.5 214.7v-1.6c0-.7-.6-1.3-1.3-1.3h-22.8c-.7 0-1.3.6-1.3 1.3v1.6" fill="#fff"/><path d="M311.5 214.7v-1.6c0-.7-.6-1.3-1.3-1.3h-22.8c-.7 0-1.3.6-1.3 1.3v1.6M290.2 214.7h21.4c1 0 1.8.8 1.8 1.8v29" stroke="#071F4D" stroke-width="1.096"/><path d="M284.3 245.6v-29c0-1 .8-1.8 1.8-1.8h1.6" fill="#fff"/><path d="M284.3 245.6v-29c0-1 .8-1.8 1.8-1.8h1.6" stroke="#071F4D" stroke-width="1.096"/><path d="M295.402 216.5c-.9 4.2-.4 9.7 2.8 17.5 2.4 5.9 1.9 10.2 1.8 12.3M300.502 216.5c-.9 4.2-.4 9.7 2.8 17.5 2.4 5.9 1.9 10.2 1.8 12.3" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="m331 258.4-.3-5.2H88.5l-1.2 5.2H331Z" fill="#C7DEFF"/><path d="M252.9 248.7H331M216.6 258.4H331M47.1 139.3l-2.6 1.5 42.7 117.6h129.2v-6.6" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="m247.2 248.6-40.4-111.3H50.5l40.3 111.3h156.4Z" fill="#fff"/><path d="m247.2 248.6-40.4-111.3H50.5l40.3 111.3h156.4Z" stroke="#071F4D"/><path d="m203.2 153.2 32.2 88.7H97.8l-32.3-88.7" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M72.2 146.9c-.77 0-1.4.63-1.4 1.4 0 .77.63 1.4 1.4 1.4.77 0 1.4-.63 1.4-1.4 0-.77-.63-1.4-1.4-1.4ZM79.3 146.9c-.77 0-1.4.63-1.4 1.4 0 .77.63 1.4 1.4 1.4.77 0 1.4-.63 1.4-1.4 0-.77-.63-1.4-1.4-1.4Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M263.5 171.2h80.3v-63.7h-80.3v63.7Z" fill="#C7DEFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="M290 143.9h-45.6l12.5 51.3H290v-51.3Z" fill="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M286 117.4h-29.3v77.8h92.9v-67.6l-55.9.6-7.7-10.8Z" fill="#00E4E5"/><path d="m332.6 127.6-38.9.6-7.7-10.8h-11.7M308.9 195.2h45.9M250.3 195.2h28.5M287.3 195.2h12.3" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M130.5 211.4H186v-44h-55.5v44Z" fill="#C7DEFF"/><path fill-rule="evenodd" clip-rule="evenodd" d="M148.7 192.5h-31.6l8.7 35.5h22.9v-35.5Z" fill="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M145.9 174.2h-20.2V228h64.1v-46.7l-38.6.4-5.3-7.5Z" fill="#006EFF"/><path d="m179 181.3-27.8.4-5.3-7.5h-7.7M176.2 201.7h19.2M163.2 210.7H195M172.1 228h-54.2M184.8 228h8.1M174.9 228h5.4" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="m293.2 155.7-6.4 6.3 15.3 15.3 22.7-22.6-6.4-6.4-16.3 16.3-8.9-8.9Z" fill="#fff"/><path d="M57.2 258.4h283.6M345.9 258.4h8.1M55.4 258.4h220.5M160.1 118.8l-1.2 2.7M156.7 127c-.3.8-.7 1.8-1.1 2.8M222 68.5c-1 .2-1.9.5-2.9.8M214.1 70.7c-5.8 1.9-11.3 4.4-16.5 7.4M195.4 79.5c-.9.5-1.7 1.1-2.5 1.6M314.2 98.5c-.6-.8-1.3-1.5-2-2.3M308.9 92.8c-4-4-8.3-7.6-13-10.8M293.9 80.7c-.8-.5-1.7-1.1-2.5-1.6" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M251.296 71.203c-3.6-1.5-18.5-2.9-21.8-1.9-1 5.8 4.9 13.5 4.9 13.5s6-9.9 16.9-11.6Z" fill="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M251.3 42.704c-6.5 6.7-7.8 13-8.8 19.3 24.4-1.1 36.3 13 42.8 20 3.2-9.1 7.8-23 7.2-29-7.1-6.4-20-11.7-41.2-10.3Z" fill="#C7DEFF"/><path d="M230 69.3c36.2-3.8 52 21.1 52 21.1s11.4-28.2 10.5-37.4c-7.3-6.5-23.3-12-45.6-10.1-9 6.3-15.6 18.7-16.9 26.4Z" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M161.604 70.7c-6 8.4-9.9 21.9-8.8 33.8 8.4 5.3 32.3 10.5 43.6 11.5 6.1-7.9 15.9-26 15.9-26s-32-4.8-50.7-19.3Z" fill="#C7DEFF"/><path d="M193.103 119.5c4.8-2.7 19.2-29.5 19.2-29.5s-35.8-5.4-53.7-21.8c-9.3 6.1-16.4 24.3-15 40.1 10.6 6.7 45.8 13.3 49.5 11.2Z" stroke="#071F4D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M189.5 111.6c-3 5.2-5.7 7.2-9.8 6.6 12.2 2.6 13.5 1.2 15.6-1.1 2.2-2.4 4.2-6.6 4.2-6.6s-3.1 2.5-10 1.1Z" fill="#071F4D"/><path d="M331 251.8v6.6M77 165.4l-2.7-6.7h7.8M222.8 228.9l2.8 6.6h-7.9" stroke="#071F4D"/></g></svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@@ -0,0 +1,292 @@
// 全局样式
// 顶部进度条颜色
#nprogress .bar {
z-index: 2400;
background-color: color-mix(in srgb, var(--theme-color) 70%, white);
}
#nprogress .peg {
box-shadow:
0 0 10px var(--theme-color),
0 0 5px var(--theme-color) !important;
}
#nprogress .spinner-icon {
border-top-color: var(--theme-color) !important;
border-left-color: var(--theme-color) !important;
}
// 处理移动端组件兼容性
@media screen and (max-width: 640px) {
* {
cursor: default !important;
}
}
// 背景滤镜
*,
::before,
::after {
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
}
// 色弱模式
.color-weak {
filter: invert(80%);
-webkit-filter: invert(80%);
}
#noop {
display: none;
}
// 语言切换选中样式
.langDropDownStyle {
// 选中项背景颜色
.is-selected {
background-color: var(--art-el-active-color) !important;
}
// 语言切换按钮菜单样式优化
.lang-btn-item {
.el-dropdown-menu__item {
padding-left: 13px !important;
padding-right: 6px !important;
margin-bottom: 3px !important;
}
&:last-child {
.el-dropdown-menu__item {
margin-bottom: 0 !important;
}
}
.menu-txt {
min-width: 60px;
display: block;
}
i {
font-size: 10px;
margin-left: 10px;
}
}
}
// 盒子默认边框
.page-content {
border: 1px solid var(--art-card-border) !important;
}
@mixin art-card-base($border-color, $shadow: none, $radius-diff: 4px) {
background: var(--default-box-color);
border: 1px solid #{$border-color} !important;
border-radius: calc(var(--custom-radius) + #{$radius-diff}) !important;
box-shadow: #{$shadow} !important;
--el-card-border-color: var(--default-border) !important;
}
.art-card,
.art-card-sm,
.art-card-xs {
border: 1px solid var(--art-card-border);
}
// 盒子边框
[data-box-mode='border-mode'] {
.page-content,
.art-table-card {
border: 1px solid var(--art-card-border) !important;
}
.art-card {
@include art-card-base(var(--art-card-border), none, 4px);
}
.art-card-sm {
@include art-card-base(var(--art-card-border), none, 0px);
}
.art-card-xs {
@include art-card-base(var(--art-card-border), none, -4px);
}
}
// 盒子阴影
[data-box-mode='shadow-mode'] {
.page-content,
.art-table-card {
box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.04) !important;
border: 1px solid var(--art-gray-200) !important;
}
.layout-sidebar {
border-right: 1px solid var(--art-card-border) !important;
}
.art-card {
@include art-card-base(
var(--art-gray-200),
(0 1px 3px 0 rgba(0, 0, 0, 0.03), 0 1px 2px -1px rgba(0, 0, 0, 0.08)),
4px
);
}
.art-card-sm {
@include art-card-base(
var(--art-gray-200),
(0 1px 3px 0 rgba(0, 0, 0, 0.03), 0 1px 2px -1px rgba(0, 0, 0, 0.08)),
2px
);
}
.art-card-xs {
@include art-card-base(
var(--art-gray-200),
(0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 1px -1px rgba(0, 0, 0, 0.08)),
-4px
);
}
}
// 元素全屏
.el-full-screen {
position: fixed;
top: 0;
left: 0;
right: 0;
width: 100vw !important;
height: 100% !important;
z-index: 2300;
margin-top: 0;
padding: 15px;
box-sizing: border-box;
background-color: var(--default-box-color);
display: flex;
flex-direction: column;
}
// 表格卡片
.art-table-card {
flex: 1;
display: flex;
flex-direction: column;
margin-top: 12px;
border-radius: calc(var(--custom-radius) / 2 + 2px) !important;
.el-card__body {
height: 100%;
overflow: hidden;
}
}
// 容器全高
.art-full-height {
height: var(--art-full-height);
display: flex;
flex-direction: column;
@media (max-width: 640px) {
height: auto;
}
}
// 徽章样式
.art-badge {
position: absolute;
top: 0;
right: 20px;
bottom: 0;
width: 6px;
height: 6px;
margin: auto;
background: #ff3860;
border-radius: 50%;
animation: breathe 1.5s ease-in-out infinite;
&.art-badge-horizontal {
right: 0;
}
&.art-badge-mixed {
right: 0;
}
&.art-badge-dual {
right: 5px;
top: 5px;
bottom: auto;
}
}
// 文字徽章样式
.art-text-badge {
position: absolute;
top: 0;
right: 12px;
bottom: 0;
min-width: 20px;
height: 18px;
line-height: 17px;
padding: 0 5px;
margin: auto;
font-size: 10px;
color: #fff;
text-align: center;
background: #fd4e4e;
border-radius: 4px;
}
@keyframes breathe {
0% {
opacity: 0.7;
transform: scale(1);
}
50% {
opacity: 1;
transform: scale(1.1);
}
100% {
opacity: 0.7;
transform: scale(1);
}
}
// 修复老机型 loading 定位问题
.art-loading-fix {
position: fixed !important;
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
width: 100vw !important;
height: 100vh !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
}
.art-loading-fix .el-loading-spinner {
position: static !important;
top: auto !important;
left: auto !important;
transform: none !important;
}
// 去除移动端点击背景色
@media screen and (max-width: 1180px) {
* {
-webkit-tap-highlight-color: transparent;
}
}
@@ -0,0 +1,93 @@
/*
* 深色主题
* 单页面移除深色主题 document.getElementsByTagName("html")[0].removeAttribute('class')
*/
$font-color: rgba(#ffffff, 0.85);
/* 覆盖element-plus默认深色背景色 */
html.dark {
// element-plus
--el-bg-color: var(--default-box-color);
--el-text-color-regular: #{$font-color};
// 富文本编辑器
// 工具栏背景颜色
--w-e-toolbar-bg-color: #18191c;
// 输入区域背景颜色
--w-e-textarea-bg-color: #090909;
// 工具栏文字颜色
--w-e-toolbar-color: var(--art-gray-600);
// 选中菜单颜色
--w-e-toolbar-active-bg-color: #25262b;
// 弹窗边框颜色
--w-e-toolbar-border-color: var(--default-border-dashed);
// 分割线颜色
--w-e-textarea-border-color: var(--default-border-dashed);
// 链接输入框边框颜色
--w-e-modal-button-border-color: var(--default-border-dashed);
// 表格头颜色
--w-e-textarea-slight-bg-color: #090909;
// 按钮背景颜色
--w-e-modal-button-bg-color: #090909;
// hover toolbar 背景颜色
--w-e-toolbar-active-color: var(--art-gray-800);
}
.dark {
.page-content .article-list .item .left .outer > div {
border-right-color: var(--dark-border-color) !important;
}
// 富文本编辑器
.editor-wrapper {
*:not(pre code *) {
color: inherit !important;
}
}
// 分隔线
.w-e-bar-divider {
background-color: var(--art-gray-300) !important;
}
.w-e-select-list,
.w-e-drop-panel,
.w-e-bar-item-group .w-e-bar-item-menus-container,
.w-e-text-container [data-slate-editor] pre > code {
border: 1px solid var(--default-border) !important;
}
// 下拉选择框
.w-e-select-list {
background-color: var(--default-box-color) !important;
}
/* 下拉选择框 hover 样式调整 */
.w-e-select-list ul li:hover,
/* 工具栏 hover 按钮背景颜色 */
.w-e-bar-item button:hover {
background-color: #090909 !important;
}
/* 代码块 */
.w-e-text-container [data-slate-editor] pre > code {
background-color: #25262b !important;
text-shadow: none !important;
}
/* 引用 */
.w-e-text-container [data-slate-editor] blockquote {
border-left: 4px solid var(--default-border-dashed) !important;
background-color: var(--art-color);
}
.editor-wrapper {
.w-e-text-container [data-slate-editor] .table-container th:last-of-type {
border-right: 1px solid var(--default-border-dashed) !important;
}
.w-e-modal {
background-color: var(--art-color);
}
}
}
@@ -0,0 +1,2 @@
// 导入暗黑主题
@use 'element-plus/theme-chalk/src/dark/css-vars.scss' as *;
@@ -0,0 +1,34 @@
// https://github.com/element-plus/element-plus/blob/dev/packages/theme-chalk/src/common/var.scss
// 自定义Element 亮色主题
@forward 'element-plus/theme-chalk/src/common/var.scss' with (
$colors: (
'white': #ffffff,
'black': #000000,
'success': (
'base': #13deb9
),
'warning': (
'base': #ffae1f
),
'danger': (
'base': #ff4d4f
),
'error': (
'base': #fa896b
)
),
$button: (
'hover-bg-color': var(--el-color-primary-light-9),
'hover-border-color': var(--el-color-primary),
'border-color': var(--el-color-primary),
'text-color': var(--el-color-primary)
),
$messagebox: (
'border-radius': '12px'
),
$popover: (
'padding': '14px',
'border-radius': '10px'
)
);
@@ -0,0 +1,519 @@
// 优化 Element Plus 组件库默认样式
:root {
// 系统主色
--main-color: var(--el-color-primary);
--el-color-white: white !important;
--el-color-black: white !important;
// 输入框边框颜色
// --el-border-color: #E4E4E7 !important; // DCDFE6
// 按钮粗度
--el-font-weight-primary: 400 !important;
--el-component-custom-height: 36px !important;
--el-component-size: var(--el-component-custom-height) !important;
// 边框、按钮圆角...
--el-border-radius-base: calc(var(--custom-radius) / 3 + 2px) !important;
--el-border-radius-small: calc(var(--custom-radius) / 3 + 4px) !important;
--el-messagebox-border-radius: calc(var(--custom-radius) / 3 + 4px) !important;
--el-popover-border-radius: calc(var(--custom-radius) / 3 + 4px) !important;
.region .el-radio-button__original-radio:checked + .el-radio-button__inner {
color: var(--theme-color);
}
}
// 优化 el-form-item 标签高度
.el-form-item__label {
height: var(--el-component-custom-height) !important;
line-height: var(--el-component-custom-height) !important;
}
// 日期选择器
.el-date-range-picker {
--el-datepicker-inrange-bg-color: var(--art-gray-200) !important;
}
// el-card 背景色跟系统背景色保持一致
html.dark .el-card {
--el-card-bg-color: var(--default-box-color) !important;
}
// 修改 el-pagination 大小
.el-pagination--default {
& {
--el-pagination-button-width: 32px !important;
--el-pagination-button-height: var(--el-pagination-button-width) !important;
}
@media (max-width: 1180px) {
& {
--el-pagination-button-width: 28px !important;
}
}
.el-select--default .el-select__wrapper {
min-height: var(--el-pagination-button-width) !important;
}
.el-pagination__jump .el-input {
height: var(--el-pagination-button-width) !important;
}
}
.el-pager li {
padding: 0 10px !important;
// border: 1px solid red !important;
}
// 优化菜单折叠展开动画(提升动画流畅度)
.el-menu.el-menu--inline {
transition: max-height 0.26s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
// 优化菜单 item hover 动画(提升鼠标跟手感)
.el-sub-menu__title,
.el-menu-item {
transition: background-color 0s !important;
}
// -------------------------------- 修改 el-size=default 组件默认高度 start --------------------------------
// 修改 el-button 高度
.el-button--default {
height: var(--el-component-custom-height) !important;
}
// circle 按钮宽度优化
.el-button--default.is-circle {
width: var(--el-component-custom-height) !important;
}
// 修改 el-select 高度
.el-select--default {
.el-select__wrapper {
min-height: var(--el-component-custom-height) !important;
}
}
// 修改 el-checkbox-button 高度
.el-checkbox-button--default .el-checkbox-button__inner,
// 修改 el-radio-button 高度
.el-radio-button--default .el-radio-button__inner {
padding: 10px 15px !important;
}
// -------------------------------- 修改 el-size=default 组件默认高度 end --------------------------------
.el-pagination.is-background .btn-next,
.el-pagination.is-background .btn-prev,
.el-pagination.is-background .el-pager li {
border-radius: 6px;
}
.el-popover {
min-width: 80px;
border-radius: var(--el-border-radius-small) !important;
}
.el-dialog {
border-radius: 100px !important;
border-radius: calc(var(--custom-radius) / 1.2 + 2px) !important;
overflow: hidden;
}
.el-dialog__header {
.el-dialog__title {
font-size: 16px;
}
}
.el-dialog__body {
padding: 25px 0 !important;
position: relative; // 为了兼容 el-pagination 样式,需要设置 relative,不然会影响 el-pagination 的样式,比如 el-pagination__jump--small 会被影响,导致 el-pagination__jump--small 按钮无法点击,详见 URL_ADDRESS.com/element-plus/element-plus/issues/5684#issuecomment-1176299275;
}
.el-dialog.el-dialog-border {
.el-dialog__body {
// 上边框
&::before,
// 下边框
&::after {
content: '';
position: absolute;
left: -16px;
width: calc(100% + 32px);
height: 1px;
background-color: var(--art-gray-300);
}
&::before {
top: 0;
}
&::after {
bottom: 0;
}
}
}
// el-message 样式优化
.el-message {
background-color: var(--default-box-color) !important;
border: 0 !important;
box-shadow:
0 6px 16px 0 rgba(0, 0, 0, 0.08),
0 3px 6px -4px rgba(0, 0, 0, 0.12),
0 9px 28px 8px rgba(0, 0, 0, 0.05) !important;
p {
font-size: 13px;
}
}
// 修改 el-dropdown 样式
.el-dropdown-menu {
padding: 6px !important;
border-radius: 10px !important;
border: none !important;
.el-dropdown-menu__item {
padding: 6px 16px !important;
border-radius: 6px !important;
&:hover:not(.is-disabled) {
color: var(--art-gray-900) !important;
background-color: var(--art-el-active-color) !important;
}
&:focus:not(.is-disabled) {
color: var(--art-gray-900) !important;
background-color: var(--art-gray-200) !important;
}
}
}
// 隐藏 select、dropdown 的三角
.el-select__popper,
.el-dropdown__popper {
margin-top: -6px !important;
.el-popper__arrow {
display: none;
}
}
.el-dropdown-selfdefine:focus {
outline: none !important;
}
// 处理移动端组件兼容性
@media screen and (max-width: 640px) {
.el-message-box,
.el-dialog {
width: calc(100% - 24px) !important;
}
.el-date-picker.has-sidebar.has-time {
width: calc(100% - 24px);
left: 12px !important;
}
.el-picker-panel *[slot='sidebar'],
.el-picker-panel__sidebar {
display: none;
}
.el-picker-panel *[slot='sidebar'] + .el-picker-panel__body,
.el-picker-panel__sidebar + .el-picker-panel__body {
margin-left: 0;
}
}
// 修改el-button样式
.el-button {
&.el-button--text {
background-color: transparent !important;
padding: 0 !important;
span {
margin-left: 0 !important;
}
}
}
// 修改el-tag样式
.el-tag {
font-weight: 500;
transition: all 0s !important;
&.el-tag--default {
height: 26px !important;
}
}
.el-checkbox-group {
&.el-table-filter__checkbox-group label.el-checkbox {
height: 17px !important;
.el-checkbox__label {
font-weight: 400 !important;
}
}
}
.el-radio--default {
// 优化单选按钮大小
.el-radio__input {
.el-radio__inner {
width: 16px;
height: 16px;
&::after {
width: 6px;
height: 6px;
}
}
}
}
.el-checkbox {
.el-checkbox__inner {
border-radius: 2px !important;
}
}
// 优化复选框样式
.el-checkbox--default {
.el-checkbox__inner {
width: 16px !important;
height: 16px !important;
border-radius: 4px !important;
&::before {
content: '';
height: 4px !important;
top: 5px !important;
background-color: #fff !important;
transform: scale(0.6) !important;
}
}
.is-checked {
.el-checkbox__inner {
&::after {
width: 3px;
height: 8px;
margin: auto;
border: 2px solid var(--el-checkbox-checked-icon-color);
border-left: 0;
border-top: 0;
transform: translate(-45%, -60%) rotate(45deg) scale(0.86) !important;
transform-origin: center;
}
}
}
}
.el-notification .el-notification__icon {
font-size: 22px !important;
}
// 修改 el-message-box 样式
.el-message-box__headerbtn .el-message-box__close,
.el-dialog__headerbtn .el-dialog__close {
top: 7px;
right: 7px;
width: 30px;
height: 30px;
border-radius: 5px;
transition: all 0.3s;
&:hover {
background-color: var(--art-hover-color) !important;
color: var(--art-gray-900) !important;
}
}
.el-message-box {
padding: 25px 20px !important;
}
.el-message-box__title {
font-weight: 500 !important;
}
.el-table__column-filter-trigger i {
color: var(--theme-color) !important;
margin: -3px 0 0 2px;
}
// 去除 el-dropdown 鼠标放上去出现的边框
.el-tooltip__trigger:focus-visible {
outline: unset;
}
// ipad 表单右侧按钮优化
@media screen and (max-width: 1180px) {
.el-table-fixed-column--right {
padding-right: 0 !important;
}
}
.login-out-dialog {
padding: 30px 20px !important;
border-radius: 10px !important;
}
// 修改 dialog 动画
.dialog-fade-enter-active {
.el-dialog:not(.is-draggable) {
animation: dialog-open 0.3s cubic-bezier(0.32, 0.14, 0.15, 0.86);
// 修复 el-dialog 动画后宽度不自适应问题
.el-select__selected-item {
display: inline-block;
}
}
}
.dialog-fade-leave-active {
animation: fade-out 0.2s linear;
.el-dialog:not(.is-draggable) {
animation: dialog-close 0.5s;
}
}
@keyframes dialog-open {
0% {
opacity: 0;
transform: scale(0.2);
}
100% {
opacity: 1;
transform: scale(1);
}
}
@keyframes dialog-close {
0% {
opacity: 1;
transform: scale(1);
}
100% {
opacity: 0;
transform: scale(0.2);
}
}
// 遮罩层动画
@keyframes fade-out {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
// 修改 el-select 样式
.el-select__popper:not(.el-tree-select__popper) {
.el-select-dropdown__list {
padding: 5px !important;
.el-select-dropdown__item {
height: 34px !important;
line-height: 34px !important;
border-radius: 6px !important;
&.is-selected {
color: var(--art-gray-900) !important;
font-weight: 400 !important;
background-color: var(--art-el-active-color) !important;
margin-bottom: 4px !important;
}
&:hover {
background-color: var(--art-hover-color) !important;
}
}
.el-select-dropdown__item:hover ~ .is-selected,
.el-select-dropdown__item.is-selected:has(~ .el-select-dropdown__item:hover) {
background-color: transparent !important;
}
}
}
// 修改 el-tree-select 样式
.el-tree-select__popper {
.el-select-dropdown__list {
padding: 5px !important;
.el-tree-node {
.el-tree-node__content {
height: 36px !important;
border-radius: 6px !important;
&:hover {
background-color: var(--art-gray-200) !important;
}
}
}
}
}
// 实现水波纹在文字下面效果
.el-button > span {
position: relative;
z-index: 10;
}
// 优化颜色选择器圆角
.el-color-picker__color {
border-radius: 2px !important;
}
// 优化日期时间选择器底部圆角
.el-picker-panel {
.el-picker-panel__footer {
border-radius: 0 0 var(--el-border-radius-base) var(--el-border-radius-base);
}
}
// 优化树型菜单样式
.el-tree-node__content {
border-radius: 4px;
margin-bottom: 4px;
padding: 1px 0;
&:hover {
background-color: var(--art-hover-color) !important;
}
}
.dark {
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
background-color: var(--art-gray-300) !important;
}
}
// 隐藏折叠菜单弹窗 hover 出现的边框
.menu-left-popper:focus-within,
.horizontal-menu-popper:focus-within {
box-shadow: none !important;
outline: none !important;
}
// 数字输入组件右侧按钮高度跟随自定义组件高度
.el-input-number--default.is-controls-right {
.el-input-number__decrease,
.el-input-number__increase {
height: calc((var(--el-component-size) / 2)) !important;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,157 @@
// sass 混合宏(函数)
/**
* 溢出省略号
* @param {Number} 行数
*/
@mixin ellipsis($rowCount: 1) {
@if $rowCount <=1 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
} @else {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: $rowCount;
-webkit-box-orient: vertical;
}
}
/**
* 控制用户能否选中文本
* @param {String} 类型
*/
@mixin userSelect($value: none) {
user-select: $value;
-moz-user-select: $value;
-ms-user-select: $value;
-webkit-user-select: $value;
}
// 绝对定位居中
@mixin absoluteCenter() {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
/**
* css3动画
*
*/
@mixin animation(
$from: (
width: 0px
),
$to: (
width: 100px
),
$name: mymove,
$animate: mymove 2s 1 linear infinite
) {
-webkit-animation: $animate;
-o-animation: $animate;
animation: $animate;
@keyframes #{$name} {
from {
@each $key, $value in $from {
#{$key}: #{$value};
}
}
to {
@each $key, $value in $to {
#{$key}: #{$value};
}
}
}
@-webkit-keyframes #{$name} {
from {
@each $key, $value in $from {
$key: $value;
}
}
to {
@each $key, $value in $to {
$key: $value;
}
}
}
}
// 圆形盒子
@mixin circle($size: 11px, $bg: #fff) {
border-radius: 50%;
width: $size;
height: $size;
line-height: $size;
text-align: center;
background: $bg;
}
// placeholder
@mixin placeholder($color: #bbb) {
// Firefox
&::-moz-placeholder {
color: $color;
opacity: 1;
}
// Internet Explorer 10+
&:-ms-input-placeholder {
color: $color;
}
// Safari and Chrome
&::-webkit-input-placeholder {
color: $color;
}
&:placeholder-shown {
text-overflow: ellipsis;
}
}
//背景透明,文字不透明。兼容IE8
@mixin betterTransparentize($color, $alpha) {
$c: rgba($color, $alpha);
$ie_c: ie_hex_str($c);
background: rgba($color, 1);
background: $c;
background: transparent \9;
zoom: 1;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#{$ie_c}, endColorstr=#{$ie_c});
-ms-filter: 'progid:DXImageTransform.Microsoft.gradient(startColorstr=#{$ie_c}, endColorstr=#{$ie_c})';
}
//添加浏览器前缀
@mixin browserPrefix($propertyName, $value) {
@each $prefix in -webkit-, -moz-, -ms-, -o-, '' {
#{$prefix}#{$propertyName}: $value;
}
}
// 边框
@mixin border($color: red) {
border: 1px solid $color;
}
// 背景滤镜
@mixin backdropBlur() {
--tw-backdrop-blur: blur(30px);
-webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness)
var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate)
var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate)
var(--tw-backdrop-sepia);
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast)
var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert)
var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
}
@@ -0,0 +1,41 @@
@charset "UTF-8";
/*滚动条*/
/*滚动条整体部分,必须要设置*/
::-webkit-scrollbar {
width: 8px !important;
height: 0 !important;
}
/*滚动条的轨道*/
::-webkit-scrollbar-track {
background-color: var(--art-gray-200);
}
/*滚动条的滑块按钮*/
::-webkit-scrollbar-thumb {
border-radius: 5px;
background-color: #cccccc !important;
transition: all 0.2s;
-webkit-transition: all 0.2s;
}
::-webkit-scrollbar-thumb:hover {
background-color: #b0abab !important;
}
/*滚动条的上下两端的按钮*/
::-webkit-scrollbar-button {
height: 0px;
width: 0;
}
.dark {
::-webkit-scrollbar-track {
background-color: var(--default-bg-color);
}
::-webkit-scrollbar-thumb {
background-color: var(--art-gray-300) !important;
}
}
@@ -0,0 +1,104 @@
@use 'sass:map';
// === 变量区域 ===
$transition: (
// 动画持续时间
duration: 0.25s,
// 滑动动画的移动距离
distance: 15px,
// 默认缓动函数
easing: cubic-bezier(0.25, 0.1, 0.25, 1),
// 淡入淡出专用的缓动函数
fade-easing: cubic-bezier(0.4, 0, 0.6, 1)
);
// 抽取配置值函数,提高可复用性
@function transition-config($key) {
@return map.get($transition, $key);
}
// 变量简写
$duration: transition-config('duration');
$distance: transition-config('distance');
$easing: transition-config('easing');
$fade-easing: transition-config('fade-easing');
// === 动画类 ===
// 淡入淡出动画
.fade {
&-enter-active,
&-leave-active {
transition: opacity $duration $fade-easing;
will-change: opacity;
}
&-enter-from,
&-leave-to {
opacity: 0;
}
&-enter-to,
&-leave-from {
opacity: 1;
}
}
// 滑动动画通用样式
@mixin slide-transition($direction) {
$distance-x: 0;
$distance-y: 0;
@if $direction == 'left' {
$distance-x: -$distance;
} @else if $direction == 'right' {
$distance-x: $distance;
} @else if $direction == 'top' {
$distance-y: -$distance;
} @else if $direction == 'bottom' {
$distance-y: $distance;
}
&-enter-active {
transition:
opacity $duration $easing,
transform $duration $easing;
will-change: opacity, transform;
}
&-leave-active {
transition:
opacity calc($duration * 0.7) $easing,
transform calc($duration * 0.7) $easing;
will-change: opacity, transform;
}
&-enter-from {
opacity: 0;
transform: translate3d($distance-x, $distance-y, 0);
}
&-enter-to {
opacity: 1;
transform: translate3d(0, 0, 0);
}
&-leave-to {
opacity: 0;
transform: translate3d(-$distance-x, -$distance-y, 0);
}
}
// 滑动动画方向类
.slide-left {
@include slide-transition('left');
}
.slide-right {
@include slide-transition('right');
}
.slide-top {
@include slide-transition('top');
}
.slide-bottom {
@include slide-transition('bottom');
}
@@ -0,0 +1,208 @@
@import 'tailwindcss';
@custom-variant dark (&:where(.dark, .dark *));
/* ==================== Light Mode Variables ==================== */
:root {
/* Base Colors */
--art-color: #ffffff;
--theme-color: var(--main-color);
/* Theme Colors - OKLCH Format */
--art-primary: oklch(0.7 0.23 260);
--art-secondary: oklch(0.72 0.19 231.6);
--art-error: oklch(0.73 0.15 25.3);
--art-info: oklch(0.58 0.03 254.1);
--art-success: oklch(0.78 0.17 166.1);
--art-warning: oklch(0.78 0.14 75.5);
--art-danger: oklch(0.68 0.22 25.3);
/* Gray Scale - Light Mode */
--art-gray-100: #f9fafb;
--art-gray-200: #f2f4f5;
--art-gray-300: #e6eaeb;
--art-gray-400: #dbdfe1;
--art-gray-500: #949eb7;
--art-gray-600: #7987a1;
--art-gray-700: #4d5875;
--art-gray-800: #383853;
--art-gray-900: #323251;
/* Border Colors */
--art-card-border: rgba(0, 0, 0, 0.08);
--default-border: #e2e8ee;
--default-border-dashed: #dbdfe9;
/* Background Colors */
--default-bg-color: #fafbfc;
--default-box-color: #ffffff;
/* Hover Color */
--art-hover-color: #edeff0;
/* Active Color */
--art-active-color: #f2f4f5;
/* Element Component Active Color */
--art-el-active-color: #f2f4f5;
}
/* ==================== Dark Mode Variables ==================== */
.dark {
/* Base Colors */
--art-color: #000000;
/* Gray Scale - Dark Mode */
--art-gray-100: #110f0f;
--art-gray-200: #17171c;
--art-gray-300: #393946;
--art-gray-400: #505062;
--art-gray-500: #73738c;
--art-gray-600: #8f8fa3;
--art-gray-700: #ababba;
--art-gray-800: #c7c7d1;
--art-gray-900: #e3e3e8;
/* Border Colors */
--art-card-border: rgba(255, 255, 255, 0.08);
--default-border: rgba(255, 255, 255, 0.1);
--default-border-dashed: #363843;
/* Background Colors */
--default-bg-color: #070707;
--default-box-color: #161618;
/* Hover Color */
--art-hover-color: #252530;
/* Active Color */
--art-active-color: #202226;
/* Element Component Active Color */
--art-el-active-color: #2e2e38;
}
/* ==================== Tailwind Theme Configuration ==================== */
@theme {
/* Box Color (Light: white / Dark: black) */
--color-box: var(--default-box-color);
/* System Theme Color */
--color-theme: var(--theme-color);
/* Hover Color */
--color-hover-color: var(--art-hover-color);
/* Active Color */
--color-active-color: var(--art-active-color);
/* Active Color */
--color-el-active-color: var(--art-active-color);
/* ElementPlus Theme Colors */
--color-primary: var(--art-primary);
--color-secondary: var(--art-secondary);
--color-error: var(--art-error);
--color-info: var(--art-info);
--color-success: var(--art-success);
--color-warning: var(--art-warning);
--color-danger: var(--art-danger);
/* Gray Scale Colors (Auto-adapts to dark mode) */
--color-g-100: var(--art-gray-100);
--color-g-200: var(--art-gray-200);
--color-g-300: var(--art-gray-300);
--color-g-400: var(--art-gray-400);
--color-g-500: var(--art-gray-500);
--color-g-600: var(--art-gray-600);
--color-g-700: var(--art-gray-700);
--color-g-800: var(--art-gray-800);
--color-g-900: var(--art-gray-900);
}
/* ==================== Custom Border Radius Utilities ==================== */
@utility rounded-custom-xs {
border-radius: calc(var(--custom-radius) / 2);
}
@utility rounded-custom-sm {
border-radius: calc(var(--custom-radius) / 2 + 2px);
}
/* ==================== Custom Utility Classes ==================== */
@layer utilities {
/* Flexbox Layout Utilities */
.flex-c {
@apply flex items-center;
}
.flex-b {
@apply flex justify-between;
}
.flex-cc {
@apply flex items-center justify-center;
}
.flex-cb {
@apply flex items-center justify-between;
}
/* Transition Utilities */
.tad-200 {
@apply transition-all duration-200;
}
.tad-300 {
@apply transition-all duration-300;
}
/* Border Utilities */
.border-full-d {
@apply border border-[var(--default-border)];
}
.border-b-d {
@apply border-b border-[var(--default-border)];
}
.border-t-d {
@apply border-t border-[var(--default-border)];
}
.border-l-d {
@apply border-l border-[var(--default-border)];
}
.border-r-d {
@apply border-r border-[var(--default-border)];
}
/* Cursor Utilities */
.c-p {
@apply cursor-pointer;
}
}
/* ==================== Custom Component Classes ==================== */
@layer components {
/* Art Card Header Component */
.art-card-header {
@apply flex justify-between pr-6 pb-1;
.title {
h4 {
@apply text-lg font-medium text-g-900;
}
p {
@apply mt-1 text-sm text-g-600;
span {
@apply ml-2 font-medium;
}
}
}
}
}

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