diff --git a/crates/squid-platform/src/permissions.rs b/crates/squid-platform/src/permissions.rs index 2b9b551..a1e5775 100644 --- a/crates/squid-platform/src/permissions.rs +++ b/crates/squid-platform/src/permissions.rs @@ -88,6 +88,12 @@ pub struct ShellExtEntry { /// PNG bytes of the owning module's icon (Windows only). #[serde(default)] pub icon: Option>, + /// True once the handler was attributed to a real software product (its + /// module carries usable FileDescription/ProductName strings). Drives the + /// same software-grouping rule the startup list uses; unattributed rows + /// land in 其他软件. + #[serde(default)] + pub named: bool, } /// A visible top-level window the popup blocker could act on. @@ -2085,9 +2091,12 @@ mod windows { icon = exe_icon_png(&clean, 0); cleaned = Some(clean); } - let friendly_name = module_label - .or_else(|| cleaned.as_deref().and_then(module_folder_name)) - .or(clsid_name); + // Attribution for the UI's software grouping: a row belongs to a + // product when its module carries real strings or sits in a + // recognisable install folder — same rule the startup list uses. + let folder_label = cleaned.as_deref().and_then(module_folder_name); + let named = module_label.is_some() || folder_label.is_some(); + let friendly_name = module_label.or(folder_label).or(clsid_name); if is_builtin_handler(&name, friendly_name.as_deref(), cleaned.as_deref()) { continue; } @@ -2105,6 +2114,7 @@ mod windows { module: cleaned.or(module), publisher, icon, + named, }); } out diff --git a/src-tauri/src/manage.rs b/src-tauri/src/manage.rs index 7617534..0e2c328 100644 --- a/src-tauri/src/manage.rs +++ b/src-tauri/src/manage.rs @@ -191,6 +191,8 @@ pub struct ExtensionView { icon: Option, /// false = currently parked in the app's restore list. registered: bool, + /// Module carries real product strings — drives the software grouping. + named: bool, } impl ExtensionView { @@ -216,6 +218,7 @@ impl From<&ShellExtEntry> for ExtensionView { publisher: entry.publisher.clone(), icon: entry.icon.as_deref().map(png_data_url), registered: true, + named: entry.named, } } } diff --git a/src/pages/PermissionsPage.tsx b/src/pages/PermissionsPage.tsx index 338c8b9..bffbfed 100644 --- a/src/pages/PermissionsPage.tsx +++ b/src/pages/PermissionsPage.tsx @@ -82,6 +82,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace const { t } = useI18n(); const [query, setQuery] = useState(""); const [openGroups, setOpenGroups] = useState>(new Set()); + const [openExtGroups, setOpenExtGroups] = useState>(new Set()); const [extCat, setExtCat] = useState(null); const [startupFilter, setStartupFilter] = useState("all"); const [showSystem, setShowSystem] = useState(false); @@ -249,6 +250,29 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace const extCategories = Object.keys(groupedExtensions); const activeCategory = extCat && extCategories.includes(extCat) ? extCat : extCategories[0] ?? null; + // Same software-grouping rule as the startup list: rows whose module + // carries real product strings group under that product (微信's shell + // extensions across several surfaces become one card); the rest sink to + // 其他软件. Groups open folded, searching force-expands. + const extGrouped = new Map(); + for (const entry of activeCategory ? groupedExtensions[activeCategory] : []) { + const named = entry.named && entry.friendlyName; + const key = named ? entry.friendlyName! : otherName; + const list = extGrouped.get(key) ?? []; + list.push(entry); + extGrouped.set(key, list); + } + const extGroups = [...extGrouped.entries()].sort( + ([a], [b]) => Number(a === otherName) - Number(b === otherName), + ); + const isExtGroupOpen = (name: string) => searching || openExtGroups.has(name); + const toggleExtGroupOpen = (name: string) => + setOpenExtGroups((current) => { + const next = new Set(current); + if (next.has(name)) next.delete(name); + else next.add(name); + return next; + }); return (
@@ -563,37 +587,102 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace />
-
- {(activeCategory ? groupedExtensions[activeCategory] : []).map((entry) => ( -
-
- -
- {entry.friendlyName ?? entry.name} - - {entry.publisher - ? `${t("Creator", "创建者")} ${entry.publisher} · ` - : ""} - {scopeLabel(entry.scope, t)} - {entry.module ? ` · ${shortPath(entry.module, 56)}` : ""} - {!entry.registered ? ` · ${t("removed", "已移除")}` : ""} - + {extGroups.map(([software, items]) => { + const onCount = items.filter((entry) => entry.registered).length; + const allOn = onCount === items.length; + const open = isExtGroupOpen(software); + return ( +
+

toggleExtGroupOpen(software)}> + {items.find((entry) => entry.icon)?.icon ? ( + e.icon)!.icon!} alt="" /> + ) : ( + + )} + {software} + + {allOn + ? t("All on", "全部开启") + : onCount === 0 + ? t("All off", "已全部关闭") + : t( + `${onCount}/${items.length} on`, + `部分开启 ${onCount}/${items.length}`, + )} + + event.stopPropagation()} + > + { + event.stopPropagation(); + toggleExtGroupOpen(software); + }} + > + {items.length > 1 + ? t( + `${items.length} places`, + `共${items.length}个菜单位置`, + ) + : t("1 place", "1个菜单位置")} + + + { + for (const entry of items) { + if (entry.registered !== next) { + await workspace.toggleExtension(entry.id, next); + } + } + }} + label={`${software} master ${allOn ? "disable" : "enable"}`} + /> + +

+ {open ? ( +
+ {items.map((entry) => ( +
+
+
+ {entry.friendlyName ?? entry.name} + + {entry.publisher + ? `${t("Creator", "创建者")} ${entry.publisher} · ` + : ""} + {scopeLabel(entry.scope, t)} + {entry.module ? ` · ${shortPath(entry.module, 56)}` : ""} + {!entry.registered ? ` · ${t("removed", "已移除")}` : ""} + +
+
+ void workspace.toggleExtension(entry.id, next)} + label={`${entry.name} ${entry.registered ? "remove" : "restore"}`} + /> +
+ ))}
-
- void workspace.toggleExtension(entry.id, next)} - label={`${entry.name} ${entry.registered ? "remove" : "restore"}`} - /> + ) : null}
- ))} -
+ ); + })} {extCategories.length === 0 ? (

{t("No matches.", "没有匹配的项目。")}

) : null} diff --git a/src/types.ts b/src/types.ts index f1812dd..fa8b9c6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -499,6 +499,8 @@ export interface ShellExtension { /** data-URL PNG of the owning module's icon; null without extraction. */ icon: string | null; registered: boolean; + /** Module carries real product strings (software grouping, like startup). */ + named: boolean; } export interface PopupWindowItem {