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>
This commit is contained in:
2025-12-11 22:09:59 +08:00
parent 93375b612f
commit 0ccddd8c63
4 changed files with 373 additions and 6 deletions

View File

@@ -1233,6 +1233,15 @@
开启后,新用户注册需通过邮箱验证才能激活账号(优先级高于自动审核)
</div>
</div>
<div class="form-group" style="margin-bottom: 10px;">
<label style="display: flex; align-items: center; gap: 10px;">
<input type="checkbox" id="taskNotifyEnabled" onchange="updateEmailSettings()" style="width: auto; max-width: none;">
启用任务完成通知
</label>
<div style="font-size: 12px; color: #666; margin-top: 5px;">
开启后,定时任务完成时将发送邮件通知给用户(用户需已设置邮箱)
</div>
</div>
<div class="form-group" style="margin-bottom: 0;">
<label style="display: block; margin-bottom: 5px;">网站基础URL</label>
<input type="text" id="baseUrl" placeholder="例如: https://example.com" style="width: 100%;" onblur="updateEmailSettings()">
@@ -2797,6 +2806,7 @@
document.getElementById('emailEnabled').checked = data.enabled;
document.getElementById('failoverEnabled').checked = data.failover_enabled;
document.getElementById('registerVerifyEnabled').checked = data.register_verify_enabled || false;
document.getElementById('taskNotifyEnabled').checked = data.task_notify_enabled || false;
document.getElementById('baseUrl').value = data.base_url || '';
}
} catch (error) {
@@ -2814,6 +2824,7 @@
enabled: document.getElementById('emailEnabled').checked,
failover_enabled: document.getElementById('failoverEnabled').checked,
register_verify_enabled: document.getElementById('registerVerifyEnabled').checked,
task_notify_enabled: document.getElementById('taskNotifyEnabled').checked,
base_url: document.getElementById('baseUrl').value.trim()
})
});