fix: auto-set mode:local after Gateway install + dashboard self-heal

- Setup flow: write mode:'local' to openclaw.json after Gateway install
- Dashboard: auto-heal missing mode field on load for existing users
This commit is contained in:
晴天
2026-03-05 22:34:07 +08:00
parent 6ca4267970
commit 46928e798c
3 changed files with 19 additions and 0 deletions

View File

@@ -76,6 +76,12 @@ async function loadDashboardData(page) {
if (servicesRes.status === 'rejected') toast('服务状态加载失败', 'error')
if (versionRes.status === 'rejected') toast('版本信息加载失败', 'error')
// 自愈:如果 openclaw.json 没有 mode 字段,自动设为 local否则 Gateway 启动不了
if (config && !config.mode) {
config.mode = 'local'
api.writeOpenclawConfig(config).catch(() => {})
}
renderStatCards(page, services, version, [], config, null)
bindActions(page)

View File

@@ -287,6 +287,18 @@ function bindEvents(page, nodeOk) {
modal.appendLog('⚠️ Gateway 安装失败: ' + e)
}
// 确保 openclaw.json 有 mode: "local",否则 Gateway 启动不了
try {
const config = await api.readOpenclawConfig()
if (config && !config.mode) {
config.mode = 'local'
await api.writeOpenclawConfig(config)
modal.appendLog('✅ 已设置 Gateway 运行模式为 local')
}
} catch (e) {
modal.appendLog('⚠️ 配置 mode 失败: ' + e)
}
toast('OpenClaw 安装成功', 'success')
setTimeout(() => window.location.reload(), 1500)
} catch (e) {