feat: 拆分邮件通知选项,根据会员权益显示

- 翻译完成邮件通知(所有用户)
- 鮮件带附件发送(VIP专属,free用户显示需VIP)
- 会员到期提醒(仅VIP用户显示)
- 添加 notify_with_attachment 字段
- 更新各等级权益:email_notify/email_attachment
This commit is contained in:
2026-04-15 01:10:59 +08:00
parent 56709b1a65
commit 9a36b9245a
4 changed files with 53 additions and 8 deletions

View File

@@ -198,18 +198,40 @@
<hr class="my-2">
<!-- 翻译完成邮件通知(所有用户都有) -->
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="notifyComplete"
{% if user.notify_on_complete %}checked{% endif %}
onchange="updateNotifySettings()">
<label class="form-check-label">翻译完成通知(含附件)</label>
<label class="form-check-label">翻译完成邮件通知</label>
</div>
<!-- 邮件带附件VIP功能 -->
{% if has_email_attachment %}
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="notifyAttachment"
{% if user.notify_with_attachment %}checked{% endif %}
onchange="updateNotifySettings()">
<label class="form-check-label">邮件带附件发送 <span class="badge bg-success">VIP</span></label>
</div>
{% else %}
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" disabled>
<label class="form-check-label text-muted">邮件带附件发送 <span class="badge bg-secondary">需VIP</span></label>
<a href="/pricing" class="small ms-2">升级会员</a>
</div>
{% endif %}
<!-- 会员到期提醒 -->
{% if user.user_type.startswith('vip') %}
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="notifyExpire"
{% if user.notify_on_expire %}checked{% endif %}
onchange="updateNotifySettings()">
<label class="form-check-label">会员到期提醒</label>
</div>
{% endif %}
<small class="text-muted">通知将发送至上述邮箱</small>
</div>
</div>
@@ -524,21 +546,27 @@
// 更新通知设置
function updateNotifySettings() {
const notifyComplete = document.getElementById('notifyComplete').checked;
const notifyExpire = document.getElementById('notifyExpire').checked;
const notifyExpire = document.getElementById('notifyExpire')?.checked || false;
const notifyAttachment = document.getElementById('notifyAttachment')?.checked || false;
fetch('/api/profile/settings', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
notify_on_complete: notifyComplete,
notify_on_expire: notifyExpire
notify_on_expire: notifyExpire,
notify_with_attachment: notifyAttachment
})
})
.then(r => r.json())
.then(data => {
if (data.success) {
// 不刷新页面,只显示提示
console.log('设置已更新');
} else if (data.feature === 'email_attachment') {
alert('邮件附件功能需要VIP会员');
location.href = '/pricing';
} else {
alert('更新失败:' + data.error);
}
});
}