feat(browser): 浏览器插件行补「入口」开关(可固定设置页一级导航)
This commit is contained in:
@@ -362,7 +362,8 @@ class PluginHost {
|
||||
/** 设置入口是否固定到设置页一级导航(仅声明了设置表单的插件可开) */
|
||||
async setSettingsNav(id: string, on: boolean): Promise<void> {
|
||||
const plugin = this.resolved.get(id)
|
||||
if (!plugin || !this.settingsSchemas.has(id)) return
|
||||
// 可固定入口 = 声明了设置表单,或内置插件带宿主专属设置页(如浏览器)
|
||||
if (!plugin || (!this.settingsSchemas.has(id) && !this.builtinSettingsPage(id))) return
|
||||
log.info('set settings nav', { pluginId: id, on })
|
||||
if (on) this.settingsNavSet.add(id)
|
||||
else this.settingsNavSet.delete(id)
|
||||
@@ -467,6 +468,11 @@ class PluginHost {
|
||||
return !this.disabled.has(id)
|
||||
}
|
||||
|
||||
/** 内置插件是否带宿主专属二级设置页(不走声明式表单,设置页特判渲染) */
|
||||
private builtinSettingsPage(id: string): boolean {
|
||||
return BUILTIN_PLUGINS.some((b) => b.manifest.id === id && b.settingsPage === true)
|
||||
}
|
||||
|
||||
list(): PluginInfo[] {
|
||||
return [...this.resolved.values()]
|
||||
.map((p) => ({
|
||||
@@ -478,8 +484,13 @@ class PluginHost {
|
||||
hasPage: Boolean(p.source === 'external' && p.manifest.entry?.page),
|
||||
hasComponent: Boolean(p.componentKey),
|
||||
hasRenderer: Boolean(p.source === 'external' && p.manifest.entry?.renderer),
|
||||
hasSettings: (this.settingsSchemas.get(p.manifest.id)?.items.length ?? 0) > 0,
|
||||
settingsNav: this.settingsNavSet.has(p.manifest.id) && (this.settingsSchemas.get(p.manifest.id)?.items.length ?? 0) > 0,
|
||||
hasSettings:
|
||||
(this.settingsSchemas.get(p.manifest.id)?.items.length ?? 0) > 0 ||
|
||||
this.builtinSettingsPage(p.manifest.id),
|
||||
settingsNav:
|
||||
this.settingsNavSet.has(p.manifest.id) &&
|
||||
((this.settingsSchemas.get(p.manifest.id)?.items.length ?? 0) > 0 ||
|
||||
this.builtinSettingsPage(p.manifest.id)),
|
||||
dependencies: this.depStatus(p),
|
||||
storageSchema: this.storageSchemas.get(p.manifest.id),
|
||||
error: p.error
|
||||
|
||||
Reference in New Issue
Block a user