bug修复调整
This commit is contained in:
@@ -228,6 +228,8 @@ pub fn check_and_relaunch_if_needed(app_data_dir: &std::path::Path) -> bool {
|
||||
pub struct KernelStatus {
|
||||
pub ready: bool,
|
||||
pub is_admin: bool,
|
||||
/// PawnIO 驱动是否已安装;旧版内核无此字段,Option 兼容
|
||||
pub pawn_io_installed: Option<bool>,
|
||||
pub uptime_ms: f64,
|
||||
pub group_count: u32,
|
||||
pub sensor_count: u32,
|
||||
@@ -370,7 +372,9 @@ impl MonitorKernel {
|
||||
self.root.join("hardware-config.json")
|
||||
}
|
||||
|
||||
/// 确保内核就位:若 cores/ 无内核或版本过期(源文件较新),从资源目录复制
|
||||
/// 确保内核就位:若 cores/ 无内核或版本过期(源文件较新),从资源目录复制。
|
||||
/// 同时把 PawnIO_setup.exe(可选资源)复制过去——内核提权启动时会静默安装它,
|
||||
/// 作为 WinRing0 被系统/杀软拦截时读取温度/频率的替代驱动。
|
||||
pub fn prepare_kernel(&self, app: &AppHandle) -> Result<MonitorKernelInfo, String> {
|
||||
let kernel = self.kernel_path();
|
||||
if let Ok(src) = app.path().resolve("binaries/ThingHK.exe", BaseDirectory::Resource) {
|
||||
@@ -385,6 +389,24 @@ impl MonitorKernel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PawnIO 安装器:可选资源,缺失时仅影响自动安装能力(不影响内核运行)
|
||||
if let Ok(setup_src) = app.path().resolve("binaries/PawnIO_setup.exe", BaseDirectory::Resource) {
|
||||
if setup_src.exists() {
|
||||
let setup_dest = self.cores_dir().join("PawnIO_setup.exe");
|
||||
let need_copy = !setup_dest.exists()
|
||||
|| fs::metadata(&setup_src)
|
||||
.and_then(|s| fs::metadata(&setup_dest).map(|d| s.len() != d.len()))
|
||||
.unwrap_or(true);
|
||||
if need_copy {
|
||||
fs::create_dir_all(self.cores_dir()).ok();
|
||||
if let Err(e) = fs::copy(&setup_src, &setup_dest) {
|
||||
crate::logger::log_warn("monitor", &format!("复制 PawnIO_setup.exe 失败: {}", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(MonitorKernelInfo {
|
||||
path: kernel.to_string_lossy().to_string(),
|
||||
exists: kernel.exists(),
|
||||
@@ -489,12 +511,20 @@ impl MonitorKernel {
|
||||
Ok(resp) if resp.status().is_success() => {
|
||||
match resp.json::<KernelStatus>().await {
|
||||
Ok(s) if s.ready => {
|
||||
// PawnIO 诊断:已提权但驱动缺失时,温度/频率等 ring0 传感器大概率无法读取
|
||||
if s.is_admin && s.pawn_io_installed == Some(false) {
|
||||
crate::logger::log_warn(
|
||||
"monitor",
|
||||
"Kernel 已提权但 PawnIO 驱动未安装,CPU 温度/频率可能无法读取(检查 cores/PawnIO_setup.exe 是否随包部署)",
|
||||
);
|
||||
}
|
||||
let _ = app.emit(
|
||||
crate::constants::events::MONITOR_READY,
|
||||
serde_json::json!({
|
||||
"isAdmin": s.is_admin,
|
||||
"sensorCount": s.sensor_count,
|
||||
"providers": s.providers,
|
||||
"pawnIoInstalled": s.pawn_io_installed,
|
||||
}),
|
||||
);
|
||||
return Ok(());
|
||||
|
||||
Reference in New Issue
Block a user