From 26ec54a4e82e5ae6e631f17ed7bbc04e08eb1187 Mon Sep 17 00:00:00 2001 From: lijunjie Date: Wed, 25 Nov 2026 09:35:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=A1=B9=E5=95=86=E5=BA=97?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=BD=92=E7=BB=84=EF=BC=88ChatGPT=20?= =?UTF-8?q?=E4=BB=8E=E5=85=B6=E4=BB=96=E8=BD=AF=E4=BB=B6=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E6=88=90=E7=BB=84=EF=BC=89+=20=E5=85=B6=E4=BB=96=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E6=8D=A2=E4=B8=AD=E6=80=A7=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 商店应用(MSIX)的程序文件对普通用户读不到版本信息,全部掉进其他软件; 新增 windows_store_product:从 WindowsApps\发布者.产品_版本_架构_包哈希\ 包目录名提取产品名(取原路径保留大小写,OpenAI.ChatGPT_… → ChatGPT), 认出的行归入 ChatGPT 组并带上原图标;带两个单测(含大小写、非商店路径) - 其他软件组头不再借用组内第一个成员的图标(ChatGPT 蓝图标配"其他软件" 误导):改用中性九宫格图标(启动项与右键菜单两处共用 GroupIcon 组件) --- crates/squid-platform/src/permissions.rs | 61 +++++++++++++++++++++++- src/pages/PermissionsPage.tsx | 51 ++++++++++++-------- src/styles.css | 10 ++++ 3 files changed, 102 insertions(+), 20 deletions(-) diff --git a/crates/squid-platform/src/permissions.rs b/crates/squid-platform/src/permissions.rs index a1e5775..afaa2ec 100644 --- a/crates/squid-platform/src/permissions.rs +++ b/crates/squid-platform/src/permissions.rs @@ -582,6 +582,30 @@ mod windows { || trimmed.starts_with(r"\\") } + /// Store packages deny version-info reads to plain users, but their + /// install folder *is* the product identity: `…\WindowsApps\ + /// OpenAI.ChatGPT_1.2025_x64__w269v…\ChatGPT.exe` → "ChatGPT". Without + /// this every packaged app (ChatGPT, Terminal, Notepad) sinks into + /// 其他软件 even though the folder spells the product name out. + fn windows_store_product(path: &str) -> Option { + const MARK: &str = "\\windowsapps\\"; + let lowered = path.to_lowercase().replace('/', "\\"); + let at = lowered.find(MARK)? + MARK.len(); + // The scan lower-cases only to *locate* the folder; the slice from + // the original path keeps the real casing (`OpenAI.ChatGPT_…`). + let original = path.replace('/', "\\"); + let package = original[at..].split('\\').next()?; + let family = package.split('_').next()?; + let product = match family.split_once('.') { + // `Publisher.Product` — the product half is what users say. + Some((_, product)) if !product.trim().is_empty() => product, + Some((publisher, _)) => publisher, + None => family, + }; + let product = product.trim(); + (!product.is_empty()).then(|| product.to_string()) + } + /// Resolve `display_name` (and the software icon) for every scanned /// entry, once per binary. Also settles `target` / `target_exists`: the /// binary the row really runs, and whether it is still on disk (a missing @@ -621,6 +645,12 @@ mod windows { // software product when the binary carries real human strings; // everything else falls into the 其他软件 bucket. entry.named = description.is_some() || product.is_some(); + if !entry.named { + if let Some(product) = windows_store_product(&probed) { + entry.display_name = product; + entry.named = true; + } + } entry.icon = icon; } } @@ -2365,10 +2395,39 @@ mod windows { use super::{ approved_enabled, clean_module_path, exe_from_command, friendly_program_name, has_cjk, is_placeholder_label, module_folder_name, parse_csv_line, split_run_path, - task_settings_enabled, write_approved, CURRENT_VERSION, + task_settings_enabled, windows_store_product, write_approved, CURRENT_VERSION, }; use winreg::RegKey; + #[test] + fn store_packages_are_attributed_by_their_package_folder() { + // MSIX installs deny version-info reads, so the folder is the + // only honest product name: these must escape 其他软件. + assert_eq!( + windows_store_product( + r"C:\Program Files\WindowsApps\OpenAI.ChatGPT_1.2025.10.0_x64__w269v8zz8d6vy\ChatGPT.exe" + ) + .as_deref(), + Some("ChatGPT") + ); + assert_eq!( + windows_store_product( + r"C:\PROGRAM FILES\WINDOWSAPPS\Microsoft.WindowsTerminal_1.21\wt.exe" + ) + .as_deref(), + Some("WindowsTerminal") + ); + } + + #[test] + fn ordinary_paths_have_no_store_product() { + assert_eq!( + windows_store_product(r"D:\Program Files\Tencent\Weixin\Weixin.exe"), + None + ); + assert_eq!(windows_store_product("Weixin.exe"), None); + } + #[test] fn toggle_round_trips_through_the_approved_marker() { // The exact pair the UI toggle relies on: write_approved stores a diff --git a/src/pages/PermissionsPage.tsx b/src/pages/PermissionsPage.tsx index bffbfed..ff458eb 100644 --- a/src/pages/PermissionsPage.tsx +++ b/src/pages/PermissionsPage.tsx @@ -3,6 +3,7 @@ import { BellRing, ChevronRight, FolderOpen, + LayoutGrid, RefreshCw, Search, ShieldCheck, @@ -30,11 +31,6 @@ function scopeLabel(scope: string, t: (en: string, zh: string) => string): strin return scope === "machine" ? t("All users", "所有用户") : t("Current user", "当前用户"); } -// The icon shared by a software group: the first entry that carries one. -function softwareIcon(items: StartupItem[]): string { - return items.find((item) => item.icon)?.icon ?? ""; -} - // A row whose program binary no longer exists on disk — the config survived // an uninstall. MangoDisk calls these 残留项 and offers to delete the config. function isLeftover(item: StartupItem): boolean { @@ -78,6 +74,35 @@ function RowIcon({ icon, label }: { icon: string | null | undefined; label: stri ); } +// 其他软件 carries no real product identity, so it never rides a member's +// icon (ChatGPT's blue tile labelled 其他软件 read as a bug). A neutral +// apps-grid glyph says "a pile of things we could not attribute". +function GroupIcon({ + software, + items, + neutral, +}: { + software: string; + items: { icon: string | null }[]; + neutral: boolean; +}) { + if (neutral) { + return ( + + ); + } + const icon = items.find((item) => item.icon)?.icon; + return icon ? ( + + ) : ( + + ); +} + export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace }) { const { t } = useI18n(); const [query, setQuery] = useState(""); @@ -380,13 +405,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace }`} >

toggleGroupOpen(software)}> - {items.find((item) => item.icon)?.icon ? ( - - ) : ( - - )} + {software} {leftovers.length > 0 ? ( @@ -594,13 +613,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace return (

toggleExtGroupOpen(software)}> - {items.find((entry) => entry.icon)?.icon ? ( - e.icon)!.icon!} alt="" /> - ) : ( - - )} + {software} {allOn diff --git a/src/styles.css b/src/styles.css index 9adcb51..c6328fa 100644 --- a/src/styles.css +++ b/src/styles.css @@ -5002,6 +5002,16 @@ select:focus-visible, font-weight: var(--nex-weight-semibold); } +/* 其他软件 gets a neutral apps-grid glyph: the bucket carries no product + identity, so borrowing a member's icon (ChatGPT's tile, say) mislabels it. */ +.perm-group-icon-neutral { + display: inline-flex; + align-items: center; + justify-content: center; + background: #e8e4da; + color: #8d949e; +} + .perm-group b { color: #909fad; font-size: var(--nex-text-3xs);