mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-07 06:12:58 +08:00
fix(lifecycle): 卸载/升级 OpenClaw 后同步刷新 Rust 缓存与前端缓存
这是 #Compat-4(安装不识别修复)的收尾补丁。除了 setup 安装场景, OpenClaw 的卸载和升级场景也存在类似的缓存失效问题。 ## Rust 端:uninstall_openclaw_inner 卸载后刷缓存 卸载完成时只 emit 了 "upgrade-progress 100",但没有刷 enhanced_path 和 CLI 检测缓存。后果: - `is_cli_installed`(60s TTL)在卸载后 60 秒内仍返回 true,UI 显示 「CLI 已安装」 - 服务状态页 gateway 被误判为还在运行 在 emit 进度 100 之后立刻调用: - `super::refresh_enhanced_path()` - `crate::commands::service::invalidate_cli_detection_cache()` ## 前端:upgrade/uninstall/installGateway/uninstallGateway 清前端缓存 `upgrade_openclaw` / `uninstall_openclaw` / `install_gateway` / `uninstall_gateway` 这四个 API 会改变 CLI 状态或 Gateway 状态,但 原先直接 invoke,没有清前端的 cachedInvoke 缓存。Rust 端自己刷了 缓存没用,前端仍吃旧的 `check_installation` / `get_services_status` / `get_version_info` 缓存(60s / 10s / 30s TTL)。 统一在调用前 invalidate 相关缓存: - upgrade/uninstall OpenClaw → 清 check_installation / check_node / check_git / get_services_status / get_status_summary / get_version_info - install/uninstall Gateway → 清 get_services_status / get_status_summary ## 验证 - `cargo check` 通过 - `npm run build` 通过
This commit is contained in:
@@ -4191,6 +4191,10 @@ async fn uninstall_openclaw_inner(
|
||||
}
|
||||
|
||||
let _ = app.emit("upgrade-progress", 100);
|
||||
// #Compat-4: 卸载后刷缓存,否则 is_cli_installed(60s TTL)/ enhanced_path
|
||||
// 仍是旧快照,UI 会在 60 秒内继续显示「CLI 已安装」或 Gateway 还在运行。
|
||||
super::refresh_enhanced_path();
|
||||
crate::commands::service::invalidate_cli_detection_cache();
|
||||
let msg = if clean_config {
|
||||
"✅ OpenClaw 已完全卸载(包括配置文件)"
|
||||
} else {
|
||||
|
||||
@@ -210,10 +210,18 @@ export const api = {
|
||||
doctorCheck: () => invoke('doctor_check'),
|
||||
doctorFix: () => invoke('doctor_fix'),
|
||||
listOpenclawVersions: (source = 'chinese') => invoke('list_openclaw_versions', { source }),
|
||||
upgradeOpenclaw: (source = 'chinese', version = null, method = 'auto') => invoke('upgrade_openclaw', { source, version, method }),
|
||||
uninstallOpenclaw: (cleanConfig = false) => invoke('uninstall_openclaw', { cleanConfig }),
|
||||
installGateway: () => invoke('install_gateway'),
|
||||
uninstallGateway: () => invoke('uninstall_gateway'),
|
||||
// #Compat-4: 升级/卸载后 CLI 路径/版本/服务状态都可能变,一次性清掉相关前端缓存;
|
||||
// Rust 端已经在命令内部调用 refresh_enhanced_path + invalidate_cli_detection_cache。
|
||||
upgradeOpenclaw: (source = 'chinese', version = null, method = 'auto') => {
|
||||
invalidate('check_installation', 'check_node', 'check_git', 'get_services_status', 'get_status_summary', 'get_version_info')
|
||||
return invoke('upgrade_openclaw', { source, version, method })
|
||||
},
|
||||
uninstallOpenclaw: (cleanConfig = false) => {
|
||||
invalidate('check_installation', 'check_node', 'check_git', 'get_services_status', 'get_status_summary', 'get_version_info')
|
||||
return invoke('uninstall_openclaw', { cleanConfig })
|
||||
},
|
||||
installGateway: () => { invalidate('get_services_status', 'get_status_summary'); return invoke('install_gateway') },
|
||||
uninstallGateway: () => { invalidate('get_services_status', 'get_status_summary'); return invoke('uninstall_gateway') },
|
||||
getNpmRegistry: () => cachedInvoke('get_npm_registry', {}, 30000),
|
||||
setNpmRegistry: (registry) => { invalidate('get_npm_registry'); return invoke('set_npm_registry', { registry }) },
|
||||
testModel: (baseUrl, apiKey, modelId, apiType = null) => invoke('test_model', { baseUrl, apiKey, modelId, apiType }),
|
||||
|
||||
Reference in New Issue
Block a user