滚动截图,细节调整
This commit is contained in:
@@ -1018,6 +1018,52 @@ pub async fn monitor_get_status(state: tauri::State<'_, MonitorKernel>) -> Resul
|
||||
state.get_status().await
|
||||
}
|
||||
|
||||
/// 检测并修复 PawnIO 驱动:确保安装器随内核部署 → 静默安装 → 重启监控内核
|
||||
/// (LHM 打开一次后不会重新发现驱动,装完必须重启才能恢复 CPU 温度/功耗读取)。
|
||||
/// 返回 { installed, needReboot };installed=false 说明未提权或安装失败,交由内核启动自装。
|
||||
#[tauri::command]
|
||||
pub async fn monitor_repair_pawnio(
|
||||
state: tauri::State<'_, MonitorKernel>,
|
||||
pm: tauri::State<'_, ProcessManager>,
|
||||
app: AppHandle,
|
||||
) -> Result<serde_json::Value, String> {
|
||||
// 1. 确保 PawnIO_setup.exe 随内核部署
|
||||
state.prepare_kernel(&app)?;
|
||||
let setup = state.cores_dir().join("PawnIO_setup.exe");
|
||||
if !setup.exists() {
|
||||
return Err("未找到 PawnIO_setup.exe 安装器(binaries 资源未随包部署),请重新部署监控内核".into());
|
||||
}
|
||||
|
||||
// 2. 静默安装驱动(继承当前进程权限;Thing 已提权则直接成功)
|
||||
let mut cmd = std::process::Command::new(&setup);
|
||||
cmd.args(["-install", "-silent"]);
|
||||
crate::process_manager::setup_creation_flags(&mut cmd);
|
||||
let (installed, need_reboot) = match cmd.status() {
|
||||
Ok(status) => {
|
||||
let code = status.code().unwrap_or(-1);
|
||||
match code {
|
||||
3010 => (true, true), // ERROR_SUCCESS_REBOOT_REQUIRED
|
||||
0 => (true, false),
|
||||
_ => (false, false),
|
||||
}
|
||||
}
|
||||
Err(e) => return Err(format!("运行 PawnIO 安装器失败: {}", e)),
|
||||
};
|
||||
|
||||
// 3. 重启监控内核,使 LHM 以 PawnIO 重新打开传感器
|
||||
state.stop_subscription(&app).await;
|
||||
if state.is_elevated() && !is_thing_elevated() {
|
||||
state.shutdown_kernel().await?;
|
||||
state.elevated.store(false, Ordering::SeqCst);
|
||||
state.start_elevated(&app).await?;
|
||||
} else {
|
||||
pm.stop(PROCESS_ID)?;
|
||||
state.start_with_subscription(&app).await?;
|
||||
}
|
||||
|
||||
Ok(serde_json::json!({ "installed": installed, "needReboot": need_reboot }))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn monitor_get_snapshot(state: tauri::State<'_, MonitorKernel>) -> Result<SensorSnapshot, String> {
|
||||
state.get_snapshot().await
|
||||
|
||||
Reference in New Issue
Block a user