diff --git a/app.py b/app.py index f8e96bd..4688a2f 100644 --- a/app.py +++ b/app.py @@ -25,6 +25,7 @@ GPUS_FILE = DATA_DIR / 'gpus.json' CPUS_FILE = DATA_DIR / 'cpus.json' CATEGORIES_FILE = DATA_DIR / 'categories.json' KNOWLEDGE_FILE = DATA_DIR / 'knowledge.json' +CONFIG_FILE = DATA_DIR / 'config.json' # 大模型配置 LLM_CONFIG = { @@ -33,6 +34,27 @@ LLM_CONFIG = { 'model': 'auto', } +# 默认网站配置 +DEFAULT_CONFIG = { + 'site_name': 'ParamHub', + 'site_subtitle': '参数百科', + 'footer_text': 'ParamHub - AI大模型与硬件参数速查平台', + 'icp_number': '', + 'copyright_year': '2024', + 'contact_email': '', + 'github_url': '', +} + +def load_config(): + """加载网站配置""" + if CONFIG_FILE.exists(): + return json.loads(CONFIG_FILE.read_text(encoding='utf-8')) + return DEFAULT_CONFIG.copy() + +def save_config(config): + """保存网站配置""" + CONFIG_FILE.write_text(json.dumps(config, ensure_ascii=False, indent=2), encoding='utf-8') + def load_data(file_path): """加载JSON数据""" if file_path.exists(): @@ -863,9 +885,26 @@ def api_toggle_item_visible(category_id, item_id): return jsonify({'success': True, 'visible': item['visible']}) +# ============ 网站配置API ============ + +@app.route('/api/config') +def api_get_config(): + """获取网站配置""" + return jsonify(load_config()) + +@app.route('/api/config', methods=['PUT']) +def api_update_config(): + """更新网站配置""" + data = request.get_json() + config = load_config() + config.update(data) + config['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + save_config(config) + return jsonify(config) + if __name__ == '__main__': print("=" * 50) - print("ParamHub - 参数百科 v1.1.0") + print("ParamHub - 参数百科 v1.2.0") print("=" * 50) print(f"访问地址: http://localhost:19010") print(f"后台管理: http://localhost:19010/admin") diff --git a/data/models.json b/data/models.json index 1cf08ef..e0e5b3b 100644 --- a/data/models.json +++ b/data/models.json @@ -189,6 +189,7 @@ "is_open_source": false, "license": "Proprietary", "description": "智谱AI大模型,中文能力强", - "created_at": "2024-01-01" + "created_at": "2024-01-01", + "visible": true } ] \ No newline at end of file diff --git a/templates/admin.html b/templates/admin.html index 6083b41..e15dfd1 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -52,6 +52,49 @@ + + +