From f55f2027e5aaa4b0ce814e15690e4849176947ad Mon Sep 17 00:00:00 2001 From: coder Date: Tue, 14 Apr 2026 18:00:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=89=B9=E7=82=B9=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=8A=A8=E6=80=81=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 访客/免费/VIP各等级显示不同可用功能 - 有权限显示✅,无权限显示❌ - 添加.gitignore排除uploads/outputs/cache目录 --- .gitignore | 3 +++ app.py | 37 ++++++++++++++++++++++++++++++++++++- templates/index.html | 9 ++++++--- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6d006b1..54d08ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ instance/ *.db __pycache__/ +uploads/ +outputs/ +cache/ diff --git a/app.py b/app.py index d519d83..a1f841d 100644 --- a/app.py +++ b/app.py @@ -120,12 +120,47 @@ def index(): daily_remaining = limits['daily_translations'] - guest.daily_count max_pages = limits['max_pages'] + # 获取用户的功能列表 + if user: + user_features = limits.get('features', []) + else: + user_features = USER_LIMITS['guest']['features'] + + # 定义所有功能及其描述 + all_features = { + 'basic_translate': {'name': '自动翻译缓存,相同文件秒出结果', 'base': True}, + 'custom_instruction': {'name': '自定义翻译要求', 'base': False}, + 'compare_view': {'name': '原文译文对比查看', 'base': False}, + 'history': {'name': '翻译历史记录', 'base': False}, + 'retranslate': {'name': '不满意重新翻译', 'base': False}, + 'export_pdf': {'name': '导出PDF格式', 'base': False}, + 'batch_translate': {'name': '批量翻译', 'base': False}, + 'custom_terms': {'name': '自定义术语库', 'base': False}, + 'priority_queue': {'name': '优先队列处理', 'base': False}, + } + + # 判断功能是否可用(vip_enterprise 的 features=["all"] 表示全部可用) + if user_features == ['all']: + user_features = list(all_features.keys()) + + # 构建功能展示列表 + feature_display = [] + for feat_key, feat_info in all_features.items(): + has_feature = feat_key in user_features + # 基础功能(所有用户都有)不显示,只显示需要权限的功能 + if not feat_info['base']: + feature_display.append({ + 'name': feat_info['name'], + 'has': has_feature + }) + return render_template('index.html', user=user, limits=limits, daily_remaining=daily_remaining, max_pages=max_pages, - plans=MEMBERSHIP_PLANS + plans=MEMBERSHIP_PLANS, + features=feature_display ) diff --git a/templates/index.html b/templates/index.html index 5090611..056eb74 100644 --- a/templates/index.html +++ b/templates/index.html @@ -72,10 +72,13 @@
✨ 功能特点
+ {% if not user or user.user_type == 'free' %} + ❌ 标记为会员专属功能,升级会员解锁 + {% endif %}