Commit Graph

16 Commits

Author SHA1 Message Date
6bff5e4d97 fix: stats loader and smtp daily reset 2025-12-13 22:01:12 +08:00
d7d878dc08 fix: 内存溢出与任务调度优化 2025-12-13 17:40:36 +08:00
9e761140c1 feat: SMTP配额自动重置(北京时间凌晨0点)
- 添加reset_smtp_daily_quota函数主动重置配额
- 添加定时任务在北京时间00:00自动重置SMTP配额
- 保留被动重置作为备份机制

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 04:01:50 +08:00
a7976bcdfc fix: SMTP配额重置使用北京时间
- 添加pytz时区支持
- 配额重置日期改为使用北京时间(UTC+8)
- 确保配额在北京时间凌晨0点重置,而不是UTC时间

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 03:57:44 +08:00
42cc86e290 fix: 修复browser_installer.py语法错误,同步服务器代码
- 修复browser_installer.py顶部错误的import语句
- 移除browser_installer.py中未正确实现的_cleanup_zombie_processes方法
- 恢复playwright_automation.py中的SIGKILL(服务器版本)
- 同步database.py和email_service.py的最新代码

注意:内存占用从50MB增加到142MB是正常的,因为:
1. 4个浏览器Worker线程(按需模式)占用基础内存
2. 新增的清理代码和SIGCHLD处理器占用少量内存
3. 当前内存使用在正常范围内

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 03:35:12 +08:00
90f503518f 修复bug和清理调试代码
1. email_service.py: 删除未定义的log_email_send调用(send_email内部已记录日志)
2. app.py: 删除[DEBUG run_task]调试打印语句
3. playwright_automation.py: 删除[调试]诊断日志块

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 15:36:36 +08:00
Yu Yon
b15e6f2af0 修复高优先级安全和稳定性问题
1. app.py:
   - 添加user_semaphores_lock线程锁,修复get_user_semaphore竞态条件
   - 将9处裸except:改为except Exception:或具体异常类型

2. database.py:
   - 将3处裸except:改为except Exception:

3. email_service.py:
   - 添加_smtp_config_lock线程锁
   - 修复daily_sent计数竞态条件:获取配置时预增,失败时回退
   - _get_available_smtp_config和_get_next_available_smtp_config使用锁保护

🤖 Generated with Claude Code
2025-12-12 15:04:58 +08:00
8c8c708ce7 fix: 修复send_email参数名错误
使用正确的参数名: to_email, body, html_body

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 23:31:22 +08:00
d6fa5b91ea feat: 定时任务截图打包发送邮件
1. 添加批次任务跟踪机制,收集同一定时任务的所有账号截图
2. 等所有账号执行完成后,将截图打包成ZIP发送一封邮件
3. 邮件包含任务执行详情表格和统计信息

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 23:21:24 +08:00
79cf3c2f30 fix: 修复邮箱绑定验证错误及多项改进
1. 修复email_verified字段缺失导致的500错误
2. 将邮件主题从"知识管理平台"改为"自动化学习"
3. 增大验证码字体(28->42)和图片尺寸(120x40->160x60)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 22:45:44 +08:00
65e2414ede fix: 修复邮件Token时间解析错误
问题:数据库中的时间戳包含微秒(如 2025-12-11 14:31:20.307257),
但代码使用 '%Y-%m-%d %H:%M:%S' 格式解析会报错。

解决:添加 parse_datetime() 函数,支持带微秒和不带微秒两种格式。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 22:33:46 +08:00
29d4bdfbcb feat: 添加邮件功能第五阶段 - 用户邮箱绑定
1. 添加邮箱绑定验证邮件模板 (templates/email/bind_email.html)
2. 在email_service.py中添加:
   - send_bind_email_verification() 发送绑定验证邮件
   - verify_bind_email_token() 验证绑定Token
3. 在database.py中添加:
   - update_user_email() 更新用户邮箱
4. 在app.py中添加API:
   - GET /api/user/email - 获取用户邮箱信息
   - POST /api/user/bind-email - 发送绑定验证邮件
   - GET /api/verify-bind-email/<token> - 验证绑定Token
   - POST /api/user/unbind-email - 解绑邮箱
5. 更新templates/index.html:
   - 将"修改密码"弹窗改为"个人设置"
   - 添加邮箱绑定/解绑功能UI
   - 显示邮箱状态(未绑定/待验证/已验证)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 22:20:29 +08:00
0ccddd8c63 feat: 添加邮件功能第四阶段 - 任务完成通知
1. 添加任务完成邮件模板 (templates/email/task_complete.html)
2. 在email_service.py中添加:
   - task_notify_enabled 字段支持
   - send_task_complete_email() 函数,支持附件大小限制和分批发送
   - send_task_complete_email_async() 异步发送函数
   - MAX_ATTACHMENT_SIZE 常量 (10MB)
3. 更新app.py:
   - 邮件设置API支持task_notify_enabled字段
   - 截图回调中集成任务完成邮件发送
4. 更新admin.html:
   - 添加"启用任务完成通知"开关
   - 更新loadEmailSettings/updateEmailSettings函数

附件超过10MB时会自动分两封邮件发送(通知+截图),作为容错机制

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 22:09:59 +08:00
93375b612f feat: 添加邮件功能第三阶段 - 密码重置
实现通过邮件自助重置密码功能:
- 新增发送密码重置邮件API (/api/forgot-password)
- 新增密码重置页面路由 (/reset-password/<token>)
- 新增确认密码重置API (/api/reset-password-confirm)

新增文件:
- templates/email/reset_password.html - 密码重置邮件模板
- templates/reset_password.html - 密码重置页面

修改文件:
- email_service.py - 添加密码重置相关函数
  - send_password_reset_email()
  - verify_password_reset_token()
  - confirm_password_reset()
- app.py - 添加密码重置相关API
- templates/login.html - 忘记密码支持两种方式:
  - 启用邮件功能:通过邮件自助重置
  - 未启用邮件:提交申请等待管理员审核

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 21:58:49 +08:00
de8edcb3a6 feat: 添加邮件功能第二阶段 - 注册邮箱验证
实现注册时的邮箱验证功能:
- 修改注册API支持邮箱验证流程
- 新增邮箱验证API (/api/verify-email/<token>)
- 新增重发验证邮件API (/api/resend-verify-email)
- 新增邮箱验证状态查询API (/api/email/verify-status)

新增文件:
- templates/email/register.html - 注册验证邮件模板
- templates/verify_success.html - 验证成功页面
- templates/verify_failed.html - 验证失败页面

修改文件:
- email_service.py - 添加发送注册验证邮件函数
- app.py - 添加邮箱验证相关API
- database.py - 添加get_user_by_email函数
- app_config.py - 添加BASE_URL配置
- templates/register.html - 支持邮箱必填切换
- templates/login.html - 添加重发验证邮件功能
- templates/admin.html - 添加注册验证开关和BASE_URL设置

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 21:51:07 +08:00
966572cc94 feat: 添加邮件功能第一阶段 - 邮件基础设施
新增功能:
- 创建 email_service.py 邮件服务模块
  - 支持多SMTP配置(主备切换、故障转移)
  - 发送纯文本/HTML邮件
  - 发送带附件邮件(支持ZIP压缩)
  - 异步发送队列(多线程工作池)
  - 每日发送限额控制
  - 发送日志记录和统计

- 数据库表结构
  - smtp_configs: 多SMTP配置表
  - email_settings: 全局邮件设置
  - email_tokens: 邮件验证Token
  - email_logs: 邮件发送日志
  - email_stats: 邮件发送统计

- API接口
  - GET/POST /yuyx/api/email/settings: 全局邮件设置
  - CRUD /yuyx/api/smtp/configs: SMTP配置管理
  - POST /yuyx/api/smtp/configs/<id>/test: 测试SMTP连接
  - POST /yuyx/api/smtp/configs/<id>/primary: 设为主配置
  - GET /yuyx/api/email/stats: 邮件统计
  - GET /yuyx/api/email/logs: 邮件日志
  - POST /yuyx/api/email/logs/cleanup: 清理日志

- 后台管理页面
  - 新增"邮件配置"Tab
  - 全局邮件开关、故障转移开关
  - SMTP配置列表管理
  - 添加/编辑SMTP配置弹窗
  - 邮件发送统计展示
  - 邮件日志查询和清理

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 21:38:28 +08:00