mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-06-25 17:54:10 +08:00
fix: #89 stripUiFields清理version info根字段,防止污染openclaw.json导致Gateway启动失败
This commit is contained in:
@@ -560,17 +560,29 @@ function getUid() {
|
||||
}
|
||||
|
||||
function stripUiFields(config) {
|
||||
// 清理根层级 ClawPanel 内部字段(version info 等),避免污染 openclaw.json
|
||||
// Issue #89: 这些字段被写入 openclaw.json 后导致 Gateway 无法启动(Unknown config keys)
|
||||
const uiRootKeys = [
|
||||
'current', 'latest', 'recommended', 'update_available',
|
||||
'latest_update_available', 'is_recommended', 'ahead_of_recommended',
|
||||
'panel_version', 'source',
|
||||
]
|
||||
for (const key of uiRootKeys) {
|
||||
delete config[key]
|
||||
}
|
||||
// 清理模型测试相关的临时字段
|
||||
const providers = config?.models?.providers
|
||||
if (!providers) return config
|
||||
for (const p of Object.values(providers)) {
|
||||
if (!Array.isArray(p.models)) continue
|
||||
for (const m of p.models) {
|
||||
if (typeof m !== 'object') continue
|
||||
delete m.lastTestAt
|
||||
delete m.latency
|
||||
delete m.testStatus
|
||||
delete m.testError
|
||||
if (!m.name && m.id) m.name = m.id
|
||||
if (providers) {
|
||||
for (const p of Object.values(providers)) {
|
||||
if (!Array.isArray(p.models)) continue
|
||||
for (const m of p.models) {
|
||||
if (typeof m !== 'object') continue
|
||||
delete m.lastTestAt
|
||||
delete m.latency
|
||||
delete m.testStatus
|
||||
delete m.testError
|
||||
if (!m.name && m.id) m.name = m.id
|
||||
}
|
||||
}
|
||||
}
|
||||
return config
|
||||
|
||||
@@ -565,10 +565,24 @@ fn has_ui_fields(val: &Value) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// 递归清理 models 数组中的 UI 专属字段(lastTestAt, latency, testStatus, testError)
|
||||
/// 并为缺少 name 字段的模型自动补上 name = id
|
||||
/// 清理 ClawPanel 内部字段,避免污染 openclaw.json 导致 Gateway 启动失败
|
||||
/// Issue #89: version info 字段被写入 openclaw.json → Unknown config keys
|
||||
fn strip_ui_fields(mut val: Value) -> Value {
|
||||
if let Some(obj) = val.as_object_mut() {
|
||||
// 清理根层级 ClawPanel 内部字段(version info 等)
|
||||
for key in &[
|
||||
"current",
|
||||
"latest",
|
||||
"recommended",
|
||||
"update_available",
|
||||
"latest_update_available",
|
||||
"is_recommended",
|
||||
"ahead_of_recommended",
|
||||
"panel_version",
|
||||
"source",
|
||||
] {
|
||||
obj.remove(*key);
|
||||
}
|
||||
// 处理 models.providers.xxx.models 结构
|
||||
if let Some(models_val) = obj.get_mut("models") {
|
||||
if let Some(models_obj) = models_val.as_object_mut() {
|
||||
|
||||
Reference in New Issue
Block a user