适配: Edge 全局参数解析 + AlgorithmManager 三级参数合并
This commit is contained in:
@@ -259,8 +259,17 @@ class SQLiteManager:
|
||||
except Exception:
|
||||
pass # 列已存在,忽略
|
||||
|
||||
# 算法全局参数表
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS algo_global_params (
|
||||
algo_code TEXT PRIMARY KEY,
|
||||
params TEXT NOT NULL DEFAULT '{}',
|
||||
updated_at TEXT
|
||||
)
|
||||
""")
|
||||
|
||||
self._init_default_algorithms()
|
||||
|
||||
|
||||
def _init_default_algorithms(self):
|
||||
"""初始化默认算法配置"""
|
||||
try:
|
||||
@@ -948,6 +957,39 @@ class SQLiteManager:
|
||||
logger.error(f"获取所有绑定ID失败: {e}")
|
||||
return []
|
||||
|
||||
def save_global_params(self, algo_code: str, params_dict: Dict[str, Any]) -> bool:
|
||||
"""保存算法全局参数(INSERT OR REPLACE)"""
|
||||
try:
|
||||
cursor = self._conn.cursor()
|
||||
now = datetime.now().isoformat()
|
||||
cursor.execute("""
|
||||
INSERT OR REPLACE INTO algo_global_params (algo_code, params, updated_at)
|
||||
VALUES (?, ?, ?)
|
||||
""", (algo_code, json.dumps(params_dict, ensure_ascii=False), now))
|
||||
self._conn.commit()
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"保存算法全局参数失败: {e}")
|
||||
return False
|
||||
|
||||
def get_all_global_params(self) -> Dict[str, Dict[str, Any]]:
|
||||
"""获取所有算法全局参数,返回 {algo_code: params_dict}"""
|
||||
result: Dict[str, Dict[str, Any]] = {}
|
||||
try:
|
||||
cursor = self._conn.cursor()
|
||||
cursor.execute("SELECT algo_code, params FROM algo_global_params")
|
||||
for row in cursor.fetchall():
|
||||
algo_code = row[0]
|
||||
params_str = row[1]
|
||||
try:
|
||||
result[algo_code] = json.loads(params_str) if params_str else {}
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
result[algo_code] = {}
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error(f"获取算法全局参数失败: {e}")
|
||||
return result
|
||||
|
||||
def log_config_update(
|
||||
self,
|
||||
config_type: str,
|
||||
|
||||
Reference in New Issue
Block a user