diff --git a/Cargo.lock b/Cargo.lock index 86e1da8..afbab0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1047,7 +1047,7 @@ checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" [[package]] name = "squid-cli" -version = "0.1.7" +version = "0.1.10" dependencies = [ "anyhow", "chrono", @@ -1066,7 +1066,7 @@ dependencies = [ [[package]] name = "squid-core" -version = "0.1.7" +version = "0.1.10" dependencies = [ "anyhow", "chrono", @@ -1085,7 +1085,7 @@ dependencies = [ [[package]] name = "squid-engine" -version = "0.1.7" +version = "0.1.10" dependencies = [ "anyhow", "chrono", @@ -1105,7 +1105,7 @@ dependencies = [ [[package]] name = "squid-platform" -version = "0.1.7" +version = "0.1.10" dependencies = [ "dirs", "libc", @@ -1123,7 +1123,7 @@ dependencies = [ [[package]] name = "squid-rules" -version = "0.1.7" +version = "0.1.10" dependencies = [ "globset", "serde", @@ -1135,7 +1135,7 @@ dependencies = [ [[package]] name = "squid-stats" -version = "0.1.7" +version = "0.1.10" dependencies = [ "chrono", "libc", @@ -1148,7 +1148,7 @@ dependencies = [ [[package]] name = "squid-tui" -version = "0.1.7" +version = "0.1.10" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index b84dbd5..a7bd2a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*"] exclude = ["src-tauri"] [workspace.package] -version = "0.1.9" +version = "0.1.10" edition = "2021" rust-version = "1.80" license = "GPL-3.0-only" diff --git a/crates/squid-core/src/model.rs b/crates/squid-core/src/model.rs index 189ff6a..722e6a6 100644 --- a/crates/squid-core/src/model.rs +++ b/crates/squid-core/src/model.rs @@ -19,10 +19,11 @@ pub enum Category { Trash, LanguagePacks, Leftovers, + UpdateInstallers, } impl Category { - pub const ALL: [Category; 9] = [ + pub const ALL: [Category; 10] = [ Category::SystemJunk, Category::AppCaches, Category::BrowserCaches, @@ -32,6 +33,7 @@ impl Category { Category::Trash, Category::LanguagePacks, Category::Leftovers, + Category::UpdateInstallers, ]; pub fn id(self) -> &'static str { @@ -45,6 +47,7 @@ impl Category { Category::Trash => "trash", Category::LanguagePacks => "languages", Category::Leftovers => "leftovers", + Category::UpdateInstallers => "update-installers", } } @@ -59,6 +62,7 @@ impl Category { Category::Trash => "Trash", Category::LanguagePacks => "Unneeded Languages", Category::Leftovers => "Uninstaller Leftovers", + Category::UpdateInstallers => "Update Installers", } } @@ -76,6 +80,7 @@ impl Category { Category::Trash => "Files waiting in the Trash", Category::LanguagePacks => "Speech and localization data for languages you do not use", Category::Leftovers => "Data belonging to apps that are no longer installed", + Category::UpdateInstallers => "Installer packages apps keep after a successful update", } } @@ -101,6 +106,9 @@ impl Category { "trash" => Category::Trash, "language" | "languages" | "language-packs" | "localization" => Category::LanguagePacks, "leftover" | "leftovers" | "uninstall-leftovers" => Category::Leftovers, + "update-installer" | "update-installers" | "upgrades" | "upgrade-packages" => { + Category::UpdateInstallers + } _ => return None, }; Some(alias) diff --git a/crates/squid-engine/src/clean.rs b/crates/squid-engine/src/clean.rs index 41c44b2..caba765 100644 --- a/crates/squid-engine/src/clean.rs +++ b/crates/squid-engine/src/clean.rs @@ -48,7 +48,9 @@ pub fn scan( cancel: &CancelToken, ) -> squid_core::Result { let prepared = prepared_rules(engine, options); - if prepared.is_empty() { + let updates_wanted = + options.categories.is_empty() || options.categories.contains(&Category::UpdateInstallers); + if prepared.is_empty() && !updates_wanted { return Err(SquidError::NothingToDo); } progress.phase("match", "locating cleanup candidates"); @@ -148,6 +150,28 @@ pub fn scan( } } + // Update installers (升级安装包): rule-driven known apps + heuristic + // sweep of AppData staging folders. The walk is bounded, so it is always + // on unless the caller filtered categories down to something else. + let updates_wanted = + options.categories.is_empty() || options.categories.contains(&Category::UpdateInstallers); + if updates_wanted { + progress.phase("update-installers", "collecting stale update packages"); + for item in crate::updates::collect(engine, cancel) { + if seen.contains_key(&item.path) { + continue; + } + let mut item = item; + if engine.is_whitelisted(&item.path) { + item = item.locked(LockReason::Whitelisted); + } else if let Some(reason) = engine.block_reason(&item) { + item = item.locked(LockReason::Protected).with_note(reason); + } + seen.insert(item.path.clone(), report.items.len()); + report.items.push(item); + } + } + if !options.fast { measure(engine, &mut report, progress, cancel)?; } diff --git a/crates/squid-engine/src/lib.rs b/crates/squid-engine/src/lib.rs index 7d08d95..63a24a8 100644 --- a/crates/squid-engine/src/lib.rs +++ b/crates/squid-engine/src/lib.rs @@ -16,6 +16,7 @@ pub mod clean; pub mod delete; pub mod purge; pub mod uninstall; +pub mod updates; use globset::GlobMatcher; use squid_core::settings::Settings; diff --git a/crates/squid-engine/src/updates.rs b/crates/squid-engine/src/updates.rs new file mode 100644 index 0000000..9cb97ec --- /dev/null +++ b/crates/squid-engine/src/updates.rs @@ -0,0 +1,324 @@ +//! Update-installers collector (升级安装包): A+B combined. +//! +//! Layer A is a table of known apps whose update drop folders never +//! self-clean (WeChat, WXWork, WPS, …) — precise paths plus the process +//! that must not be running while we sweep. Layer B is a heuristic sweep +//! of one level under each AppData root, descending into directories +//! *named* like update staging areas (update/upgrade/setup/patch/…) so +//! unknown apps are still caught. Layer A results are also fed back into +//! B's seen-set, so one folder is never offered twice. +//! +//! Both layers only ever propose individual **installer-shaped files** +//! (`.exe .msi .msp .zip .7z .rar .cab .crx .nupkg .appx .patch`, ≥ 1 MiB, +//! untouched for ≥ 7 days). Runtime components that apps keep next to +//! those packages (`.bin`, `.dll`, version folders) are deliberately never +//! matched: WeChat's `update\RadiumWMPF.bin` is the *current* version, not +//! junk. Per-file items reuse the plain File deletion + undo path. + +use squid_core::{Category, CleanupItem, ItemKind, LockReason}; +use std::collections::HashSet; +use std::path::{Path, PathBuf}; + +/// 7 天:用户确认的阈值。升级后一周内没人再碰的包,应用自己也不会再用了。 +pub const MIN_AGE_DAYS: u64 = 7; +/// 1 MiB:小碎片不值得列出来。 +pub const MIN_SIZE_BYTES: u64 = 1024 * 1024; + +const INSTALLER_EXTENSIONS: [&str; 11] = [ + "exe", "msi", "msp", "zip", "7z", "rar", "cab", "crx", "nupkg", "appx", "patch", +]; + +/// Directory names that mark an update staging area (layer B). +const UPDATE_DIR_NAMES: [&str; 9] = [ + "update", + "updates", + "upgrade", + "upgrades", + "setup", + "installer", + "installers", + "patch", + "patches", +]; + +/// Vendor folders layer B must not sweep. WinGet's package cache belongs to +/// the developer category; Tencent/kingsoft/Netease are covered precisely by +/// layer A (the heuristic would only double-report the same bytes). +const SKIP_VENDORS: [&str; 4] = ["Microsoft", "winget", "Tencent", "kingsoft"]; + +/// Layer A: known apps → (directory relative to the AppData roots, display +/// label, process that locks the group while running). +struct KnownApp { + dir: &'static str, + label: &'static str, + process: &'static str, +} + +#[cfg(windows)] +const KNOWN_APPS: &[KnownApp] = &[ + KnownApp { + dir: r"Tencent\xwechat\update", + label: "微信", + process: "weixin.exe", + }, + KnownApp { + dir: r"Tencent\WXWork\patch", + label: "企业微信", + process: "wxwork.exe", + }, + KnownApp { + dir: r"kingsoft\office6\update", + label: "WPS Office", + process: "wps.exe", + }, + KnownApp { + dir: r"kingsoft\WPS Cloud Files\update", + label: "WPS 云文档", + process: "wpscloudsvr.exe", + }, + KnownApp { + dir: r"Netease\MailMaster\Update", + label: "网易邮箱大师", + process: "mailmaster.exe", + }, +]; + +/// macOS layer A: Squirrel's update payload folders (`*.nupkg`, full +/// machines) under AppData-style roots. +#[cfg(not(windows))] +const KNOWN_APPS: &[KnownApp] = &[KnownApp { + dir: "SquirrelTemp", + label: "Squirrel 更新包", + process: "", +}]; + +#[cfg(windows)] +fn appdata_roots() -> Vec { + let mut roots = Vec::new(); + if let Some(local) = std::env::var_os("LOCALAPPDATA") { + roots.push(PathBuf::from(local)); + } + if let Some(roaming) = std::env::var_os("APPDATA") { + roots.push(PathBuf::from(roaming)); + } + roots +} + +#[cfg(not(windows))] +fn appdata_roots() -> Vec { + let home = squid_core::paths::home_dir(); + vec![ + home.join("Library/Caches"), + home.join("Library/Application Support"), + ] +} + +pub fn is_installer(file: &Path) -> bool { + let Some(ext) = file.extension().and_then(|ext| ext.to_str()) else { + return false; + }; + INSTALLER_EXTENSIONS + .iter() + .any(|wanted| ext.eq_ignore_ascii_case(wanted)) +} + +fn stale_enough(meta: &std::fs::Metadata) -> bool { + if meta.len() < MIN_SIZE_BYTES { + return false; + } + let modified = meta + .modified() + .or_else(|_| meta.created()) + .unwrap_or(std::time::SystemTime::UNIX_EPOCH); + modified + .elapsed() + .map(|age| age.as_secs() >= MIN_AGE_DAYS * 86_400) + .unwrap_or(true) +} + +/// Depth-capped sweep of one staging directory: every stale installer file +/// becomes its own item (File kind → plain delete + undo path). +fn sweep( + dir: &Path, + label: &str, + rule: &str, + blocked: bool, + out: &mut Vec, + seen: &mut HashSet, +) { + let walker = walkdir::WalkDir::new(dir) + .max_depth(3) + .follow_links(false) + .into_iter() + .filter_entry(|entry| !entry.file_type().is_symlink()); + for entry in walker.flatten() { + if !entry.file_type().is_file() { + continue; + } + let path = entry.path(); + let Ok(meta) = entry.metadata() else { continue }; + if !is_installer(path) || !stale_enough(&meta) { + continue; + } + if !seen.insert(path.to_path_buf()) { + continue; + } + let item = CleanupItem::new( + path.to_path_buf(), + ItemKind::File, + Category::UpdateInstallers, + format!("{label} · {}", squash_name(path)), + ) + .with_rule(rule) + .with_anchors(std::iter::once(dir.to_path_buf())) + .with_note("升级完成后不再需要;需要时应用会自动重新下载"); + let item = if blocked { + item.locked(LockReason::AppRunning) + } else { + item + }; + out.push(item); + } +} + +/// Long hashed package names read badly in a list; keep a head+tail hint. +fn squash_name(path: &Path) -> String { + let name = path + .file_name() + .map_or_else(String::new, |n| n.to_string_lossy().into_owned()); + let chars: Vec = name.chars().collect(); + if chars.len() <= 42 { + return name; + } + let head: String = chars[..24].iter().collect(); + let tail: String = chars[chars.len() - 16..].iter().collect(); + format!("{head}…{tail}") +} + +/// One entry point. The caller dedups against rule-matched items and the +/// safety layer (whitelist / protected) is applied like for any other item. +pub fn collect(engine: &crate::Engine, cancel: &squid_core::CancelToken) -> Vec { + let mut out = Vec::new(); + let mut seen: HashSet = HashSet::new(); + if cancel.is_cancelled() { + return out; + } + let running: Vec = engine + .platform() + .running_executables() + .into_iter() + .map(|proc| { + proc.rsplit(['/', '\\']) + .next() + .unwrap_or_default() + .to_lowercase() + }) + .collect(); + let roots = appdata_roots(); + + // Layer A: precise known-app staging folders. + for app in KNOWN_APPS { + let blocked = !app.process.is_empty() && running.iter().any(|name| name == app.process); + for root in &roots { + let dir = root.join(app.dir); + if dir.is_dir() { + sweep( + &dir, + app.label, + "update-installers-known", + blocked, + &mut out, + &mut seen, + ); + } + } + } + + // Layer B: heuristic sweep of //. + for root in &roots { + let Ok(vendors) = std::fs::read_dir(root) else { + continue; + }; + for vendor in vendors.flatten() { + if cancel.is_cancelled() { + return out; + } + if !vendor.file_type().map(|t| t.is_dir()).unwrap_or(false) { + continue; + } + let vendor_name = vendor.file_name().to_string_lossy().into_owned(); + if SKIP_VENDORS + .iter() + .any(|skip| vendor_name.eq_ignore_ascii_case(skip)) + { + continue; + } + let Ok(subs) = std::fs::read_dir(vendor.path()) else { + continue; + }; + for sub in subs.flatten() { + let name = sub.file_name().to_string_lossy().into_owned(); + if !UPDATE_DIR_NAMES.contains(&name.to_lowercase().as_str()) || !sub.path().is_dir() + { + continue; + } + sweep( + &sub.path(), + &vendor_name, + "update-installers-scan", + false, + &mut out, + &mut seen, + ); + } + } + } + out +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn installer_shapes_are_matched_and_runtime_is_not() { + assert!(is_installer(Path::new("a/patch.zip"))); + assert!(is_installer(Path::new("a/Weixin.EXE"))); + assert!(is_installer(Path::new("a/update.bin.patch"))); + // Runtime components must never match — this is the WeChat rule. + assert!(!is_installer(Path::new("a/RadiumWMPF.bin"))); + assert!(!is_installer(Path::new("a/Weixin.dll"))); + assert!(!is_installer(Path::new("a/manifest.dat"))); + assert!(!is_installer(Path::new("a/noext"))); + } + + #[test] + fn tiny_files_are_not_offered() { + let temp = std::env::temp_dir().join(format!("squid-updates-size-{}", std::process::id())); + let Ok(()) = std::fs::create_dir_all(&temp) else { + eprintln!("skipping: scratch dir failed"); + return; + }; + let file = temp.join("small.exe"); + if let Err(error) = std::fs::write(&file, vec![0u8; 1024]) { + eprintln!("skipping: scratch write denied ({error})"); + return; + } + let meta = std::fs::metadata(&file).expect("meta"); + assert!(!stale_enough(&meta)); + let big = temp.join("big.exe"); + if std::fs::write(&big, vec![0u8; 2 * 1024 * 1024]).is_ok() { + let meta = std::fs::metadata(&big).expect("big meta"); + // fresh: size passes but the 7-day gate holds it back + assert!(!stale_enough(&meta)); + } + let _ = std::fs::remove_dir_all(&temp); + } + + #[test] + fn long_package_names_get_squashed() { + let name = squash_name(Path::new(&format!("C:/x/{}-x64_zh-CN.msi", "a".repeat(60)))); + assert!(name.chars().count() <= 42, "{name}"); + assert!(name.ends_with("-x64_zh-CN.msi")); + } +} diff --git a/crates/squid-stats/src/lib.rs b/crates/squid-stats/src/lib.rs index 80bca7d..467a8ce 100644 --- a/crates/squid-stats/src/lib.rs +++ b/crates/squid-stats/src/lib.rs @@ -251,6 +251,15 @@ impl Sampler { } pub fn refresh(&mut self) -> SystemSnapshot { + self.refresh_with(true) + } + + /// `want_processes=false` is the widget-grade light refresh: it skips the + /// per-pid CPU/memory walk (hundreds of Get-ProcessTimes calls on + /// Windows) and the top-process sort, keeping only a cheap pid sweep for + /// the process count. The always-on desktop widget pays this on every + /// beat; only 实时监控 asks for the full table. + pub fn refresh_with(&mut self, want_processes: bool) -> SystemSnapshot { let elapsed = self.last.elapsed().max(Duration::from_millis(80)); self.last = Instant::now(); @@ -258,11 +267,19 @@ impl Sampler { .refresh_cpu_specifics(sysinfo::CpuRefreshKind::nothing().with_cpu_usage()); self.system .refresh_memory_specifics(sysinfo::MemoryRefreshKind::nothing().with_ram().with_swap()); - self.system.refresh_processes_specifics( - ProcessesToUpdate::All, - true, - ProcessRefreshKind::nothing().with_cpu().with_memory(), - ); + if want_processes { + self.system.refresh_processes_specifics( + ProcessesToUpdate::All, + true, + ProcessRefreshKind::nothing().with_cpu().with_memory(), + ); + } else { + self.system.refresh_processes_specifics( + ProcessesToUpdate::All, + true, + ProcessRefreshKind::nothing(), + ); + } self.networks.refresh(true); self.disks .refresh_specifics(true, DiskRefreshKind::nothing().with_io_usage()); @@ -272,7 +289,11 @@ impl Sampler { let memory = memory_stats(&self.system); let network = net_rates(&self.networks, seconds); let disk = disk_rates(&self.disks, seconds); - let top_processes = top_processes(&self.system, 12); + let top_processes = if want_processes { + top_processes(&self.system, 12) + } else { + Vec::new() + }; let mut snapshot = SystemSnapshot { taken_at_ms: now_ms(), @@ -917,6 +938,24 @@ mod tests { assert!(!apps.is_empty()); } + /// The widget-grade light refresh: every meter the desktop panel draws + /// still moves, but the per-process table stays empty (that walk is the + /// expensive part of a refresh on Windows). + #[test] + fn the_light_refresh_keeps_the_meters_and_drops_the_table() { + let mut sampler = Sampler::new(); + std::thread::sleep(Duration::from_millis(220)); + let snapshot = sampler.refresh_with(false); + assert_eq!(snapshot.cpu.per_core.len(), snapshot.cpu.logical_cores); + assert!(snapshot.memory.total.as_u64() > 0); + assert!(snapshot.processes > 0); + assert!(snapshot.top_processes.is_empty()); + // A light beat must not poison the full one: the next full refresh + // still walks processes and produces a ranking. + let full = sampler.refresh_with(true); + assert!(!full.top_processes.is_empty() || full.processes == 0); + } + #[test] fn percentages_never_exceed_one_hundred() { let stats = MemoryStats { diff --git a/crates/squid-tui/src/theme.rs b/crates/squid-tui/src/theme.rs index 0d84f55..cceeedc 100644 --- a/crates/squid-tui/src/theme.rs +++ b/crates/squid-tui/src/theme.rs @@ -134,6 +134,7 @@ impl Strings { C::ProjectArtifacts => "构建产物", C::LanguagePacks => "多余语言包", C::Leftovers => "卸载残留", + C::UpdateInstallers => "升级安装包", C::Trash => self.bin(), }, }) diff --git a/package.json b/package.json index 4e0e51e..7c32101 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "squid-desktop", "private": true, - "version": "0.1.9", + "version": "0.1.10", "type": "module", "scripts": { "dev": "vite --port 1420 --strictPort", diff --git a/release/0.1.10/README-Windows-x64.txt b/release/0.1.10/README-Windows-x64.txt new file mode 100644 index 0000000..74cdc5d --- /dev/null +++ b/release/0.1.10/README-Windows-x64.txt @@ -0,0 +1,47 @@ +Squid 0.1.10 - Windows x64 + +系统要求 +-------- +- Windows 10 或 Windows 11(x64;ARM64 设备通过系统兼容层运行)。 +- Microsoft Edge WebView2 Runtime。Windows 10/11 通常已内置;如果 Squid + 启动后窗口空白,请从微软官方页面安装 WebView2 Evergreen Runtime: + https://developer.microsoft.com/microsoft-edge/webview2/ +- 安装与运行都不需要管理员权限。安装位置为 + %LOCALAPPDATA%\Programs\Squid。 +- 权限管理页中,机单(HKLM)范围的启动项开关与系统服务需要以管理员身份 + 运行 Squid 才能修改,界面会给出明确提示。 + +安装 +---- +1. 运行 Squid-Setup-0.1.10-win-x64.exe。 +2. 这是未签名构建。若 SmartScreen 显示警告,请选择“更多信息” > “仍要运行”。 +3. 升级直接覆盖安装,不再询问是否先卸载旧版本;用户配置自动继承。 +4. 卸载请在 Windows“设置 > 应用”中移除 Squid。 + +更新 +---- +Squid 使用与 nex_shift 一致的 releases 分支更新通道。更新包会先校验 +文件大小与 SHA256,再在退出后运行同一个安装程序。若构建时写入发布公钥, +还会验证清单的 Ed25519 签名。 + +校验 +---- +PowerShell: + Get-FileHash .\Squid-Setup-0.1.10-win-x64.exe -Algorithm SHA256 + +提示 +---- +- 覆盖升级前请先完全退出 Squid(关闭窗口只会进入托盘,请在托盘图标 + 上右键退出),否则安装程序无法替换正在运行的程序文件。 +- 本机若装有腾讯电脑管家,其"程序保护"可能拦截未签名安装程序写入 + 临时目录,报"NSIS Error - Error writing temporary file"。三种绕法, + 按方便程度排序: + 1) 双击本目录的「一键安装.bat」——它会把安装包复制到 C 盘临时目录 + 再启动(管家只拦从非系统盘启动的安装程序,此法本机验证有效); + 2) 管家弹窗出现时选"允许",或将安装文件加入信任区后重试; + 3) 使用便携包 Squid-0.1.10-portable-win-x64.zip,解压后把 Squid 目录 + 内的文件覆盖到安装目录(先退出托盘中的 Squid),效果相同。 +- 桌面小工具在安装后默认开启,会出现在屏幕右上角;新版新增 CPU 面板 + (总占用曲线 + 每核渐变占用柱),可在主程序「桌面小工具」页开关各面板。 +- 清理新增「升级安装包」分类:应用升级后留在 AppData 的安装包(微信、 + 企业微信、WPS 等),放置超过 7 天才会被找出;删除确认时可一键跳过。 diff --git a/release/0.1.10/RELEASE_NOTES.md b/release/0.1.10/RELEASE_NOTES.md new file mode 100644 index 0000000..c932e22 --- /dev/null +++ b/release/0.1.10/RELEASE_NOTES.md @@ -0,0 +1,25 @@ +Squid 0.1.10 更新说明 + +新增 +- 清理新增「升级安装包」分类:找出应用升级完成后留在 AppData 里的安装包 + (微信、企业微信、WPS、网易邮箱等已知应用精确规则 + AppData 启发式扫描)。 + 只匹配安装包形态(exe/msi/zip/7z 等)且放置超过 7 天的文件,微信运行库组件 + 不会被误删;应用正在运行时相关安装包自动锁定。删除确认时会提示升级包数量 + 与大小,可一键「跳过升级包,只删其余」。 +- 桌面小工具新增「CPU」面板:总体占用率历史曲线 + 整行渐变占用柱,一根柱对应 + 一个逻辑核心;柱色随占用率在绿→黄→橙→红之间连续渐变(含柱内纵向微渐变), + 悬停显示「核心 N: xx%」(编号与任务管理器一致从 0 开始);核心较多时柱宽自动 + 收窄。管理页与桌面设置弹层可独立开关该面板。 + +优化 +- 桌面常驻 CPU 占用大幅下降(实测本机构从约 8.5% 全机总占用降至 0.2%): + 小工具改用轻量采样(跳过全机逐进程枚举,那是旧版每秒最贵的一步)、两个 + 窗口共享同一次采样、小工具折叠或主窗口收进托盘后完全停止采样。实时监控 + 页打开时才有完整进程表,功能不受影响。 +- 修复小工具窗口自身的自适应尺寸回环(尺寸→重锚定→再触发自适应无限循环), + 该回环会让主进程与小工具渲染进程空转互叫并频繁写配置文件;修复后小工具 + 开着时 Squid 全家 CPU 占用接近 0%。 + +调整 +- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统 + 名称联动);macOS 仍为「废纸篓」。 diff --git a/release/0.1.10/SHA256SUMS.txt b/release/0.1.10/SHA256SUMS.txt new file mode 100644 index 0000000..ac2aaaa --- /dev/null +++ b/release/0.1.10/SHA256SUMS.txt @@ -0,0 +1,2 @@ +5e46b4aa28ef410a32cb609c937055cff611627d99384f78ada5cea7ff2991ba *Squid-Setup-0.1.10-win-x64.exe +aa11e2293b521e16bb1d6bdde25a8cd12d2021308dddba6c8936fee0ac363cf0 *Squid-0.1.10-portable-win-x64.zip diff --git a/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe b/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe new file mode 100644 index 0000000..e0b6519 Binary files /dev/null and b/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe differ diff --git a/release/0.1.10/squid-update.json b/release/0.1.10/squid-update.json new file mode 100644 index 0000000..03789f0 --- /dev/null +++ b/release/0.1.10/squid-update.json @@ -0,0 +1,13 @@ +{ + "schema": 1, + "version": "0.1.10", + "date": "2026-11-18", + "notes": "Squid 0.1.10\n\n新增\n- 清理新增「升级安装包」分类:找出应用升级完成后留在 AppData 里的安装包\n (微信、企业微信、WPS、网易邮箱等已知应用精确规则 + AppData 启发式扫描)。\n 只匹配安装包形态(exe/msi/zip/7z 等)且放置超过 7 天的文件,微信运行库组件\n 不会被误删;应用正在运行时相关安装包自动锁定。删除确认时会提示升级包数量\n 与大小,可一键「跳过升级包,只删其余」。\n- 桌面小工具新增「CPU」面板:总体占用率历史曲线 + 整行渐变占用柱,一根柱对应\n 一个逻辑核心;柱色随占用率在绿→黄→橙→红之间连续渐变(含柱内纵向微渐变),\n 悬停显示「核心 N: xx%」(编号与任务管理器一致从 0 开始);核心较多时柱宽自动\n 收窄。管理页与桌面设置弹层可独立开关该面板。\n\n优化\n- 桌面常驻 CPU 占用大幅下降(实测本机构从约 8.5% 全机总占用降至 0.2%):\n 小工具改用轻量采样(跳过全机逐进程枚举,那是旧版每秒最贵的一步)、两个\n 窗口共享同一次采样、小工具折叠或主窗口收进托盘后完全停止采样。实时监控\n 页打开时才有完整进程表,功能不受影响。\n- 修复小工具窗口自身的自适应尺寸回环(尺寸→重锚定→再触发自适应无限循环),\n 该回环会让主进程与小工具渲染进程空转互叫并频繁写配置文件;修复后小工具\n 开着时 Squid 全家 CPU 占用接近 0%。\n\n调整\n- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统\n 名称联动);macOS 仍为「废纸篓」。", + "artifacts": { + "windows": { + "file": "Squid-Setup-0.1.10-win-x64.exe", + "sha256": "5e46b4aa28ef410a32cb609c937055cff611627d99384f78ada5cea7ff2991ba", + "size": 3566497 + } + } +} \ No newline at end of file diff --git a/release/0.1.10/一键安装.bat b/release/0.1.10/一键安装.bat new file mode 100644 index 0000000..4a8d881 --- /dev/null +++ b/release/0.1.10/一键安装.bat @@ -0,0 +1,5 @@ +@echo off +rem 360/QQPC Manager blocks unsigned installers started from non-system +rem drives when they unpack into TEMP. Copy the setup to %TEMP% on C: first. +copy /Y "%~dp0Squid-Setup-0.1.10-win-x64.exe" "%TEMP%\" >nul +start "" "%TEMP%\Squid-Setup-0.1.10-win-x64.exe" diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index d56bb7c..f21054a 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3502,7 +3502,7 @@ dependencies = [ [[package]] name = "squid-core" -version = "0.1.9" +version = "0.1.10" dependencies = [ "anyhow", "chrono", @@ -3521,7 +3521,7 @@ dependencies = [ [[package]] name = "squid-desktop" -version = "0.1.9" +version = "0.1.10" dependencies = [ "base64 0.22.1", "chrono", @@ -3545,7 +3545,7 @@ dependencies = [ [[package]] name = "squid-engine" -version = "0.1.9" +version = "0.1.10" dependencies = [ "anyhow", "chrono", @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "squid-platform" -version = "0.1.9" +version = "0.1.10" dependencies = [ "dirs 6.0.0", "libc", @@ -3583,7 +3583,7 @@ dependencies = [ [[package]] name = "squid-rules" -version = "0.1.9" +version = "0.1.10" dependencies = [ "globset", "serde", @@ -3595,7 +3595,7 @@ dependencies = [ [[package]] name = "squid-stats" -version = "0.1.9" +version = "0.1.10" dependencies = [ "chrono", "libc", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index cdc735d..6387b50 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squid-desktop" -version = "0.1.9" +version = "0.1.10" description = "Squid — a CleanMyMac-inspired cleaner, uninstaller and system monitor." authors = ["squid contributors"] edition = "2021" diff --git a/src-tauri/src/app.rs b/src-tauri/src/app.rs index d7b1a50..3fc0456 100644 --- a/src-tauri/src/app.rs +++ b/src-tauri/src/app.rs @@ -32,6 +32,9 @@ pub struct AppState { plans: Mutex>, apps: Mutex>, sampler: Mutex, + /// Last light snapshot, so the widget window and the main window polling + /// a beat apart share one refresh instead of paying for two. + snapshot_cache: Mutex>, } impl AppState { @@ -824,10 +827,34 @@ pub async fn storage_largest_files( } #[tauri::command] -pub fn system_snapshot(app: AppHandle) -> Result { +pub fn system_snapshot(app: AppHandle, full: Option) -> Result { + // `full` costs a per-pid CPU/memory walk of every process on the machine + // (hundreds of syscalls) plus the top-12 sort — the 实时监控 page needs + // it; the desktop widget, overview tiles and every background poll pass + // false and ride the light refresh. Light answers are cached for two + // seconds so windows polling in step pay for one refresh, not several. let state = app.state::(); + if full.unwrap_or(false) { + let mut sampler = AppState::lock(&state.sampler)?; + let snapshot = sampler.refresh(); + if let Ok(mut cache) = AppState::lock(&state.snapshot_cache) { + *cache = Some((Instant::now(), snapshot.clone())); + } + return Ok(snapshot); + } + if let Ok(cache) = AppState::lock(&state.snapshot_cache) { + if let Some((at, snapshot)) = cache.as_ref() { + if at.elapsed() < Duration::from_secs(2) { + return Ok(snapshot.clone()); + } + } + } let mut sampler = AppState::lock(&state.sampler)?; - Ok(sampler.refresh()) + let snapshot = sampler.refresh_with(false); + if let Ok(mut cache) = AppState::lock(&state.snapshot_cache) { + *cache = Some((Instant::now(), snapshot.clone())); + } + Ok(snapshot) } #[tauri::command] diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 648c043..793b160 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -19,6 +19,8 @@ fn show_main_window(app: &AppHandle) { let _ = window.show(); let _ = window.unminimize(); let _ = window.set_focus(); + // The page stops sampling while parked in the tray; wake it up. + let _ = app.emit("squid://visible", true); } } @@ -93,6 +95,9 @@ pub fn run() { if let WindowEvent::CloseRequested { api, .. } = event { api.prevent_close(); let _ = window.hide(); + // A hidden window must not keep sampling the whole machine; + // the page pauses its polling on this signal. + let _ = window.emit("squid://visible", false); } }) .manage(app::AppState::default()) diff --git a/src-tauri/src/widget.rs b/src-tauri/src/widget.rs index 9935c91..4c54cb7 100644 --- a/src-tauri/src/widget.rs +++ b/src-tauri/src/widget.rs @@ -87,6 +87,7 @@ pub struct WidgetPrefs { /// Master switch: hides the window entirely when off. pub enabled: bool, pub panel_run: bool, + pub panel_cpu: bool, pub panel_network: bool, pub panel_disk: bool, pub panel_storage: bool, @@ -109,6 +110,7 @@ impl Default for WidgetPrefs { Self { enabled: true, panel_run: true, + panel_cpu: true, panel_network: true, panel_disk: true, panel_storage: true, @@ -229,7 +231,11 @@ fn place_window(app: &AppHandle, prefs: &WidgetPrefs) { /// ordinary app window, so it can never cover the user's work. fn sync_window(app: &AppHandle, prefs: &WidgetPrefs) { if !prefs.enabled - || (!prefs.panel_run && !prefs.panel_network && !prefs.panel_disk && !prefs.panel_storage) + || !(prefs.panel_run + || prefs.panel_cpu + || prefs.panel_network + || prefs.panel_disk + || prefs.panel_storage) { if let Some(window) = app.get_webview_window(WIDGET_LABEL) { let _ = window.hide(); @@ -290,6 +296,7 @@ pub fn widget_get(app: AppHandle) -> WidgetView { pub struct WidgetPatch { pub enabled: Option, pub panel_run: Option, + pub panel_cpu: Option, pub panel_network: Option, pub panel_disk: Option, pub panel_storage: Option, @@ -319,6 +326,9 @@ pub fn widget_set(app: AppHandle, patch: WidgetPatch) -> Result(null); const [autoCheck, setAutoCheck] = useState(true); const [setupOpen, setSetupOpen] = useState(false); + // The 托盘驻留 case: a hidden main window must stop sampling the machine. + const [windowVisible, setWindowVisible] = useState(true); const cleanup = useScanWorkspace("cleanup"); const purge = useScanWorkspace("purge"); const apps = useAppsWorkspace(); const permissions = usePermissionsWorkspace(page === "permissions"); - const systemActive = page === "overview" || page === "system"; - const system = useSystemSnapshot(systemActive); + const systemActive = (page === "overview" || page === "system") && windowVisible; + // Only the 实时监控 top-process table needs the expensive per-pid walk; + // the overview tiles ride the light refresh. + const system = useSystemSnapshot(systemActive, 1800, page === "system"); const update = useUpdateFlow(bootstrap?.updateFeedUrl ?? "", autoCheck); useEffect(() => { @@ -231,6 +235,23 @@ export default function App() { }; }, []); + useEffect(() => { + let cancelled = false; + let unlisten: (() => void) | null = null; + void api + .onWindowVisible((next) => { + if (!cancelled) setWindowVisible(next); + }) + .then((stop) => { + if (cancelled) stop(); + else unlisten = stop; + }); + return () => { + cancelled = true; + unlisten?.(); + }; + }, []); + useEffect(() => { const order: PageId[] = [ "overview", @@ -303,7 +324,7 @@ export default function App() { : null; return ( - + void; }) { - const { lang, t } = useI18n(); + const { lang, t, bin } = useI18n(); const Icon = CATEGORY_META[item.category].icon; return (
{item.label} - {categoryLabel(item.category, lang)} + {categoryLabel(item.category, lang, bin)} {shortPath(item.displayPath, 90)} @@ -171,6 +172,21 @@ export function CleanupInventory({ }, [focus, result]); const removables = result?.items.filter((item) => !item.lock).length ?? 0; + // 升级安装包:selection may include stale update packages; the confirm + // dialog offers a one-click "delete everything else, keep these" escape. + const selectedUpdaters = useMemo(() => { + if (!result) return { indexes: [] as number[], total: 0 }; + let total = 0; + const indexes: number[] = []; + result.items.forEach((item, index) => { + if (item.category === "update-installers" && workspace.selected.has(index)) { + indexes.push(index); + total += item.onDisk; + } + }); + return { indexes, total }; + }, [result, workspace.selected]); + if (workspace.scanning) { return ( { - const summary = await workspace.clean(mode); + const confirm = async (indexes?: number[]) => { + const summary = await workspace.clean(mode, indexes); setConfirming(false); if (summary) { push( @@ -289,7 +305,7 @@ export function CleanupInventory({ {t("Permanent", "永久")}
+ {selectedUpdaters.indexes.length > 0 ? ( +
+ +
+ + {t( + `Includes ${formatCount(selectedUpdaters.indexes.length)} update installers (${formatBytes(selectedUpdaters.total)})`, + `其中包含 ${formatCount(selectedUpdaters.indexes.length)} 个升级安装包(${formatBytes(selectedUpdaters.total)})`, + )} + + + {t( + "Apps re-download them when needed. Delete them too?", + "应用需要时会自动重新下载。要一并清理吗?", + )} + +
+ +
+ ) : null} ); diff --git a/src/components/WidgetPanels.tsx b/src/components/WidgetPanels.tsx index bd5c76a..1558020 100644 --- a/src/components/WidgetPanels.tsx +++ b/src/components/WidgetPanels.tsx @@ -50,6 +50,7 @@ export interface MetricHistory { netDown: number[]; diskRead: number[]; diskWrite: number[]; + cpu: number[]; } /** Append-only ring buffers over the snapshot stream (sparkline source). */ @@ -59,6 +60,7 @@ export function useHistory(): [MetricHistory, (snapshot: SystemSnapshot) => void netDown: [], diskRead: [], diskWrite: [], + cpu: [], }); const bump = useMemo( () => (snapshot: SystemSnapshot) => { @@ -70,18 +72,27 @@ export function useHistory(): [MetricHistory, (snapshot: SystemSnapshot) => void push(ref.current.netDown, snapshot.network.rx_per_sec); push(ref.current.diskRead, snapshot.disk.read_per_sec); push(ref.current.diskWrite, snapshot.disk.write_per_sec); + push(ref.current.cpu, snapshot.cpu.total); }, [], ); return [ref.current, bump]; } -function Spark({ values, color }: { values: number[]; color: string }) { +function Spark({ + values, + color, + max, +}: { + values: number[]; + color: string; + max?: number; +}) { // The history array is mutated in place between renders, so the polyline // must be rebuilt every render — a useMemo on identity would freeze the // first (empty) result forever. if (values.length < 2) return ; - const top = Math.max(...values, 1); + const top = max ?? Math.max(...values, 1); const width = 300; const step = width / (HISTORY - 1); const offset = HISTORY - values.length; @@ -109,6 +120,92 @@ export function uptimeFull(seconds: number, zh: boolean): string { : `${d}d ${h}h ${m}m ${s}s`; } +/* 逻辑核心占用柱状图:整行均分(核心多则柱变窄),柱色 = 占用率在 + * 绿→黄→橙→红 四个锚点之间连续插值,柱内再做纵向微渐变;悬停显示 + * 「核心 N: xx%」(编号与任务管理器一致从 0 开始)。 */ +const LOAD_STOPS: Array<[number, [number, number, number]]> = [ + [0, [46, 204, 113]], + [33, [247, 224, 120]], + [66, [245, 165, 76]], + [100, [233, 87, 63]], +]; + +function loadRgb(value: number): [number, number, number] { + const v = Math.max(0, Math.min(100, value)); + for (let i = 1; i < LOAD_STOPS.length; i += 1) { + const [at, rgb] = LOAD_STOPS[i]; + if (v <= at) { + const [prevAt, prevRgb] = LOAD_STOPS[i - 1]; + const t = (v - prevAt) / (at - prevAt); + return rgb.map((channel, k) => + Math.round(prevRgb[k] + (channel - prevRgb[k]) * t), + ) as [number, number, number]; + } + } + return LOAD_STOPS[LOAD_STOPS.length - 1][1]; +} + +function loadColor(value: number): string { + return `rgb(${loadRgb(value).join(",")})`; +} + +function barFill(value: number): string { + const base = loadRgb(value); + const deep = base.map((channel) => Math.round(channel * 0.62)); + const gloss = base.map((channel) => Math.round(channel + (255 - channel) * 0.35)); + const css = (rgb: number[]) => `rgb(${rgb.join(",")})`; + return `linear-gradient(180deg, ${css(gloss)} 0%, ${css(base)} 45%, ${css(deep)} 100%)`; +} + +function CpuPanel({ + total, + cores, + history, + zh, +}: { + total: number; + cores: number[]; + history: MetricHistory; + zh: boolean; +}) { + return ( +
+
+

CPU

+
+ + {Math.round(total)}% + +
+
+ + {cores.length > 0 ? ( + <> +
+ {cores.map((value, index) => ( + + + + ))} +
+
+ {zh ? `逻辑核心 ×${cores.length}` : `Logical cores ×${cores.length}`} +
+ + ) : null} +
+ ); +} + export function DiskGlyph() { return (
diff --git a/src/components/ui.tsx b/src/components/ui.tsx index a8945ae..bfda236 100644 --- a/src/components/ui.tsx +++ b/src/components/ui.tsx @@ -5,6 +5,7 @@ import { Check, ChevronDown, Code2, + DownloadCloud, FileWarning, Globe2, Languages, @@ -88,8 +89,8 @@ export const CATEGORY_META: Record = { tone: "teal", }, trash: { - en: "Trash", - zh: "废纸篓", + en: "Recycle Bin", + zh: "回收站", blurbEn: "Files waiting to be emptied", blurbZh: "等待清空的文件", icon: Trash2, @@ -111,11 +112,25 @@ export const CATEGORY_META: Record = { icon: Puzzle, tone: "amber", }, + "update-installers": { + en: "Update installers", + zh: "升级安装包", + blurbEn: "Installer packages apps keep after updating", + blurbZh: "应用升级后留下的安装包,需要时会自动重新下载", + icon: DownloadCloud, + tone: "green", + }, }; export const CATEGORY_ORDER = Object.keys(CATEGORY_META) as Category[]; -export function categoryLabel(category: Category, language: "zh" | "en"): string { +export function categoryLabel( + category: Category, + language: "zh" | "en", + binName?: string, +): string { + // The bin category borrows the OS word for it: 回收站 on Windows, 废纸篓 on macOS. + if (category === "trash" && binName) return binName; return language === "zh" ? CATEGORY_META[category].zh : CATEGORY_META[category].en; } @@ -612,7 +627,7 @@ export function CategoryCard({ onInspect: () => void; focused?: boolean; }) { - const { lang, t } = useI18n(); + const { lang, t, bin } = useI18n(); const meta = CATEGORY_META[category]; const Icon = meta.icon; return ( @@ -630,11 +645,11 @@ export function CategoryCard({ checked={selected} disabled={disabled} onChange={onToggle} - label={categoryLabel(category, lang)} + label={categoryLabel(category, lang, bin)} />
- {categoryLabel(category, lang)} + {categoryLabel(category, lang, bin)} {lang === "zh" ? meta.blurbZh : meta.blurbEn}
diff --git a/src/hooks/useScanWorkspace.ts b/src/hooks/useScanWorkspace.ts index 0dd1f01..1411d95 100644 --- a/src/hooks/useScanWorkspace.ts +++ b/src/hooks/useScanWorkspace.ts @@ -35,9 +35,10 @@ export interface ScanWorkspace { cancel: () => Promise; toggleItem: (index: number) => void; toggleCategory: (category: Category) => void; + deselect: (indexes: number[]) => void; selectAll: () => void; clearSelection: () => void; - clean: (mode: DeleteMode) => Promise; + clean: (mode: DeleteMode, indexes?: number[]) => Promise; clearError: () => void; reset: () => void; } @@ -149,6 +150,16 @@ export function useScanWorkspace(kind: ScanKind): ScanWorkspace { const clearSelection = useCallback(() => setSelected(new Set()), []); + const deselect = useCallback((indexes: number[]) => { + if (indexes.length === 0) return; + const drop = new Set(indexes); + setSelected((current) => { + const next = new Set(current); + for (const index of drop) next.delete(index); + return next; + }); + }, []); + const selectedTotal = useMemo(() => { if (!result) return 0; let total = 0; @@ -159,8 +170,10 @@ export function useScanWorkspace(kind: ScanKind): ScanWorkspace { const selectedCount = selected.size; const clean = useCallback( - async (mode: DeleteMode) => { - if (!result || selected.size === 0 || deleting) return null; + async (mode: DeleteMode, indexes?: number[]) => { + if (!result || deleting) return null; + const targets = indexes ?? [...selected]; + if (targets.length === 0) return null; const id = jobId(); activeJob.current = id; setCurrentJob(id); @@ -171,8 +184,8 @@ export function useScanWorkspace(kind: ScanKind): ScanWorkspace { try { const next = kind === "cleanup" - ? await api.cleanupDelete(id, result.scanId, [...selected], mode) - : await api.purgeDelete(id, result.scanId, [...selected], mode); + ? await api.cleanupDelete(id, result.scanId, targets, mode) + : await api.purgeDelete(id, result.scanId, targets, mode); if (activeJob.current !== id) return null; setResult(null); setSelected(new Set()); @@ -217,6 +230,7 @@ export function useScanWorkspace(kind: ScanKind): ScanWorkspace { cancel, toggleItem, toggleCategory, + deselect, selectAll, clearSelection, clean, diff --git a/src/hooks/useSystemSnapshot.ts b/src/hooks/useSystemSnapshot.ts index 58593a2..d858112 100644 --- a/src/hooks/useSystemSnapshot.ts +++ b/src/hooks/useSystemSnapshot.ts @@ -3,7 +3,19 @@ import { api } from "../lib/api"; import { messageFrom } from "../lib/format"; import type { SystemSnapshot } from "../types"; -export function useSystemSnapshot(active: boolean, intervalMs = 1800) { +/** + * Polls system_snapshot for a page. + * + * - `full` asks the backend for the expensive per-process walk (only the + * 实时监控 top-process table needs it); light refreshes cost a fraction. + * - Polling pauses while the window is hidden (tray) or the tab is hidden, + * so an icon in the notification area does not keep sampling forever. + */ +export function useSystemSnapshot( + active: boolean, + intervalMs = 1800, + full = false, +) { const [snapshot, setSnapshot] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); @@ -14,7 +26,7 @@ export function useSystemSnapshot(active: boolean, intervalMs = 1800) { inFlight.current = true; setLoading(true); try { - setSnapshot(await api.systemSnapshot()); + setSnapshot(await api.systemSnapshot(full)); setError(null); } catch (reason) { setError(messageFrom(reason)); @@ -22,13 +34,35 @@ export function useSystemSnapshot(active: boolean, intervalMs = 1800) { inFlight.current = false; setLoading(false); } - }, []); + }, [full]); useEffect(() => { if (!active) return; - void refresh(); - const timer = window.setInterval(() => void refresh(), intervalMs); - return () => window.clearInterval(timer); + let live = true; + let timer: number | null = null; + const tick = () => { + if (live && !document.hidden) void refresh(); + }; + const start = () => { + if (timer === null) { + void refresh(); + timer = window.setInterval(tick, intervalMs); + } + }; + const stop = () => { + if (timer !== null) { + window.clearInterval(timer); + timer = null; + } + }; + const onVisibility = () => (document.hidden ? stop() : start()); + start(); + document.addEventListener("visibilitychange", onVisibility); + return () => { + live = false; + stop(); + document.removeEventListener("visibilitychange", onVisibility); + }; }, [active, intervalMs, refresh]); return { snapshot, error, loading, refresh }; diff --git a/src/i18n.tsx b/src/i18n.tsx index 6763299..d0c027d 100644 --- a/src/i18n.tsx +++ b/src/i18n.tsx @@ -15,18 +15,23 @@ const I18nContext = createContext(null); export function I18nProvider({ lang, setLang, + binNoun = "trash", children, }: { lang: Language; setLang: (language: Language) => void; + binNoun?: "trash" | "recycle-bin"; children: ReactNode; }) { + // Windows calls it 回收站; macOS and freedesktop keep 废纸篓. + const zhBin = binNoun === "recycle-bin" ? "回收站" : "废纸篓"; + const enBin = binNoun === "recycle-bin" ? "Recycle Bin" : "Trash"; const value: I18nValue = { lang, setLang, t: (en, zh) => (lang === "zh" ? zh : en), - bin: lang === "zh" ? "废纸篓" : "Trash", - binLower: lang === "zh" ? "废纸篓" : "trash", + bin: lang === "zh" ? zhBin : enBin, + binLower: lang === "zh" ? zhBin : enBin.toLowerCase(), currency: lang === "zh" ? "zh-CN" : "en-US", }; return {children}; diff --git a/src/lib/api.ts b/src/lib/api.ts index 5e9ac98..ed562a6 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -64,7 +64,7 @@ export const api = { invoke("storage_explore", { jobId, path, depth, top }), storageLargestFiles: (jobId: string, path: string, limit = 40) => invoke("storage_largest_files", { jobId, path, limit }), - systemSnapshot: () => invoke("system_snapshot"), + systemSnapshot: (full = false) => invoke("system_snapshot", { full }), stopProcess: (process: SystemSnapshot["top_processes"][number]) => invoke("stop_process", { process }), historyList: (limit = 60) => invoke("history_list", { limit }), @@ -107,6 +107,8 @@ export const api = { listen("update://status", (event) => handler(event.payload)), onNavigate: (handler: (page: PageId) => void) => listen("squid://navigate", (event) => handler(event.payload)), + onWindowVisible: (handler: (visible: boolean) => void) => + listen("squid://visible", (event) => handler(event.payload)), onPopupClosed: (handler: (event: PopupClosedEvent) => void) => listen("popup://closed", (event) => handler(event.payload)), onWidgetSettings: (handler: (prefs: WidgetPrefs) => void) => diff --git a/src/pages/ApplicationsPage.tsx b/src/pages/ApplicationsPage.tsx index 4e1f01c..41e3b76 100644 --- a/src/pages/ApplicationsPage.tsx +++ b/src/pages/ApplicationsPage.tsx @@ -277,7 +277,7 @@ export function ApplicationsPage({ {item.label} {shortPath(item.displayPath, 44)} - {categoryLabel(item.category, lang)} + {categoryLabel(item.category, lang, bin)} {item.note ? ` · ${item.note}` : ""} {item.lock ? ` · ${lockLabel(item.lock, t)}` : ""} diff --git a/src/pages/HistoryPage.tsx b/src/pages/HistoryPage.tsx index 7d9d5d8..5a27388 100644 --- a/src/pages/HistoryPage.tsx +++ b/src/pages/HistoryPage.tsx @@ -92,8 +92,8 @@ export function HistoryPage() { eyebrow={t("History", "历史记录")} title={t("Every change, on the record.", "每一次改动,都有记录。")} description={t( - "Review past cleanups and put files back from the Trash when you change your mind.", - "查看过去的清理记录,改变主意时还可以从废纸篓还原文件。", + `Review past cleanups and put files back from the ${bin} when you change your mind.`, + `查看过去的清理记录,改变主意时还可以从${bin}还原文件。`, )} actions={