卸载增强:来源徽章、安装不完整检测与残留记录清理(G2 完成 C 批)
- AppInfo 新增 uninstall_string/reg_key/dead 字段(serde default,全平台默认值) - Windows 卸载扫描:MsiQueryProductStateW 探测 MSI 产品状态,安装目录与卸载器双缺失 → 「安装不完整」 - 包管理器来源徽章:winget/scoop/Chocolatey/JetBrains Toolbox/Microsoft Store 按路径指纹识别 - 死应用卸载方案:幽灵 bundle 行改为锁定说明,新增 app_remove_record 命令删除孤儿注册表记录(HKLM 走一次 UAC 提权 reg.exe,HKCU 进程内直删) - 应用页 UI:安装不完整红色徽章 + 包管理器来源徽章 + 清理残留引导卡 - AI 模型体积诚实化:manifest 行只带自身字节,cluster 总额写入 note,杜绝 清理点 求和双计 - 修正 squid-engine Cargo.toml 误置的 libc 依赖段 - demo 点击测试扩至 53 项全过(隐私锁定/永久删除、优化开关与恢复默认、进阶启动项签名徽章与开关、卸载徽章与残留清理)dev
parent
337f309c2a
commit
cdc60fbe6d
|
|
@ -1172,6 +1172,7 @@ dependencies = [
|
|||
"squid-rules",
|
||||
"squid-stats",
|
||||
"walkdir",
|
||||
"winreg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1184,6 +1185,7 @@ dependencies = [
|
|||
"png",
|
||||
"rayon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"squid-core",
|
||||
"sysinfo",
|
||||
"unicode-width 0.2.0",
|
||||
|
|
|
|||
|
|
@ -415,10 +415,23 @@ pub struct AppInfo {
|
|||
pub has_sibling_install: bool,
|
||||
pub publisher: Option<String>,
|
||||
pub installed_ms: Option<u64>,
|
||||
/// Raw `DisplayIcon` registry value (Windows): a path, optionally with an
|
||||
/// Raw `DisplayIcon` registry value (Windows): a path, optionally with a
|
||||
/// `,index` suffix — the icon Explorer shows for this app.
|
||||
#[serde(default)]
|
||||
pub display_icon: Option<String>,
|
||||
/// The uninstaller command recorded by the app itself, when present.
|
||||
#[serde(default)]
|
||||
pub uninstall_string: Option<String>,
|
||||
/// Windows: the exact registry key holding this entry
|
||||
/// (`HKCU|HKLM` + subkey), so an orphaned record can be removed after
|
||||
/// its files are gone.
|
||||
#[serde(default)]
|
||||
pub reg_key: Option<String>,
|
||||
/// Install is broken: neither the install folder nor the uninstaller
|
||||
/// target exists any more (or MSI reports the product absent while the
|
||||
/// registry record remains). 「安装不完整」 — offer leftover cleanup.
|
||||
#[serde(default)]
|
||||
pub dead: bool,
|
||||
}
|
||||
|
||||
impl AppInfo {
|
||||
|
|
|
|||
|
|
@ -23,3 +23,6 @@ sha2.workspace = true
|
|||
filetime.workspace = true
|
||||
dirs.workspace = true
|
||||
libc.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winreg = "0.52"
|
||||
|
|
|
|||
|
|
@ -210,14 +210,17 @@ fn ollama_models(home: &Path) -> Vec<CleanupItem> {
|
|||
shared_note = format!(";另有 {shared_skipped} 个共享层被其它模型使用,不计算在内");
|
||||
}
|
||||
let label = format!("Ollama · {name}");
|
||||
// Manifest File item carries the cluster's label and total; blob
|
||||
// items are plain File rows (they only exist while the cluster is
|
||||
// ticked as a whole; individually the user may also untick one).
|
||||
let mut item = model_item(manifest, label.clone(), size, newest, &rule);
|
||||
// The manifest is the anchor row and carries the cluster label. Every
|
||||
// row — manifest and blobs alike — carries **its own** size: the 清理点
|
||||
// row sums its members, so charging the total to the manifest on top
|
||||
// of the blobs would double-count the model.
|
||||
let manifest_bytes = std::fs::metadata(&manifest).map(|m| m.len()).unwrap_or(0);
|
||||
let mut item = model_item(manifest, label.clone(), manifest_bytes, newest, &rule);
|
||||
item.kind = ItemKind::File; // the manifest file itself
|
||||
item.note = Some(format!(
|
||||
"{};删除后 `ollama pull` 可原样恢复{shared_note}",
|
||||
age.clone().unwrap_or_else(|| "从未记录使用时间".into())
|
||||
"{};整个模型可释放 {},删除后 `ollama pull` 可原样恢复{shared_note}",
|
||||
age.clone().unwrap_or_else(|| "从未记录使用时间".into()),
|
||||
Bytes(size + manifest_bytes)
|
||||
));
|
||||
rows.push(item);
|
||||
for (blob, bytes, ms) in blob_items {
|
||||
|
|
@ -383,16 +386,18 @@ mod tests {
|
|||
assert_eq!(rows.len(), 2, "{rows:?}");
|
||||
assert!(rows.iter().all(|r| r.rule_id == "ai-ollama-qwen3-8b"));
|
||||
assert_eq!(rows[0].label, "Ollama · qwen3/8b");
|
||||
assert_eq!(
|
||||
rows.iter().map(|r| r.size.as_u64()).sum::<u64>(),
|
||||
2048,
|
||||
"manifest row carries the cluster total, blob its own size"
|
||||
);
|
||||
// Each row carries its own size; the cluster total rides in the note.
|
||||
let total = rows.iter().map(|r| r.size.as_u64()).sum::<u64>();
|
||||
assert!(total >= 2048, "manifest + exclusive blob, no double count");
|
||||
assert!(rows[0]
|
||||
.note
|
||||
.as_deref()
|
||||
.is_some_and(|n| n.contains("可释放")));
|
||||
assert!(rows.iter().all(|r| !r.selected), "models never pre-checked");
|
||||
assert!(rows[0]
|
||||
.note
|
||||
.as_deref()
|
||||
.is_some_and(|n| n.contains("重新下载")));
|
||||
.is_some_and(|n| n.contains("可原样恢复")));
|
||||
let _ = std::fs::remove_dir_all(&root);
|
||||
}
|
||||
|
||||
|
|
@ -432,15 +437,26 @@ mod tests {
|
|||
.iter()
|
||||
.filter(|r| r.rule_id == "ai-ollama-b-latest")
|
||||
.collect();
|
||||
// A: manifest + own blob, sized 100 (the shared 5 GB belongs to nobody yet).
|
||||
// A: manifest (its own JSON bytes) + own blob sized 100; the shared
|
||||
// 5 GB belongs to nobody yet, so it is billed to neither row.
|
||||
assert_eq!(model_a.len(), 2, "{model_a:?}");
|
||||
assert_eq!(model_a[0].size.as_u64(), 100);
|
||||
assert_eq!(model_a[1].size.as_u64(), 100);
|
||||
assert!(
|
||||
model_a[0].size.as_u64() < 200,
|
||||
"manifest carries its own bytes"
|
||||
);
|
||||
assert!(model_a[0]
|
||||
.note
|
||||
.as_deref()
|
||||
.is_some_and(|n| n.contains("共享层")));
|
||||
// B: only the manifest survives, sized 0 → skipped entirely.
|
||||
assert!(model_b.iter().all(|r| r.size.as_u64() == 0) || model_b.is_empty());
|
||||
// B: only the manifest survives (its own JSON bytes, not the shared
|
||||
// 5 GB), and its note says the layers are held by other models.
|
||||
assert_eq!(model_b.len(), 1, "{model_b:?}");
|
||||
assert!(model_b[0].size.as_u64() < 200, "manifest bytes only");
|
||||
assert!(model_b[0]
|
||||
.note
|
||||
.as_deref()
|
||||
.is_some_and(|n| n.contains("共享层")));
|
||||
let _ = std::fs::remove_dir_all(&root);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,14 @@ pub fn build_plan(
|
|||
Some(version) => format!("{} · {}", app.source, version),
|
||||
None => app.source.clone(),
|
||||
});
|
||||
if system {
|
||||
if app.dead || app.path.as_os_str().is_empty() {
|
||||
// 安装不完整: 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 system {
|
||||
bundle_item = bundle_item
|
||||
.locked(LockReason::Protected)
|
||||
.with_note("system application");
|
||||
|
|
@ -472,6 +479,7 @@ mod tests {
|
|||
publisher: None,
|
||||
installed_ms: None,
|
||||
display_icon: None,
|
||||
..AppInfo::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ mod tests {
|
|||
#[test]
|
||||
fn exe_extraction_handles_quotes_and_arguments() {
|
||||
assert_eq!(
|
||||
windows::exe_of(r#""C:\Program Files\Tool\warp.exe" --quiet""#.as_ref()).as_deref(),
|
||||
windows::exe_of(r#""C:\Program Files\Tool\warp.exe" --quiet""#).as_deref(),
|
||||
Some(r"C:\Program Files\Tool\warp.exe")
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ pub fn app_from_bundle(
|
|||
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
|
||||
.map(|d| d.as_millis() as u64),
|
||||
display_icon: None,
|
||||
..AppInfo::default()
|
||||
};
|
||||
if app.name.to_lowercase() == "safari" {
|
||||
// Safari cannot be removed and its caches are managed by the OS.
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ impl Platform for Linux {
|
|||
publisher: desktop.icon.clone(),
|
||||
installed_ms: None,
|
||||
display_icon: None,
|
||||
..AppInfo::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -236,6 +237,7 @@ impl Platform for Linux {
|
|||
publisher: None,
|
||||
installed_ms: None,
|
||||
display_icon: None,
|
||||
..AppInfo::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use std::path::{Path, PathBuf};
|
|||
use std::process::Command;
|
||||
use sysinfo::{Disks, System};
|
||||
use winreg::enums::{
|
||||
HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_32KEY, KEY_WOW64_64KEY,
|
||||
HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_32KEY, KEY_WOW64_64KEY, KEY_WRITE,
|
||||
};
|
||||
use winreg::RegKey;
|
||||
|
||||
|
|
@ -23,27 +23,135 @@ const UNINSTALL_SUBKEY: &str = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Unins
|
|||
const NT_VERSION_KEY: &str = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion";
|
||||
const BIOS_KEY: &str = r"HARDWARE\DESCRIPTION\System\BIOS";
|
||||
|
||||
fn open_uninstall_hives() -> Vec<(RegKey, &'static str)> {
|
||||
fn open_uninstall_hives() -> Vec<(RegKey, &'static str, &'static str)> {
|
||||
let mut hives = Vec::new();
|
||||
let views = [
|
||||
(KEY_WOW64_64KEY, "Registry (HKLM 64-bit)"),
|
||||
(KEY_WOW64_32KEY, "Registry (HKLM 32-bit)"),
|
||||
(KEY_WOW64_64KEY, "Registry (HKLM 64-bit)", "HKLM64"),
|
||||
(KEY_WOW64_32KEY, "Registry (HKLM 32-bit)", "HKLM32"),
|
||||
];
|
||||
for (flag, label) in views {
|
||||
for (flag, label, tag) in views {
|
||||
if let Ok(key) = RegKey::predef(HKEY_LOCAL_MACHINE)
|
||||
.open_subkey_with_flags(UNINSTALL_SUBKEY, KEY_READ | flag)
|
||||
{
|
||||
hives.push((key, label));
|
||||
hives.push((key, label, tag));
|
||||
}
|
||||
}
|
||||
if let Ok(key) =
|
||||
RegKey::predef(HKEY_CURRENT_USER).open_subkey_with_flags(UNINSTALL_SUBKEY, KEY_READ)
|
||||
{
|
||||
hives.push((key, "Registry (HKCU)"));
|
||||
hives.push((key, "Registry (HKCU)", "HKCU"));
|
||||
}
|
||||
hives
|
||||
}
|
||||
|
||||
/// MSI install-state probe (the honest "安装不完整" detector). A registry
|
||||
/// 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 {
|
||||
#[link(name = "msi")]
|
||||
extern "system" {
|
||||
fn MsiQueryProductStateW(product: *const u16) -> i32;
|
||||
}
|
||||
|
||||
// INSTALLSTATE: 0 Unknown, 1 Broken, 2 Advertised, 3 Removed,
|
||||
// 4 Installed, 5 Local, 6 Source, 7 Default.
|
||||
fn wide(text: &str) -> Vec<u16> {
|
||||
text.encode_utf16().chain(std::iter::once(0)).collect()
|
||||
}
|
||||
|
||||
/// True when the MSI product for `guid` is missing or unusable.
|
||||
pub fn product_broken(guid: &str) -> bool {
|
||||
let normalized = guid.to_ascii_uppercase();
|
||||
let state = unsafe { MsiQueryProductStateW(wide(&normalized).as_ptr()) };
|
||||
matches!(state, 0 | 1 | 3)
|
||||
}
|
||||
}
|
||||
|
||||
/// The product GUID inside an `MsiExec.exe /X{GUID}` style command.
|
||||
fn msi_guid(uninstall_string: &str) -> Option<&str> {
|
||||
let upper = uninstall_string.to_ascii_uppercase();
|
||||
if !upper.contains("MSIEXEC") {
|
||||
return None;
|
||||
}
|
||||
let start = uninstall_string.find('{')?;
|
||||
let end = uninstall_string[start..].find('}')? + start + 1;
|
||||
Some(&uninstall_string[start..end])
|
||||
}
|
||||
|
||||
/// Which manager owns this install, by path fingerprint (MangoDisk's source
|
||||
/// merge, cheapened to what the registry already tells us). The badge is
|
||||
/// honest provenance, not a guess: only well-known layouts qualify.
|
||||
fn package_source(path: &Path, fallback: &str) -> String {
|
||||
let lower = path.to_string_lossy().to_lowercase();
|
||||
if lower.contains("\\windowsapps\\") {
|
||||
return "Microsoft Store".into();
|
||||
}
|
||||
if lower.contains("\\scoop\\apps\\") {
|
||||
return "scoop".into();
|
||||
}
|
||||
if lower.contains("\\chocolatey\\") {
|
||||
return "Chocolatey".into();
|
||||
}
|
||||
if lower.contains("\\winget\\") || lower.contains("\\packages\\desktopappinstaller") {
|
||||
return "winget".into();
|
||||
}
|
||||
if lower.contains("\\jetbrains\\toolbox\\apps\\") {
|
||||
return "Toolbox".into();
|
||||
}
|
||||
fallback.into()
|
||||
}
|
||||
|
||||
/// Remove the 安装不完整 registry record of a dead app (the orphan no
|
||||
/// msiexec can honour). `reg_key` is the scanner's "HKLM64|<subkey>" tag.
|
||||
/// HKLM needs admin, so an in-process denial escalates through one UAC
|
||||
/// prompt via `reg.exe` — the record either goes or the user declines.
|
||||
pub fn remove_uninstall_record(reg_key: &str) -> std::result::Result<(), String> {
|
||||
let (tag, name) = reg_key.split_once('|').ok_or("注册表记录标识无效")?;
|
||||
let hive_path = match tag {
|
||||
"HKLM64" | "HKLM32" | "HKCU" => UNINSTALL_SUBKEY,
|
||||
_ => return Err("注册表记录标识无效".into()),
|
||||
};
|
||||
if tag != "HKCU" {
|
||||
use std::os::windows::process::CommandExt;
|
||||
// reg.exe spells the 32-bit view through WOW6432Node.
|
||||
let elevated_path = format!(
|
||||
"HKLM\\{}\\{}",
|
||||
if tag == "HKLM32" {
|
||||
r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||
} else {
|
||||
hive_path
|
||||
},
|
||||
name
|
||||
);
|
||||
let status = Command::new("reg.exe")
|
||||
.args(["delete", &elevated_path, "/f"])
|
||||
.creation_flags(0x0800_0000) // no console flash
|
||||
.status();
|
||||
if matches!(&status, Ok(s) if s.success()) {
|
||||
return Ok(());
|
||||
}
|
||||
// Direct write denied (ACL or lack of admin): escalate once.
|
||||
let script = format!(
|
||||
"$ErrorActionPreference='Stop'; Start-Process -FilePath 'reg.exe' -ArgumentList 'delete','{}','/f' -Verb RunAs -WindowStyle Hidden -Wait",
|
||||
elevated_path.replace('\'', "''")
|
||||
);
|
||||
let escalated = Command::new("powershell.exe")
|
||||
.args(["-NoProfile", "-NonInteractive", "-Command", &script])
|
||||
.creation_flags(0x0800_0000)
|
||||
.status()
|
||||
.map_err(|error| format!("无法启动提权助手:{error}"))?;
|
||||
if !escalated.success() {
|
||||
return Err("管理员授权被取消,注册表记录未删除".into());
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let hive = RegKey::predef(HKEY_CURRENT_USER)
|
||||
.open_subkey_with_flags(hive_path, KEY_READ | KEY_WRITE)
|
||||
.map_err(|error| format!("无法打开卸载注册表:{error}"))?;
|
||||
hive.delete_subkey_all(name)
|
||||
.map_err(|error| format!("删除注册表记录失败:{error}"))
|
||||
}
|
||||
|
||||
fn str_value(key: &RegKey, name: &str) -> Option<String> {
|
||||
key.get_value::<String, _>(name)
|
||||
.ok()
|
||||
|
|
@ -213,7 +321,7 @@ impl Platform for Windows {
|
|||
.map(|p| p.to_lowercase())
|
||||
.collect();
|
||||
let mut apps = Vec::new();
|
||||
for (hive, source) in open_uninstall_hives() {
|
||||
for (hive, source, tag) in open_uninstall_hives() {
|
||||
let names = hive
|
||||
.enum_keys()
|
||||
.filter_map(|name| name.ok())
|
||||
|
|
@ -254,6 +362,21 @@ impl Platform for Windows {
|
|||
running.iter().any(|exe| exe.starts_with(&loc))
|
||||
})
|
||||
.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) {
|
||||
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
|
||||
}
|
||||
};
|
||||
// Size: Windows installers report EstimatedSize (KB) for
|
||||
// Add/Remove Programs — the same number Settings shows.
|
||||
// Absent that, measure the install folder when asked.
|
||||
|
|
@ -267,18 +390,25 @@ impl Platform for Windows {
|
|||
.unwrap_or_default(),
|
||||
None => Bytes::ZERO,
|
||||
};
|
||||
let mut source = package_source(&path, source);
|
||||
if dead {
|
||||
source.push_str(" · 安装不完整");
|
||||
}
|
||||
apps.push(AppInfo {
|
||||
name: display_name,
|
||||
bundle_id: None,
|
||||
path,
|
||||
version: str_value(&key, "DisplayVersion"),
|
||||
size,
|
||||
source: source.into(),
|
||||
source,
|
||||
running: running_app,
|
||||
has_sibling_install: false,
|
||||
publisher: str_value(&key, "Publisher"),
|
||||
installed_ms: install_date_ms(str_value(&key, "InstallDate")),
|
||||
display_icon: str_value(&key, "DisplayIcon"),
|
||||
uninstall_string,
|
||||
reg_key: Some(format!("{tag}|{name}")),
|
||||
dead,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2612,6 +2612,7 @@ mod tests {
|
|||
publisher: None,
|
||||
installed_ms: None,
|
||||
display_icon: None,
|
||||
..AppInfo::default()
|
||||
};
|
||||
let items = vec![
|
||||
CleanupItem::new(
|
||||
|
|
@ -2708,6 +2709,7 @@ mod tests {
|
|||
publisher: None,
|
||||
installed_ms: None,
|
||||
display_icon: None,
|
||||
..AppInfo::default()
|
||||
}];
|
||||
app.uninstall.filter = "Squid".into();
|
||||
assert_eq!(app.uninstall.visible().len(), 1);
|
||||
|
|
|
|||
|
|
@ -2053,6 +2053,7 @@ mod tests {
|
|||
publisher: None,
|
||||
installed_ms: None,
|
||||
display_icon: None,
|
||||
..AppInfo::default()
|
||||
},
|
||||
// Sorted the way `build_plan` sorts: biggest first, so the bundle
|
||||
// is *not* the first item here.
|
||||
|
|
|
|||
|
|
@ -3573,6 +3573,7 @@ dependencies = [
|
|||
"squid-rules",
|
||||
"squid-stats",
|
||||
"walkdir",
|
||||
"winreg 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3585,6 +3586,7 @@ dependencies = [
|
|||
"png 0.17.16",
|
||||
"rayon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"squid-core",
|
||||
"sysinfo",
|
||||
"unicode-width",
|
||||
|
|
|
|||
|
|
@ -1193,6 +1193,26 @@ pub async fn app_uninstall(
|
|||
Ok(DeleteResultView::from_outcome(outcome))
|
||||
}
|
||||
|
||||
/// 卸载增强: drop the 安装不完整 registry record after its files are gone.
|
||||
/// HKLM removal escalates through one UAC prompt; a declined prompt is an
|
||||
/// error the page surfaces, never a silent no-op.
|
||||
#[tauri::command]
|
||||
pub async fn app_remove_record(_app: AppHandle, reg_key: String) -> Result<(), String> {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
squid_platform::windows::remove_uninstall_record(®_key)
|
||||
})
|
||||
.await
|
||||
.map_err(|error| error.to_string())?
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let _ = reg_key;
|
||||
Err("此系统没有注册表记录".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// What `storage_explore` answers: the tree plus how fresh it is (A⑥).
|
||||
/// `cached` = served from the in-memory size cache; `measuredAtMs` = age of
|
||||
/// the measurement so the page can say "12 分钟前" honestly. `Node` itself
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ pub fn run() {
|
|||
app::apps_scan,
|
||||
app::app_plan,
|
||||
app::app_uninstall,
|
||||
app::app_remove_record,
|
||||
app::storage_explore,
|
||||
app::storage_insights,
|
||||
app::write_text_file,
|
||||
|
|
|
|||
|
|
@ -406,8 +406,11 @@ pub async fn advanced_scan(app: AppHandle) -> Result<AdvancedScanView, String> {
|
|||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn advanced_set_enabled(app: AppHandle, id: String, enabled: bool) -> Result<(), String> {
|
||||
let manage = app.state::<ManageState>();
|
||||
pub async fn advanced_set_enabled(
|
||||
_app: AppHandle,
|
||||
id: String,
|
||||
enabled: bool,
|
||||
) -> Result<(), String> {
|
||||
// Advanced rows carry their whole state in the id + a fresh scan match.
|
||||
let entry = tauri::async_runtime::spawn_blocking(squid_platform::advanced::scan_advanced)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ export const api = {
|
|||
appPlan: (jobId: string, appKey: string) => invoke<PlanResult>("app_plan", { jobId, appKey }),
|
||||
appUninstall: (jobId: string, planId: string, selected: number[], mode: DeleteMode) =>
|
||||
invoke<DeleteResult>("app_uninstall", { jobId, planId, selected, mode }),
|
||||
appRemoveRecord: (regKey: string) => invoke<void>("app_remove_record", { regKey }),
|
||||
storageExplore: (jobId: string, path?: string | null, depth = 1, top = 16, force = false) =>
|
||||
invoke<ExploreResult>("storage_explore", { jobId, path, depth, top, force }),
|
||||
storageInsights: () => invoke<SpaceInsight[]>("storage_insights"),
|
||||
|
|
|
|||
|
|
@ -2,15 +2,18 @@ import {
|
|||
AppWindow,
|
||||
ChevronRight,
|
||||
FolderOpen,
|
||||
Hammer,
|
||||
PackageX,
|
||||
Play,
|
||||
Search,
|
||||
ShieldAlert,
|
||||
ShieldCheck,
|
||||
Trash2,
|
||||
} from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useI18n } from "../i18n";
|
||||
import { formatBytes, formatCount, shortPath } from "../lib/format";
|
||||
import { api } from "../lib/api";
|
||||
import { formatBytes, formatCount, messageFrom, shortPath } from "../lib/format";
|
||||
import type { AppInfo, DeleteMode } from "../types";
|
||||
import type { AppsWorkspace } from "../hooks/useAppsWorkspace";
|
||||
import {
|
||||
|
|
@ -27,6 +30,23 @@ import {
|
|||
useToast,
|
||||
} from "../components/ui";
|
||||
|
||||
/* 卸载增强: package-manager provenance as a chip. The backend only badges
|
||||
well-known layouts, so the chip states a fact, never a guess. */
|
||||
const SOURCE_BADGES: Record<string, [string, string]> = {
|
||||
winget: ["winget", "winget"],
|
||||
scoop: ["scoop", "scoop"],
|
||||
Chocolatey: ["Chocolatey", "Chocolatey"],
|
||||
"Microsoft Store": ["Store", "Microsoft Store"],
|
||||
Toolbox: ["Toolbox", "JetBrains Toolbox"],
|
||||
};
|
||||
|
||||
function sourceBadge(source: string): [string, string] | null {
|
||||
for (const [key, badge] of Object.entries(SOURCE_BADGES)) {
|
||||
if (source.includes(key)) return badge;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function AppRow({
|
||||
app,
|
||||
selected,
|
||||
|
|
@ -38,6 +58,7 @@ function AppRow({
|
|||
}) {
|
||||
const { t } = useI18n();
|
||||
const letter = app.name.trim().slice(0, 1).toUpperCase() || "?";
|
||||
const badge = sourceBadge(app.source);
|
||||
return (
|
||||
<button className={`app-row ${selected ? "is-selected" : ""}`} onClick={onSelect}>
|
||||
<span className="app-glyph" aria-hidden="true">
|
||||
|
|
@ -52,12 +73,24 @@ function AppRow({
|
|||
{t("Running", "运行中")}
|
||||
</span>
|
||||
) : null}
|
||||
{app.dead ? (
|
||||
<span className="status-chip is-danger">
|
||||
<ShieldAlert size={10} />
|
||||
{t("Incomplete install", "安装不完整")}
|
||||
</span>
|
||||
) : null}
|
||||
{badge ? (
|
||||
<span className="status-chip is-source" title={badge[1]}>
|
||||
<Hammer size={10} />
|
||||
{badge[0]}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
<span>{app.bundle_id || shortPath(app.path, 45)}</span>
|
||||
</span>
|
||||
<span className="app-row-meta">
|
||||
<strong>{formatBytes(app.size)}</strong>
|
||||
<small>{app.version ? `v${app.version}` : app.source}</small>
|
||||
<small>{app.version ? `v${app.version}` : app.publisher || app.source}</small>
|
||||
</span>
|
||||
<ChevronRight size={16} />
|
||||
</button>
|
||||
|
|
@ -75,6 +108,7 @@ export function ApplicationsPage({
|
|||
const [query, setQuery] = useState("");
|
||||
const [confirming, setConfirming] = useState(false);
|
||||
const [mode, setMode] = useState<DeleteMode>("trash");
|
||||
const [recordBusy, setRecordBusy] = useState(false);
|
||||
|
||||
const apps = useMemo(() => {
|
||||
const needle = query.trim().toLowerCase();
|
||||
|
|
@ -109,6 +143,24 @@ export function ApplicationsPage({
|
|||
}
|
||||
};
|
||||
|
||||
// 卸载增强: an 安装不完整 entry is only fully gone once its registry
|
||||
// record goes too — otherwise Windows (and every scanner) still lists it.
|
||||
const removeRecord = async () => {
|
||||
const regKey = workspace.plan?.app.reg_key;
|
||||
if (!regKey || recordBusy) return;
|
||||
setRecordBusy(true);
|
||||
try {
|
||||
await api.appRemoveRecord(regKey);
|
||||
push(t("Orphaned registry record removed", "已清除残留的注册表记录"), "success");
|
||||
workspace.chooseApp(null);
|
||||
await workspace.scan();
|
||||
} catch (reason) {
|
||||
push(messageFrom(reason), "danger");
|
||||
} finally {
|
||||
setRecordBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="page apps-page">
|
||||
<PageHeader
|
||||
|
|
@ -233,6 +285,32 @@ export function ApplicationsPage({
|
|||
</button>
|
||||
</div>
|
||||
|
||||
{workspace.plan.app.dead ? (
|
||||
<div className="plan-dead-callout">
|
||||
<ShieldAlert size={16} />
|
||||
<div>
|
||||
<strong>{t("Incomplete install", "安装不完整")}</strong>
|
||||
<p>
|
||||
{t(
|
||||
"The program files are already gone; only its registry record and leftovers remain. Removing the record makes Windows stop listing it.",
|
||||
"程序本体已经不存在,只剩下注册表记录和残留文件。清除记录后,系统将不再列出这个应用。",
|
||||
)}
|
||||
</p>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
icon={<PackageX size={14} />}
|
||||
disabled={recordBusy}
|
||||
onClick={() => void removeRecord()}
|
||||
>
|
||||
{recordBusy
|
||||
? t("Cleaning…", "正在清理…")
|
||||
: t("Clean leftovers", "清理残留记录")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{workspace.plan.warnings.length > 0 ? (
|
||||
<div className="plan-warnings">
|
||||
{workspace.plan.warnings.map((warning) => (
|
||||
|
|
|
|||
|
|
@ -990,6 +990,44 @@ select:focus-visible,
|
|||
background: var(--nex-primary-tint);
|
||||
}
|
||||
|
||||
/* 卸载增强: 安装不完整 rows and package-manager provenance chips. */
|
||||
.status-chip.is-danger {
|
||||
color: #b3372c;
|
||||
background: #fdeae7;
|
||||
}
|
||||
|
||||
.status-chip.is-source {
|
||||
color: #4c5f94;
|
||||
background: #e9edf8;
|
||||
}
|
||||
|
||||
.plan-dead-callout {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #f3cfc9;
|
||||
border-radius: 14px;
|
||||
background: #fdf1ef;
|
||||
color: #8c2f26;
|
||||
}
|
||||
|
||||
.plan-dead-callout > svg {
|
||||
flex: none;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.plan-dead-callout strong {
|
||||
display: block;
|
||||
font-size: var(--nex-text-sm);
|
||||
}
|
||||
|
||||
.plan-dead-callout p {
|
||||
margin: 4px 0 8px;
|
||||
color: #a05a53;
|
||||
font-size: var(--nex-text-xs);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* Header gauge and cards */
|
||||
|
||||
.overview-hero {
|
||||
|
|
|
|||
|
|
@ -165,6 +165,12 @@ export interface AppInfo {
|
|||
publisher: string | null;
|
||||
installed_ms: number | null;
|
||||
display_icon: string | null;
|
||||
/** Recorded uninstaller command (Windows), when the app left one. */
|
||||
uninstall_string?: string | null;
|
||||
/** Windows: "HKLM64|<subkey>" — the uninstall registry record itself. */
|
||||
reg_key?: string | null;
|
||||
/** 安装不完整: the record survives but the product files are gone. */
|
||||
dead?: boolean;
|
||||
/** data-URL PNG icon (apps_scan only; null when extraction failed). */
|
||||
icon?: string | null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue