From 74be7688c9cfe536f985ba12ede8a3def2f0c439 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Sat, 11 Apr 2026 02:27:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20v1.2.0=20=E6=96=B0=E5=A2=9E=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新功能: - 后台管理新增'网站配置'菜单 - 支持配置:网站名称、副标题、备案号、联系邮箱、GitHub、页脚文字 - 前台页面自动读取配置显示 - 页脚支持备案号链接 配置存储在 data/config.json --- app.py | 41 ++++++++++++++++++++- data/models.json | 3 +- templates/admin.html | 85 ++++++++++++++++++++++++++++++++++++++++++++ templates/index.html | 33 +++++++++++++---- 4 files changed, 153 insertions(+), 9 deletions(-) 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 @@ + + +