mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-06 20:02:49 +08:00
fix: 优化升级进度条体验,每行日志递增进度并显示阶段提示
This commit is contained in:
@@ -158,17 +158,20 @@ pub async fn upgrade_openclaw(app: tauri::AppHandle, source: String) -> Result<S
|
||||
.spawn()
|
||||
.map_err(|e| format!("执行升级命令失败: {e}"))?;
|
||||
|
||||
// 读取 stderr(npm 主要输出在 stderr)
|
||||
let stderr = child.stderr.take();
|
||||
let stdout = child.stdout.take();
|
||||
|
||||
let _ = app.emit("upgrade-progress", 30);
|
||||
|
||||
// stderr 每行递增进度(10→80 区间),让用户看到进度在动
|
||||
let app2 = app.clone();
|
||||
let handle = std::thread::spawn(move || {
|
||||
let mut progress: u32 = 15;
|
||||
if let Some(pipe) = stderr {
|
||||
for line in BufReader::new(pipe).lines().map_while(Result::ok) {
|
||||
let _ = app2.emit("upgrade-log", &line);
|
||||
if progress < 75 {
|
||||
progress += 2;
|
||||
let _ = app2.emit("upgrade-progress", progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -176,7 +176,10 @@ export function showUpgradeModal() {
|
||||
},
|
||||
setProgress(pct) {
|
||||
fill.style.width = pct + '%'
|
||||
text.textContent = pct >= 100 ? '完成' : `升级中... ${pct}%`
|
||||
if (pct >= 100) text.textContent = '完成'
|
||||
else if (pct >= 75) text.textContent = '正在安装...'
|
||||
else if (pct >= 30) text.textContent = '正在下载依赖...'
|
||||
else text.textContent = '准备中...'
|
||||
},
|
||||
setDone(msg) {
|
||||
text.textContent = msg || '升级完成'
|
||||
|
||||
Reference in New Issue
Block a user