stream cards
This commit is contained in:
@@ -8,22 +8,13 @@ use serde::Serialize;
|
|||||||
use sysinfo::{System, Disks};
|
use sysinfo::{System, Disks};
|
||||||
use wmi::{COMLibrary, WMIConnection};
|
use wmi::{COMLibrary, WMIConnection};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
// 引入 chrono 用于时间计算和格式化
|
// 引入 tauri::Emitter 用于发送事件 (Tauri v2)
|
||||||
|
use tauri::Emitter;
|
||||||
use chrono::{Duration, FixedOffset, Local, NaiveDate, TimeZone};
|
use chrono::{Duration, FixedOffset, Local, NaiveDate, TimeZone};
|
||||||
|
|
||||||
// --- 1. 数据结构 ---
|
// --- 1. 数据结构 (保持不变,用于序列化部分数据) ---
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, Clone)] // 增加 Clone trait 方便使用
|
||||||
struct SystemHealthReport {
|
|
||||||
hardware: HardwareSummary,
|
|
||||||
storage: Vec<StorageDevice>,
|
|
||||||
events: Vec<SystemEvent>,
|
|
||||||
minidumps: MinidumpInfo,
|
|
||||||
drivers: Vec<DriverIssue>,
|
|
||||||
battery: Option<BatteryInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
struct HardwareSummary {
|
struct HardwareSummary {
|
||||||
cpu_name: String,
|
cpu_name: String,
|
||||||
sys_vendor: String,
|
sys_vendor: String,
|
||||||
@@ -38,7 +29,7 @@ struct HardwareSummary {
|
|||||||
c_drive_used_gb: u64,
|
c_drive_used_gb: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, Clone)]
|
||||||
struct StorageDevice {
|
struct StorageDevice {
|
||||||
model: String,
|
model: String,
|
||||||
health_status: String,
|
health_status: String,
|
||||||
@@ -46,7 +37,7 @@ struct StorageDevice {
|
|||||||
is_danger: bool,
|
is_danger: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, Clone)]
|
||||||
struct SystemEvent {
|
struct SystemEvent {
|
||||||
time_generated: String,
|
time_generated: String,
|
||||||
event_id: u32,
|
event_id: u32,
|
||||||
@@ -55,21 +46,21 @@ struct SystemEvent {
|
|||||||
analysis_hint: String,
|
analysis_hint: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, Clone)]
|
||||||
struct MinidumpInfo {
|
struct MinidumpInfo {
|
||||||
found: bool,
|
found: bool,
|
||||||
count: usize,
|
count: usize,
|
||||||
explanation: String,
|
explanation: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, Clone)]
|
||||||
struct DriverIssue {
|
struct DriverIssue {
|
||||||
device_name: String,
|
device_name: String,
|
||||||
error_code: u32,
|
error_code: u32,
|
||||||
description: String,
|
description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize, Clone)]
|
||||||
struct BatteryInfo {
|
struct BatteryInfo {
|
||||||
health_percentage: u32,
|
health_percentage: u32,
|
||||||
is_ac_connected: bool,
|
is_ac_connected: bool,
|
||||||
@@ -122,269 +113,255 @@ struct Win32_ComputerSystem {
|
|||||||
Model: Option<String>,
|
Model: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 辅助函数:生成 WMI 查询用的时间字符串 ---
|
// --- 辅助函数 ---
|
||||||
// WMI 要求的时间格式类似于: 20231125000000.000000+000
|
|
||||||
fn get_wmi_query_time(days_ago: i64) -> String {
|
fn get_wmi_query_time(days_ago: i64) -> String {
|
||||||
let target_date = Local::now() - Duration::days(days_ago);
|
let target_date = Local::now() - Duration::days(days_ago);
|
||||||
// 这里我们只生成前半部分 YYYYMMDDHHMMSS,WMI 字符串比较支持这种前缀
|
|
||||||
// 或者生成完整格式 .000000+000 (简化处理,假设本地时区)
|
|
||||||
target_date.format("%Y%m%d%H%M%S.000000+000").to_string()
|
target_date.format("%Y%m%d%H%M%S.000000+000").to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 辅助函数:格式化显示用的时间 ---
|
|
||||||
fn format_wmi_time(wmi_str: &str) -> String {
|
fn format_wmi_time(wmi_str: &str) -> String {
|
||||||
if wmi_str.len() < 25 {
|
if wmi_str.len() < 25 {
|
||||||
return wmi_str.to_string();
|
return wmi_str.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
let year = wmi_str[0..4].parse::<i32>().unwrap_or(1970);
|
let year = wmi_str[0..4].parse::<i32>().unwrap_or(1970);
|
||||||
let month = wmi_str[4..6].parse::<u32>().unwrap_or(1);
|
let month = wmi_str[4..6].parse::<u32>().unwrap_or(1);
|
||||||
let day = wmi_str[6..8].parse::<u32>().unwrap_or(1);
|
let day = wmi_str[6..8].parse::<u32>().unwrap_or(1);
|
||||||
let hour = wmi_str[8..10].parse::<u32>().unwrap_or(0);
|
let hour = wmi_str[8..10].parse::<u32>().unwrap_or(0);
|
||||||
let min = wmi_str[10..12].parse::<u32>().unwrap_or(0);
|
let min = wmi_str[10..12].parse::<u32>().unwrap_or(0);
|
||||||
let sec = wmi_str[12..14].parse::<u32>().unwrap_or(0);
|
let sec = wmi_str[12..14].parse::<u32>().unwrap_or(0);
|
||||||
|
|
||||||
let sign = &wmi_str[21..22];
|
let sign = &wmi_str[21..22];
|
||||||
let offset_val = wmi_str[22..25].parse::<i32>().unwrap_or(0);
|
let offset_val = wmi_str[22..25].parse::<i32>().unwrap_or(0);
|
||||||
let offset_mins = if sign == "-" { -offset_val } else { offset_val };
|
let offset_mins = if sign == "-" { -offset_val } else { offset_val };
|
||||||
|
|
||||||
let offset = FixedOffset::east_opt(offset_mins * 60).unwrap_or(FixedOffset::east_opt(0).unwrap());
|
let offset = FixedOffset::east_opt(offset_mins * 60).unwrap_or(FixedOffset::east_opt(0).unwrap());
|
||||||
|
|
||||||
let naive_date = NaiveDate::from_ymd_opt(year, month, day).unwrap_or(NaiveDate::from_ymd_opt(1970, 1, 1).unwrap());
|
let naive_date = NaiveDate::from_ymd_opt(year, month, day).unwrap_or(NaiveDate::from_ymd_opt(1970, 1, 1).unwrap());
|
||||||
let naive_dt = naive_date.and_hms_opt(hour, min, sec).unwrap_or_default();
|
let naive_dt = naive_date.and_hms_opt(hour, min, sec).unwrap_or_default();
|
||||||
|
|
||||||
match offset.from_local_datetime(&naive_dt).single() {
|
match offset.from_local_datetime(&naive_dt).single() {
|
||||||
Some(dt) => {
|
Some(dt) => dt.with_timezone(&Local).format("%Y-%m-%d %H:%M:%S").to_string(),
|
||||||
dt.with_timezone(&Local).format("%Y-%m-%d %H:%M:%S").to_string()
|
|
||||||
},
|
|
||||||
None => format!("{}-{:02}-{:02} {:02}:{:02}:{:02}", year, month, day, hour, min, sec)
|
None => format!("{}-{:02}-{:02} {:02}:{:02}:{:02}", year, month, day, hour, min, sec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 核心逻辑 ---
|
// --- 核心逻辑:分步流式传输 ---
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn run_diagnosis() -> Result<SystemHealthReport, String> {
|
async fn run_diagnosis(window: tauri::Window) -> Result<(), String> {
|
||||||
let report = tokio::task::spawn_blocking(|| {
|
// 使用 spawn 在后台线程运行,避免阻塞 Tauri 主线程
|
||||||
// 1. 高效初始化:只创建空实例,不扫描进程
|
// 注意:这里不等待 join,而是让它在后台跑,通过 window.emit 发送进度
|
||||||
let mut sys = System::new();
|
std::thread::spawn(move || {
|
||||||
sys.refresh_memory();
|
// 1. 硬件概览 (最快)
|
||||||
sys.refresh_cpu();
|
{
|
||||||
|
let mut sys = System::new();
|
||||||
|
sys.refresh_memory();
|
||||||
|
sys.refresh_cpu();
|
||||||
|
|
||||||
|
let wmi_con = WMIConnection::new(COMLibrary::new().unwrap()).ok();
|
||||||
|
|
||||||
|
let mut bios_ver = "Unknown".to_string();
|
||||||
|
let mut mobo_vendor = "Unknown".to_string();
|
||||||
|
let mut mobo_product = "Unknown".to_string();
|
||||||
|
let mut sys_vendor = "Unknown".to_string();
|
||||||
|
let mut sys_product = "Unknown".to_string();
|
||||||
|
|
||||||
|
if let Some(con) = &wmi_con {
|
||||||
|
if let Ok(results) = con.raw_query::<Win32_BIOS>("SELECT SMBIOSBIOSVersion FROM Win32_BIOS") {
|
||||||
|
if let Some(bios) = results.first() { bios_ver = bios.SMBIOSBIOSVersion.clone().unwrap_or_default(); }
|
||||||
|
}
|
||||||
|
if let Ok(results) = con.raw_query::<Win32_BaseBoard>("SELECT Manufacturer, Product FROM Win32_BaseBoard") {
|
||||||
|
if let Some(board) = results.first() {
|
||||||
|
mobo_vendor = board.Manufacturer.clone().unwrap_or_default();
|
||||||
|
mobo_product = board.Product.clone().unwrap_or_default();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Ok(results) = con.raw_query::<Win32_ComputerSystem>("SELECT Manufacturer, Model FROM Win32_ComputerSystem") {
|
||||||
|
if let Some(cs) = results.first() {
|
||||||
|
sys_vendor = cs.Manufacturer.clone().unwrap_or_default();
|
||||||
|
sys_product = cs.Model.clone().unwrap_or_default();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// C盘
|
||||||
|
let mut c_total = 0u64;
|
||||||
|
let mut c_used = 0u64;
|
||||||
|
let disks = Disks::new_with_refreshed_list();
|
||||||
|
for disk in &disks {
|
||||||
|
if disk.mount_point().to_string_lossy().starts_with("C:") {
|
||||||
|
c_total = disk.total_space() / 1024 / 1024 / 1024;
|
||||||
|
let free = disk.available_space() / 1024 / 1024 / 1024;
|
||||||
|
c_used = c_total - free;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let cpu_brand = if let Some(cpu) = sys.cpus().first() {
|
||||||
|
cpu.brand().trim().to_string()
|
||||||
|
} else {
|
||||||
|
"Unknown CPU".to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
let hardware = HardwareSummary {
|
||||||
|
cpu_name: cpu_brand,
|
||||||
|
sys_vendor, sys_product, mobo_vendor, mobo_product,
|
||||||
|
memory_total_gb: sys.total_memory() / 1024 / 1024 / 1024,
|
||||||
|
memory_used_gb: sys.used_memory() / 1024 / 1024 / 1024,
|
||||||
|
os_version: System::long_os_version().unwrap_or("Unknown".to_string()),
|
||||||
|
bios_version: bios_ver,
|
||||||
|
c_drive_total_gb: c_total,
|
||||||
|
c_drive_used_gb: c_used,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 发送硬件事件
|
||||||
|
let _ = window.emit("report-hardware", hardware);
|
||||||
|
}
|
||||||
|
|
||||||
|
// WMI 连接复用 (如果需要) 或者重新建立
|
||||||
let wmi_con = WMIConnection::new(COMLibrary::new().unwrap()).ok();
|
let wmi_con = WMIConnection::new(COMLibrary::new().unwrap()).ok();
|
||||||
|
|
||||||
// 1. 硬件基础信息
|
// 2. 存储设备 (较快)
|
||||||
let mut bios_ver = "Unknown".to_string();
|
{
|
||||||
let mut mobo_vendor = "Unknown".to_string();
|
let mut storage = Vec::new();
|
||||||
let mut mobo_product = "Unknown".to_string();
|
if let Some(con) = &wmi_con {
|
||||||
let mut sys_vendor = "Unknown".to_string();
|
let query = "SELECT Model, Status FROM Win32_DiskDrive";
|
||||||
let mut sys_product = "Unknown".to_string();
|
if let Ok(results) = con.raw_query::<Win32_DiskDrive>(query) {
|
||||||
|
for disk in results {
|
||||||
if let Some(con) = &wmi_con {
|
let status = disk.Status.unwrap_or("Unknown".to_string());
|
||||||
if let Ok(results) = con.raw_query::<Win32_BIOS>("SELECT SMBIOSBIOSVersion FROM Win32_BIOS") {
|
let (explanation, is_danger) = match status.as_str() {
|
||||||
if let Some(bios) = results.first() {
|
"OK" => ("健康".to_string(), false),
|
||||||
bios_ver = bios.SMBIOSBIOSVersion.clone().unwrap_or("Unknown".to_string());
|
"Pred Fail" => ("预测即将损坏".to_string(), true),
|
||||||
}
|
_ => ("状态异常".to_string(), true),
|
||||||
}
|
|
||||||
if let Ok(results) = con.raw_query::<Win32_BaseBoard>("SELECT Manufacturer, Product FROM Win32_BaseBoard") {
|
|
||||||
if let Some(board) = results.first() {
|
|
||||||
mobo_vendor = board.Manufacturer.clone().unwrap_or("Unknown".to_string());
|
|
||||||
mobo_product = board.Product.clone().unwrap_or("Unknown".to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Ok(results) = con.raw_query::<Win32_ComputerSystem>("SELECT Manufacturer, Model FROM Win32_ComputerSystem") {
|
|
||||||
if let Some(cs) = results.first() {
|
|
||||||
sys_vendor = cs.Manufacturer.clone().unwrap_or("Unknown".to_string());
|
|
||||||
sys_product = cs.Model.clone().unwrap_or("Unknown".to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- C 盘空间检查 ---
|
|
||||||
let mut c_total = 0u64;
|
|
||||||
let mut c_used = 0u64;
|
|
||||||
let disks = Disks::new_with_refreshed_list();
|
|
||||||
for disk in &disks {
|
|
||||||
if disk.mount_point().to_string_lossy().starts_with("C:") {
|
|
||||||
c_total = disk.total_space() / 1024 / 1024 / 1024;
|
|
||||||
let free = disk.available_space() / 1024 / 1024 / 1024;
|
|
||||||
c_used = c_total - free;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let cpu_brand = if let Some(cpu) = sys.cpus().first() {
|
|
||||||
cpu.brand().trim().to_string()
|
|
||||||
} else {
|
|
||||||
"Unknown CPU".to_string()
|
|
||||||
};
|
|
||||||
|
|
||||||
let hardware = HardwareSummary {
|
|
||||||
cpu_name: cpu_brand,
|
|
||||||
mobo_vendor,
|
|
||||||
mobo_product,
|
|
||||||
sys_vendor,
|
|
||||||
sys_product,
|
|
||||||
memory_total_gb: sys.total_memory() / 1024 / 1024 / 1024,
|
|
||||||
memory_used_gb: sys.used_memory() / 1024 / 1024 / 1024,
|
|
||||||
os_version: System::long_os_version().unwrap_or("Unknown".to_string()),
|
|
||||||
bios_version: bios_ver,
|
|
||||||
c_drive_total_gb: c_total,
|
|
||||||
c_drive_used_gb: c_used,
|
|
||||||
};
|
|
||||||
|
|
||||||
// 2. 存储设备健康度
|
|
||||||
let mut storage = Vec::new();
|
|
||||||
if let Some(con) = &wmi_con {
|
|
||||||
let query = "SELECT Model, Status FROM Win32_DiskDrive";
|
|
||||||
if let Ok(results) = con.raw_query::<Win32_DiskDrive>(query) {
|
|
||||||
for disk in results {
|
|
||||||
let status = disk.Status.unwrap_or("Unknown".to_string());
|
|
||||||
let (explanation, is_danger) = match status.as_str() {
|
|
||||||
"OK" => ("健康".to_string(), false),
|
|
||||||
"Pred Fail" => ("预测即将损坏".to_string(), true),
|
|
||||||
_ => ("状态异常".to_string(), true),
|
|
||||||
};
|
|
||||||
storage.push(StorageDevice {
|
|
||||||
model: disk.Model.unwrap_or("Generic Disk".to_string()),
|
|
||||||
health_status: status,
|
|
||||||
human_explanation: explanation,
|
|
||||||
is_danger,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 关键日志 (严格模式 + 时间优化 + 扩展)
|
|
||||||
let mut events = Vec::new();
|
|
||||||
if let Some(con) = &wmi_con {
|
|
||||||
// [关键优化] 计算30天前的时间字符串
|
|
||||||
let start_time_str = get_wmi_query_time(30);
|
|
||||||
|
|
||||||
// [关键优化] SQL 中加入 TimeGenerated >= '...' 过滤,大幅减少扫描量
|
|
||||||
let query = format!(
|
|
||||||
"SELECT TimeGenerated, EventCode, SourceName, Message FROM Win32_NTLogEvent WHERE Logfile = 'System' AND TimeGenerated >= '{}' AND (EventCode = 41 OR EventCode = 18 OR EventCode = 19 OR EventCode = 7 OR EventCode = 1001 OR EventCode = 4101)",
|
|
||||||
start_time_str
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Ok(results) = con.raw_query::<Win32_NTLogEvent>(&query) {
|
|
||||||
for event in results {
|
|
||||||
let mut is_target_event = false;
|
|
||||||
let mut hint = String::new();
|
|
||||||
|
|
||||||
// 严格来源校验
|
|
||||||
if event.EventCode == 41 && event.SourceName == "Microsoft-Windows-Kernel-Power" {
|
|
||||||
is_target_event = true;
|
|
||||||
hint = "系统意外断电 (电源/强关)".to_string();
|
|
||||||
} else if (event.EventCode == 18 || event.EventCode == 19) && event.SourceName == "Microsoft-Windows-WHEA-Logger" {
|
|
||||||
is_target_event = true;
|
|
||||||
hint = "WHEA 硬件致命错误 (CPU/超频/PCIe)".to_string();
|
|
||||||
} else if event.EventCode == 7 && (event.SourceName == "Disk" || event.SourceName == "disk") {
|
|
||||||
is_target_event = true;
|
|
||||||
hint = "硬盘出现坏道 (Disk Bad Block)".to_string();
|
|
||||||
} else if event.EventCode == 1001 && event.SourceName == "BugCheck" {
|
|
||||||
is_target_event = true;
|
|
||||||
hint = "系统发生蓝屏死机 (BSOD)".to_string();
|
|
||||||
} else if event.EventCode == 4101 && event.SourceName == "Display" {
|
|
||||||
is_target_event = true;
|
|
||||||
hint = "显卡驱动停止响应并已恢复 (TDR)".to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_target_event {
|
|
||||||
events.push(SystemEvent {
|
|
||||||
time_generated: format_wmi_time(&event.TimeGenerated),
|
|
||||||
event_id: event.EventCode,
|
|
||||||
source: event.SourceName,
|
|
||||||
message: event.Message.unwrap_or("无详细信息".to_string()),
|
|
||||||
analysis_hint: hint,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示最近 10 条(因为加了时间范围,可以多显示一点)
|
|
||||||
if events.len() >= 10 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Minidump
|
|
||||||
let mut minidump = MinidumpInfo { found: false, count: 0, explanation: "无蓝屏记录".to_string() };
|
|
||||||
if let Ok(entries) = fs::read_dir("C:\\Windows\\Minidump") {
|
|
||||||
let count = entries.count();
|
|
||||||
if count > 0 {
|
|
||||||
minidump = MinidumpInfo {
|
|
||||||
found: true,
|
|
||||||
count,
|
|
||||||
explanation: format!("发现 {} 次蓝屏崩溃", count),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 驱动设备检查
|
|
||||||
let mut driver_issues = Vec::new();
|
|
||||||
if let Some(con) = &wmi_con {
|
|
||||||
let query = "SELECT Name, ConfigManagerErrorCode FROM Win32_PnPEntity WHERE ConfigManagerErrorCode <> 0";
|
|
||||||
if let Ok(results) = con.raw_query::<Win32_PnPEntity>(query) {
|
|
||||||
for dev in results {
|
|
||||||
let code = dev.ConfigManagerErrorCode.unwrap_or(0);
|
|
||||||
let desc = match code {
|
|
||||||
10 => "设备无法启动 (Code 10)。通常是驱动不兼容。",
|
|
||||||
28 => "驱动程序未安装 (Code 28)。",
|
|
||||||
43 => "硬件报告问题已被停止 (Code 43)。显卡常见,可能虚焊。",
|
|
||||||
_ => "设备状态异常。",
|
|
||||||
};
|
|
||||||
driver_issues.push(DriverIssue {
|
|
||||||
device_name: dev.Name.unwrap_or("未知设备".to_string()),
|
|
||||||
error_code: code,
|
|
||||||
description: desc.to_string(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. 电池健康度
|
|
||||||
let mut battery_info = None;
|
|
||||||
if let Some(con) = &wmi_con {
|
|
||||||
if let Ok(results) = con.raw_query::<Win32_Battery>("SELECT DesignCapacity, FullChargeCapacity, BatteryStatus FROM Win32_Battery") {
|
|
||||||
if let Some(bat) = results.first() {
|
|
||||||
let design = bat.DesignCapacity.unwrap_or(0);
|
|
||||||
let full = bat.FullChargeCapacity.unwrap_or(0);
|
|
||||||
let status = bat.BatteryStatus.unwrap_or(0);
|
|
||||||
|
|
||||||
if design > 0 {
|
|
||||||
let health = ((full as f64 / design as f64) * 100.0) as u32;
|
|
||||||
let ac_plugged = status == 2 || status == 6 || status == 1;
|
|
||||||
|
|
||||||
let explain = if health < 60 {
|
|
||||||
"电池老化严重,建议更换,否则可能导致供电不稳。".to_string()
|
|
||||||
} else {
|
|
||||||
"电池状态良好。".to_string()
|
|
||||||
};
|
};
|
||||||
|
storage.push(StorageDevice {
|
||||||
battery_info = Some(BatteryInfo {
|
model: disk.Model.unwrap_or("Generic Disk".to_string()),
|
||||||
health_percentage: health,
|
health_status: status,
|
||||||
is_ac_connected: ac_plugged,
|
human_explanation: explanation,
|
||||||
explanation: explain,
|
is_danger,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let _ = window.emit("report-storage", storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemHealthReport {
|
// 3. 驱动 (快)
|
||||||
hardware,
|
{
|
||||||
storage,
|
let mut driver_issues = Vec::new();
|
||||||
events,
|
if let Some(con) = &wmi_con {
|
||||||
minidumps: minidump,
|
let query = "SELECT Name, ConfigManagerErrorCode FROM Win32_PnPEntity WHERE ConfigManagerErrorCode <> 0";
|
||||||
drivers: driver_issues,
|
if let Ok(results) = con.raw_query::<Win32_PnPEntity>(query) {
|
||||||
battery: battery_info
|
for dev in results {
|
||||||
|
let code = dev.ConfigManagerErrorCode.unwrap_or(0);
|
||||||
|
let desc = match code {
|
||||||
|
10 => "设备无法启动 (Code 10)。通常是驱动不兼容。",
|
||||||
|
28 => "驱动程序未安装 (Code 28)。",
|
||||||
|
43 => "硬件报告问题已被停止 (Code 43)。显卡常见,可能虚焊。",
|
||||||
|
_ => "设备状态异常。",
|
||||||
|
};
|
||||||
|
driver_issues.push(DriverIssue {
|
||||||
|
device_name: dev.Name.unwrap_or("未知设备".to_string()),
|
||||||
|
error_code: code,
|
||||||
|
description: desc.to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = window.emit("report-drivers", driver_issues);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.await
|
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
|
|
||||||
Ok(report)
|
// 4. Minidump (快)
|
||||||
|
{
|
||||||
|
let mut minidump = MinidumpInfo { found: false, count: 0, explanation: "无蓝屏记录".to_string() };
|
||||||
|
if let Ok(entries) = fs::read_dir("C:\\Windows\\Minidump") {
|
||||||
|
let count = entries.count();
|
||||||
|
if count > 0 {
|
||||||
|
minidump = MinidumpInfo {
|
||||||
|
found: true,
|
||||||
|
count,
|
||||||
|
explanation: format!("发现 {} 次蓝屏崩溃", count),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = window.emit("report-minidumps", minidump);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 电池 (快)
|
||||||
|
{
|
||||||
|
let mut battery_info = None;
|
||||||
|
if let Some(con) = &wmi_con {
|
||||||
|
if let Ok(results) = con.raw_query::<Win32_Battery>("SELECT DesignCapacity, FullChargeCapacity, BatteryStatus FROM Win32_Battery") {
|
||||||
|
if let Some(bat) = results.first() {
|
||||||
|
let design = bat.DesignCapacity.unwrap_or(0);
|
||||||
|
let full = bat.FullChargeCapacity.unwrap_or(0);
|
||||||
|
let status = bat.BatteryStatus.unwrap_or(0);
|
||||||
|
if design > 0 {
|
||||||
|
let health = ((full as f64 / design as f64) * 100.0) as u32;
|
||||||
|
let ac_plugged = status == 2 || status == 6 || status == 1;
|
||||||
|
let explain = if health < 60 {
|
||||||
|
"电池老化严重,建议更换,否则可能导致供电不稳。".to_string()
|
||||||
|
} else {
|
||||||
|
"电池状态良好。".to_string()
|
||||||
|
};
|
||||||
|
battery_info = Some(BatteryInfo {
|
||||||
|
health_percentage: health,
|
||||||
|
is_ac_connected: ac_plugged,
|
||||||
|
explanation: explain,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 即使是 None 也要发,以便前端知道检查完成了
|
||||||
|
// 这里为了简化,直接发 Option
|
||||||
|
let _ = window.emit("report-battery", battery_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 日志 (最慢,放在最后)
|
||||||
|
{
|
||||||
|
let mut events = Vec::new();
|
||||||
|
if let Some(con) = &wmi_con {
|
||||||
|
let start_time_str = get_wmi_query_time(30);
|
||||||
|
let query = format!(
|
||||||
|
"SELECT TimeGenerated, EventCode, SourceName, Message FROM Win32_NTLogEvent WHERE Logfile = 'System' AND TimeGenerated >= '{}' AND (EventCode = 41 OR EventCode = 18 OR EventCode = 19 OR EventCode = 7 OR EventCode = 1001 OR EventCode = 4101)",
|
||||||
|
start_time_str
|
||||||
|
);
|
||||||
|
|
||||||
|
if let Ok(results) = con.raw_query::<Win32_NTLogEvent>(&query) {
|
||||||
|
for event in results {
|
||||||
|
let mut is_target_event = false;
|
||||||
|
let mut hint = String::new();
|
||||||
|
|
||||||
|
if event.EventCode == 41 && event.SourceName == "Microsoft-Windows-Kernel-Power" {
|
||||||
|
is_target_event = true; hint = "系统意外断电 (电源/强关)".to_string();
|
||||||
|
} else if (event.EventCode == 18 || event.EventCode == 19) && event.SourceName == "Microsoft-Windows-WHEA-Logger" {
|
||||||
|
is_target_event = true; hint = "WHEA 硬件致命错误 (CPU/超频/PCIe)".to_string();
|
||||||
|
} else if event.EventCode == 7 && (event.SourceName == "Disk" || event.SourceName == "disk") {
|
||||||
|
is_target_event = true; hint = "硬盘出现坏道 (Disk Bad Block)".to_string();
|
||||||
|
} else if event.EventCode == 1001 && event.SourceName == "BugCheck" {
|
||||||
|
is_target_event = true; hint = "系统发生蓝屏死机 (BSOD)".to_string();
|
||||||
|
} else if event.EventCode == 4101 && event.SourceName == "Display" {
|
||||||
|
is_target_event = true; hint = "显卡驱动停止响应并已恢复 (TDR)".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_target_event {
|
||||||
|
events.push(SystemEvent {
|
||||||
|
time_generated: format_wmi_time(&event.TimeGenerated),
|
||||||
|
event_id: event.EventCode,
|
||||||
|
source: event.SourceName,
|
||||||
|
message: event.Message.unwrap_or("无详细信息".to_string()),
|
||||||
|
analysis_hint: hint,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if events.len() >= 10 { break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = window.emit("report-events", events);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 全部完成信号
|
||||||
|
let _ = window.emit("diagnosis-finished", ());
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
599
src/App.vue
599
src/App.vue
@@ -17,53 +17,39 @@
|
|||||||
<button class="secondary-btn" @click="triggerImport" :disabled="loading">
|
<button class="secondary-btn" @click="triggerImport" :disabled="loading">
|
||||||
📂 导入报告
|
📂 导入报告
|
||||||
</button>
|
</button>
|
||||||
<button class="secondary-btn" @click="exportReport" :disabled="!report || loading">
|
<button class="secondary-btn" @click="exportReport" :disabled="!isReportValid || loading">
|
||||||
💾 导出报告
|
💾 导出报告
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 隐藏的文件输入框 -->
|
<input type="file" ref="fileInput" @change="handleFileImport" accept=".json" style="display: none" />
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
ref="fileInput"
|
|
||||||
@change="handleFileImport"
|
|
||||||
accept=".json"
|
|
||||||
style="display: none"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div v-if="errorMsg" class="error-box">
|
<div v-if="errorMsg" class="error-box">⚠️ {{ errorMsg }}</div>
|
||||||
⚠️ {{ errorMsg }}
|
<!-- 完成提示 -->
|
||||||
</div>
|
<div v-if="scanFinished" class="success-box">✅ 扫描已完成!所有项目检查完毕。</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 结果显示区域 -->
|
<!-- 结果显示区域 -->
|
||||||
<div v-if="report" class="dashboard fade-in">
|
<div class="dashboard fade-in">
|
||||||
|
|
||||||
<!-- 1. 硬件概览 (带进度条可视化) -->
|
<!-- 1. 硬件概览 -->
|
||||||
<div class="card summary">
|
<div v-if="report.hardware" class="card summary slide-up">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>🖥️ 硬件概览与资源占用</h2>
|
<h2>🖥️ 硬件概览与资源占用</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid-container-summary">
|
<div class="grid-container-summary">
|
||||||
<!-- 左侧基础信息 -->
|
|
||||||
<div class="basic-info">
|
<div class="basic-info">
|
||||||
<div class="info-item">
|
<div class="info-item">
|
||||||
<span class="label">CPU 型号</span>
|
<span class="label">CPU 型号</span>
|
||||||
<span class="value text-ellipsis" :title="report.hardware.cpu_name">{{ report.hardware.cpu_name }}</span>
|
<span class="value text-ellipsis" :title="report.hardware.cpu_name">{{ report.hardware.cpu_name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- 整机信息 (品牌机看这个) -->
|
|
||||||
<div class="info-item">
|
<div class="info-item">
|
||||||
<span class="label">整机型号 (System)</span>
|
<span class="label">整机型号 (System)</span>
|
||||||
<span class="value text-ellipsis" :title="report.hardware.sys_vendor + ' ' + report.hardware.sys_product">
|
<span class="value text-ellipsis">{{ report.hardware.sys_vendor }} {{ report.hardware.sys_product }}</span>
|
||||||
{{ report.hardware.sys_vendor }} {{ report.hardware.sys_product }}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- 主板信息 (DIY看这个) -->
|
|
||||||
<div class="info-item">
|
<div class="info-item">
|
||||||
<span class="label">主板型号 (BaseBoard)</span>
|
<span class="label">主板型号 (BaseBoard)</span>
|
||||||
<span class="value text-ellipsis" :title="report.hardware.mobo_vendor + ' ' + report.hardware.mobo_product">
|
<span class="value text-ellipsis">{{ report.hardware.mobo_vendor }} {{ report.hardware.mobo_product }}</span>
|
||||||
{{ report.hardware.mobo_vendor }} {{ report.hardware.mobo_product }}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item">
|
<div class="info-item">
|
||||||
<span class="label">BIOS 版本</span>
|
<span class="label">BIOS 版本</span>
|
||||||
@@ -75,49 +61,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 右侧可视化条 -->
|
|
||||||
<div class="usage-bars">
|
<div class="usage-bars">
|
||||||
<!-- C盘空间可视化 -->
|
|
||||||
<div class="usage-item">
|
<div class="usage-item">
|
||||||
<div class="progress-label">
|
<div class="progress-label">
|
||||||
<span>C盘空间 (已用 {{ report.hardware.c_drive_used_gb }}GB / 总计 {{ report.hardware.c_drive_total_gb }}GB)</span>
|
<span>C盘空间 (已用 {{ report.hardware.c_drive_used_gb }}GB / 总计 {{ report.hardware.c_drive_total_gb }}GB)</span>
|
||||||
<strong>{{ calculatePercent(report.hardware.c_drive_used_gb, report.hardware.c_drive_total_gb) }}%</strong>
|
<strong>{{ calculatePercent(report.hardware.c_drive_used_gb, report.hardware.c_drive_total_gb) }}%</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="progress-bar-large">
|
<div class="progress-bar-large">
|
||||||
<div class="fill"
|
<div class="fill" :style="getProgressStyle(report.hardware.c_drive_used_gb, report.hardware.c_drive_total_gb)"></div>
|
||||||
:style="getProgressStyle(report.hardware.c_drive_used_gb, report.hardware.c_drive_total_gb)">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 内存占用可视化 -->
|
|
||||||
<div class="usage-item">
|
<div class="usage-item">
|
||||||
<div class="progress-label">
|
<div class="progress-label">
|
||||||
<span>内存占用 (已用 {{ report.hardware.memory_used_gb }}GB / 总计 {{ report.hardware.memory_total_gb }}GB)</span>
|
<span>内存占用 (已用 {{ report.hardware.memory_used_gb }}GB / 总计 {{ report.hardware.memory_total_gb }}GB)</span>
|
||||||
<strong>{{ calculatePercent(report.hardware.memory_used_gb, report.hardware.memory_total_gb) }}%</strong>
|
<strong>{{ calculatePercent(report.hardware.memory_used_gb, report.hardware.memory_total_gb) }}%</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="progress-bar-large">
|
<div class="progress-bar-large">
|
||||||
<div class="fill"
|
<div class="fill" :style="getProgressStyle(report.hardware.memory_used_gb, report.hardware.memory_total_gb)"></div>
|
||||||
:style="getProgressStyle(report.hardware.memory_used_gb, report.hardware.memory_total_gb)">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 2. 驱动与设备管理器状态 -->
|
<!-- 2. 驱动状态 -->
|
||||||
<div class="card" :class="{ danger: report.drivers.length > 0, success: report.drivers.length === 0 }">
|
<div v-if="report.drivers" class="card slide-up" :class="{ danger: report.drivers.length > 0, success: report.drivers.length === 0 }">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>🔌 驱动与设备状态</h2>
|
<h2>🔌 驱动与设备状态</h2>
|
||||||
<span class="badge" :class="report.drivers.length > 0 ? 'badge-red' : 'badge-green'">
|
<span class="badge" :class="report.drivers.length > 0 ? 'badge-red' : 'badge-green'">
|
||||||
{{ report.drivers.length > 0 ? '发现异常' : '正常' }}
|
{{ report.drivers.length > 0 ? '发现异常' : '正常' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="report.drivers.length === 0" class="good-news">✅ 设备管理器中未发现带有黄色感叹号或错误的设备。</div>
|
||||||
<div v-if="report.drivers.length === 0" class="good-news">
|
|
||||||
✅ 设备管理器中未发现带有黄色感叹号或错误的设备。
|
|
||||||
</div>
|
|
||||||
<div v-else class="list-container">
|
<div v-else class="list-container">
|
||||||
<div v-for="(drv, idx) in report.drivers" :key="idx" class="list-item error-item">
|
<div v-for="(drv, idx) in report.drivers" :key="idx" class="list-item error-item">
|
||||||
<div class="item-header">
|
<div class="item-header">
|
||||||
@@ -129,8 +104,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 3. 电池健康度 (仅笔记本显示) -->
|
<!-- 3. 电池健康 -->
|
||||||
<div v-if="report.battery" class="card" :class="{ danger: report.battery.health_percentage < 60 }">
|
<div v-if="report.battery" class="card slide-up" :class="{ danger: report.battery.health_percentage < 60 }">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>🔋 电池健康度 (寿命)</h2>
|
<h2>🔋 电池健康度 (寿命)</h2>
|
||||||
<span class="badge" :class="report.battery.is_ac_connected ? 'badge-blue' : 'badge-gray'">
|
<span class="badge" :class="report.battery.is_ac_connected ? 'badge-blue' : 'badge-gray'">
|
||||||
@@ -144,17 +119,15 @@
|
|||||||
<strong>{{ report.battery.health_percentage }}%</strong>
|
<strong>{{ report.battery.health_percentage }}%</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="progress-bar">
|
<div class="progress-bar">
|
||||||
<div class="fill"
|
<div class="fill" :style="{ width: report.battery.health_percentage + '%', background: getBatteryColor(report.battery.health_percentage) }"></div>
|
||||||
:style="{ width: report.battery.health_percentage + '%', background: getBatteryColor(report.battery.health_percentage) }">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="explanation">{{ report.battery.explanation }}</p>
|
<p class="explanation">{{ report.battery.explanation }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 4. 硬盘健康度 -->
|
<!-- 4. 硬盘健康 -->
|
||||||
<div class="card" :class="{ danger: hasStorageDanger }">
|
<div v-if="report.storage" class="card slide-up" :class="{ danger: hasStorageDanger }">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>💾 硬盘健康度 (S.M.A.R.T)</h2>
|
<h2>💾 硬盘健康度 (S.M.A.R.T)</h2>
|
||||||
</div>
|
</div>
|
||||||
@@ -172,36 +145,30 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 5. 蓝屏分析 -->
|
<!-- 5. 蓝屏分析 -->
|
||||||
<div class="card" :class="{ danger: report.minidumps.found, success: !report.minidumps.found }">
|
<div v-if="report.minidumps" class="card slide-up" :class="{ danger: report.minidumps.found, success: !report.minidumps.found }">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>☠️ 蓝屏死机记录 (BSOD)</h2>
|
<h2>☠️ 蓝屏死机记录 (BSOD)</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-box">
|
<div class="content-box">
|
||||||
<p class="main-text">{{ report.minidumps.explanation }}</p>
|
<p class="main-text">{{ report.minidumps.explanation }}</p>
|
||||||
<p v-if="report.minidumps.found" class="tip">
|
<p v-if="report.minidumps.found" class="tip">💡 建议使用 BlueScreenView 或 WinDbg 工具打开 C:\Windows\Minidump 文件夹下的 .dmp 文件进行深入分析。</p>
|
||||||
💡 建议使用 BlueScreenView 或 WinDbg 工具打开 C:\Windows\Minidump 文件夹下的 .dmp 文件进行深入分析。
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 6. 关键系统日志 -->
|
<!-- 6. 关键日志 -->
|
||||||
<div class="card" :class="{ danger: report.events.length > 0 }">
|
<div v-if="report.events" class="card slide-up" :class="{ danger: report.events.length > 0 }">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>⚡ 关键供电与硬件日志 (Event Log)</h2>
|
<h2>⚡ 关键供电与硬件日志 (Event Log)</h2>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="report.events.length === 0" class="good-news">✅ 近期日志中未发现 Kernel-Power(41) 或 WHEA(18/19) 等致命错误。</div>
|
||||||
<div v-if="report.events.length === 0" class="good-news">
|
|
||||||
✅ 近期日志中未发现 Kernel-Power(41) 或 WHEA(18/19) 等致命错误。
|
|
||||||
</div>
|
|
||||||
<div v-else class="list-container">
|
<div v-else class="list-container">
|
||||||
<div v-for="(evt, idx) in report.events" :key="idx" class="list-item warning-item">
|
<div v-for="(evt, idx) in report.events" :key="idx" class="list-item warning-item">
|
||||||
<div class="item-header">
|
<div class="item-header">
|
||||||
<span class="event-id">ID: {{ evt.event_id }}</span>
|
<span class="event-id">ID: {{ evt.event_id }}</span>
|
||||||
<span class="event-source">{{ evt.source }}</span>
|
<span class="event-source">{{ evt.source }}</span>
|
||||||
<span class="event-time">{{ formatTime(evt.time_generated) }}</span>
|
<span class="event-time">{{ evt.time_generated }}</span>
|
||||||
</div>
|
</div>
|
||||||
<p class="description highlight">{{ evt.analysis_hint }}</p>
|
<p class="description highlight">{{ evt.analysis_hint }}</p>
|
||||||
<!-- 新增:显示原始错误信息 -->
|
|
||||||
<p v-if="evt.message" class="description raw-message">{{ evt.message }}</p>
|
<p v-if="evt.message" class="description raw-message">{{ evt.message }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -212,70 +179,67 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, onUnmounted } from 'vue';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
import { listen } from '@tauri-apps/api/event';
|
||||||
|
|
||||||
const report = ref(null);
|
// 初始化 report 为包含空字段的对象,避免 v-if 报错
|
||||||
const loading = ref(false);
|
const emptyReport = () => ({
|
||||||
const errorMsg = ref('');
|
hardware: null,
|
||||||
const fileInput = ref(null); // 文件输入框的引用
|
storage: null,
|
||||||
|
events: null,
|
||||||
const hasStorageDanger = computed(() => {
|
minidumps: null,
|
||||||
return report.value?.storage.some(d => d.is_danger);
|
drivers: null,
|
||||||
|
battery: null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const report = ref(emptyReport());
|
||||||
|
const loading = ref(false);
|
||||||
|
const errorMsg = ref('');
|
||||||
|
const scanFinished = ref(false);
|
||||||
|
const fileInput = ref(null);
|
||||||
|
let unlistenFns = []; // 存储事件取消函数
|
||||||
|
|
||||||
|
const hasStorageDanger = computed(() => {
|
||||||
|
return report.value?.storage?.some(d => d.is_danger) || false;
|
||||||
|
});
|
||||||
|
|
||||||
|
const isReportValid = computed(() => {
|
||||||
|
// 只要有任意一项数据,就认为可以导出
|
||||||
|
return report.value && (report.value.hardware || report.value.storage);
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- 辅助函数保持不变 ---
|
||||||
function calculatePercent(used, total) {
|
function calculatePercent(used, total) {
|
||||||
if (total === 0) return 0;
|
if (!total || total === 0) return 0;
|
||||||
return Math.round((used / total) * 100);
|
return Math.round((used / total) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProgressStyle(used, total) {
|
function getProgressStyle(used, total) {
|
||||||
const percent = calculatePercent(used, total);
|
const percent = calculatePercent(used, total);
|
||||||
let color = '#2ed573';
|
let color = '#2ed573';
|
||||||
|
if (percent >= 90) color = '#ff4757';
|
||||||
if (percent >= 90) {
|
else if (percent >= 75) color = '#ffa502';
|
||||||
color = '#ff4757';
|
return { width: `${percent}%`, background: color };
|
||||||
} else if (percent >= 75) {
|
|
||||||
color = '#ffa502';
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
width: `${percent}%`,
|
|
||||||
background: color
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBatteryColor(percentage) {
|
function getBatteryColor(percentage) {
|
||||||
if (percentage < 50) return '#ff4757';
|
if (percentage < 50) return '#ff4757';
|
||||||
if (percentage < 80) return '#ffa502';
|
if (percentage < 80) return '#ffa502';
|
||||||
return '#2ed573';
|
return '#2ed573';
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTime(wmiTime) {
|
// --- 导出/导入 ---
|
||||||
if (!wmiTime) return "Unknown Time";
|
|
||||||
return wmiTime.replace('T', ' ').substring(0, 19);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- 导出报告功能 ---
|
|
||||||
function exportReport() {
|
function exportReport() {
|
||||||
if (!report.value) return;
|
if (!isReportValid.value) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dataStr = JSON.stringify(report.value, null, 2);
|
const dataStr = JSON.stringify(report.value, null, 2);
|
||||||
// 使用 Blob 创建文件对象
|
|
||||||
const blob = new Blob([dataStr], { type: "application/json" });
|
const blob = new Blob([dataStr], { type: "application/json" });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
|
|
||||||
// 创建临时链接触发下载
|
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
// 文件名包含时间戳,避免重名
|
|
||||||
const timestamp = new Date().toISOString().slice(0, 19).replace(/[:T]/g, "-");
|
const timestamp = new Date().toISOString().slice(0, 19).replace(/[:T]/g, "-");
|
||||||
link.download = `SystemDoctor_Report_${timestamp}.json`;
|
link.download = `SystemDoctor_Report_${timestamp}.json`;
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
|
|
||||||
// 清理
|
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -283,71 +247,103 @@ function exportReport() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 导入报告功能 ---
|
function triggerImport() { fileInput.value.click(); }
|
||||||
function triggerImport() {
|
|
||||||
// 触发隐藏的文件输入框点击
|
|
||||||
fileInput.value.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleFileImport(event) {
|
function handleFileImport(event) {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
try {
|
try {
|
||||||
const json = JSON.parse(e.target.result);
|
const json = JSON.parse(e.target.result);
|
||||||
// 简单的格式校验:检查是否有关键字段
|
if (json && (json.hardware || json.storage)) {
|
||||||
if (json && json.hardware && json.storage) {
|
report.value = json; // 导入时一次性覆盖
|
||||||
report.value = json;
|
scanFinished.value = false; // 导入的不显示“扫描完成”
|
||||||
errorMsg.value = '';
|
errorMsg.value = '';
|
||||||
} else {
|
} else {
|
||||||
errorMsg.value = "无效的报告文件:格式不正确或内容缺失。";
|
errorMsg.value = "无效的报告文件。";
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
errorMsg.value = "导入失败: 无法解析文件 (" + err.message + ")";
|
errorMsg.value = "解析失败: " + err.message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
// 清空 value 以便允许重复选择同一个文件
|
|
||||||
event.target.value = '';
|
event.target.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- 扫描逻辑 (流式) ---
|
||||||
async function startScan() {
|
async function startScan() {
|
||||||
// 1. 如果界面已有报告,先清空
|
// 1. 重置状态
|
||||||
if (report.value) {
|
report.value = emptyReport();
|
||||||
report.value = null;
|
errorMsg.value = '';
|
||||||
|
scanFinished.value = false;
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
// 2. 清理旧的监听器
|
||||||
|
if (unlistenFns.length > 0) {
|
||||||
|
for (const fn of unlistenFns) fn();
|
||||||
|
unlistenFns = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
loading.value = true;
|
// 3. 注册新的事件监听器
|
||||||
errorMsg.value = '';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await invoke('run_diagnosis');
|
const l1 = await listen('report-hardware', (e) => report.value.hardware = e.payload);
|
||||||
console.log("诊断结果:", result);
|
const l2 = await listen('report-storage', (e) => report.value.storage = e.payload);
|
||||||
report.value = result;
|
const l3 = await listen('report-drivers', (e) => report.value.drivers = e.payload);
|
||||||
|
const l4 = await listen('report-minidumps', (e) => report.value.minidumps = e.payload);
|
||||||
|
const l5 = await listen('report-battery', (e) => report.value.battery = e.payload); // 可能是null
|
||||||
|
const l6 = await listen('report-events', (e) => report.value.events = e.payload);
|
||||||
|
const l7 = await listen('diagnosis-finished', () => {
|
||||||
|
loading.value = false;
|
||||||
|
scanFinished.value = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
unlistenFns.push(l1, l2, l3, l4, l5, l6, l7);
|
||||||
|
|
||||||
|
// 4. 触发后端任务 (fire and forget)
|
||||||
|
await invoke('run_diagnosis');
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
errorMsg.value = "扫描失败: " + e + " (请确保以管理员身份运行此程序)";
|
errorMsg.value = "启动扫描失败: " + e;
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 组件销毁时清理监听
|
||||||
|
onUnmounted(() => {
|
||||||
|
for (const fn of unlistenFns) fn();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- 添加全局样式重置 body -->
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
overflow-x: hidden; /* 防止水平滚动条 */
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* 基础布局 */
|
/* 保持原有的样式,只增加动画 */
|
||||||
|
/* ... (之前的样式代码省略,下面是新增的) ... */
|
||||||
|
|
||||||
|
@keyframes slideUp {
|
||||||
|
from { opacity: 0; transform: translateY(20px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-up {
|
||||||
|
animation: slideUp 0.5s ease-out forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-box {
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 12px 20px;
|
||||||
|
background-color: #eafaf1;
|
||||||
|
color: #27ae60;
|
||||||
|
border: 1px solid #d4efdf;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: center;
|
||||||
|
animation: slideUp 0.3s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- 必须包含原来的所有样式,为了完整性我把它们复制回来 --- */
|
||||||
.container {
|
.container {
|
||||||
max-width: 1200px; /* 改宽了: 从960px增加到1200px */
|
max-width: 1200px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 30px 20px;
|
padding: 30px 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -357,340 +353,95 @@ body {
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header { text-align: center; margin-bottom: 30px; }
|
||||||
text-align: center;
|
h1 { font-size: 2rem; margin-bottom: 8px; color: #2c3e50; letter-spacing: -0.5px; }
|
||||||
margin-bottom: 30px;
|
.subtitle { color: #7f8c8d; font-size: 1rem; }
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
.actions { display: flex; flex-direction: column; align-items: center; margin-bottom: 35px; gap: 15px; }
|
||||||
font-size: 2rem;
|
.secondary-actions { display: flex; gap: 15px; }
|
||||||
margin-bottom: 8px;
|
|
||||||
color: #2c3e50;
|
|
||||||
letter-spacing: -0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
color: #7f8c8d;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 操作区域 */
|
|
||||||
.actions {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 35px;
|
|
||||||
gap: 15px; /* 增加按钮组之间的间距 */
|
|
||||||
}
|
|
||||||
|
|
||||||
.secondary-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.scan-btn {
|
.scan-btn {
|
||||||
background: linear-gradient(135deg, #42b983 0%, #2ecc71 100%);
|
background: linear-gradient(135deg, #42b983 0%, #2ecc71 100%);
|
||||||
color: white;
|
color: white; border: none; padding: 14px 40px; font-size: 1.1rem; border-radius: 50px; cursor: pointer;
|
||||||
border: none;
|
box-shadow: 0 4px 15px rgba(46, 204, 113, 0.25); transition: all 0.2s ease; font-weight: 600; display: flex; align-items: center; justify-content: center; min-width: 200px;
|
||||||
padding: 14px 40px;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
border-radius: 50px;
|
|
||||||
cursor: pointer;
|
|
||||||
box-shadow: 0 4px 15px rgba(46, 204, 113, 0.25);
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
font-weight: 600;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
}
|
||||||
|
.scan-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(46, 204, 113, 0.35); filter: brightness(1.05); }
|
||||||
|
.scan-btn:active:not(:disabled) { transform: translateY(1px); }
|
||||||
|
.scan-btn:disabled { background: #bdc3c7; cursor: not-allowed; box-shadow: none; opacity: 0.8; }
|
||||||
|
|
||||||
.scan-btn:hover:not(:disabled) {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 6px 20px rgba(46, 204, 113, 0.35);
|
|
||||||
filter: brightness(1.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.scan-btn:active:not(:disabled) {
|
|
||||||
transform: translateY(1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.scan-btn:disabled {
|
|
||||||
background: #bdc3c7;
|
|
||||||
cursor: not-allowed;
|
|
||||||
box-shadow: none;
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 辅助按钮样式 */
|
|
||||||
.secondary-btn {
|
.secondary-btn {
|
||||||
background: white;
|
background: white; border: 1px solid #dcdfe6; color: #606266; padding: 8px 20px; font-size: 0.9rem; border-radius: 20px;
|
||||||
border: 1px solid #dcdfe6;
|
cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 5px;
|
||||||
color: #606266;
|
|
||||||
padding: 8px 20px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
border-radius: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 5px;
|
|
||||||
}
|
}
|
||||||
|
.secondary-btn:hover:not(:disabled) { color: #409eff; border-color: #c6e2ff; background-color: #ecf5ff; }
|
||||||
|
.secondary-btn:disabled { color: #c0c4cc; cursor: not-allowed; background-color: #f5f7fa; }
|
||||||
|
|
||||||
.secondary-btn:hover:not(:disabled) {
|
.error-box { margin-top: 5px; padding: 12px 20px; background-color: #ffeaea; color: #c0392b; border: 1px solid #ffcccc; border-radius: 8px; font-weight: 500; font-size: 0.95rem; }
|
||||||
color: #409eff;
|
|
||||||
border-color: #c6e2ff;
|
|
||||||
background-color: #ecf5ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.secondary-btn:disabled {
|
.dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 25px; }
|
||||||
color: #c0c4cc;
|
.fade-in { animation: fadeIn 0.4s ease-out; }
|
||||||
cursor: not-allowed;
|
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
|
||||||
background-color: #f5f7fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-box {
|
|
||||||
margin-top: 5px;
|
|
||||||
padding: 12px 20px;
|
|
||||||
background-color: #ffeaea;
|
|
||||||
color: #c0392b;
|
|
||||||
border: 1px solid #ffcccc;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 仪表盘网格 */
|
|
||||||
.dashboard {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
|
|
||||||
gap: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fade-in {
|
|
||||||
animation: fadeIn 0.4s ease-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fadeIn {
|
|
||||||
from { opacity: 0; transform: translateY(15px); }
|
|
||||||
to { opacity: 1; transform: translateY(0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 卡片通用样式 */
|
|
||||||
.card {
|
.card {
|
||||||
background: white;
|
background: white; border-radius: 12px; padding: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.04);
|
||||||
border-radius: 12px;
|
border-top: 4px solid #42b983; transition: transform 0.2s, box-shadow 0.2s;
|
||||||
padding: 20px;
|
|
||||||
box-shadow: 0 5px 15px rgba(0,0,0,0.04);
|
|
||||||
border-top: 4px solid #42b983;
|
|
||||||
transition: transform 0.2s, box-shadow 0.2s;
|
|
||||||
border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;
|
border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.08); }
|
||||||
.card:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 8px 25px rgba(0,0,0,0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.danger { border-top-color: #ff4757; background: #fffbfb; }
|
.card.danger { border-top-color: #ff4757; background: #fffbfb; }
|
||||||
.card.success { border-top-color: #2ed573; }
|
.card.success { border-top-color: #2ed573; }
|
||||||
|
.card.summary { border-top-color: #3742fa; grid-column: 1 / -1; }
|
||||||
|
|
||||||
.card.summary {
|
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid #f1f2f6; }
|
||||||
border-top-color: #3742fa;
|
h2 { font-size: 1.2rem; margin: 0; font-weight: 600; }
|
||||||
grid-column: 1 / -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
.grid-container-summary { display: grid; grid-template-columns: 1fr 1.5fr; gap: 30px; align-items: start; }
|
||||||
display: flex;
|
@media (max-width: 768px) { .grid-container-summary { grid-template-columns: 1fr; gap: 20px; } }
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
padding-bottom: 12px;
|
|
||||||
border-bottom: 1px solid #f1f2f6;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
.basic-info, .usage-bars { display: flex; flex-direction: column; gap: 15px; }
|
||||||
font-size: 1.2rem;
|
.usage-bars { padding-top: 10px; }
|
||||||
margin: 0;
|
.usage-item { display: flex; flex-direction: column; gap: 8px; }
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 硬件概览布局 */
|
.info-item { display: flex; flex-direction: column; }
|
||||||
.grid-container-summary {
|
.label { font-size: 0.8rem; color: #95a5a6; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
|
||||||
display: grid;
|
.value { font-size: 1.05rem; font-weight: 500; color: #2c3e50; }
|
||||||
grid-template-columns: 1fr 1.5fr;
|
.text-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
gap: 30px;
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
.progress-label { display: flex; justify-content: space-between; font-size: 0.9rem; color: #636e72; }
|
||||||
.grid-container-summary {
|
.progress-label strong { color: #2c3e50; font-size: 1rem; }
|
||||||
grid-template-columns: 1fr;
|
.progress-bar-large { width: 100%; height: 20px; background: #e6e8ec; border-radius: 10px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); }
|
||||||
gap: 20px;
|
.fill { height: 100%; transition: width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.6s ease; }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.basic-info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-item {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
color: #95a5a6;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.value {
|
|
||||||
font-size: 1.05rem;
|
|
||||||
font-weight: 500;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
.text-ellipsis {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 大型进度条样式 */
|
|
||||||
.usage-bars {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 25px;
|
|
||||||
padding-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-item {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-label {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: #636e72;
|
|
||||||
}
|
|
||||||
.progress-label strong {
|
|
||||||
color: #2c3e50;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar-large {
|
|
||||||
width: 100%;
|
|
||||||
height: 20px;
|
|
||||||
background: #e6e8ec;
|
|
||||||
border-radius: 10px;
|
|
||||||
overflow: hidden;
|
|
||||||
box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.fill {
|
|
||||||
height: 100%;
|
|
||||||
transition: width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.6s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 列表样式 */
|
|
||||||
.list-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-item {
|
|
||||||
background: #fcfdfe;
|
|
||||||
padding: 12px 15px;
|
|
||||||
border-radius: 8px;
|
|
||||||
border: 1px solid #ececec;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
.list-container { display: flex; flex-direction: column; gap: 12px; }
|
||||||
|
.list-item { background: #fcfdfe; padding: 12px 15px; border-radius: 8px; border: 1px solid #ececec; }
|
||||||
.list-item.error-item { background: #fff5f5; border-color: #ffcccc; }
|
.list-item.error-item { background: #fff5f5; border-color: #ffcccc; }
|
||||||
.list-item.warning-item { background: #fffcf0; border-color: #ffeaa7; }
|
.list-item.warning-item { background: #fffcf0; border-color: #ffeaa7; }
|
||||||
|
|
||||||
.item-header {
|
.item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; flex-wrap: wrap; gap: 5px; }
|
||||||
display: flex;
|
.description { margin: 0; color: #636e72; font-size: 0.9rem; line-height: 1.5; }
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
margin: 0;
|
|
||||||
color: #636e72;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description.highlight { color: #d35400; font-weight: 500; }
|
.description.highlight { color: #d35400; font-weight: 500; }
|
||||||
.description.raw-message {
|
.description.raw-message { margin-top: 5px; font-size: 0.85rem; color: #7f8c8d; font-family: Consolas, monospace; background: #f0f3f4; padding: 5px 8px; border-radius: 4px; word-break: break-all; }
|
||||||
margin-top: 5px;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
color: #7f8c8d;
|
|
||||||
font-family: Consolas, Monaco, 'Courier New', monospace;
|
|
||||||
background: #f0f3f4;
|
|
||||||
padding: 5px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 状态文本与徽章 */
|
|
||||||
.status-text { font-weight: 600; font-size: 0.9rem; }
|
.status-text { font-weight: 600; font-size: 0.9rem; }
|
||||||
.text-green { color: #27ae60; }
|
.text-green { color: #27ae60; }
|
||||||
.text-red { color: #c0392b; }
|
.text-red { color: #c0392b; }
|
||||||
|
|
||||||
.badge {
|
.badge { font-size: 0.75rem; padding: 3px 10px; border-radius: 12px; color: white; font-weight: 600; letter-spacing: 0.5px; }
|
||||||
font-size: 0.75rem;
|
|
||||||
padding: 3px 10px;
|
|
||||||
border-radius: 12px;
|
|
||||||
color: white;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
.badge-green { background-color: #2ed573; }
|
.badge-green { background-color: #2ed573; }
|
||||||
.badge-red { background-color: #ff4757; }
|
.badge-red { background-color: #ff4757; }
|
||||||
.badge-blue { background-color: #3742fa; }
|
.badge-blue { background-color: #3742fa; }
|
||||||
.badge-gray { background-color: #95a5a6; }
|
.badge-gray { background-color: #95a5a6; }
|
||||||
|
.code-tag { background: #ff4757; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; }
|
||||||
|
|
||||||
.code-tag {
|
.good-news { color: #27ae60; font-weight: 600; background: #eafaf1; padding: 15px; border-radius: 8px; border: 1px solid #d4efdf; text-align: center; }
|
||||||
background: #ff4757; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; font-weight: bold;
|
.tip { margin-top: 15px; font-size: 0.85rem; color: #d35400; background: #fff3e0; padding: 12px; border-radius: 6px; border: 1px solid #ffe0b2; }
|
||||||
}
|
|
||||||
|
|
||||||
.good-news {
|
|
||||||
color: #27ae60; font-weight: 600; background: #eafaf1; padding: 15px; border-radius: 8px; border: 1px solid #d4efdf; text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tip {
|
|
||||||
margin-top: 15px; font-size: 0.85rem; color: #d35400; background: #fff3e0; padding: 12px; border-radius: 6px; border: 1px solid #ffe0b2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 电池进度条 */
|
|
||||||
.progress-wrapper { margin-bottom: 15px; }
|
.progress-wrapper { margin-bottom: 15px; }
|
||||||
.progress-bar {
|
.progress-bar { width: 100%; height: 10px; background: #e6e8ec; border-radius: 5px; overflow: hidden; }
|
||||||
width: 100%; height: 10px; background: #e6e8ec; border-radius: 5px; overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 日志元数据 */
|
.event-id, .event-source, .event-time { font-size: 0.75rem; color: #7f8c8d; }
|
||||||
.event-id, .event-source, .event-time {
|
.event-id { font-weight: bold; color: #2c3e50; background: #dfe6e9; padding: 1px 5px; border-radius: 4px; margin-right: 8px; }
|
||||||
font-size: 0.75rem; color: #7f8c8d;
|
|
||||||
}
|
|
||||||
.event-id {
|
|
||||||
font-weight: bold; color: #2c3e50; background: #dfe6e9; padding: 1px 5px; border-radius: 4px; margin-right: 8px;
|
|
||||||
}
|
|
||||||
.event-time { margin-left: auto; }
|
.event-time { margin-left: auto; }
|
||||||
|
|
||||||
/* 内容盒模型 */
|
|
||||||
.content-box { padding: 5px 0; }
|
.content-box { padding: 5px 0; }
|
||||||
.main-text { font-weight: 500; color: #2c3e50; margin-bottom: 10px;}
|
.main-text { font-weight: 500; color: #2c3e50; margin-bottom: 10px; }
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user