feat: 添加详细日志,修复关机API

This commit is contained in:
xiaji
2026-04-13 23:00:16 +08:00
parent c6c92d31ec
commit df602d8773
2 changed files with 69 additions and 17 deletions

View File

@@ -333,19 +333,27 @@ impl eframe::App for App {
let client = client_shutdown.clone();
let node = node_shutdown.clone();
let state = state_shutdown.clone();
st.add_log("正在执行关机流程...");
st.add_log("1. 停止所有虚拟机...");
st.add_log("开始执行关机流程...");
st.add_log(&format!("节点: {}", node));
ctx.request_repaint();
thread::spawn(move || {
let rt = tokio::runtime::Runtime::new().unwrap();
let _ = rt.block_on(async {
rt.block_on(async {
let client = client.lock().unwrap();
if let Some(c) = client.as_ref() {
c.shutdown_node(&node).await.ok();
match c.shutdown_node(&node).await {
Ok(response) => {
state.write().unwrap().add_log("✓ 关机命令发送成功");
state.write().unwrap().add_log(&format!("响应: {}", response));
}
Err(e) => {
state.write().unwrap().add_log(&format!("✗ 关机失败: {}", e));
}
}
} else {
state.write().unwrap().add_log("✗ 未连接到服务器");
}
});
state.write().unwrap().add_log("2. 正在关闭 Proxmox 主机...");
state.write().unwrap().add_log("关机命令已发送");
});
}
});