发布 0.1.15:Windows 卸载调用系统卸载程序并修复应用图标
- Windows 卸载改用应用注册的卸载命令,MSI 使用 msiexec /x,并在完成后清理残留注册表记录 - 从 InstallLocation、MSI、DisplayIcon 与卸载程序路径推断安装目录,修复 0 B 与无法卸载 - Program Files 应用不再被误判为无权限,卸载后自动刷新列表并保留结果摘要 - Windows 与 macOS 应用列表优先显示真实图标,条目键回退到注册表键 - 版本与发布文档更新到 0.1.15main
parent
404d0b6e69
commit
16914f29d8
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -2,7 +2,17 @@
|
|||
|
||||
Squid 的重要变更记录在这里。版本号使用语义化版本,日期为发布日。
|
||||
|
||||
## [Unreleased]
|
||||
## [0.1.15] - 2026-11-30
|
||||
|
||||
### 应用卸载
|
||||
|
||||
- Windows 应用卸载现在会调用应用自己的卸载程序:MSI 条目使用 `msiexec /x`,其他条目按注册表命令执行;卸载完成后自动清理残留的卸载注册表记录。
|
||||
- 修复 Windows 应用列表中没有 `InstallLocation` 的条目显示 0 B、无法卸载的问题。安装目录会依次从注册表、MSI `InstallLocation`、`DisplayIcon` 和卸载程序路径推断。
|
||||
- 修复 Program Files 下的应用被误判为“无权限”,导致只删除残留、应用本体仍在的问题。应用自己的卸载程序会负责提权。
|
||||
- 卸载程序已经删除的文件不再被当成失败;卸载完成后自动刷新应用列表,同时保留结果摘要。
|
||||
- Windows 应用图标优先使用扫描时解析到的 `DisplayIcon`、卸载程序或可执行文件,缺失图标的情况更少。
|
||||
- macOS 应用卸载列表现在也显示真实应用图标。
|
||||
- 应用条目的唯一键在没有 bundle id 时回退到注册表键,避免 Windows 条目互相覆盖或无法选中。
|
||||
|
||||
### 文档
|
||||
|
||||
|
|
|
|||
|
|
@ -3583,7 +3583,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-cli"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -3603,7 +3603,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-core"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -3622,7 +3622,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-engine"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -3645,7 +3645,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-guard"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"hex",
|
||||
|
|
@ -3661,7 +3661,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-platform"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"file_icon_provider",
|
||||
|
|
@ -3681,7 +3681,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-rules"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"serde",
|
||||
|
|
@ -3693,7 +3693,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-stats"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
|
@ -3706,7 +3706,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-tui"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||
exclude = ["src-tauri"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
edition = "2021"
|
||||
rust-version = "1.95"
|
||||
license = "GPL-3.0-only"
|
||||
|
|
|
|||
|
|
@ -20,18 +20,18 @@ The desktop app supports macOS 12+ and Windows 10/11 x64. The CLI and TUI share
|
|||
|
||||
## Download and install
|
||||
|
||||
Current version **0.1.14** (2026-11-25). Desktop installers are published on the origin repository's `releases` branch:
|
||||
Current version **0.1.15** (2026-11-30). Desktop installers are published on the origin repository's `releases` branch:
|
||||
|
||||
| Platform | Installer |
|
||||
| --- | --- |
|
||||
| macOS 12+ | [`Squid-0.1.14-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.14-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.14-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.14-win-x64.exe) |
|
||||
| macOS 12+ | [`Squid-0.1.15-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.15-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.15-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.15-win-x64.exe) |
|
||||
|
||||
Release directory: <https://git.unissense.tech/mula/nex_squid/src/branch/releases>
|
||||
|
||||
Both installers are unsigned builds. On macOS, right-click **Open** the first time; on Windows, choose **More info** > **Run anyway** when SmartScreen appears. See the [usage guide](docs/USAGE.md) for installation, daily use, uninstall, and troubleshooting.
|
||||
|
||||
The same installers are attached to the [GitHub release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.14). The GitHub repository does not carry the `releases` branch. The app still checks the origin update channel.
|
||||
The same installers are attached to the [GitHub release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.15). The GitHub repository does not carry the `releases` branch. The app still checks the origin update channel.
|
||||
|
||||
## Features
|
||||
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -10,19 +10,19 @@ Squid 是面向 macOS 与 Windows 的本地系统维护工具。桌面端、CLI
|
|||
|
||||
## Download / 下载
|
||||
|
||||
Latest release: **0.1.14** (2026-11-25).
|
||||
Latest release: **0.1.15** (2026-11-30).
|
||||
|
||||
| Platform | Package |
|
||||
| --- | --- |
|
||||
| macOS 12+ | [`Squid-0.1.14-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.14-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.14-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.14-win-x64.exe) |
|
||||
| macOS 12+ | [`Squid-0.1.15-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.15-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.15-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.15-win-x64.exe) |
|
||||
|
||||
Installers live on the origin repository's `releases` branch:
|
||||
<https://git.unissense.tech/mula/nex_squid/src/branch/releases>
|
||||
|
||||
The same installers are attached to the [GitHub release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.14). The GitHub repository does not carry the `releases` branch, and the app's update feed still points at the origin channel.
|
||||
The same installers are attached to the [GitHub release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.15). The GitHub repository does not carry the `releases` branch, and the app's update feed still points at the origin channel.
|
||||
|
||||
安装包发布在 origin 仓库的 `releases` 分支,并同步附到 [GitHub Release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.14)。GitHub 不承载 `releases` 分支;应用更新仍从 origin 的发布通道检查。
|
||||
安装包发布在 origin 仓库的 `releases` 分支,并同步附到 [GitHub Release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.15)。GitHub 不承载 `releases` 分支;应用更新仍从 origin 的发布通道检查。
|
||||
|
||||
## Highlights / 功能
|
||||
|
||||
|
|
|
|||
|
|
@ -20,18 +20,18 @@ Squid 是面向 macOS 与 Windows 的本地系统维护工具:清理可重建
|
|||
|
||||
## 下载与安装
|
||||
|
||||
当前版本 **0.1.14**(2026-11-25)。桌面安装包发布在 origin 仓库的 `releases` 分支:
|
||||
当前版本 **0.1.15**(2026-11-30)。桌面安装包发布在 origin 仓库的 `releases` 分支:
|
||||
|
||||
| 平台 | 安装包 |
|
||||
| --- | --- |
|
||||
| macOS 12+ | [`Squid-0.1.14-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.14-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.14-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.14-win-x64.exe) |
|
||||
| macOS 12+ | [`Squid-0.1.15-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.15-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.15-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.15-win-x64.exe) |
|
||||
|
||||
发布目录:<https://git.unissense.tech/mula/nex_squid/src/branch/releases>
|
||||
|
||||
两个安装包都是未签名构建。macOS 首次打开请在访达中右键选择“打开”;Windows SmartScreen 提示时选择“更多信息” > “仍要运行”。完整的安装、使用、卸载与故障排查见[使用帮助](docs/USAGE.zh-CN.md)。
|
||||
|
||||
同一批安装包也会附到 [GitHub Release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.14)。GitHub 不承载 `releases` 分支;应用更新仍从 origin 的发布通道检查。
|
||||
同一批安装包也会附到 [GitHub Release](https://github.com/VulpineLiu/squid/releases/tag/v0.1.15)。GitHub 不承载 `releases` 分支;应用更新仍从 origin 的发布通道检查。
|
||||
|
||||
## 功能
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
Squid 0.1.14
|
||||
Squid 0.1.15
|
||||
|
||||
- 全站统一标准组件库:页签、卡片、行、状态标签、工具栏与搜索框使用同一套定义,不再由各模块自行实现。
|
||||
- 空间清理的“垃圾清理 / 重复文件 / 大文件”三个页签与设置页页签保持同一套样式。
|
||||
- 权限管理的开机启动项改用统一行布局,状态、来源、路径和操作位置与其他模块一致。
|
||||
- 精简设置页与各页面布局;一级标题下不再重复二级描述,标题末尾不再带句号。
|
||||
- 主界面的更新提示直接打开“设置 → 更新”分区。
|
||||
- macOS 隐藏仅支持 Windows 的系统维护模块;权限管理保留开机启动项。
|
||||
- Windows 应用卸载现在会调用应用自己的卸载程序:MSI 条目使用 `msiexec /x`,其他条目按注册表命令执行;卸载完成后自动清理残留的卸载注册表记录。
|
||||
- 修复 Windows 应用列表中没有 `InstallLocation` 的条目显示 0 B、无法卸载的问题。安装目录会依次从注册表、MSI `InstallLocation`、`DisplayIcon` 和卸载程序路径推断。
|
||||
- 修复 Program Files 下的应用被误判为“无权限”,导致只删除残留、应用本体仍在的问题。应用自己的卸载程序会负责提权。
|
||||
- 卸载程序已经删除的文件不再被当成失败;卸载完成后自动刷新应用列表,同时保留结果摘要。
|
||||
- Windows 应用图标优先使用扫描时解析到的 `DisplayIcon`、卸载程序或可执行文件,缺失图标的情况更少。
|
||||
- macOS 应用卸载列表现在也显示真实应用图标。
|
||||
- 应用条目的唯一键在没有 bundle id 时回退到注册表键,避免 Windows 条目互相覆盖或无法选中。
|
||||
|
||||
macOS 与 Windows 安装包均为未签名构建。macOS 首次打开请在访达中右键选择“打开”;Windows SmartScreen 提示时选择“更多信息” > “仍要运行”。
|
||||
|
|
|
|||
|
|
@ -442,6 +442,7 @@ impl AppInfo {
|
|||
pub fn key(&self) -> String {
|
||||
self.bundle_id
|
||||
.clone()
|
||||
.or_else(|| self.reg_key.clone())
|
||||
.unwrap_or_else(|| self.path.to_string_lossy().into_owned())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,9 +124,14 @@ pub fn build_plan(
|
|||
}
|
||||
|
||||
// 1. The bundle itself.
|
||||
let bundle_kind = if app.path.is_file() {
|
||||
ItemKind::File
|
||||
} else {
|
||||
ItemKind::Path
|
||||
};
|
||||
let mut bundle_item = CleanupItem::new(
|
||||
app.path.clone(),
|
||||
ItemKind::Path,
|
||||
bundle_kind,
|
||||
Category::Leftovers,
|
||||
app.name.clone(),
|
||||
)
|
||||
|
|
@ -136,13 +141,28 @@ pub fn build_plan(
|
|||
Some(version) => format!("{} · {}", app.source, version),
|
||||
None => app.source.clone(),
|
||||
});
|
||||
if app.dead || app.path.as_os_str().is_empty() {
|
||||
if app.dead {
|
||||
// 安装不完整: there is no bundle to move to the bin — the plan
|
||||
// carries only the leftovers and the registry record the page
|
||||
// offers to drop.
|
||||
bundle_item = bundle_item
|
||||
.locked(LockReason::Protected)
|
||||
.with_note("程序本体已不存在,仅需清理注册表记录与残留");
|
||||
} else if app.path.as_os_str().is_empty() {
|
||||
// Windows Installer entries can be installed without exposing an
|
||||
// install folder. Keep the row selectable so remove_plan runs the
|
||||
// vendor uninstaller instead of pretending the app is missing.
|
||||
if app
|
||||
.uninstall_string
|
||||
.as_deref()
|
||||
.is_some_and(|raw| !raw.trim().is_empty())
|
||||
{
|
||||
bundle_item.note = Some("由系统卸载程序卸载".into());
|
||||
} else {
|
||||
bundle_item = bundle_item
|
||||
.locked(LockReason::Protected)
|
||||
.with_note("无法定位安装目录,且没有可用的卸载命令");
|
||||
}
|
||||
} else if system {
|
||||
bundle_item = bundle_item
|
||||
.locked(LockReason::Protected)
|
||||
|
|
@ -151,7 +171,10 @@ pub fn build_plan(
|
|||
bundle_item = bundle_item
|
||||
.locked(LockReason::AppRunning)
|
||||
.with_note("quit the app first");
|
||||
} else if !crate::writable_by_us(&app.path) && !crate::is_root() {
|
||||
} else if !cfg!(windows) && !crate::writable_by_us(&app.path) && !crate::is_root() {
|
||||
// Windows apps in Program Files are not writable by the user, but
|
||||
// their own uninstaller handles elevation. Locking the bundle here
|
||||
// made Squid delete only leftovers and leave the app installed.
|
||||
bundle_item = bundle_item.locked(LockReason::NotOwned).with_note(format!(
|
||||
"{} to remove this copy",
|
||||
squid_core::elevation_hint()
|
||||
|
|
@ -280,7 +303,17 @@ pub fn remove_plan(
|
|||
progress: &Progress,
|
||||
cancel: &CancelToken,
|
||||
) -> squid_core::Result<DeleteOutcome> {
|
||||
let prepared = engine.platform().prepare_uninstall(&plan.app);
|
||||
// A plan may contain only leftovers. The platform uninstaller belongs to
|
||||
// the app bundle, so run it only when the bundle itself is selected.
|
||||
let uninstalling_app = plan
|
||||
.items
|
||||
.iter()
|
||||
.any(|item| item.selected && item.lock.is_none() && item.rule_id == "uninstall-bundle");
|
||||
let prepared = if uninstalling_app {
|
||||
engine.platform().prepare_uninstall(&plan.app)
|
||||
} else {
|
||||
squid_platform::LifecycleReport::default()
|
||||
};
|
||||
for note in &prepared.notes {
|
||||
progress.note(note.clone());
|
||||
}
|
||||
|
|
@ -294,8 +327,35 @@ pub fn remove_plan(
|
|||
));
|
||||
}
|
||||
|
||||
let job = DeleteJob::new(plan.items.clone(), mode, "squid uninstall");
|
||||
let outcome = delete::execute(engine, &job, progress, cancel)?;
|
||||
// The vendor uninstaller may already have removed some (or all) of the
|
||||
// selected paths. Treat those as removed instead of reporting ENOENT as a
|
||||
// failure — that made a successful Windows uninstall look broken.
|
||||
let mut job_items = Vec::with_capacity(plan.items.len());
|
||||
let mut already_removed: Vec<CleanupItem> = Vec::new();
|
||||
for item in &plan.items {
|
||||
let removable = item.selected && item.lock.is_none();
|
||||
let gone = removable
|
||||
&& std::fs::symlink_metadata(&item.path)
|
||||
.is_err_and(|error| error.kind() == std::io::ErrorKind::NotFound);
|
||||
if gone {
|
||||
already_removed.push(item.clone());
|
||||
} else {
|
||||
job_items.push(item.clone());
|
||||
}
|
||||
}
|
||||
let job = DeleteJob::new(job_items, mode, "squid uninstall");
|
||||
let mut outcome = if job.removable().is_empty() && !already_removed.is_empty() {
|
||||
let mut outcome = DeleteOutcome::default();
|
||||
outcome.summary.mode = Some(mode);
|
||||
outcome
|
||||
} else {
|
||||
delete::execute(engine, &job, progress, cancel)?
|
||||
};
|
||||
for item in already_removed {
|
||||
outcome.summary.freed += item.size;
|
||||
outcome.summary.freed_allocated += item.allocated;
|
||||
outcome.summary.removed += 1;
|
||||
}
|
||||
|
||||
let removed: Vec<PathBuf> = outcome
|
||||
.summary
|
||||
|
|
@ -304,7 +364,11 @@ pub fn remove_plan(
|
|||
.and_then(squid_core::ledger::load_session)
|
||||
.map(|session| session.entries.into_iter().map(|e| e.path).collect())
|
||||
.unwrap_or_default();
|
||||
let finished = engine.platform().finish_uninstall(&plan.app, &removed);
|
||||
let finished = if uninstalling_app {
|
||||
engine.platform().finish_uninstall(&plan.app, &removed)
|
||||
} else {
|
||||
squid_platform::LifecycleReport::default()
|
||||
};
|
||||
for note in finished.notes {
|
||||
progress.note(note);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1233,6 +1233,14 @@ mod windows {
|
|||
}
|
||||
}
|
||||
}
|
||||
// The scanner already resolved a usable icon file (DisplayIcon, the
|
||||
// uninstaller, or the executable) for installs whose raw registry
|
||||
// value is missing or unparsable.
|
||||
if let Some(source) = app.icon_source.as_deref() {
|
||||
if let Some(icon) = exe_icon_png(&source.to_string_lossy(), 0) {
|
||||
return Some(icon);
|
||||
}
|
||||
}
|
||||
let target = primary_executable(app)?;
|
||||
exe_icon_png(&target, 0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,22 @@ fn open_uninstall_hives() -> Vec<(RegKey, &'static str, &'static str)> {
|
|||
/// record whose product state is Unknown/Broken/Removed means the MSI
|
||||
/// package itself is gone — the record is an orphan no msiexec can honour.
|
||||
mod msi {
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[link(name = "msi")]
|
||||
extern "system" {
|
||||
fn MsiQueryProductStateW(product: *const u16) -> i32;
|
||||
fn MsiGetProductInfoW(
|
||||
product: *const u16,
|
||||
property: *const u16,
|
||||
value: *mut u16,
|
||||
value_len: *mut u32,
|
||||
) -> u32;
|
||||
}
|
||||
|
||||
const ERROR_SUCCESS: u32 = 0;
|
||||
const ERROR_MORE_DATA: u32 = 234;
|
||||
|
||||
// INSTALLSTATE: 0 Unknown, 1 Broken, 2 Advertised, 3 Removed,
|
||||
// 4 Installed, 5 Local, 6 Source, 7 Default.
|
||||
fn wide(text: &str) -> Vec<u16> {
|
||||
|
|
@ -65,6 +76,42 @@ mod msi {
|
|||
let state = unsafe { MsiQueryProductStateW(wide(&normalized).as_ptr()) };
|
||||
matches!(state, 0 | 1 | 3)
|
||||
}
|
||||
|
||||
/// The install folder recorded by Windows Installer. Some packages omit
|
||||
/// `InstallLocation` from the registry but still expose it here, which is
|
||||
/// what keeps their row from showing 0 KB and gives the uninstall plan a
|
||||
/// real target.
|
||||
pub fn install_location(guid: &str) -> Option<PathBuf> {
|
||||
let product = wide(&guid.to_ascii_uppercase());
|
||||
let property = wide("InstallLocation");
|
||||
let mut buffer = vec![0u16; 260];
|
||||
let mut length = buffer.len() as u32;
|
||||
let mut status = unsafe {
|
||||
MsiGetProductInfoW(
|
||||
product.as_ptr(),
|
||||
property.as_ptr(),
|
||||
buffer.as_mut_ptr(),
|
||||
&mut length,
|
||||
)
|
||||
};
|
||||
if status == ERROR_MORE_DATA {
|
||||
buffer.resize(length as usize, 0);
|
||||
status = unsafe {
|
||||
MsiGetProductInfoW(
|
||||
product.as_ptr(),
|
||||
property.as_ptr(),
|
||||
buffer.as_mut_ptr(),
|
||||
&mut length,
|
||||
)
|
||||
};
|
||||
}
|
||||
if status != ERROR_SUCCESS || length == 0 {
|
||||
return None;
|
||||
}
|
||||
let text = String::from_utf16_lossy(&buffer[..length as usize]);
|
||||
let text = text.trim().trim_matches('"').trim();
|
||||
(!text.is_empty()).then(|| PathBuf::from(super::expand_env_vars(text)))
|
||||
}
|
||||
}
|
||||
|
||||
/// The product GUID inside an `MsiExec.exe /X{GUID}` style command.
|
||||
|
|
@ -163,6 +210,161 @@ fn dword_value(key: &RegKey, name: &str) -> Option<u32> {
|
|||
key.get_value::<u32, _>(name).ok()
|
||||
}
|
||||
|
||||
/// `EstimatedSize` is documented as a DWORD in KB, but some installers write
|
||||
/// it as a string. Read both; zero is treated as "not reported" so the caller
|
||||
/// can measure the install folder instead.
|
||||
fn estimated_size_kb(key: &RegKey) -> Option<u64> {
|
||||
if let Ok(kb) = key.get_value::<u32, _>("EstimatedSize") {
|
||||
if kb > 0 {
|
||||
return Some(u64::from(kb));
|
||||
}
|
||||
}
|
||||
if let Ok(kb) = key.get_value::<u64, _>("EstimatedSize") {
|
||||
if kb > 0 {
|
||||
return Some(kb);
|
||||
}
|
||||
}
|
||||
if let Ok(text) = key.get_value::<String, _>("EstimatedSize") {
|
||||
let digits: String = text.chars().filter(|c| c.is_ascii_digit()).collect();
|
||||
if let Ok(kb) = digits.parse::<u64>() {
|
||||
if kb > 0 {
|
||||
return Some(kb);
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Expand the `%VAR%` spellings installers commonly write into registry paths.
|
||||
fn expand_env_vars(text: &str) -> String {
|
||||
let mut out = String::with_capacity(text.len());
|
||||
let mut rest = text;
|
||||
while let Some(start) = rest.find('%') {
|
||||
out.push_str(&rest[..start]);
|
||||
let after = &rest[start + 1..];
|
||||
let Some(end) = after.find('%') else {
|
||||
out.push_str(&rest[start..]);
|
||||
return out;
|
||||
};
|
||||
let name = &after[..end];
|
||||
match std::env::var(name) {
|
||||
Ok(value) => out.push_str(&value),
|
||||
Err(_) => {
|
||||
out.push('%');
|
||||
out.push_str(name);
|
||||
out.push('%');
|
||||
}
|
||||
}
|
||||
rest = &after[end + 1..];
|
||||
}
|
||||
out.push_str(rest);
|
||||
out
|
||||
}
|
||||
|
||||
/// A directory that is specific enough to be an application's install root.
|
||||
/// Never return a drive root, Program Files itself, or a Windows system folder:
|
||||
/// those are shared by every app and must not become an uninstall target.
|
||||
fn plausible_install_dir(path: &Path) -> Option<PathBuf> {
|
||||
if !path.is_absolute() || !path.is_dir() {
|
||||
return None;
|
||||
}
|
||||
let lower = path
|
||||
.to_string_lossy()
|
||||
.trim_end_matches(['\\', '/'])
|
||||
.to_lowercase();
|
||||
if lower.len() <= 3 {
|
||||
return None;
|
||||
}
|
||||
for key in [
|
||||
"ProgramFiles",
|
||||
"ProgramFiles(x86)",
|
||||
"SystemRoot",
|
||||
"LOCALAPPDATA",
|
||||
"APPDATA",
|
||||
"ProgramData",
|
||||
] {
|
||||
let Ok(root) = std::env::var(key) else {
|
||||
continue;
|
||||
};
|
||||
let root = root.trim_end_matches(['\\', '/']).to_lowercase();
|
||||
if lower == root {
|
||||
return None;
|
||||
}
|
||||
if key == "SystemRoot"
|
||||
&& (lower.starts_with(&format!("{root}\\system32"))
|
||||
|| lower.starts_with(&format!("{root}\\syswow64"))
|
||||
|| lower.starts_with(&format!("{root}\\installer")))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(path.to_path_buf())
|
||||
}
|
||||
|
||||
/// Whether the app's uninstall registry record still exists.
|
||||
pub fn uninstall_record_exists(reg_key: &str) -> bool {
|
||||
let Some((tag, name)) = reg_key.split_once('|') else {
|
||||
return false;
|
||||
};
|
||||
let path = format!(r"{UNINSTALL_SUBKEY}\{name}");
|
||||
match tag {
|
||||
"HKCU" => RegKey::predef(HKEY_CURRENT_USER)
|
||||
.open_subkey_with_flags(&path, KEY_READ)
|
||||
.is_ok(),
|
||||
"HKLM64" => RegKey::predef(HKEY_LOCAL_MACHINE)
|
||||
.open_subkey_with_flags(&path, KEY_READ | KEY_WOW64_64KEY)
|
||||
.is_ok(),
|
||||
"HKLM32" => RegKey::predef(HKEY_LOCAL_MACHINE)
|
||||
.open_subkey_with_flags(&path, KEY_READ | KEY_WOW64_32KEY)
|
||||
.is_ok(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the uninstaller the app registered with Windows. MSI entries often use
|
||||
/// `/I{GUID}` for "modify/install"; `/X` is the uninstall verb. Non-MSI
|
||||
/// commands are passed to `cmd.exe` exactly as recorded so vendor-specific
|
||||
/// flags survive.
|
||||
fn run_uninstaller(app: &AppInfo) -> std::result::Result<(), String> {
|
||||
let raw = app
|
||||
.uninstall_string
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
.filter(|s| !s.is_empty())
|
||||
.ok_or_else(|| "应用没有提供卸载命令".to_string())?;
|
||||
let mut command = if let Some(guid) = msi_guid(raw) {
|
||||
let mut command = Command::new("msiexec.exe");
|
||||
command.args(["/x", guid, "/qb", "/norestart"]);
|
||||
command
|
||||
} else {
|
||||
let mut command = Command::new("cmd.exe");
|
||||
command.args(["/C", raw]);
|
||||
command
|
||||
};
|
||||
let cwd = if app.path.is_dir() {
|
||||
Some(app.path.clone())
|
||||
} else {
|
||||
app.path.parent().map(Path::to_path_buf)
|
||||
};
|
||||
if let Some(cwd) = cwd.filter(|path| path.is_dir()) {
|
||||
command.current_dir(cwd);
|
||||
}
|
||||
use std::os::windows::process::CommandExt;
|
||||
command.creation_flags(0x0800_0000); // no console flash
|
||||
let status = command
|
||||
.status()
|
||||
.map_err(|error| format!("无法启动卸载程序:{error}"))?;
|
||||
// 3010/1641 are success-with-reboot-required codes from msiexec and
|
||||
// installers built on it; treating them as failures made a completed
|
||||
// uninstall look broken.
|
||||
let code = status.code().unwrap_or(-1);
|
||||
if status.success() || matches!(code, 3010 | 1641) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("卸载程序退出码 {code}"))
|
||||
}
|
||||
}
|
||||
|
||||
/// The registry's `ProductName` freezes at "Windows 10 …" on every machine
|
||||
/// upgraded from 10 (Microsoft documents it as unreliable); Windows 11 keeps
|
||||
/// reporting API version 10.0 too. The build number is the real signal:
|
||||
|
|
@ -245,7 +447,8 @@ fn days_since_epoch(y: i32, m: u32, d: u32) -> Option<u64> {
|
|||
|
||||
/// Strip surrounding quotes and `cmd /c` wrappers from an uninstall string.
|
||||
fn uninstall_program(uninstall_string: &str) -> Option<PathBuf> {
|
||||
let s = uninstall_string.trim();
|
||||
let expanded = expand_env_vars(uninstall_string.trim());
|
||||
let s = expanded.as_str();
|
||||
let path_part = if s.starts_with('"') {
|
||||
s.strip_prefix('"')?.split('"').next()?
|
||||
} else {
|
||||
|
|
@ -254,14 +457,14 @@ fn uninstall_program(uninstall_string: &str) -> Option<PathBuf> {
|
|||
s.split_whitespace().next()?
|
||||
};
|
||||
let candidate = PathBuf::from(path_part);
|
||||
candidate.exists().then_some(candidate)
|
||||
(candidate.is_absolute() && candidate.exists()).then_some(candidate)
|
||||
}
|
||||
|
||||
/// `DisplayIcon` is a path with an optional icon index, usually quoted:
|
||||
/// `"C:\Program Files\App\app.exe",0`. The file manager accepts the path
|
||||
/// without the index and returns the application's default icon.
|
||||
fn display_icon_path(value: Option<String>) -> Option<PathBuf> {
|
||||
let raw = value?.trim().to_string();
|
||||
let raw = expand_env_vars(value?.trim());
|
||||
let unquoted = raw
|
||||
.strip_prefix('"')
|
||||
.and_then(|value| value.split('"').next())
|
||||
|
|
@ -387,59 +590,95 @@ impl Platform for Windows {
|
|||
) {
|
||||
continue;
|
||||
}
|
||||
let install_location = str_value(&key, "InstallLocation")
|
||||
.map(|l| l.trim_matches('"').to_string())
|
||||
.map(PathBuf::from)
|
||||
.filter(|p| p.is_dir());
|
||||
let display_icon = str_value(&key, "DisplayIcon");
|
||||
let uninstall_string = str_value(&key, "UninstallString");
|
||||
let path = install_location
|
||||
let guid = uninstall_string.as_deref().and_then(msi_guid);
|
||||
let install_location = str_value(&key, "InstallLocation")
|
||||
.map(|location| {
|
||||
PathBuf::from(expand_env_vars(location.trim().trim_matches('"')))
|
||||
})
|
||||
.and_then(|path| plausible_install_dir(&path));
|
||||
let msi_location = guid
|
||||
.and_then(msi::install_location)
|
||||
.and_then(|path| plausible_install_dir(&path));
|
||||
let uninstaller = uninstall_string.as_deref().and_then(uninstall_program);
|
||||
let icon_file = display_icon_path(display_icon.clone());
|
||||
let install_dir = install_location
|
||||
.clone()
|
||||
.or_else(|| uninstall_string.as_deref().and_then(uninstall_program))
|
||||
.or(msi_location)
|
||||
.or_else(|| {
|
||||
icon_file
|
||||
.as_ref()
|
||||
.and_then(|path| path.parent())
|
||||
.and_then(plausible_install_dir)
|
||||
})
|
||||
.or_else(|| {
|
||||
uninstaller
|
||||
.as_ref()
|
||||
.and_then(|path| path.parent())
|
||||
.and_then(plausible_install_dir)
|
||||
});
|
||||
// Prefer the install folder; fall back to the uninstaller or
|
||||
// the icon binary so the plan always points at something the
|
||||
// user recognises rather than an empty path.
|
||||
let path = install_dir
|
||||
.clone()
|
||||
.or_else(|| uninstaller.clone())
|
||||
.or_else(|| icon_file.clone())
|
||||
.unwrap_or_default();
|
||||
let running_app = install_location
|
||||
let running_app = install_dir
|
||||
.as_ref()
|
||||
.map(|loc| {
|
||||
let loc = loc.to_string_lossy().to_lowercase();
|
||||
running.iter().any(|exe| exe.starts_with(&loc))
|
||||
.map(|location| {
|
||||
let location = location.to_string_lossy().to_lowercase();
|
||||
running.iter().any(|exe| exe.starts_with(&location))
|
||||
})
|
||||
.unwrap_or(false);
|
||||
// 安装不完整 detection (MangoDisk's cross-check): the record
|
||||
// exists but the product cannot be found any more — the MSI
|
||||
// state says gone, or neither the install folder nor the
|
||||
// uninstaller binary is on disk.
|
||||
let dead = match uninstall_string.as_deref().and_then(msi_guid) {
|
||||
let uninstaller_gone = uninstaller
|
||||
.as_ref()
|
||||
.map(|exe| !exe.exists())
|
||||
.unwrap_or(true);
|
||||
let dead = match guid {
|
||||
Some(guid) => msi::product_broken(guid),
|
||||
None => {
|
||||
let uninstaller_gone = uninstall_string
|
||||
.as_deref()
|
||||
.and_then(uninstall_program)
|
||||
.map(|exe| !exe.exists())
|
||||
.unwrap_or(true);
|
||||
install_location.is_none() && uninstaller_gone
|
||||
}
|
||||
None => !path.exists() && uninstaller_gone,
|
||||
};
|
||||
// Size: Windows installers report EstimatedSize (KB) for
|
||||
// Add/Remove Programs — the same number Settings shows.
|
||||
// Absent that, measure the install folder when asked.
|
||||
let size = match dword_value(&key, "EstimatedSize") {
|
||||
Some(kb) => Bytes(u64::from(kb) * 1024),
|
||||
None if size => install_location
|
||||
.as_ref()
|
||||
.map(|loc| {
|
||||
squid_core::fs::measure(loc, squid_core::ItemKind::Path).allocated
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
None => Bytes::ZERO,
|
||||
};
|
||||
let size = estimated_size_kb(&key)
|
||||
.map(|kb| Bytes(kb.saturating_mul(1024)))
|
||||
.or_else(|| {
|
||||
if !size {
|
||||
return None;
|
||||
}
|
||||
let target = install_dir
|
||||
.as_ref()
|
||||
.or_else(|| path.is_file().then_some(&path))?;
|
||||
let kind = if target.is_dir() {
|
||||
squid_core::ItemKind::Path
|
||||
} else {
|
||||
squid_core::ItemKind::File
|
||||
};
|
||||
Some(squid_core::fs::measure(target, kind).allocated)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let mut source = package_source(&path, source);
|
||||
if dead {
|
||||
source.push_str(" · 安装不完整");
|
||||
}
|
||||
let icon_source = icon_file
|
||||
.clone()
|
||||
.or_else(|| path.is_file().then(|| path.clone()));
|
||||
apps.push(AppInfo {
|
||||
name: display_name,
|
||||
bundle_id: None,
|
||||
path,
|
||||
icon_source: display_icon_path(str_value(&key, "DisplayIcon")),
|
||||
// `icon_source` is the lazy path used by the shared icon
|
||||
// helper; a file path is enough there.
|
||||
icon_source,
|
||||
version: str_value(&key, "DisplayVersion"),
|
||||
size,
|
||||
source,
|
||||
|
|
@ -447,7 +686,7 @@ impl Platform for Windows {
|
|||
has_sibling_install: false,
|
||||
publisher: str_value(&key, "Publisher"),
|
||||
installed_ms: install_date_ms(str_value(&key, "InstallDate")),
|
||||
display_icon: str_value(&key, "DisplayIcon"),
|
||||
display_icon,
|
||||
uninstall_string,
|
||||
reg_key: Some(format!("{tag}|{name}")),
|
||||
dead,
|
||||
|
|
@ -472,14 +711,53 @@ impl Platform for Windows {
|
|||
}
|
||||
fn prepare_uninstall(&self, app: &AppInfo) -> LifecycleReport {
|
||||
let mut report = LifecycleReport::default();
|
||||
report.warnings.push(format!(
|
||||
"{} ships its own uninstaller; squid only removes leftover data on Windows",
|
||||
app.name
|
||||
));
|
||||
if app
|
||||
.uninstall_string
|
||||
.as_deref()
|
||||
.is_some_and(|raw| !raw.trim().is_empty())
|
||||
{
|
||||
match run_uninstaller(app) {
|
||||
Ok(()) => {
|
||||
report
|
||||
.notes
|
||||
.push(format!("已运行 {} 的系统卸载程序", app.name));
|
||||
}
|
||||
Err(error) => report.warnings.push(format!(
|
||||
"系统卸载程序未能完成:{error}。Squid 将继续清理已选中的残留。"
|
||||
)),
|
||||
}
|
||||
return report;
|
||||
}
|
||||
report
|
||||
.warnings
|
||||
.push("该应用没有提供卸载命令,Squid 只会移除已选中的文件。".into());
|
||||
report
|
||||
}
|
||||
fn finish_uninstall(&self, _app: &AppInfo, _removed: &[PathBuf]) -> LifecycleReport {
|
||||
LifecycleReport::default()
|
||||
fn finish_uninstall(&self, app: &AppInfo, _removed: &[PathBuf]) -> LifecycleReport {
|
||||
let mut report = LifecycleReport::default();
|
||||
let bundle_gone = app.path.as_os_str().is_empty() || !app.path.exists();
|
||||
if !bundle_gone {
|
||||
return report;
|
||||
}
|
||||
if let Some(guid) = app.uninstall_string.as_deref().and_then(msi_guid) {
|
||||
if !msi::product_broken(guid) {
|
||||
report
|
||||
.warnings
|
||||
.push("系统卸载程序未完成,已保留卸载注册表记录".into());
|
||||
return report;
|
||||
}
|
||||
}
|
||||
if let Some(reg_key) = app.reg_key.as_deref() {
|
||||
if uninstall_record_exists(reg_key) {
|
||||
match remove_uninstall_record(reg_key) {
|
||||
Ok(()) => report.notes.push("已清除卸载后残留的注册表记录".into()),
|
||||
Err(error) => report
|
||||
.warnings
|
||||
.push(format!("残留注册表记录未能清除:{error}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
report
|
||||
}
|
||||
fn volumes(&self) -> Result<Vec<Volume>> {
|
||||
let system_drive = std::env::var("SystemDrive").unwrap_or_else(|_| "C:".into());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Squid Usage Guide
|
||||
|
||||
For Squid 0.1.14. See [`README.en.md`](../README.en.md) for the project overview and [`CHANGELOG.md`](../CHANGELOG.md) for version history.
|
||||
For Squid 0.1.15. See [`README.en.md`](../README.en.md) for the project overview and [`CHANGELOG.md`](../CHANGELOG.md) for version history.
|
||||
|
||||
## 1. Download and install
|
||||
|
||||
|
|
@ -9,12 +9,12 @@ Desktop installers are published on the origin repository's `releases` branch an
|
|||
- Release directory: <https://git.unissense.tech/mula/nex_squid/src/branch/releases>
|
||||
- Update manifest: <https://git.unissense.tech/mula/nex_squid/raw/branch/releases/squid-update.json>
|
||||
|
||||
Current version 0.1.14:
|
||||
Current version 0.1.15:
|
||||
|
||||
| Platform | Installer |
|
||||
| --- | --- |
|
||||
| macOS 12+ | [`Squid-0.1.14-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.14-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.14-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.14-win-x64.exe) |
|
||||
| macOS 12+ | [`Squid-0.1.15-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.15-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.15-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.15-win-x64.exe) |
|
||||
|
||||
Both installers are unsigned builds. Verify their exact size and SHA256 against `SHA256SUMS.txt` in the release directory.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Squid 使用帮助
|
||||
|
||||
适用于 Squid 0.1.14。项目说明见 [`README.zh-CN.md`](../README.zh-CN.md),版本历史见 [`CHANGELOG.md`](../CHANGELOG.md)。
|
||||
适用于 Squid 0.1.15。项目说明见 [`README.zh-CN.md`](../README.zh-CN.md),版本历史见 [`CHANGELOG.md`](../CHANGELOG.md)。
|
||||
|
||||
## 1. 下载与安装
|
||||
|
||||
|
|
@ -9,12 +9,12 @@ Squid 的桌面安装包发布在 origin 仓库的 `releases` 分支,并同步
|
|||
- 发布目录:<https://git.unissense.tech/mula/nex_squid/src/branch/releases>
|
||||
- 更新清单:<https://git.unissense.tech/mula/nex_squid/raw/branch/releases/squid-update.json>
|
||||
|
||||
当前版本 0.1.14:
|
||||
当前版本 0.1.15:
|
||||
|
||||
| 平台 | 安装包 |
|
||||
| --- | --- |
|
||||
| macOS 12+ | [`Squid-0.1.14-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.14-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.14-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.14-win-x64.exe) |
|
||||
| macOS 12+ | [`Squid-0.1.15-macOS-universal.dmg`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-0.1.15-macOS-universal.dmg) |
|
||||
| Windows 10/11 x64 | [`Squid-Setup-0.1.15-win-x64.exe`](https://git.unissense.tech/mula/nex_squid/raw/branch/releases/Squid-Setup-0.1.15-win-x64.exe) |
|
||||
|
||||
两个安装包都是未签名构建。校验文件大小和 SHA256 的方法见发布目录中的 `SHA256SUMS.txt`。
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "squid-desktop",
|
||||
"private": true,
|
||||
"version": "0.1.14",
|
||||
"version": "0.1.15",
|
||||
"type": "module",
|
||||
"author": "mula.liu",
|
||||
"license": "GPL-3.0-only",
|
||||
|
|
|
|||
|
|
@ -4764,7 +4764,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-core"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -4783,7 +4783,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-desktop"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
|
|
@ -4810,7 +4810,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-engine"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
|
@ -4833,7 +4833,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-guard"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"hex",
|
||||
|
|
@ -4849,7 +4849,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-platform"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"file_icon_provider",
|
||||
|
|
@ -4869,7 +4869,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-rules"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"serde",
|
||||
|
|
@ -4881,7 +4881,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "squid-stats"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "squid-desktop"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
description = "Squid — a CleanMyMac-inspired cleaner, uninstaller and system monitor."
|
||||
authors = ["mula.liu"]
|
||||
edition = "2021"
|
||||
|
|
|
|||
|
|
@ -1037,10 +1037,25 @@ pub async fn tweaks_restore_all() -> Result<Vec<String>, String> {
|
|||
pub struct AppEntry {
|
||||
#[serde(flatten)]
|
||||
app: AppInfo,
|
||||
/// `data:image/png;base64,…` of the app's icon (Windows only).
|
||||
/// `data:image/png;base64,…` of the app's icon.
|
||||
icon: Option<String>,
|
||||
}
|
||||
|
||||
fn app_icon_png(entry: &AppInfo) -> Option<Vec<u8>> {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
squid_platform::permissions::app_icon(entry)
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
squid_platform::apps::icon_png(entry, 64)
|
||||
}
|
||||
}
|
||||
|
||||
fn app_icon_data_url(entry: &AppInfo) -> Option<String> {
|
||||
app_icon_png(entry).map(|png| format!("data:image/png;base64,{}", STANDARD.encode(png)))
|
||||
}
|
||||
|
||||
#[derive(Clone, serde::Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AppsView {
|
||||
|
|
@ -1066,12 +1081,7 @@ pub async fn apps_scan(app: AppHandle, job_id: String) -> Result<AppsView, Strin
|
|||
.map(|entry| {
|
||||
let icon = icons
|
||||
.entry(entry.key())
|
||||
.or_insert_with(|| {
|
||||
squid_platform::permissions::app_icon(entry).map(|png| {
|
||||
use base64::{engine::general_purpose::STANDARD as B64, Engine as _};
|
||||
format!("data:image/png;base64,{}", B64.encode(&png))
|
||||
})
|
||||
})
|
||||
.or_insert_with(|| app_icon_data_url(entry))
|
||||
.clone();
|
||||
AppEntry {
|
||||
app: entry.clone(),
|
||||
|
|
@ -1115,10 +1125,9 @@ pub async fn app_icon(app: AppHandle, app_key: String) -> Result<Option<String>,
|
|||
let Some(chosen) = chosen else {
|
||||
return Ok(None);
|
||||
};
|
||||
let png =
|
||||
tauri::async_runtime::spawn_blocking(move || squid_platform::apps::icon_png(&chosen, 64))
|
||||
.await
|
||||
.map_err(|error| format!("Could not read the application icon: {error}"))?;
|
||||
let png = tauri::async_runtime::spawn_blocking(move || app_icon_png(&chosen))
|
||||
.await
|
||||
.map_err(|error| format!("Could not read the application icon: {error}"))?;
|
||||
let icon = png.map(|bytes| format!("data:image/png;base64,{}", STANDARD.encode(bytes)));
|
||||
AppState::lock(&app.state::<AppState>().app_icons)?.insert(app_key, icon.clone());
|
||||
Ok(icon)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Squid",
|
||||
"version": "0.1.14",
|
||||
"version": "0.1.15",
|
||||
"identifier": "app.nex.squid",
|
||||
"mainBinaryName": "squid-desktop",
|
||||
"build": {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { useCallback, useMemo, useState } from "react";
|
||||
import { api, subscribeJobProgress } from "../lib/api";
|
||||
import { isCancelled, messageFrom } from "../lib/format";
|
||||
import type {
|
||||
AppInfo,
|
||||
DeleteMode,
|
||||
DeleteResult,
|
||||
JobProgress,
|
||||
PlanResult,
|
||||
import {
|
||||
appKey,
|
||||
type AppInfo,
|
||||
type DeleteMode,
|
||||
type DeleteResult,
|
||||
type JobProgress,
|
||||
type PlanResult,
|
||||
} from "../types";
|
||||
|
||||
function jobId(): string {
|
||||
|
|
@ -27,7 +28,7 @@ export interface AppsWorkspace {
|
|||
planSelected: Set<number>;
|
||||
summary: DeleteResult | null;
|
||||
planSelectedTotal: number;
|
||||
scan: () => Promise<void>;
|
||||
scan: (options?: { keepSummary?: boolean }) => Promise<void>;
|
||||
chooseApp: (app: AppInfo | null) => void;
|
||||
buildPlan: (app: AppInfo) => Promise<void>;
|
||||
togglePlanItem: (index: number) => void;
|
||||
|
|
@ -54,13 +55,13 @@ export function useAppsWorkspace(): AppsWorkspace {
|
|||
const [summary, setSummary] = useState<DeleteResult | null>(null);
|
||||
const [activeJob, setActiveJob] = useState<string | null>(null);
|
||||
|
||||
const scan = useCallback(async () => {
|
||||
if (scanning || deleting) return;
|
||||
const scan = useCallback(async (options?: { keepSummary?: boolean }) => {
|
||||
if (scanning) return;
|
||||
const id = jobId();
|
||||
setActiveJob(id);
|
||||
setScanning(true);
|
||||
setError(null);
|
||||
setSummary(null);
|
||||
if (!options?.keepSummary) setSummary(null);
|
||||
const stop = await subscribeJobProgress(id, setProgress);
|
||||
try {
|
||||
const result = await api.appsScan(id);
|
||||
|
|
@ -75,7 +76,7 @@ export function useAppsWorkspace(): AppsWorkspace {
|
|||
setProgress(null);
|
||||
setActiveJob(null);
|
||||
}
|
||||
}, [deleting, scanning]);
|
||||
}, [scanning]);
|
||||
|
||||
const chooseApp = useCallback((app: AppInfo | null) => {
|
||||
setSelectedApp(app);
|
||||
|
|
@ -94,7 +95,7 @@ export function useAppsWorkspace(): AppsWorkspace {
|
|||
setError(null);
|
||||
const stop = await subscribeJobProgress(id, setProgress);
|
||||
try {
|
||||
const next = await api.appPlan(id, app.bundle_id || app.path);
|
||||
const next = await api.appPlan(id, appKey(app));
|
||||
setPlan(next);
|
||||
setPlanSelected(
|
||||
new Set(
|
||||
|
|
@ -152,31 +153,34 @@ export function useAppsWorkspace(): AppsWorkspace {
|
|||
setDeleting(true);
|
||||
setError(null);
|
||||
const stop = await subscribeJobProgress(id, setProgress);
|
||||
let result: DeleteResult | null = null;
|
||||
try {
|
||||
const result = await api.appUninstall(id, plan.planId, [...planSelected], mode);
|
||||
result = await api.appUninstall(id, plan.planId, [...planSelected], mode);
|
||||
setSummary(result);
|
||||
setApps((current) =>
|
||||
current.filter(
|
||||
(app) =>
|
||||
(app.bundle_id || app.path) !==
|
||||
(plan.app.bundle_id || plan.app.path),
|
||||
(app) => appKey(app) !== appKey(plan.app),
|
||||
),
|
||||
);
|
||||
setPlan(null);
|
||||
setPlanSelected(new Set());
|
||||
setSelectedApp(null);
|
||||
return result;
|
||||
} catch (reason) {
|
||||
if (!isCancelled(reason)) setError(messageFrom(reason));
|
||||
return null;
|
||||
} finally {
|
||||
stop();
|
||||
setDeleting(false);
|
||||
setProgress(null);
|
||||
setActiveJob(null);
|
||||
}
|
||||
if (result) {
|
||||
// The uninstaller and registry cleanup can leave the inventory stale;
|
||||
// refresh it automatically while the result summary stays visible.
|
||||
await scan({ keepSummary: true });
|
||||
}
|
||||
return result;
|
||||
},
|
||||
[deleting, plan, planSelected],
|
||||
[deleting, plan, planSelected, scan],
|
||||
);
|
||||
|
||||
const cancel = useCallback(async () => {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { useMemo, useState } from "react";
|
|||
import { useI18n } from "../i18n";
|
||||
import { api } from "../lib/api";
|
||||
import { formatBytes, formatCount, messageFrom, shortPath } from "../lib/format";
|
||||
import type { AppInfo, DeleteMode } from "../types";
|
||||
import { appKey, type AppInfo, type DeleteMode } from "../types";
|
||||
import type { AppsWorkspace } from "../hooks/useAppsWorkspace";
|
||||
import {
|
||||
Badge,
|
||||
|
|
@ -140,8 +140,8 @@ export function ApplicationsPage({
|
|||
const planIcon = useMemo(() => {
|
||||
const planApp = workspace.plan?.app;
|
||||
if (!planApp) return null;
|
||||
const key = planApp.bundle_id || planApp.path;
|
||||
return workspace.apps.find((a) => (a.bundle_id || a.path) === key)?.icon ?? null;
|
||||
const key = appKey(planApp);
|
||||
return workspace.apps.find((a) => appKey(a) === key)?.icon ?? null;
|
||||
}, [workspace.plan, workspace.apps]);
|
||||
|
||||
const uninstall = async () => {
|
||||
|
|
@ -182,14 +182,16 @@ export function ApplicationsPage({
|
|||
eyebrow={t("Applications", "应用程序")}
|
||||
title={t("Uninstall completely", "卸载,干净彻底")}
|
||||
actions={
|
||||
<Button
|
||||
variant={workspace.scanned ? "secondary" : "primary"}
|
||||
icon={<Search size={16} />}
|
||||
onClick={() => void workspace.scan()}
|
||||
disabled={workspace.scanning || workspace.deleting}
|
||||
>
|
||||
{workspace.scanned ? t("Scan again", "重新扫描") : t("Find applications", "查找应用")}
|
||||
</Button>
|
||||
workspace.scanned ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={<Search size={16} />}
|
||||
onClick={() => void workspace.scan()}
|
||||
disabled={workspace.scanning || workspace.deleting}
|
||||
>
|
||||
{t("Scan again", "重新扫描")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
|
||||
|
|
@ -241,11 +243,12 @@ export function ApplicationsPage({
|
|||
<div className="app-list">
|
||||
{apps.map((app) => (
|
||||
<AppRow
|
||||
key={app.bundle_id || app.path}
|
||||
key={appKey(app)}
|
||||
app={app}
|
||||
selected={
|
||||
(workspace.selectedApp?.bundle_id || workspace.selectedApp?.path) ===
|
||||
(app.bundle_id || app.path)
|
||||
workspace.selectedApp
|
||||
? appKey(workspace.selectedApp) === appKey(app)
|
||||
: false
|
||||
}
|
||||
onSelect={() => void workspace.buildPlan(app)}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -172,6 +172,10 @@ export interface AppInfo {
|
|||
icon?: string | null;
|
||||
}
|
||||
|
||||
export function appKey(app: Pick<AppInfo, "bundle_id" | "reg_key" | "path">): string {
|
||||
return app.bundle_id || app.reg_key || app.path;
|
||||
}
|
||||
|
||||
export interface AppsResult {
|
||||
apps: AppInfo[];
|
||||
total: number;
|
||||
|
|
|
|||
Loading…
Reference in New Issue