diff --git a/app.py b/app.py index e83c4f6..8463961 100644 --- a/app.py +++ b/app.py @@ -223,6 +223,8 @@ def pricing(): 'priority_queue': '优先处理队列', 'custom_instruction': '自定义翻译要求', 'api_access': 'API接口调用', + 'email_notify': '邮件通知', + 'email_attachment': '邮件附件发送', } # 从数据库读取动态配置的会员套餐 @@ -289,10 +291,15 @@ def profile(): daily_remaining = limits['daily_translations'] - user.daily_count if limits['daily_translations'] > 0 else '无限' max_pages = limits['max_pages'] if limits['max_pages'] > 0 else '无限' + # 检查是否有邮件附件权限 + user_features = limits.get('features', []) + has_email_attachment = 'email_attachment' in user_features or user_features == ['all'] + return render_template('profile.html', user=user, daily_remaining=daily_remaining, - max_pages=max_pages + max_pages=max_pages, + has_email_attachment=has_email_attachment ) @@ -876,6 +883,14 @@ def update_settings(): user.notify_on_complete = data.get('notify_on_complete', True) if 'notify_on_expire' in data: user.notify_on_expire = data.get('notify_on_expire', True) + if 'notify_with_attachment' in data: + # 检查是否有附件权限 + limits = USER_LIMITS.get(user.user_type, USER_LIMITS['free']) + user_features = limits.get('features', []) + if 'email_attachment' in user_features or user_features == ['all']: + user.notify_with_attachment = data.get('notify_with_attachment', False) + else: + return jsonify({'error': '邮件附件功能需VIP会员', 'feature': 'email_attachment'}), 403 if 'email_notify' in data: user.email_notify = data.get('email_notify', True) diff --git a/config.py b/config.py index 1c89152..7c9404f 100644 --- a/config.py +++ b/config.py @@ -39,19 +39,19 @@ USER_LIMITS = { "daily_translations": 10, "max_pages": 50, "max_file_size": 30 * 1024 * 1024, # 30MB - "features": ["basic_translate", "retranslate", "export_pdf", "history"], + "features": ["basic_translate", "retranslate", "export_pdf", "history", "email_notify"], }, "vip_basic": { # 基础会员 (月付 ¥29) "daily_translations": 50, "max_pages": 100, "max_file_size": 50 * 1024 * 1024, - "features": ["basic_translate", "compare_view", "retranslate", "history", "priority_queue", "export_pdf"], + "features": ["basic_translate", "compare_view", "retranslate", "history", "priority_queue", "export_pdf", "email_notify", "email_attachment"], }, "vip_pro": { # 专业会员 (月付 ¥99) "daily_translations": 200, "max_pages": 500, "max_file_size": 100 * 1024 * 1024, - "features": ["basic_translate", "compare_view", "retranslate", "history", "priority_queue", "export_pdf", "batch_translate", "custom_terms"], + "features": ["basic_translate", "compare_view", "retranslate", "history", "priority_queue", "export_pdf", "batch_translate", "custom_terms", "email_notify", "email_attachment"], }, "vip_enterprise": { # 企业会员 (年付 ¥999) "daily_translations": -1, # 无限制 diff --git a/models.py b/models.py index ccc2acd..5faa544 100644 --- a/models.py +++ b/models.py @@ -54,6 +54,7 @@ class User(db.Model): # 邮件通知设置 email_notify = db.Column(db.Boolean, default=True) # 邮件通知开关 notify_on_complete = db.Column(db.Boolean, default=True) # 翻译完成通知 + notify_with_attachment = db.Column(db.Boolean, default=False) # 邮件带附件(VIP功能) notify_on_expire = db.Column(db.Boolean, default=True) # 会员到期提醒 # 关系 @@ -132,6 +133,7 @@ class User(db.Model): 'invite_rewards': self.invite_rewards, 'email_notify': self.email_notify, 'notify_on_complete': self.notify_on_complete, + 'notify_with_attachment': self.notify_with_attachment, 'notify_on_expire': self.notify_on_expire, 'daily_count': self.daily_count, 'total_count': self.total_count, diff --git a/templates/profile.html b/templates/profile.html index 841ddcb..a3c219b 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -198,18 +198,40 @@