启动项商店应用归组(ChatGPT 从其他软件独立成组)+ 其他软件换中性图标

- 商店应用(MSIX)的程序文件对普通用户读不到版本信息,全部掉进其他软件;
  新增 windows_store_product:从 WindowsApps\发布者.产品_版本_架构_包哈希\
  包目录名提取产品名(取原路径保留大小写,OpenAI.ChatGPT_… → ChatGPT),
  认出的行归入 ChatGPT 组并带上原图标;带两个单测(含大小写、非商店路径)
- 其他软件组头不再借用组内第一个成员的图标(ChatGPT 蓝图标配"其他软件"
  误导):改用中性九宫格图标(启动项与右键菜单两处共用 GroupIcon 组件)
dev
lijunjie 2026-11-25 09:35:35 +08:00
parent 5cc86269ed
commit 26ec54a4e8
3 changed files with 102 additions and 20 deletions

View File

@ -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<String> {
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

View File

@ -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 (
<span className="perm-group-icon perm-group-icon-neutral" aria-hidden="true">
<LayoutGrid size={16} />
</span>
);
}
const icon = items.find((item) => item.icon)?.icon;
return icon ? (
<img className="perm-group-icon" src={icon} alt="" />
) : (
<span className="perm-group-icon perm-group-icon-fallback" aria-hidden="true">
{software.trim().slice(0, 1).toUpperCase()}
</span>
);
}
export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace }) {
const { t } = useI18n();
const [query, setQuery] = useState("");
@ -380,13 +405,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace
}`}
>
<h4 className="perm-group" onClick={() => toggleGroupOpen(software)}>
{items.find((item) => item.icon)?.icon ? (
<img className="perm-group-icon" src={softwareIcon(items)} alt="" />
) : (
<span className="perm-group-icon perm-group-icon-fallback" aria-hidden="true">
{software.trim().slice(0, 1).toUpperCase()}
</span>
)}
<GroupIcon software={software} items={items} neutral={software === otherName} />
<span className="perm-group-name">{software}</span>
{leftovers.length > 0 ? (
<span className="perm-sig is-leftover">
@ -594,13 +613,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace
return (
<div key={software} className={`perm-group-card ${open ? "is-open" : ""}`}>
<h4 className="perm-group" onClick={() => toggleExtGroupOpen(software)}>
{items.find((entry) => entry.icon)?.icon ? (
<img className="perm-group-icon" src={items.find((e) => e.icon)!.icon!} alt="" />
) : (
<span className="perm-group-icon perm-group-icon-fallback" aria-hidden="true">
{software.trim().slice(0, 1).toUpperCase()}
</span>
)}
<GroupIcon software={software} items={items} neutral={software === otherName} />
<span className="perm-group-name">{software}</span>
<b className={allOn ? "is-all" : onCount === 0 ? "is-none" : "is-part"}>
{allOn

View File

@ -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);