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

@@ -9,6 +9,7 @@
### 修复 (Bug Fixes)
- **Gateway 首次安装后无法启动** — 安装流程未设置 `mode: "local"`,导致 Gateway 不知道以什么模式运行。现在安装完成后自动写入,仪表盘加载时也会自愈补全
- **Windows Node.js 检测失败** — `enhanced_path()` 扩展为跨平台Windows 上自动扫描 Program Files、LOCALAPPDATA、APPDATA、常见盘符C/D/E/F下的 Node.js 安装路径
- **Git SSH 导致安装失败 (exit 128)** — npm 依赖使用 SSH 协议拉取 GitHub 仓库,用户没配 SSH Key 时报 `Permission denied (publickey)`。安装前自动执行 `git config --global url.https://...insteadOf ssh://...` 切换为 HTTPS
- **npm 安装失败无引导** — 安装/升级 OpenClaw 失败时仅显示"安装失败"现在自动诊断错误类型Git SSH 权限 / Git 未安装 / EPERM 文件占用 / MODULE_NOT_FOUND 安装不完整 / ENOENT / 权限不足 / 网络错误 / 缓存损坏)并给出具体修复命令

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) {