右键菜单按软件分组:同软件的多条菜单项合并为一张卡片
- 与开机启动项同款样式:组头 = 软件图标 + 软件名 + 开启状态(全部开启/ 部分开启 x/y/已全部关闭)+ 共 N 个菜单位置 + 组级总开关(一键开/关该 软件在本类别的全部处理器);展开见每行的作用面(文件/文件夹/桌面/ 驱动器/所有对象)、创建者与模块路径 - 归组规则与启动项一致:模块带真实产品字符串或能认出安装目录的归入该 软件组,认不出的落入其他软件(排最后);搜索词命中时自动展开 - 归属标记由后端给出:ShellExtEntry 新增 named 字段(serde default,旧 manage.json 备份可正常反序列化),manage.rs 的 ExtensionView 透传 - 菜单位置类别页签与计数不变;demo 点击测试 9 断言全过(分组、计数、 其他软件兜底、总开关批量调用、类别计数联动、搜索展开)dev
parent
507b81f74a
commit
0cfd360d31
|
|
@ -88,6 +88,12 @@ pub struct ShellExtEntry {
|
|||
/// PNG bytes of the owning module's icon (Windows only).
|
||||
#[serde(default)]
|
||||
pub icon: Option<Vec<u8>>,
|
||||
/// 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
|
||||
|
|
|
|||
|
|
@ -191,6 +191,8 @@ pub struct ExtensionView {
|
|||
icon: Option<String>,
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace
|
|||
const { t } = useI18n();
|
||||
const [query, setQuery] = useState("");
|
||||
const [openGroups, setOpenGroups] = useState<Set<string>>(new Set());
|
||||
const [openExtGroups, setOpenExtGroups] = useState<Set<string>>(new Set());
|
||||
const [extCat, setExtCat] = useState<string | null>(null);
|
||||
const [startupFilter, setStartupFilter] = useState<StartupFilter>("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<string, typeof view.extensions>();
|
||||
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 (
|
||||
<div className="page permissions-page">
|
||||
|
|
@ -563,37 +587,102 @@ export function PermissionsPage({ workspace }: { workspace: PermissionsWorkspace
|
|||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div className="perm-rows">
|
||||
{(activeCategory ? groupedExtensions[activeCategory] : []).map((entry) => (
|
||||
<div
|
||||
className={`settings-row ${!entry.registered ? "is-muted" : ""} ${
|
||||
workspace.busyId === entry.id ? "is-busy" : ""
|
||||
}`}
|
||||
key={entry.id}
|
||||
>
|
||||
<div className="perm-row">
|
||||
<RowIcon icon={entry.icon} label={entry.friendlyName ?? entry.name} />
|
||||
<div>
|
||||
<span>{entry.friendlyName ?? entry.name}</span>
|
||||
<small title={entry.module ?? entry.handler}>
|
||||
{entry.publisher
|
||||
? `${t("Creator", "创建者")} ${entry.publisher} · `
|
||||
: ""}
|
||||
{scopeLabel(entry.scope, t)}
|
||||
{entry.module ? ` · ${shortPath(entry.module, 56)}` : ""}
|
||||
{!entry.registered ? ` · ${t("removed", "已移除")}` : ""}
|
||||
</small>
|
||||
{extGroups.map(([software, items]) => {
|
||||
const onCount = items.filter((entry) => entry.registered).length;
|
||||
const allOn = onCount === items.length;
|
||||
const open = isExtGroupOpen(software);
|
||||
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>
|
||||
)}
|
||||
<span className="perm-group-name">{software}</span>
|
||||
<b className={allOn ? "is-all" : onCount === 0 ? "is-none" : "is-part"}>
|
||||
{allOn
|
||||
? t("All on", "全部开启")
|
||||
: onCount === 0
|
||||
? t("All off", "已全部关闭")
|
||||
: t(
|
||||
`${onCount}/${items.length} on`,
|
||||
`部分开启 ${onCount}/${items.length}`,
|
||||
)}
|
||||
</b>
|
||||
<span
|
||||
className="perm-group-tail"
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
<span
|
||||
className="perm-group-count"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleExtGroupOpen(software);
|
||||
}}
|
||||
>
|
||||
{items.length > 1
|
||||
? t(
|
||||
`${items.length} places`,
|
||||
`共${items.length}个菜单位置`,
|
||||
)
|
||||
: t("1 place", "1个菜单位置")}
|
||||
<ChevronRight
|
||||
size={13}
|
||||
className={`perm-group-chv ${open ? "is-open" : ""}`}
|
||||
/>
|
||||
</span>
|
||||
<Toggle
|
||||
checked={allOn}
|
||||
disabled={workspace.busyId !== null}
|
||||
onChange={async (next) => {
|
||||
for (const entry of items) {
|
||||
if (entry.registered !== next) {
|
||||
await workspace.toggleExtension(entry.id, next);
|
||||
}
|
||||
}
|
||||
}}
|
||||
label={`${software} master ${allOn ? "disable" : "enable"}`}
|
||||
/>
|
||||
</span>
|
||||
</h4>
|
||||
{open ? (
|
||||
<div className="perm-rows">
|
||||
{items.map((entry) => (
|
||||
<div
|
||||
className={`settings-row ${!entry.registered ? "is-muted" : ""} ${
|
||||
workspace.busyId === entry.id ? "is-busy" : ""
|
||||
}`}
|
||||
key={entry.id}
|
||||
>
|
||||
<div className="perm-row perm-row-noicon">
|
||||
<div>
|
||||
<span>{entry.friendlyName ?? entry.name}</span>
|
||||
<small title={entry.module ?? entry.handler}>
|
||||
{entry.publisher
|
||||
? `${t("Creator", "创建者")} ${entry.publisher} · `
|
||||
: ""}
|
||||
{scopeLabel(entry.scope, t)}
|
||||
{entry.module ? ` · ${shortPath(entry.module, 56)}` : ""}
|
||||
{!entry.registered ? ` · ${t("removed", "已移除")}` : ""}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={entry.registered}
|
||||
disabled={workspace.busyId !== null}
|
||||
onChange={(next) => void workspace.toggleExtension(entry.id, next)}
|
||||
label={`${entry.name} ${entry.registered ? "remove" : "restore"}`}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={entry.registered}
|
||||
disabled={workspace.busyId !== null}
|
||||
onChange={(next) => void workspace.toggleExtension(entry.id, next)}
|
||||
label={`${entry.name} ${entry.registered ? "remove" : "restore"}`}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{extCategories.length === 0 ? (
|
||||
<p className="perm-empty">{t("No matches.", "没有匹配的项目。")}</p>
|
||||
) : null}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue