feat(browser): 浏览器插件行补「入口」开关(可固定设置页一级导航)

This commit is contained in:
Rick Ye
2026-09-11 17:46:28 +08:00
parent 4eb78ebc48
commit 70930e4952
4 changed files with 20 additions and 4 deletions
@@ -17,6 +17,8 @@ export const browserPlugin: BuiltinPlugin = {
order: 10,
description: '受管浏览器'
},
/** 宿主专属二级设置页(代理设置 + 登录态导入;见 SettingsModal 插件页特判) */
settingsPage: true,
main: (api) => {
for (const tool of browserTools) {
api.pi.registerTool(tool)
@@ -14,6 +14,9 @@ export interface BuiltinPlugin {
main?: HarnessPluginFactory
/** 渲染层宿主树组件 key(renderer/src/plugins/builtin-components.ts) */
component?: string
/** 带宿主专属二级设置页(设置页插件行可点击进入、可固定一级入口;
* 不走声明式设置表单,页面内容由设置页特判渲染) */
settingsPage?: true
}
export const BUILTIN_PLUGINS: BuiltinPlugin[] = [browserPlugin]
+14 -3
View File
@@ -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
+1 -1
View File
@@ -401,7 +401,7 @@ export interface PluginInfo {
hasComponent: boolean
/** 有渲染层模块(entry.renderer,宿主动态 import 后注册宿主内 React 组件) */
hasRenderer: boolean
/** 已声明设置表单(api.ui.registerSettings;空 schema 视为无) */
/** 有设置页可进:已声明设置表单(api.ui.registerSettings),或内置插件带宿主专属设置页(如浏览器) */
hasSettings: boolean
/** 设置入口已固定到设置页一级导航(用户开关;仅 hasSettings 时可开) */
settingsNav: boolean