diff --git a/admin.py b/admin.py
index 150223d..f7a6ef8 100644
--- a/admin.py
+++ b/admin.py
@@ -313,35 +313,56 @@ def clear_cache():
@admin_required
def settings():
"""系统配置"""
- if request.method == 'POST':
- data = request.json if request.is_json else request.form
-
- for key, value in data.items():
- SystemConfig.set(key, value)
-
- if request.is_json:
- return jsonify({'success': True})
- flash('配置已保存', 'success')
-
- # 获取所有配置
- configs = SystemConfig.query.all()
- config_dict = {c.key: c.value for c in configs}
-
- # 获取动态配置
- dynamic_configs = DynamicConfig.query.all()
-
# 获取LLM动态配置
llm_config = get_llm_config()
+ # 获取网站基础配置
+ site_config = {
+ 'site_name': DynamicConfig.get('site_name', 'PDF翻译助手'),
+ 'site_footer': DynamicConfig.get('site_footer', '© 2026 PDF翻译助手'),
+ 'max_file_size': DynamicConfig.get('max_file_size', 50),
+ 'cache_expire_days': DynamicConfig.get('cache_expire_days', 30),
+ 'enable_email_notify': DynamicConfig.get('enable_email_notify', True),
+ 'enable_cache': DynamicConfig.get('enable_cache', True),
+ 'enable_guest': DynamicConfig.get('enable_guest', True),
+ 'default_source_lang': DynamicConfig.get('default_source_lang', 'en'),
+ 'default_target_lang': DynamicConfig.get('default_target_lang', 'zh'),
+ }
+
return render_template('admin/settings.html',
- configs=config_dict,
- dynamic_configs=dynamic_configs,
- user_limits=USER_LIMITS,
- membership_plans=MEMBERSHIP_PLANS,
- llm_config=llm_config
+ llm_config=llm_config,
+ site_config=site_config
)
+@admin_bp.route('/settings/site', methods=['POST'])
+@admin_required
+def save_site_settings():
+ """保存网站基础配置"""
+ data = request.json
+
+ # 保存每个配置项
+ for key, value in data.items():
+ if key in ['max_file_size', 'cache_expire_days']:
+ DynamicConfig.set(f'site_{key}', int(value), category='site', value_type='int', user_id=session.get('user_id'))
+ elif key in ['enable_email_notify', 'enable_cache', 'enable_guest']:
+ DynamicConfig.set(f'site_{key}', bool(value), category='site', value_type='bool', user_id=session.get('user_id'))
+ else:
+ DynamicConfig.set(f'site_{key}', value, category='site', user_id=session.get('user_id'))
+
+ # 记录日志
+ log = OperationLog(
+ user_id=session.get('user_id'),
+ username='admin',
+ action='save_site_settings',
+ detail='保存网站基础配置'
+ )
+ db.session.add(log)
+ db.session.commit()
+
+ return jsonify({'success': True})
+
+
# ==================== 用户权限配置 ====================
@admin_bp.route('/settings/user-limits', methods=['GET', 'POST'])
@admin_required
@@ -1450,4 +1471,20 @@ def init_default_backup_llm():
def get_backup_llm_configs():
"""获取所有备用大模型配置(供其他模块使用)"""
configs = BackupLLMConfig.query.filter_by(is_active=True).order_by(BackupLLMConfig.sort_order).all()
- return [c.to_dict() for c in configs]
\ No newline at end of file
+ return [c.to_dict() for c in configs]
+
+
+# ==================== 获取网站基础配置(供其他模块使用) ====================
+def get_site_config():
+ """获取网站基础配置"""
+ return {
+ 'site_name': DynamicConfig.get('site_name', 'PDF翻译助手'),
+ 'site_footer': DynamicConfig.get('site_footer', '© 2026 PDF翻译助手'),
+ 'max_file_size': DynamicConfig.get('max_file_size', 50),
+ 'cache_expire_days': DynamicConfig.get('cache_expire_days', 30),
+ 'enable_email_notify': DynamicConfig.get('enable_email_notify', True),
+ 'enable_cache': DynamicConfig.get('enable_cache', True),
+ 'enable_guest': DynamicConfig.get('enable_guest', True),
+ 'default_source_lang': DynamicConfig.get('default_source_lang', 'en'),
+ 'default_target_lang': DynamicConfig.get('default_target_lang', 'zh'),
+ }
\ No newline at end of file
diff --git a/templates/admin/settings.html b/templates/admin/settings.html
index bcd774a..25e1f58 100644
--- a/templates/admin/settings.html
+++ b/templates/admin/settings.html
@@ -22,16 +22,16 @@
后台管理
@@ -42,6 +42,92 @@
系统配置
+
+
+
+
@@ -50,14 +136,7 @@
配置不同用户类型的权限限制,包括翻译次数、页数限制、功能权限等。
-
支持操作:
-
- - 添加新的用户类型
- - 编辑现有类型的权限
- - 删除自定义类型(系统类型不可删除)
- - 启用/禁用用户类型
-
-
+
管理用户类型
@@ -71,15 +150,7 @@
配置会员套餐的价格、周期、描述等,用户购买后可升级用户类型。
-
支持操作:
-
- - 添加新的会员套餐
- - 编辑套餐价格和描述
- - 删除自定义套餐(系统套餐不可删除)
- - 上架/下架套餐
- - 设置推荐套餐
-
-
+
管理会员套餐
@@ -88,6 +159,21 @@
+
+
+
+
+
配置翻译使用的LLM大模型API地址、模型名称等参数。
+
当前模型: {{ llm_config.get('model', '未设置') }}
+
+ 配置大模型
+
+
+
+
+
-
-
-
-
-
-
配置翻译使用的LLM大模型API地址、模型名称等参数。
-
当前模型: {{ llm_config.model }}
-
- 配置大模型
-
-
-
-
+
-
应用名称: PDF翻译助手
-
版本: 2.0.0
+
应用名称: {{ site_config.site_name }}
+
版本: 2.3.1
框架: Flask + SQLAlchemy
-
缓存有效期: 30天
-
默认最大文件: 50MB
+
最大文件: {{ site_config.max_file_size }}MB
+
缓存有效期: {{ site_config.cache_expire_days }}天
数据库: SQLite
-
API地址: {{ llm_config.api_base }}
-
超时时间: {{ llm_config.timeout }}秒
+
API地址: {{ llm_config.get('api_base', '未设置') }}
+
超时时间: {{ llm_config.get('timeout', 180) }}秒
+
+