feat(browser): 浏览器插件行补「入口」开关(可固定设置页一级导航)
This commit is contained in:
@@ -17,6 +17,8 @@ export const browserPlugin: BuiltinPlugin = {
|
|||||||
order: 10,
|
order: 10,
|
||||||
description: '受管浏览器'
|
description: '受管浏览器'
|
||||||
},
|
},
|
||||||
|
/** 宿主专属二级设置页(代理设置 + 登录态导入;见 SettingsModal 插件页特判) */
|
||||||
|
settingsPage: true,
|
||||||
main: (api) => {
|
main: (api) => {
|
||||||
for (const tool of browserTools) {
|
for (const tool of browserTools) {
|
||||||
api.pi.registerTool(tool)
|
api.pi.registerTool(tool)
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ export interface BuiltinPlugin {
|
|||||||
main?: HarnessPluginFactory
|
main?: HarnessPluginFactory
|
||||||
/** 渲染层宿主树组件 key(renderer/src/plugins/builtin-components.ts) */
|
/** 渲染层宿主树组件 key(renderer/src/plugins/builtin-components.ts) */
|
||||||
component?: string
|
component?: string
|
||||||
|
/** 带宿主专属二级设置页(设置页插件行可点击进入、可固定一级入口;
|
||||||
|
* 不走声明式设置表单,页面内容由设置页特判渲染) */
|
||||||
|
settingsPage?: true
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BUILTIN_PLUGINS: BuiltinPlugin[] = [browserPlugin]
|
export const BUILTIN_PLUGINS: BuiltinPlugin[] = [browserPlugin]
|
||||||
|
|||||||
@@ -362,7 +362,8 @@ class PluginHost {
|
|||||||
/** 设置入口是否固定到设置页一级导航(仅声明了设置表单的插件可开) */
|
/** 设置入口是否固定到设置页一级导航(仅声明了设置表单的插件可开) */
|
||||||
async setSettingsNav(id: string, on: boolean): Promise<void> {
|
async setSettingsNav(id: string, on: boolean): Promise<void> {
|
||||||
const plugin = this.resolved.get(id)
|
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 })
|
log.info('set settings nav', { pluginId: id, on })
|
||||||
if (on) this.settingsNavSet.add(id)
|
if (on) this.settingsNavSet.add(id)
|
||||||
else this.settingsNavSet.delete(id)
|
else this.settingsNavSet.delete(id)
|
||||||
@@ -467,6 +468,11 @@ class PluginHost {
|
|||||||
return !this.disabled.has(id)
|
return !this.disabled.has(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 内置插件是否带宿主专属二级设置页(不走声明式表单,设置页特判渲染) */
|
||||||
|
private builtinSettingsPage(id: string): boolean {
|
||||||
|
return BUILTIN_PLUGINS.some((b) => b.manifest.id === id && b.settingsPage === true)
|
||||||
|
}
|
||||||
|
|
||||||
list(): PluginInfo[] {
|
list(): PluginInfo[] {
|
||||||
return [...this.resolved.values()]
|
return [...this.resolved.values()]
|
||||||
.map((p) => ({
|
.map((p) => ({
|
||||||
@@ -478,8 +484,13 @@ class PluginHost {
|
|||||||
hasPage: Boolean(p.source === 'external' && p.manifest.entry?.page),
|
hasPage: Boolean(p.source === 'external' && p.manifest.entry?.page),
|
||||||
hasComponent: Boolean(p.componentKey),
|
hasComponent: Boolean(p.componentKey),
|
||||||
hasRenderer: Boolean(p.source === 'external' && p.manifest.entry?.renderer),
|
hasRenderer: Boolean(p.source === 'external' && p.manifest.entry?.renderer),
|
||||||
hasSettings: (this.settingsSchemas.get(p.manifest.id)?.items.length ?? 0) > 0,
|
hasSettings:
|
||||||
settingsNav: this.settingsNavSet.has(p.manifest.id) && (this.settingsSchemas.get(p.manifest.id)?.items.length ?? 0) > 0,
|
(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),
|
dependencies: this.depStatus(p),
|
||||||
storageSchema: this.storageSchemas.get(p.manifest.id),
|
storageSchema: this.storageSchemas.get(p.manifest.id),
|
||||||
error: p.error
|
error: p.error
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ export interface PluginInfo {
|
|||||||
hasComponent: boolean
|
hasComponent: boolean
|
||||||
/** 有渲染层模块(entry.renderer,宿主动态 import 后注册宿主内 React 组件) */
|
/** 有渲染层模块(entry.renderer,宿主动态 import 后注册宿主内 React 组件) */
|
||||||
hasRenderer: boolean
|
hasRenderer: boolean
|
||||||
/** 已声明设置表单(api.ui.registerSettings;空 schema 视为无) */
|
/** 有设置页可进:已声明设置表单(api.ui.registerSettings),或内置插件带宿主专属设置页(如浏览器) */
|
||||||
hasSettings: boolean
|
hasSettings: boolean
|
||||||
/** 设置入口已固定到设置页一级导航(用户开关;仅 hasSettings 时可开) */
|
/** 设置入口已固定到设置页一级导航(用户开关;仅 hasSettings 时可开) */
|
||||||
settingsNav: boolean
|
settingsNav: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user