新增查当周按钮,代码重构与数据分离
- 新增"查当周"按钮,计算当周周一至周日的加班总工时 - 新增 createQueryButton 工厂函数,消除月按钮重复代码 - 修复 calculateTimeDifference 返回字符串导致 NaN 的 bug - 修复 sumOfSecondColumn/get_work_time 缺少空值保护的 bug - 修复 isWorkDay 中 == 改为 === - var 统一为 const/let,提取 QUERY_DELAY_MS 常量 - 提取 getCustomMonthRange 中重复的 formatLocal - 按钮增加 cursor:pointer 样式 - 数据与代码分离:main.template.js(~300行)+ build.py 自动组装 main.js - update.py/comp_json.py 支持命令行年份参数,默认当年 - comp_json.py 增加去重逻辑 - 更新 README 为 GitHub 开源项目风格,含快速上手和每年更新章节 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
21
build.py
Normal file
21
build.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import json
|
||||
|
||||
# 读取 data.json
|
||||
with open("data.json", "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
# 读取模板
|
||||
with open("main.template.js", "r", encoding="utf-8") as f:
|
||||
template = f.read()
|
||||
|
||||
# 构造数据块
|
||||
data_block = "const workDayData = " + json.dumps(data, ensure_ascii=False, indent=2) + ";"
|
||||
|
||||
# 替换占位符
|
||||
output = template.replace("/* WORKDAY_DATA_PLACEHOLDER */", data_block)
|
||||
|
||||
# 写出 main.js
|
||||
with open("main.js", "w", encoding="utf-8") as f:
|
||||
f.write(output)
|
||||
|
||||
print(f"main.js 构建完成 ({len(output)} 字符)")
|
||||
Reference in New Issue
Block a user