From f0d9ca09aa232e30891f2098887ff0ed704e6690 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Tue, 28 Apr 2026 12:57:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20init=5Fdb=E5=85=BC=E5=AE=B9=E6=97=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=BC=BA=E5=A4=B1=E7=9A=84=E7=B3=BB=E7=BB=9F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/app.py b/backend/app.py index 08bf12f..2bfa46f 100644 --- a/backend/app.py +++ b/backend/app.py @@ -276,6 +276,20 @@ def init_db(): ] for key, value, desc in default_configs: cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc)) + else: + # 检查并添加缺失的配置项(兼容旧数据库) + default_configs = [ + ('app_developer', 'OpenClaw Team', '开发者'), + ('app_update_date', '2026-04-27', '更新日期'), + ('app_technology', '智谱 GLM-4.5-Air 大模型', '技术基础'), + ('app_description', '提供智能对话、多种智能体服务', '应用简介'), + ('privacy_policy_url', '', '隐私政策链接'), + ('user_agreement_url', '', '用户协议链接'), + ] + for key, value, desc in default_configs: + cursor.execute('SELECT COUNT(*) FROM system_configs WHERE key=?', (key,)) + if cursor.fetchone()[0] == 0: + cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc)) # 初始化管理员账户 cursor.execute('SELECT COUNT(*) FROM admin_users')