Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c200dab57 | ||
|
|
e32e13c1f1 | ||
|
|
4fa716a0e2 | ||
|
|
eeeaed1e14 | ||
|
|
4941e8b6c0 | ||
|
|
6d214aa4cb | ||
|
|
0f61236884 | ||
|
|
9cd24e3cb6 | ||
|
|
12ff003249 | ||
|
|
df6811552d | ||
|
|
006087b98b | ||
|
|
f3a468fef8 | ||
|
|
db7e89368a | ||
|
|
3ef22088b7 | ||
|
|
15f9bf67ee | ||
|
|
2293deba8a | ||
|
|
2fe94db4b9 | ||
|
|
41f23c349d | ||
|
|
5416328d4c | ||
|
|
4b7cfba2c1 | ||
|
|
f5970408dc | ||
|
|
a3320926de | ||
|
|
db6fda77c9 | ||
|
|
7053e8d890 | ||
|
|
42d3ad48d0 | ||
|
|
2eda11396d | ||
|
|
38ef68d176 | ||
|
|
640d41adbe | ||
|
|
206f3ea226 | ||
|
|
fb1e662b81 | ||
|
|
171aa9c83f | ||
|
|
94e73a29c5 | ||
|
|
02c532f095 | ||
|
|
a97aa268de | ||
|
|
54b509d49e | ||
|
|
8aaac3e831 | ||
|
|
ac6b73adb9 | ||
|
|
f677dbe5c1 | ||
|
|
f5905b7d0c | ||
|
|
e055adade5 | ||
|
|
89a7ad966a | ||
|
|
602d9dd4f3 | ||
|
|
db1ab3abdf | ||
|
|
ad8ff8ee84 | ||
|
|
5651adeed6 | ||
|
|
2ca3d4b6cf | ||
|
|
a36d5c061b | ||
|
|
68ea39907b | ||
|
|
b3082156bd | ||
|
|
0749fbf172 | ||
|
|
72bcdc15c2 | ||
|
|
e70722abeb | ||
|
|
59cfb31ba5 | ||
|
|
08410821c7 | ||
|
|
2d2cf506fe | ||
|
|
229e3e6878 | ||
|
|
46749aa711 | ||
|
|
a4697b368a | ||
|
|
1664821117 | ||
|
|
19078629d1 | ||
|
|
0a59488872 | ||
|
|
6b9102ba6c | ||
|
|
911fd7661f | ||
|
|
8cf38ba3b6 | ||
|
|
8de05ab479 | ||
|
|
1146670263 | ||
|
|
35cb9ce8bc | ||
|
|
619ac1fe81 | ||
|
|
8738620065 | ||
|
|
dd7bc9c01a | ||
|
|
4e8b3e7d43 | ||
|
|
b976b80d9d | ||
|
|
e1b4097573 | ||
|
|
9c6e77a1f2 | ||
|
|
c77a26cd99 | ||
|
|
0a32518060 | ||
|
|
f0c32c4f20 | ||
|
|
6c2966a2ff | ||
|
|
c89da029c8 | ||
|
|
b8124aa448 | ||
|
|
c73c113721 | ||
|
|
8bf33b65cd | ||
|
|
8cc747b6e8 | ||
|
|
ee26409ac9 | ||
|
|
a33f4b2929 | ||
|
|
8a1e06e94b | ||
|
|
12f8ec2bd2 | ||
|
|
b76e703dba | ||
|
|
c0fd432fc8 | ||
|
|
2bc1986e93 | ||
|
|
97899b5d06 | ||
|
|
5df05b4ebc | ||
|
|
9f9cd3e730 | ||
|
|
fb70082d54 | ||
|
|
32de74f103 | ||
|
|
cad685fe40 | ||
|
|
a7dbc5a77e | ||
|
|
f0a94bf523 | ||
|
|
872d3dc5c8 | ||
|
|
816af4b960 | ||
|
|
27f9054671 | ||
|
|
0964245246 | ||
|
|
e7c874537e | ||
|
|
489748dfc1 | ||
|
|
eeb951f9f6 | ||
|
|
68f29d0a14 | ||
|
|
6525275a54 | ||
|
|
8c61a05d8a | ||
|
|
57028b8626 | ||
|
|
5abdd91f35 | ||
|
|
008f6f5998 | ||
|
|
41bcb44e34 | ||
|
|
26d4125798 | ||
|
|
08d26a416e | ||
|
|
ffeebf80e6 | ||
|
|
e115bb7113 | ||
|
|
2a08338ed1 | ||
|
|
ee46776648 | ||
|
|
f8f108af5d | ||
|
|
87f995ca47 | ||
|
|
3214305dea | ||
|
|
7e0838de64 | ||
|
|
be1a2899ba | ||
|
|
dd546fc07b | ||
|
|
a4c172bc98 | ||
|
|
c7add9574e | ||
|
|
b034b51685 | ||
|
|
600379933d | ||
|
|
530cfe38dc | ||
|
|
11fc3cee6a | ||
|
|
78aa8c361c | ||
|
|
f30ab9cc29 | ||
|
|
6d2dd93628 | ||
|
|
813bee743b | ||
|
|
0ab43d0ed8 | ||
|
|
a1a06504a5 | ||
|
|
b86bc1bf97 | ||
|
|
67bb73fa30 | ||
|
|
6f248b0741 | ||
|
|
9f6deaae76 | ||
|
|
d605a7f9cc | ||
|
|
42c7cf24f2 | ||
|
|
c00c4423f0 | ||
|
|
3f901d3882 | ||
|
|
65540fb121 | ||
|
|
9d067c0646 | ||
|
|
be07de0e92 | ||
|
|
0354a1ca58 | ||
|
|
1a16b1b5b7 | ||
|
|
f8889cdf51 | ||
|
|
8593f0fec4 | ||
|
|
e5884bd943 | ||
|
|
657f444041 | ||
|
|
16d59e4e69 | ||
|
|
ea92c62bb9 | ||
|
|
121df38da1 | ||
|
|
75d0903c0a | ||
|
|
8375df692a | ||
|
|
3b5ce2d219 | ||
|
|
9cfa096ec8 | ||
|
|
30218cc339 | ||
|
|
1178ea37b3 | ||
|
|
5c90747d0f | ||
|
|
be6817bafd | ||
|
|
7af2132b99 | ||
|
|
acca8c5e8a | ||
|
|
aee37b200f | ||
|
|
05842f36d5 | ||
|
|
76d7459515 | ||
|
|
fc2cf49c35 | ||
|
|
93795ffec0 | ||
|
|
4b168c3982 | ||
|
|
e3dc6369ee | ||
|
|
bdcc0326bf | ||
|
|
20d93187f9 | ||
|
|
b2db418d39 | ||
|
|
d19b783302 | ||
|
|
13eb46f4e1 | ||
|
|
7a4f3590ef | ||
|
|
9e61206be2 | ||
|
|
e5c598e67a | ||
|
|
39bf3e14a0 | ||
|
|
ce0422979a | ||
|
|
bfef048695 | ||
|
|
2f67a15083 | ||
|
|
d773f783eb | ||
|
|
dc8d038e34 | ||
|
|
195edb8b32 | ||
|
|
59b2ee9acb | ||
|
|
d7f3cbfcfd | ||
|
|
d2b24051af | ||
|
|
0973533bab | ||
|
|
61e9e123c4 | ||
|
|
60a177605a | ||
|
|
60112ad367 | ||
|
|
c95720514b | ||
|
|
2fafd9af18 | ||
|
|
4d9928abf3 | ||
|
|
28b74fce4e | ||
|
|
d468d15032 | ||
|
|
c1c54e61fc | ||
|
|
966d529551 | ||
|
|
186636a8e4 | ||
|
|
c749d951a0 | ||
|
|
9a14f5aca6 | ||
|
|
9927066abb | ||
|
|
7e46b5cc06 | ||
|
|
eef5df9ce2 | ||
|
|
83d8204847 | ||
|
|
0489fbe62c | ||
|
|
5d339b3d0e | ||
|
|
724a4f7b77 |
@@ -1,51 +1,117 @@
|
|||||||
# ---------- 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
|
# SDK 打包产物(tools/sdk_pack.py 生成,含 api.json 与 zip,不入库)
|
||||||
*.swo
|
dist-sdk/
|
||||||
|
# 本地工具输出(tools/net_capture.py 抓包结果含登录态/token,禁止入库)
|
||||||
# ---------- 操作系统 ----------
|
out/
|
||||||
.DS_Store
|
desktop/**/setup-*.exe
|
||||||
Thumbs.db
|
desktop/**/installer/
|
||||||
desktop.ini
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
# ---------- 日志 ----------
|
|
||||||
*.log
|
# ---------- 虚拟环境 ----------
|
||||||
logs/
|
.venv/
|
||||||
|
venv/
|
||||||
# ---------- 测试 / 覆盖率 ----------
|
env/
|
||||||
.pytest_cache/
|
ENV/
|
||||||
.coverage
|
|
||||||
htmlcov/
|
# ---------- 环境变量 / 密钥 ----------
|
||||||
.tox/
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
# 控制面签名密钥 / 运行期产物(禁止入库)
|
||||||
|
.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
|
||||||
|
# 本地技能目录(含明文凭据,不入库)
|
||||||
|
.skills/
|
||||||
|
# 工具 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/
|
||||||
|
|
||||||
|
# 根目录本地临时产物 / 探针输出(一次性文件,禁止入库;tmp_check_renew.csv 含员工个人信息)
|
||||||
|
aa.md
|
||||||
|
aa.json
|
||||||
|
tmp_check_renew.csv
|
||||||
|
/.tmp*/
|
||||||
|
tmp_probe_js/
|
||||||
|
|
||||||
|
# vc运行库
|
||||||
|
vc_redist/
|
||||||
|
vc_redist_x64/
|
||||||
|
vc_redist_x86/
|
||||||
|
|
||||||
|
静态资源/
|
||||||
|
.assets/
|
||||||
|
# lotsmall 联调账号配置(含明文密码,勿入库)
|
||||||
|
tests/lotsmall_probe/account.json
|
||||||
|
|
||||||
|
# aitable 探针落盘产物(银行卡/身份证照片等员工隐私材料,禁止入库)
|
||||||
|
tests/aitable_probe/_out/
|
||||||
|
|
||||||
|
# 测试下载/生成的图片与数据集(证件照、银行卡照片等员工隐私材料 + OCR 训练图,禁止入库)
|
||||||
|
tests/_out/
|
||||||
|
tests/dataset*/
|
||||||
|
tests/*_dataset*.zip
|
||||||
|
tests/下载/
|
||||||
|
tests/downloads/
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# 最小 CI:全量 Python 语法编译 + 插件纯逻辑单测。
|
||||||
|
# 执行环境:Windows runner(项目插件依赖 Windows/COM 场景,单测本身跨平台)。
|
||||||
|
# 本地等价命令:.venv\Scripts\python.exe tools/ci_check.py [--frontend]
|
||||||
|
# 前端构建未纳入默认流水线(需 runner 预装 Node/pnpm 与 node_modules),
|
||||||
|
# 可在本机用 --frontend 单独验证。
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- check
|
||||||
|
|
||||||
|
python-check:
|
||||||
|
stage: check
|
||||||
|
interruptible: true
|
||||||
|
script:
|
||||||
|
- python -m venv .venv
|
||||||
|
- .venv/Scripts/python.exe -m pip install --quiet --upgrade pip
|
||||||
|
- .venv/Scripts/python.exe -m pip install --quiet pytest==9.2.0 openpyxl requests pandas
|
||||||
|
- .venv/Scripts/python.exe tools/ci_check.py
|
||||||
|
cache:
|
||||||
|
key: pip-$CI_COMMIT_REF_SLUG
|
||||||
|
paths:
|
||||||
|
- .venv/
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
AI 智能体开发约束 & 项目执行规范
|
||||||
|
本文件为项目根目录全局 Agent 行为规则,AI 编码、重构、调试、优化、答疑均需默认遵循以下配置,无需用户重复说明。
|
||||||
|
|
||||||
|
---
|
||||||
|
1. 运行环境规范
|
||||||
|
- 默认强制使用本地 .venv 虚拟环境,禁止使用任何沙箱环境、在线临时环境、容器模拟环境。
|
||||||
|
- 所有代码运行、依赖安装、调试、语法检查、模块测试,均基于项目根目录 .venv 环境执行。
|
||||||
|
- 如需安装依赖,仅操作本地虚拟环境,不污染全局 Python 环境。
|
||||||
|
- 所有需要【写入文件内容】的操作(导出落盘、覆盖目标文件、复制/移动文件、下载保存等)一律不使用沙箱:执行时触发沙箱外运行(requires_approval 申请用户批准),避免被沙箱拦截(如 D:\资料 等受保护目录只读可读、写入被拒)。
|
||||||
|
2. 影刀开发规范
|
||||||
|
- 影刀项目默认采用单文件自包含架构。
|
||||||
|
- 输出影刀脚本、逻辑代码、流程封装时,优先单文件独立实现,功能自包含、可直接导入运行,不拆分冗余子文件。
|
||||||
|
- 单文件需具备完整性:依赖声明、核心逻辑、异常处理、入口执行全部内聚在当前文件。
|
||||||
|
3. 项目通用架构规范
|
||||||
|
- 代码组织:不同业务、不同流程独立模块化运行,互不侵入、互不影响。
|
||||||
|
- 各方向零依赖:项目并存多个独立演进方向,彼此【绝不跨目录 import】,登录/数据导出等数据层各自内置(允许少量重复换取完全解耦),任一方向可单独拷贝、单独演进、独享依赖与启动:
|
||||||
|
- 桌面端 desktop/:中心机 desktop/controlplane-next/(**现役**,Midway + cool-admin 8 + Art Design Pro)+ 执行机桌面壳 desktop/electron-shell/(当前宿主,Electron + Node,内置便携 python 环境 python-env/<版本>/ 跑插件)+ 内网文件服务器 desktop/fileserver/(FastAPI,下载 8802 / 管理台 8899)。第一代中心机 desktop/controlplane/(FastAPI)与老版执行机底座 desktop/webhost/ 均已从仓库移除(2026-11)。各自互不 import、独立演进、可单独拷贝(模块搜索根 = desktop/,运行均以 desktop/ 为 cwd)。
|
||||||
|
- 插件 plugins/:根级独立目录(按号段分桶 plugins/XQ0001-0100/),被执行机(electron-shell 壳)按账号权限自下载加载,不随底座发布;打包产物落 dist-plugin/<id>_v<版本>.zip(本地生成,.gitignore 不入库)。
|
||||||
|
- 影刀版 workflows/:单文件自包含,需求脚本按号段分桶(workflows/XQ0001-0100/)。
|
||||||
|
- app/ 蓝图版:已弃用并已从仓库移除,仅在历史文档中提及。
|
||||||
|
- 公共库 libs/:跨方向共享的独立 Python 工具库——`libs/desktopauto/`(桌面自动化:识图点击/图像存在判断/OCR 文字坐标/键鼠/窗口对象/进程启停)、`libs/aitable/`(钉钉 AI 表格读写 + 月报/周报采集)。按正常库开发(包 + pyproject.toml + `_selftest.py`),可 `pip install -e` 或用 `sys.path` 引用;其中 `libs/desktopauto/` 已改为 SDK 下发(`sdk.json`,执行机按插件 `plugin.json.requires.sdks` 下载挂载),**禁止再预装进 python-env 或 vendored 复制进插件包**(同名包会让 SDK 挂载 fail-fast);`libs/aitable/` 仍按「执行机预装依赖」或「vendored 复制进插件包」供给。插件使用公共库不算违反插件自包含,禁止的是 import 业务代码(根目录/desktop/其它插件)。用法与坑位见技能 `.skills/37du-Desktop-Auto/SKILL.md`。
|
||||||
|
- 代码形态分三类,按各方向性质采用不同组织方式(【单文件自包含】仅适用于影刀版,其它一律按正常项目开发):
|
||||||
|
- workflows/(影刀版):沿用单文件自包含架构(见第 2 节,仅影刀适用)。
|
||||||
|
- 桌面端各后端(controlplane-next 中心机、electron-shell 执行机壳、fileserver 文件服务器):按正常模块化项目开发,允许按包/模块/多文件拆分,不做单文件约束(electron-shell 主进程为 CommonJS 模块,fileserver 为 Python 包)。
|
||||||
|
- 插件(执行机加载的执行单元,源码位于根级 plugins/XQ0001-0100/<中文目录>/,如 plugins/XQ0001-0100/XQ0011 考勤月报封存检查/,id 用固定规则 xq{单号},与目录名解耦):内部按正常项目组织,可拆 config/data/logic/report/ui 等多文件;但强调【插件自包含】——插件内模块只能互相引用、依赖 Python 标准库/第三方依赖/壳注入的插件接口(`webhost.backend.plugins.base`,运行时由 electron-shell/python/webhost/ 提供),严禁 import 插件包之外的任何代码(根目录、desktop 底座业务一律禁止),保证插件完整交付物=插件包本身,可单独拷贝发布、独立演进。插件目录结构、前端(ui/ 与 ui-src/)存放、打包产物位置(dist-plugin/<id>_v<版本>.zip)、发布流程等细则见 docs/插件/插件开发规范.md 与 docs/插件/发版规范.md。
|
||||||
|
- 环境变量按模块隔离,各自使用自己目录下的 .env,互不覆盖、互不依赖:
|
||||||
|
- 根目录 .env:仅供 workflows/(影刀) 脚本使用,承载各 XQ 业务路径/账号等配置(`workflows/share/*.py` 统一读项目根 .env,缺失再兼容 cwd .env 与系统变量);禁止向根 .env 写入桌面端变量。
|
||||||
|
- desktop/controlplane-next/ → desktop/controlplane-next/server/.env(**现役中心机**,含 CONTROLPLANE_TOKEN、CONTROLPLANE_ADMIN_SECRET、CENTER_PORT、CENTER_DATA_DIR、MYSQL_*、DINGTALK_*);desktop/fileserver/ → desktop/fileserver/.env(内网文件服务器,含 FILESERVER_PORT、FILESERVER_TOKEN、FILESERVER_BASE_URL、CONTROLPLANE_URL/TOKEN)
|
||||||
|
- desktop/controlplane/(FastAPI 旧中心机)已于 2026-11 从仓库移除,不再有配置目录;历史配置仅存于 git 历史
|
||||||
|
- desktop/electron-shell/ → desktop/electron-shell/.env(开发态配置:CONTROLPLANE_URL/TOKEN、PYTHON_EXE、SHELL_PYTHON_ENV_ROOT、RUN_TIMEOUT 等),打包态读 asar 内 resources/.env(源 .env.packaged);运行数据根 %LOCALAPPDATA%\37duAutomation
|
||||||
|
- 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. 发版与自动更新操作规范
|
||||||
|
- 自动更新:插件由执行机按账号权限自下载(electron-shell/electron/plugin-sync.js);壳子由执行机自动下载安装包 + 用户点击升级重启(electron-shell/electron/shell-updater.js,NSIS `/S` 静默安装);便携环境包单独版本化下发(env-sync.js)。版本源都在中心机控制面。
|
||||||
|
- 发版统一走 agent CLI(仓库根 `tools\agent_cli.py`,任意 cwd 均可:`.venv\Scripts\python.exe tools/agent_cli.py ...`)。插件用 publish / grant / revoke;壳子用 file push --category shell,环境包用 file push --category python-env;中心机为内网 `172.30.30.243`(controlplane-next / Midway,systemd `37du-controlplane-next.service`),改代码后按 `37du-Center-Deploy` 技能或 docs/部署/服务端前后端部署SOP.md 部署。⚠️ `desktop/controlplane/`(FastAPI 旧中心机)已于 2026-11 从仓库移除,**不要再去该目录找代码或配置**;旧命令 `python -m controlplane.tools.agent_cli` 早已移除,一律用 `tools/agent_cli.py`。CLI 配置只读 `controlplane-next/server/.env` 与 `fileserver/.env`。
|
||||||
|
- **插件发布必须走「测试通道 → 人工验证 → 转正」**(2026-10-31 起):`publish` 默认进测试通道(`plugins.status=testing` + `plugins.test_version`),**只有管理员账号**能同步到在测版本,其他账号继续用 `latest_version`;人工验证通过后由**人**执行 `plugin-status <id> --status published` 转正(服务端把 test_version 提升为 latest_version,复用同一版本号、不重新打包),全量已授权账号下次同步生效。⚠️ **agent 不得自行执行转正**,也不得默认使用 `publish --prod` 直发正式(仅紧急热修且经人确认时使用)。测试版本号必须高于当前正式版(执行机只升不降)。
|
||||||
|
- 鉴权:密码登录 `--admin puddy --password 123456`,**一律显式加 `--base http://172.30.30.243:8800`(内网生产控制面,执行机实际连接源)**,或中心机本机密钥自签。⚠️ 控制面只有内网这一套(执行机唯一连接源),不存在第二套库;端口分工(**控制面与文件服务器同机部署在内网 `172.30.30.243`**):8800 控制面(controlplane-next)/ 8090 控制台前端(nginx 反代 /api)/ 8802 文件服务器下载(`desktop/fileserver/`,现役目录 `/opt/37du/fileserver`)/ 8899 文件服务器管理台。
|
||||||
|
- **SDK 发布直发正式(不走测试通道,2026-11-10 起)**:SDK 无独立执行入口、不能单独运行,发到 testing 也无从验证;`sdk-publish` 正常加 `--prod` 直发正式(仍需先过兼容预检门禁)。要小范围验证就发**消费插件**的测试版(插件那条线不变)。SDK 版本号三处一致(`sdk.json` / `__version__` / `pyproject.toml`),改了代码必须升版本(同版本重打会被执行机拒装);`sdk-status --status disabled/revoked`、`sdk-yank` 属人工确认动作。SOP 见技能 `.skills/37du-SDK-Deploy/SKILL.md`。
|
||||||
|
- 完整流程、命令示例见 docs/插件/发版规范.md、docs/桌面端/桌面端发版SOP.md;中心机部署见 docs/部署/服务端前后端部署SOP.md 或技能 `.skills/37du-Center-Deploy/SKILL.md`(SSH、编译、重启、验证)。
|
||||||
|
|
||||||
|
6. 误删防护(命令守卫 / 硬规则)
|
||||||
|
- **禁止用 shell 做删除/还原/迁移工程的操作**:`Remove-Item`、`del`、`erase`、`rd`/`rmdir`、`rm`、`Move-Item`、`git clean`、`git reset --hard`、`git restore .`、`git checkout -- .`、`git stash drop/clear`、`robocopy /MIR` 等一律不许出现在 PowerShell/CMD 命令里。删除文件只用 `delete_file` 工具(单文件、带路径校验与用户审批);丢弃改动优先 `git stash`,不要 `reset --hard`。
|
||||||
|
- 清理构建产物、临时目录交给现成脚本(打包/清理脚本),不要手写递归删除命令。
|
||||||
|
- 兜底机制(用户级 CodeBuddy 钩子,对所有项目生效):`%USERPROFILE%\.codebuddy\hooks\cmd_guard.py`,注册在 `%USERPROFILE%\.codebuddy\settings.json` 的 `hooks.PreToolUse`(matcher `.*`,只检查 shell 类工具的 command 字段,写文件内容不参与判定)。
|
||||||
|
- **硬拦截(不可绕过)**:删除/移动目标命中「项目根、当前 cwd、其祖先目录、盘符根(`C:\`)、`/MIR` 镜像、格式化/diskpart/cipher 擦盘」,以及 `delete_file` 指向工程本体;命中即 exit 2 阻断。
|
||||||
|
- **软拦截**:其余删除类命令同样阻断(exit 2),确属人工确认过的清理才可在命令里加注释标记 `# 37du-guard-allow` 放行。
|
||||||
|
- 命中记录在 `%USERPROFILE%\.codebuddy\hooks\cmd_guard.log`;守卫自身异常一律放行(exit 0),不会卡死工作流。
|
||||||
|
- 校验改动是否生效:`python "%USERPROFILE%\.codebuddy\hooks\cmd_guard.py" --selftest <用例.json>`(用例为每行一个 `{"name","command","expect"}` JSON)。
|
||||||
@@ -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/>.
|
||||||
|
|||||||
@@ -1,2 +1,244 @@
|
|||||||
# Process-Automation
|
# Process-Automation(37duAutomation)
|
||||||
|
|
||||||
|
HR 业务流程自动化平台:覆盖 HRBP OA 审批、EHR 数据核对/导出、社保、考勤、排班、雇主险、门店经营数据核对等场景,提供**桌面端插件体系**(中心机 + 执行机 + 文件服务器)与 **影刀 RPA 单文件版**两条落地路线,配套「需求单 → 评分」文档体系与统一发版 CLI。
|
||||||
|
|
||||||
|
## 项目简介
|
||||||
|
|
||||||
|
形态上分两条落地路线:
|
||||||
|
|
||||||
|
* **桌面端插件体系**:中心机控制面(插件 / SDK 发布、账号权限、壳子与环境包分发、运行日志集中留存)+ 执行机桌面壳(Electron + Node,内置便携 Python 环境跑插件,公共库按 `requires.sdks` 版本化下发挂载)+ 独立内网文件服务器(大文件直连下载)。插件按账号权限自动同步加载,账号登录后即可用。
|
||||||
|
* **影刀 RPA 单文件版**:`workflows/` 下按业务隔离的单文件自包含脚本,直接导入影刀平台运行。
|
||||||
|
|
||||||
|
业务上覆盖两大类场景:
|
||||||
|
|
||||||
|
* **OA 审批自动化**:DrissionPage 浏览器自动化 + OA/EHR 接口,自动处理请假、加班、离职电子签、续签、调动改签等审批,内置规则校验、OCR(rapidocr 3.x)附件识别、钉钉/工作沟通推送、审批报告生成。
|
||||||
|
* **EHR / 经营数据处理**:对接 HR 平台接口与本地 Excel,完成考勤异常核对、排班异常识别、工资卡核对、社保增减名单/告知书、雇主险名额、门店出勤积分、通联/微盟/CRM/新美大/抖音等平台数据导出与核对。
|
||||||
|
|
||||||
|
## 部署拓扑(现役)
|
||||||
|
|
||||||
|
```
|
||||||
|
执行机(员工电脑) 内网服务器 172.30.30.243
|
||||||
|
┌───────────────────────────┐ ┌────────────────────────────────────┐
|
||||||
|
│ desktop/electron-shell │ X-API-Token/Bearer │ 8800 controlplane-next 控制面 │
|
||||||
|
│ Electron + Node 主进程 │ ───────────────────▶ │ (Midway/cool-admin, systemd │
|
||||||
|
│ 本地 HTTP/WS :8799 │ │ 37du-controlplane-next) │
|
||||||
|
│ └ 插件(Python 子进程) │ 大文件直连下载 │ 8090 控制台前端(nginx 反代 /api) │
|
||||||
|
└───────────────────────────┘ ───────────────────▶ │ 8802 fileserver 文件服务器 │
|
||||||
|
│ 8899 文件服务器管理台 │
|
||||||
|
│ 3306 MySQL │
|
||||||
|
└────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
| 端口 | 组件 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| 8800 | 控制面 `desktop/controlplane-next/server` | 生产(内网)唯一版本源,执行机连接的就是这里 |
|
||||||
|
| 8090 | 控制台前端(nginx) | Art Design Pro 静态站,`/api` 反代 8800 |
|
||||||
|
| 8802 | 文件服务器 `desktop/fileserver` | 壳子安装包 / 环境包 / Chrome 包,下载免鉴权 |
|
||||||
|
| 8899 | 文件服务器管理台(nginx) | 上传 / 删除 / 下载统计 |
|
||||||
|
| 8799 | 客户端本地服务 | 仅本机,UI 与主进程通信 |
|
||||||
|
|
||||||
|
> ⚠️ 控制面只有内网 `http://172.30.30.243:8800` 一套(systemd `37du-controlplane-next.service`),执行机只连这一套;
|
||||||
|
> 发版 / 授权 / 登记一律显式加 `--base http://172.30.30.243:8800`,不要指向本机或其他地址。
|
||||||
|
|
||||||
|
## 仓库结构
|
||||||
|
|
||||||
|
```
|
||||||
|
37duAutomation/
|
||||||
|
├── desktop/ # 桌面端各方向独立演进(模块搜索根 = desktop/,运行 cwd = desktop/)
|
||||||
|
│ ├── controlplane-next/ # 中心机(现役):Midway + cool-admin 8 + Art Design Pro
|
||||||
|
│ │ ├── server/ # 后端(TS,端口由 CENTER_PORT 决定,生产 8800)
|
||||||
|
│ │ ├── frontend/ # 控制台前端(Vue3 + Element Plus + Vite,dev 3006)
|
||||||
|
│ │ ├── migrations/ # 增量 SQL(手工在中心机 MySQL 执行后重启服务)
|
||||||
|
│ │ └── schema_*.sql # 现网库只读快照 / cool 框架表 DDL
|
||||||
|
│ ├── electron-shell/ # 执行机桌面壳(现役宿主,当前 1.10.10)
|
||||||
|
│ │ ├── electron/ # 主进程 41 个模块:本地服务、插件/SDK 同步、调度/执行/队列/流程、壳子自更新、托盘
|
||||||
|
│ │ ├── frontend/ # 壳自有 Vue3 前端源码(构建 → renderer/dist)
|
||||||
|
│ │ ├── renderer/dist/ # 打进 asar 的前端产物
|
||||||
|
│ │ ├── python/webhost/ # 壳内置 Python 运行时子集(插件 ABI + 执行协议 + SDK 挂载)
|
||||||
|
│ │ ├── python-env/ # 便携 Python 环境包(版本目录 + current.json,开发态联调)
|
||||||
|
│ │ ├── scripts/ # copy-renderer.ps1 / build-python-env.ps1 / pack.js / after-pack.js
|
||||||
|
│ │ └── dist-app/ # electron-builder 产物(NSIS,setup-37du-shell-<ver>.exe)
|
||||||
|
│ └── fileserver/ # 内网文件服务器(FastAPI,8802 / 管理台 8899)
|
||||||
|
├── plugins/ # 插件源码(被执行机按账号权限自下载,不随壳子发布)
|
||||||
|
│ └── XQ0001-0100/ # 按号段分桶,每插件一个中文目录(XQ0002 雇主险增减操作/ …)
|
||||||
|
├── dist-plugin/ # 插件打包产物 <id>_v<版本>.zip(本地生成,.gitignore 不入库)
|
||||||
|
├── dist-sdk/ # SDK 打包产物 <id>_v<版本>.zip(本地生成,.gitignore 不入库)
|
||||||
|
├── workflows/ # 影刀 RPA 单文件版(每 100 号一桶,对应 docs/需求单/XQ00xx)
|
||||||
|
│ ├── share/ # 共享指令:登录(OA/HR/ERP/收银/门店/微盟/CRM)、钉钉推送、花名册导出
|
||||||
|
│ ├── XQ0001-0100/
|
||||||
|
│ └── README.md # 影刀版开发指南
|
||||||
|
├── libs/ # 跨方向共享的独立 Python 库(非业务代码)
|
||||||
|
│ ├── desktopauto/ # 桌面自动化:识图点击 / 图像存在判断 / OCR 文字坐标 / 键鼠 / 窗口 / 进程
|
||||||
|
│ ├── hr_sdk/ # HR(RedseaPlatform)接口封装:台账导出 / 花名册 / 审批 / 考勤 / 封存
|
||||||
|
│ ├── dingtalk/ # 钉钉 SDK:群机器人 / 企业应用鉴权 / dws 单聊群聊推送 / AI 表格
|
||||||
|
│ ├── hotel_report/ # 金贵系统 SDK:交班 / 销售明细 / 营业日报 / 会员卡统计(WCF 只读)
|
||||||
|
│ └── aitable/ # 钉钉 AI 表格读写 + 月报/周报采集
|
||||||
|
├── tools/
|
||||||
|
│ ├── agent_cli.py # 统一发版 CLI(插件/SDK 发布与转正、授权、壳子/环境包 file push)
|
||||||
|
│ ├── sdk_pack.py # SDK 打包(校验 sdk.json / 生成 api.json / 出 zip,--install 装到 sdk 根联调)
|
||||||
|
│ └── sdk_compat_check.py # SDK 发版兼容预检门禁(插件 compat / API diff / 自测,三分级定能否发)
|
||||||
|
├── tests/ # 试验与冒烟脚本(xq0002 雇主险、xq0041 新美大、日志回传、_app_ 蓝图归档)
|
||||||
|
├── docs/ # 文档(索引见 docs/README.md)
|
||||||
|
│ ├── 需求单/ # 各 XQ 四件套 + 需求单索引 + 评分规则 + 实现形态登记表
|
||||||
|
│ ├── 插件/ # 插件开发规范 / 插件 UI 开发规范 / 发版规范
|
||||||
|
│ ├── 架构/ # 架构蓝图 / 插件管理系统设计 / 客户端设计 / 服务端迁移方案
|
||||||
|
│ ├── 部署/ # 服务端(控制面 + 文件服务器)部署 SOP
|
||||||
|
│ └── 桌面端/ # 客户端交接 / 桌面端发版 SOP / 日志回传 / 账号加密 / 产品化差距分析
|
||||||
|
├── AGENTS.md # AI 智能体开发约束 & 项目执行规范
|
||||||
|
└── requirements.txt # Python 依赖(影刀版 + 插件 + 工具链)
|
||||||
|
```
|
||||||
|
|
||||||
|
> `dist-plugin/`、`dist-sdk/` 分别是插件与 SDK zip 的本地打包输出(`.gitignore` 忽略,不入库);`app/`(早期模块化蓝图)、`desktop/controlplane/`(旧 FastAPI 中心机)、`desktop/webhost/`(旧执行机底座)均已从仓库移除;`.skills/` 为本地 Agent 技能目录(不入库)。
|
||||||
|
>
|
||||||
|
> `libs/` 里 4 个库走 **SDK 版本化下发**(`sdk.json` + `tools/sdk_pack.py` 打包,执行机按插件 `requires.sdks` 下载挂载);`aitable/` 仍走环境包预装或插件 vendored。SDK **不得**预装进 python-env(同名包会让挂载 fail-fast)。
|
||||||
|
|
||||||
|
## 核心功能
|
||||||
|
|
||||||
|
| 模块 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| 自动登录/会话 | OA(SSO)、EHR、社保、ERP、收银、门店、微盟、CRM 登录;cookie 按账号隔离缓存,过期自动重登 |
|
||||||
|
| 审批流程引擎 | 待办获取、表单解析、规则校验、结果提交、报告生成 |
|
||||||
|
| 请假/加班审批 | 多类型(事假/病假/产假/年度福利假/加班类型等)分支校验,含附件 OCR |
|
||||||
|
| 电子签类 | 离职、续签、调动改签、转正不通过(离职+入职)流程自动审核 |
|
||||||
|
| 考勤异常处理 | 周/月考勤异常核对,三查复核,钉钉推送 |
|
||||||
|
| 考勤月报封存检查 | 月报封存状态、加班补偿、休班核对等多维检查与封存数据导出 |
|
||||||
|
| 排班异常识别 | 调动/预入职台账导出 + 部门排班集合比对判定,序列/离职过滤,按店长分组钉钉单聊推送 |
|
||||||
|
| 工资卡核对 / 花名册检查 | 身份证/姓名/银行卡号格式与一致性校验;花名册字段合规检查 |
|
||||||
|
| 社保类 | 增减名单梳理、导入名单生成、社保系统增减员办理与回盘核对、参保异常处理 |
|
||||||
|
| 社保告知书 | 按模板生成 Word/PDF 告知书并合并下发 |
|
||||||
|
| 雇主险 | 名额调度、增减操作、变更名单导出 |
|
||||||
|
| 数据导出/核对类 | 物料收发汇总、ERP 采购订单、通联交易、微盟、CRM 多报表、新美大、抖音、出勤积分、定性评价推送 |
|
||||||
|
| 执行机能力 | 执行队列、流程编排(DAG)+ 版本回滚、cron 定时、运行历史与日志回看、插件界面内嵌、运行备注、通知浮窗(WS 秒达)、日志集中回传、壳子/环境包/SDK 自动下发、插件正式/测试通道 |
|
||||||
|
| 重试/日志 | 项目级最大 3 次重试;INFO 屏蔽大体积 JSON 调试日志,`DEBUG=1` 全量输出 |
|
||||||
|
|
||||||
|
各 XQ 的落地状态(影刀版 / 插件版)以 `docs/需求单/实现形态登记表.md` 为准,不在此处手工维护。
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
| 层 | 技术 |
|
||||||
|
|---|---|
|
||||||
|
| 插件 / 影刀脚本 | Python 3.11、DrissionPage、pandas / openpyxl、rapidocr 3.x + ddddocr + opencv、python-docx、chinese_calendar |
|
||||||
|
| 执行机壳 | Electron 30.5.1 + Node(CommonJS 主进程,可无 Electron 跑 CLI)、better-sqlite3、ws、adm-zip |
|
||||||
|
| 便携运行时 | embeddable Python 3.11.9 + 插件依赖(`scripts/build-python-env.ps1` 构建,独立版本化下发);公共库走 SDK 独立下发 |
|
||||||
|
| 中心机后端 | Node ≥20、Midway 3.20、cool-admin-midway 8.0、TypeORM + MySQL、Redis(可选) |
|
||||||
|
| 控制台前端 | Vue3 + Vite + Element Plus + Art Design Pro(pnpm ≥8.8,Node ≥20.19) |
|
||||||
|
| 文件服务器 | Python FastAPI + uvicorn,文件落盘 + MySQL 元数据(未配库时 JSON 兜底) |
|
||||||
|
| 发版工具 | `tools/agent_cli.py`(Python,走控制面 admin HTTP 接口) |
|
||||||
|
|
||||||
|
> Python 侧一律使用项目本地虚拟环境 `d:\work\code\37duAutomation\.venv`(`.venv\Scripts\python.exe`),不使用全局 Python、不使用沙箱。
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### Python 侧(影刀版 / 插件 / 工具)
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.venv\Scripts\Activate.ps1
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
### 桌面端(本地开发)
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 1) 文件服务器(cwd = desktop/)
|
||||||
|
cd d:\work\code\37duAutomation\desktop
|
||||||
|
..\.venv\Scripts\python.exe -m fileserver.main # http://127.0.0.1:8802
|
||||||
|
|
||||||
|
# 2) 中心机后端(controlplane-next,本地默认 8001)
|
||||||
|
cd d:\work\code\37duAutomation\desktop\controlplane-next\server
|
||||||
|
npm install
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# 3) 控制台前端(dev 3006,/api → 127.0.0.1:8001)
|
||||||
|
cd d:\work\code\37duAutomation\desktop\controlplane-next\frontend
|
||||||
|
pnpm install
|
||||||
|
pnpm dev
|
||||||
|
|
||||||
|
# 4) 执行机客户端
|
||||||
|
cd d:\work\code\37duAutomation\desktop\electron-shell
|
||||||
|
npm install
|
||||||
|
npm run copy-renderer # frontend/ → renderer/dist(前端有改动时)
|
||||||
|
npm run electron # Electron 窗口模式;npm start = 纯 Node CLI 模式
|
||||||
|
```
|
||||||
|
|
||||||
|
> `desktop/controlplane/`(FastAPI 旧中心机)与 `desktop/webhost/`(旧执行机底座)已于 2026-11 从仓库移除,现役只有 `controlplane-next` + `electron-shell` + `fileserver`;存量环境排障请查 git 历史。
|
||||||
|
|
||||||
|
### 影刀版脚本(单文件自包含,直接运行)
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 先跑登录指令写入共享登录态(cookies 按账号隔离)
|
||||||
|
python workflows\share\oa_login.py
|
||||||
|
python workflows\share\hr_login.py
|
||||||
|
python workflows\share\roster_export.py
|
||||||
|
|
||||||
|
# 业务脚本示例
|
||||||
|
python "workflows\XQ0001-0100\XQ0001 排班异常识别\shift_abnormal_check.py"
|
||||||
|
python "workflows\XQ0001-0100\XQ0003 EHR系统请假流程审核\leave_approval.py"
|
||||||
|
python "workflows\XQ0001-0100\XQ0010 EHR系统月考勤异常处理\attendance_abnormal_monthly.py"
|
||||||
|
python "workflows\XQ0001-0100\XQ0014 社保系统增减员办理\import_add.py"
|
||||||
|
```
|
||||||
|
|
||||||
|
完整清单与开发约定见 `workflows/README.md`。
|
||||||
|
|
||||||
|
## 插件开发与发版
|
||||||
|
|
||||||
|
* 插件源码:`plugins/XQ0001-0100/<XQ00xx 中文名>/`,id 固定为 `xq{单号}`;内部按 `config/ data/ logic/ report/ ui/` 多文件组织,**自包含**(只能引用自身模块 + 标准库/三方依赖 + 底座注入的 `webhost.backend.plugins.base`)。
|
||||||
|
* 规范:[docs/插件/插件开发规范.md](docs/插件/插件开发规范.md)、[docs/插件/插件UI开发规范.md](docs/插件/插件UI开发规范.md)。
|
||||||
|
* 发版(示例,**务必显式 --base 内网**):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 插件发布(zip 由插件目录内 _pack.py 生成);默认进「测试通道」,只有管理员账号能同步到在测版本
|
||||||
|
.venv\Scripts\python.exe tools\agent_cli.py `
|
||||||
|
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
|
||||||
|
publish <插件.zip> --id xq0011 --version 1.2.0
|
||||||
|
|
||||||
|
# 人工验证通过后转正(由人执行,服务端把 test_version 提升为 latest_version,不重新打包)
|
||||||
|
.venv\Scripts\python.exe tools\agent_cli.py --admin puddy --password 123456 --base http://172.30.30.243:8800 `
|
||||||
|
plugin-status xq0011 --status published
|
||||||
|
|
||||||
|
# 账号授权 / 撤销
|
||||||
|
.venv\Scripts\python.exe tools\agent_cli.py --admin puddy --password 123456 --base http://172.30.30.243:8800 grant <账号> xq0011
|
||||||
|
.venv\Scripts\python.exe tools\agent_cli.py --admin puddy --password 123456 --base http://172.30.30.243:8800 revoke <账号> xq0011
|
||||||
|
|
||||||
|
# 壳子安装包发布(上传文件服务器 + 登记 file_sources(shell))
|
||||||
|
.venv\Scripts\python.exe tools\agent_cli.py `
|
||||||
|
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
|
||||||
|
file push <setup-37du-shell-x.y.z.exe> --category shell --version x.y.z --notes "更新说明"
|
||||||
|
|
||||||
|
# 便携环境包 / SDK 发布
|
||||||
|
.venv\Scripts\python.exe tools\agent_cli.py --admin puddy --password 123456 --base http://172.30.30.243:8800 `
|
||||||
|
file push <python-env-x.y.z.zip> --category python-env --version x.y.z
|
||||||
|
.venv\Scripts\python.exe tools\agent_cli.py --admin puddy --password 123456 --base http://172.30.30.243:8800 `
|
||||||
|
sdk-publish "dist-sdk\hr_sdk_v0.1.3.zip" --id hr_sdk --version 0.1.3 --prod # SDK 直发正式(需先过兼容预检)
|
||||||
|
```
|
||||||
|
|
||||||
|
* 执行机侧:登录后按账号权限自下载(`plugin-sync.js` / `sdk-sync.js`),升级前自动备份可回滚;壳子 / 环境包 / SDK / 插件各自独立升级,随 30 分钟统一时间线检查。
|
||||||
|
* **插件必须走「测试通道 → 人工验证 → 转正」**:`publish` 默认进 testing,`--prod` 直发正式仅限紧急热修且经人确认;转正属人工动作,AI/脚本不得自行执行。
|
||||||
|
* SDK 用 `sdk-publish`(同样先过 `tools/sdk_compat_check.py` 门禁),无独立执行入口故直发正式;版本号需 `sdk.json` / `__version__` / `pyproject.toml` 三处一致。
|
||||||
|
* 完整流程:[docs/插件/发版规范.md](docs/插件/发版规范.md)、[docs/桌面端/桌面端发版SOP.md](docs/桌面端/桌面端发版SOP.md)。
|
||||||
|
|
||||||
|
## 文档体系
|
||||||
|
|
||||||
|
| 文档 | 内容 |
|
||||||
|
|---|---|
|
||||||
|
| [docs/README.md](docs/README.md) | 文档总索引 |
|
||||||
|
| [docs/部署/服务端前后端部署SOP.md](docs/部署/服务端前后端部署SOP.md) | 控制面 / 文件服务器部署到内网中心机 |
|
||||||
|
| [docs/桌面端/桌面端发版SOP.md](docs/桌面端/桌面端发版SOP.md) | 壳子 / 环境包 / 文件服务器发版 |
|
||||||
|
| [docs/桌面端/Node版客户端开发交接文档.md](docs/桌面端/Node版客户端开发交接文档.md) | 客户端架构、模块、与控制面的契约 |
|
||||||
|
| [docs/插件/发版规范.md](docs/插件/发版规范.md) | 插件发布 / 授权 / 自动更新(测试通道 → 转正) |
|
||||||
|
| [docs/架构/SDK挂载机制设计.md](docs/架构/SDK挂载机制设计.md) | SDK 版本化下发、挂载与兼容策略(`requires.sdks`) |
|
||||||
|
| [docs/插件/SDK兼容预检工具.md](docs/插件/SDK兼容预检工具.md) | `sdk_compat_check.py` 用法与三分级判定(发版门禁) |
|
||||||
|
| [docs/桌面端/客户端产品化差距分析.md](docs/桌面端/客户端产品化差距分析.md) | 客户端产品化差距、优先级与落地顺序(随版本校正) |
|
||||||
|
| [docs/桌面端/运行日志集中回传.md](docs/桌面端/运行日志集中回传.md) | 运行日志 / 壳日志回传契约与排障 |
|
||||||
|
| [docs/需求单/README.md](docs/需求单/README.md) | 需求单索引(XQ0001~XQ0063) |
|
||||||
|
| [docs/需求单/评分规则.md](docs/需求单/评分规则.md) | RPA 场景分级与量化评审标准 |
|
||||||
|
|
||||||
|
每个需求单维护 需求 / 流程 / 开发 / 评分 四件套,按号段分桶存放;已落地场景的评分文档为初稿,需业务方签字 + 网络信息部审批 + 人资备案。
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
1. 运行环境:Python 侧统一 `.venv`;控制面 `server/` 需 Node ≥20,前端需 pnpm ≥8.8;客户端打包需能放行 electron postinstall,且**统一走 `npm run pack`**(自动切 Electron ABI 原生模块 + 包内哈希校验,直接 `electron-builder` 会产出装不上的包)。
|
||||||
|
2. 确保目标机器装有 Chrome/Edge(服务端可下发 Chrome 安装包,客户端自动检测/静默安装)。
|
||||||
|
3. 首次使用需登录一次(账号密码或钉钉扫码),会话 cookie 按账号隔离写入 `%LOCALAPPDATA%\37duAutomation\.sessions\<账号>\`。
|
||||||
|
4. 客户端数据根 `%LOCALAPPDATA%\37duAutomation`:插件配置 `plugin_configs/<插件id>.json`(明文 JSON)、打包态插件 `plugins/`、便携环境 `python-env/`、SDK `sdk/<id>/<version>/`、运行备注、日志与运行历史等;跨端(历史版本 / 影刀版)共用同一路径契约。
|
||||||
|
5. 插件不随安装包分发、壳子不打包插件;插件 / SDK / 壳子 / 环境包解耦发布,回滚窗口内各自可退。
|
||||||
|
6. `desktop/controlplane/`(FastAPI 旧中心机)、`desktop/webhost/`(旧执行机底座)已于 2026-11 从仓库移除,不再有可运行代码或配置;新需求一律落在 `controlplane-next`、`electron-shell`、`fileserver`。历史仅存于 git 历史。
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
一、延时加班
|
|
||||||
(一)驳回门槛(任一不满足直接驳回)
|
|
||||||
1. 日期匹配规则:加班开始时间所属日期 = 加班申请日期。当日开始、次日结束的跨天加班,按开始时间判定日期,视为符合要求。
|
|
||||||
2. 时长达标规则:以「申请结束时间 - 申请开始时间」计算申请加班总时长,统一执行以下计时标准:
|
|
||||||
◦ 不足1小时的,直接驳回;
|
|
||||||
◦ 满1小时及以上的,超出1小时的部分按0.5小时为单位向下取整累加,不足0.5小时的部分不计入有效时长。
|
|
||||||
◦ 跨天延时加班的总时长统一套用上述取整规则,不按日期分段计算。
|
|
||||||
3. 区间合规校验:申请开始时间 ≥ 当日规定下班时间,且申请结束时间 ≤ 当日实际下班打卡时间;超出该区间的申请直接驳回。
|
|
||||||
(二)弹性到岗兑换规则(仅影响结算时长,不影响审批通过与否)
|
|
||||||
员工可使用当日加班时长等额兑换次日晚到时长,兑换额度、校验规则如下:
|
|
||||||
1. 弹性额度D计算规则
|
|
||||||
◦ 计算基准:以当日实际下班打卡时间为准,与申请结束时间无关。
|
|
||||||
◦ 触发条件:实际下班打卡时间 < 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. 额外校验:申请日期必须为春节法定节假日;春节假期内的调休休息日,不适用本规则,按休息日加班规则执行。
|
|
||||||
---
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
@Module: app
|
|
||||||
@FileName: __init__.py
|
|
||||||
@Author: 小布丁
|
|
||||||
@CreateTime: 2026-08-05 17:00
|
|
||||||
@Description: 应用主包
|
|
||||||
@Version: 1.0.0
|
|
||||||
"""
|
|
||||||
@@ -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
|
|
||||||
"""
|
|
||||||
@@ -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
|
|
||||||
"""
|
|
||||||
@@ -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
|
|
||||||
"""
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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)
|
|
||||||
@@ -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
|
|
||||||
@@ -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)
|
|
||||||
@@ -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}
|
|
||||||
@@ -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()
|
|
||||||
@@ -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)
|
|
||||||
@@ -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()
|
|
||||||
@@ -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,
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
@Module: utils
|
|
||||||
@FileName: __init__.py
|
|
||||||
@Author: 小布丁
|
|
||||||
@CreateTime: 2026-08-05 17:00
|
|
||||||
@Description: 项目级通用工具包
|
|
||||||
@Version: 1.0.0
|
|
||||||
"""
|
|
||||||
@@ -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
|
|
||||||
@@ -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)
|
|
||||||
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 移到这里)
|
||||||
|
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,307 @@
|
|||||||
|
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
|
||||||
|
status?: string
|
||||||
|
category?: string
|
||||||
|
flags?: string
|
||||||
|
sort?: string
|
||||||
|
order?: string
|
||||||
|
}) {
|
||||||
|
return request.get<{ items: any[]; total: number; stats?: Record<string, number> }>({
|
||||||
|
url: '/api/admin/plugins',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传发布插件包(multipart;channel=test 进测试通道,仅管理员可见) */
|
||||||
|
export function uploadPlugin(file: File, params: { plugin_id: string; name?: string; version: string; channel?: 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 })
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== SDK(挂载到执行机的纯 Python 运行库) ====================
|
||||||
|
|
||||||
|
/** SDK 列表(含版本历史与当前可用版本) */
|
||||||
|
export function fetchSdks() {
|
||||||
|
return request.get<{ items: any[]; total: number }>({ url: '/api/admin/sdks' })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传发布 SDK 包(multipart;channel=test 进测试通道,仅管理员账号可同步) */
|
||||||
|
export function uploadSdk(file: File, params: { sdk_id: string; name?: string; version: string; channel?: string }) {
|
||||||
|
const fd = new FormData()
|
||||||
|
fd.append('file', file)
|
||||||
|
return request.post<any>({ url: '/api/admin/sdk-pkg', data: fd, params, timeout: 300000 })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新 SDK 状态(published=把在测版本转正) */
|
||||||
|
export function patchSdk(sdk_id: string, body: any) {
|
||||||
|
return request.post<any>({ url: '/api/admin/sdk/patch', params: { sdk_id }, data: body })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 撤回某个 SDK 版本(执行机下次同步回落到最高可用版本) */
|
||||||
|
export function yankSdk(sdk_id: string, version: string) {
|
||||||
|
return request.post<any>({ url: '/api/admin/sdk-yank', data: { sdk_id, version } })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 SDK(连带版本与磁盘包文件) */
|
||||||
|
export function deleteSdk(sdk_id: string) {
|
||||||
|
return request.post<any>({ url: '/api/admin/sdk/delete', data: { sdk_id } })
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 字典(可维护枚举,如场景分类 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'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 954 B |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 726 B |
|
After Width: | Height: | Size: 944 B |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 810 B |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 514 B |
|
After Width: | Height: | Size: 409 B |
|
After Width: | Height: | Size: 431 B |
|
After Width: | Height: | Size: 439 B |
|
After Width: | Height: | Size: 292 B |
|
After Width: | Height: | Size: 286 B |
|
After Width: | Height: | Size: 293 B |
|
After Width: | Height: | Size: 448 B |
|
After Width: | Height: | Size: 416 B |
|
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 |
|
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 |
|
After Width: | Height: | Size: 2.1 KiB |
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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');
|
||||||
|
}
|
||||||