diff --git a/crates/squid-platform/src/permissions.rs b/crates/squid-platform/src/permissions.rs index 0ed7f59..8f41d9e 100644 --- a/crates/squid-platform/src/permissions.rs +++ b/crates/squid-platform/src/permissions.rs @@ -439,6 +439,7 @@ mod windows { /// Resolve `display_name` (and the software icon) for every scanned /// entry, once per binary. fn decorate_display_names(entries: &mut [StartupEntry]) { + let vendors = vendor_icon_map(); let mut cache: std::collections::HashMap = Default::default(); for entry in entries { let Some(exe) = exe_from_command(&entry.command) else { @@ -453,10 +454,10 @@ mod windows { probed }; let (description, product, icon) = cache - .entry(exe) + .entry(probed.clone()) .or_insert_with(|| { let (description, product, _company) = version_strings(&probed); - (description, product, exe_icon_png(&probed, 0)) + (description, product, software_icon(&probed, &vendors)) }) .clone(); entry.display_name = @@ -465,6 +466,181 @@ mod windows { } } + /// Whether a PE/ICO file ships *real* icon resources. Service stubs such + /// as `qmbsrv.exe` or Edge's `elevation_service.exe` embed none, and + /// `ExtractAssociatedIconW` then silently returns the generic Windows + /// app tile — the cause of whole columns of 权限管理 rows looking alike. + fn has_icon_resources(path: &str) -> bool { + use windows_sys::Win32::UI::Shell::ExtractIconExW; + let wide: Vec = path.encode_utf16().chain(std::iter::once(0)).collect(); + // SAFETY: NUL-terminated buffer; null handle arrays only ask for the + // count of icons the module carries. + (unsafe { + ExtractIconExW( + wide.as_ptr(), + -1, + std::ptr::null_mut(), + std::ptr::null_mut(), + 0, + ) + }) > 0 + } + + /// `App Paths` is the canonical "where does this tool really live" answer: + /// `SpaceAgent.exe` registers the product binary even when the row points + /// at a stripped-down service stub. Returns an (icon path, index) pair + /// that differs from `except` and exists on disk. + fn app_paths_icon_spec(exe_name: &str, except: &str) -> Option<(String, u16)> { + const APP_PATHS: &str = r"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"; + const APP_PATHS_WOW: &str = + r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths"; + let candidates = [ + (HKEY_LOCAL_MACHINE, APP_PATHS), + (HKEY_LOCAL_MACHINE, APP_PATHS_WOW), + (HKEY_CURRENT_USER, APP_PATHS), + ]; + for (hive, base) in candidates { + let Ok(root) = RegKey::predef(hive).open_subkey_with_flags(base, KEY_READ) else { + continue; + }; + let Ok(app) = root.open_subkey_with_flags(exe_name, KEY_READ) else { + continue; + }; + let default: String = app.get_value("").unwrap_or_default(); + let icon: String = app + .open_subkey_with_flags("DefaultIcon", KEY_READ) + .and_then(|key| key.get_value("")) + .unwrap_or_default(); + let spec = if icon.trim().is_empty() { + &default + } else { + &icon + }; + let (path, index) = parse_display_icon(spec)?; + if path.eq_ignore_ascii_case(except.trim_matches('"')) { + continue; + } + if Path::new(&path).exists() { + return Some((path, index)); + } + } + None + } + + /// A sibling in the same folder that does ship an icon: vendors park + /// `Workspace.ico` next to the stub (H3C) or the full binary sits one + /// directory entry away (Edge). `.ico` files win; otherwise the largest + /// `.exe` with real icon resources — the main product binary. + fn sibling_icon_spec(dir: &Path) -> Option<(String, u16)> { + let Ok(read_dir) = std::fs::read_dir(dir) else { + return None; + }; + let mut files: Vec = read_dir.filter_map(Result::ok).map(|f| f.path()).collect(); + files.sort(); + for path in &files { + let is_ico = path + .extension() + .and_then(|e| e.to_str()) + .is_some_and(|e| e.eq_ignore_ascii_case("ico")); + if is_ico { + return Some((path.to_string_lossy().into_owned(), 0)); + } + } + let mut best: Option<(u64, String)> = None; + for path in &files { + let is_exe = path + .extension() + .and_then(|e| e.to_str()) + .is_some_and(|e| e.eq_ignore_ascii_case("exe")); + if !is_exe || !has_icon_resources(&path.to_string_lossy()) { + continue; + } + let size = std::fs::metadata(path).map(|m| m.len()).unwrap_or(0); + if best.as_ref().map_or(true, |(known, _)| size > *known) { + best = Some((size, path.to_string_lossy().into_owned())); + } + } + best.map(|(_, path)| (path, 0)) + } + + /// Directory → `DisplayIcon` from the uninstall registry — the authoritative + /// "this folder belongs to product X, and X's icon is here" table. Edge, + /// 电脑管家 and SpaceAgent all register one whose parent is exactly the + /// folder holding their icon-less service stubs. Built once per scan. + fn vendor_icon_map() -> std::collections::HashMap { + const UNINSTALLS: [&str; 3] = [ + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", + r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall", + r"Software\Microsoft\Windows\CurrentVersion\Uninstall", + ]; + let mut map: std::collections::HashMap = Default::default(); + for hive in [HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER] { + for base in UNINSTALLS { + let Ok(root) = RegKey::predef(hive).open_subkey_with_flags(base, KEY_READ) else { + continue; + }; + for name in root.enum_keys().filter_map(Result::ok) { + let Ok(app) = root.open_subkey_with_flags(&name, KEY_READ) else { + continue; + }; + let Some(spec): Option = app.get_value("DisplayIcon").ok() else { + continue; + }; + let Some((path, index)) = parse_display_icon(&spec) else { + continue; + }; + let Some(dir) = Path::new(&path).parent() else { + continue; + }; + let dir = dir + .to_string_lossy() + .to_lowercase() + .trim_end_matches('\\') + .to_string(); + if !dir.is_empty() && !map.contains_key(&dir) && Path::new(&path).exists() { + map.insert(dir, (path, index)); + } + } + } + } + map + } + + /// Startup-list icon with the vendor fallbacks the generic extraction + /// lacks: real resources first, then App Paths, then the uninstall + /// registry's DisplayIcon for the same folder, then a sibling file. + /// `None` (a neutral placeholder in the UI) beats a misleading tile. + fn software_icon( + path: &str, + vendors: &std::collections::HashMap, + ) -> Option> { + if has_icon_resources(path) { + return exe_icon_png(path, 0); + } + let file = Path::new(path); + let name = file.file_name()?.to_string_lossy().to_string(); + if let Some((spec, index)) = app_paths_icon_spec(&name, path) { + if let Some(icon) = exe_icon_png(&spec, index) { + return Some(icon); + } + } + let dir_key = file + .parent() + .map(|dir| dir.to_string_lossy().to_lowercase()) + .unwrap_or_default(); + if let Some((spec, index)) = vendors.get(dir_key.trim_end_matches('\\')) { + if let Some(icon) = exe_icon_png(spec, *index) { + return Some(icon); + } + } + if let Some((spec, index)) = file.parent().and_then(sibling_icon_spec) { + if let Some(icon) = exe_icon_png(&spec, index) { + return Some(icon); + } + } + None + } + /// ImagePath entries sometimes carry `"` around paths with spaces even /// mid-command; strip and resolve to something `GetFileVersionInfo` likes. fn exe_to_existing_path(exe: &str) -> String { diff --git a/release/0.1.10/RELEASE_NOTES.md b/release/0.1.10/RELEASE_NOTES.md index 34d34d2..1059559 100644 --- a/release/0.1.10/RELEASE_NOTES.md +++ b/release/0.1.10/RELEASE_NOTES.md @@ -21,6 +21,13 @@ Squid 0.1.10 更新说明 开着时 Squid 全家 CPU 占用接近 0%。 修复 +- 空间清理:修复扫描后分类卡片与复选框全部不可点击的问题(勾选状态没有 + 进入结果列表的派生缓存,点击后视图停留在扫描瞬间);「可选」角标不再 + 遮挡复选框。 +- 权限管理:修复大量启动项/服务显示通用图标的问题——服务壳程序(如微软 + Edge 提权服务、电脑管家 qmbsrv、H3C SpaceAgent)自身不含图标资源, + 现改为回退读取注册表 App Paths、卸载信息 DisplayIcon 与同目录主程序 + 图标,让每一行显示真正的软件图标。 - 深度清理:默认检查目录(~/code 等 macOS 风格)在本机全都不存在时不再报 「请先选择目录」,自动回退到用户主目录扫描;「要检查的项目目录」旁新增 「浏览…」按钮可直接多选文件夹;扫描出错信息此前会被静默吞掉,现在会以 diff --git a/release/0.1.10/SHA256SUMS.txt b/release/0.1.10/SHA256SUMS.txt index 2ca0c60..85c291f 100644 --- a/release/0.1.10/SHA256SUMS.txt +++ b/release/0.1.10/SHA256SUMS.txt @@ -1,2 +1,2 @@ -ce99d51d92fdedcd9f858fde032a0aaf1d159d12962a06b8f1a30b46f361c990 *Squid-Setup-0.1.10-win-x64.exe -53cda1033de7db972961ebd6a707ac311fbd05e01fd12243cfd499b90636231e *Squid-0.1.10-portable-win-x64.zip +eb0d0740f3dcb0faa1f95323195d90d907271572de54481acafbb65550b53d7c Squid-Setup-0.1.10-win-x64.exe +35f68b65cee48b25aef2b9bc20db7bdc34cae8e77bc85e546a406df3c151a525 Squid-0.1.10-portable-win-x64.zip \ No newline at end of file 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 index 566538a..ed37095 100644 Binary files a/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe 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 index fb809b6..5116662 100644 --- a/release/0.1.10/squid-update.json +++ b/release/0.1.10/squid-update.json @@ -1,13 +1,13 @@ -{ +{ "schema": 1, "version": "0.1.10", "date": "2026-11-19", - "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- 深度清理:默认检查目录(~/code 等 macOS 风格)在本机全都不存在时不再报\n 「请先选择目录」,自动回退到用户主目录扫描;「要检查的项目目录」旁新增\n 「浏览…」按钮可直接多选文件夹;扫描出错信息此前会被静默吞掉,现在会以\n 红色横幅显示。\n- 托盘交互:左键单击/双击图标 = 直接打开主界面,右键 = 弹出菜单(原先\n 左键也会弹菜单)。\n\n调整\n- 「日常清理」与「深度清理」合并为一个「空间清理」页:一次扫描同时检查缓存\n 垃圾与项目构建目录,结果汇总为一份清单。默认只勾选日常清理项,「升级安装\n 包 / 项目产物 / 开发文件」三类为可选(虚线卡片 + 可选角标),勾选后与日常\n 项合并成一次清理。深度扫描目录、文件年龄(3/7/30 天)、Git 保护收进页面\n 顶部设置栏;扫描与删除全程有步骤条与实时进度;侧边栏与托盘菜单同步精简,\n 快捷键重排(Ctrl+2 = 空间清理)。\n- 桌面小工具 Win+D 常驻:按下「显示桌面」后小工具约 2 秒内自动回到桌面\n (窗口保持桌面层:在壁纸与图标之上、其他软件窗口之下;自己关闭/折叠\n 不会把它叫回来)。\n- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统\n 名称联动);macOS 仍为「废纸篓」。", + "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- 空间清理:修复扫描后分类卡片与复选框全部不可点击的问题(勾选状态没有进入结果列表的派生缓存,点击后视图停留在扫描瞬间);「可选」角标不再遮挡复选框。\n- 权限管理:修复大量启动项/服务显示通用图标的问题——服务壳程序(如微软 Edge 提权服务、电脑管家 qmbsrv、H3C SpaceAgent)自身不含图标资源,现改为回退读取注册表 App Paths、卸载信息 DisplayIcon 与同目录主程序图标。\n- 深度清理:默认检查目录(~/code 等 macOS 风格)在本机全都不存在时不再报\n 「请先选择目录」,自动回退到用户主目录扫描;「要检查的项目目录」旁新增\n 「浏览…」按钮可直接多选文件夹;扫描出错信息此前会被静默吞掉,现在会以\n 红色横幅显示。\n- 托盘交互:左键单击/双击图标 = 直接打开主界面,右键 = 弹出菜单(原先\n 左键也会弹菜单)。\n\n调整\n- 「日常清理」与「深度清理」合并为一个「空间清理」页:一次扫描同时检查缓存\n 垃圾与项目构建目录,结果汇总为一份清单。默认只勾选日常清理项,「升级安装\n 包 / 项目产物 / 开发文件」三类为可选(虚线卡片 + 可选角标),勾选后与日常\n 项合并成一次清理。深度扫描目录、文件年龄(3/7/30 天)、Git 保护收进页面\n 顶部设置栏;扫描与删除全程有步骤条与实时进度;侧边栏与托盘菜单同步精简,\n 快捷键重排(Ctrl+2 = 空间清理)。\n- 桌面小工具 Win+D 常驻:按下「显示桌面」后小工具约 2 秒内自动回到桌面\n (窗口保持桌面层:在壁纸与图标之上、其他软件窗口之下;自己关闭/折叠\n 不会把它叫回来)。\n- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统\n 名称联动);macOS 仍为「废纸篓」。", "artifacts": { "windows": { "file": "Squid-Setup-0.1.10-win-x64.exe", - "sha256": "ce99d51d92fdedcd9f858fde032a0aaf1d159d12962a06b8f1a30b46f361c990", - "size": 3570273 + "sha256": "eb0d0740f3dcb0faa1f95323195d90d907271572de54481acafbb65550b53d7c", + "size": 3576785 } } } \ No newline at end of file diff --git a/src/pages/SpacePage.tsx b/src/pages/SpacePage.tsx index 0aced60..e30b031 100644 --- a/src/pages/SpacePage.tsx +++ b/src/pages/SpacePage.tsx @@ -134,7 +134,11 @@ export function SpacePage({ }); } return all.sort((a, b) => b.item.onDisk - a.item.onDisk); - }, [cleanup.result, purge.result]); + // Each Entry carries the workspace object (and with it the `selected` + // Set), so a click must rebuild this list; without the sets in the deps + // every derived card tick, hero number, and row checkbox stays frozen on + // the scan-time snapshot — the cards look dead even though state changed. + }, [cleanup.result, purge.result, cleanup.selected, purge.selected]); const groups = useMemo(() => { const map = new Map< @@ -155,7 +159,10 @@ export function SpacePage({ map.set(entry.item.category, group); } return map; - }, [entries]); + // The selection sets are read through `entry.source`, so they must also + // sit in the dependency list — otherwise toggling a card updates state + // but the memo (and every card tick derived from it) stays frozen. + }, [entries, cleanup.selected, purge.selected]); const selectedStats = useMemo(() => { let count = 0; @@ -167,7 +174,7 @@ export function SpacePage({ } } return { count, total }; - }, [entries]); + }, [entries, cleanup.selected, purge.selected]); const optionalSelected = useMemo(() => { let count = 0; @@ -181,7 +188,7 @@ export function SpacePage({ } } return count; - }, [entries]); + }, [entries, cleanup.selected, purge.selected]); // 升级安装包 keep the confirm-dialog escape: count them inside the current // selection so the banner can offer "skip installers, clean the rest". @@ -199,7 +206,7 @@ export function SpacePage({ } } return { count, total }; - }, [entries]); + }, [entries, cleanup.selected, purge.selected]); const toggleGroup = (category: Category) => { const allOn = groupSelected(category); diff --git a/src/styles.css b/src/styles.css index c166aa3..d9be827 100644 --- a/src/styles.css +++ b/src/styles.css @@ -5466,6 +5466,9 @@ select:focus-visible, top: -8px; right: 8px; z-index: 2; + /* Sits over the card corner where the checkbox lives: it is a label, + never a click target, so the tick underneath stays hittable. */ + pointer-events: none; border-radius: 99px; padding: 2px 9px; background: #3f6bbd;