(
pluginPath: string,
featureCode: string,
cmdName?: string
)
| 417 | |
| 418 | // 创建或更新插件视图 |
| 419 | public async createPluginView( |
| 420 | pluginPath: string, |
| 421 | featureCode: string, |
| 422 | cmdName?: string |
| 423 | ): Promise<void> { |
| 424 | if (!this.mainWindow) return |
| 425 | |
| 426 | // 先尝试复用已存在的分离窗口单例插件,再决定是否切走主窗口当前插件。 |
| 427 | // 这里顺序不能后置,否则设置页等主窗口插件入口会先被 hide,再发现目标其实只需要聚焦已有分离窗口。 |
| 428 | if ( |
| 429 | this.currentPluginPath !== pluginPath && |
| 430 | (await this.reuseDetachedSingletonIfExists(pluginPath, featureCode, 'main-window')) |
| 431 | ) { |
| 432 | return |
| 433 | } |
| 434 | |
| 435 | // 先处理当前视图切换,再开始新装配会话,避免 hidePluginView 误中断新会话 |
| 436 | if (this.currentPluginPath != null && this.currentPluginPath !== pluginPath) { |
| 437 | this.assemblyCoordinator.trace('hide-current-plugin-before-switch', { |
| 438 | pluginPath, |
| 439 | featureCode, |
| 440 | currentPluginPath: this.currentPluginPath |
| 441 | }) |
| 442 | this.hidePluginView() |
| 443 | } |
| 444 | |
| 445 | const assembly = this.assemblyCoordinator.beginAssembly(pluginPath, featureCode) |
| 446 | |
| 447 | console.log('[Plugin] 准备加载插件:', { assemblyId: assembly.id, pluginPath, featureCode }) |
| 448 | this.assemblyCoordinator.trace('create-plugin-view-enter', { |
| 449 | assemblyId: assembly.id, |
| 450 | pluginPath, |
| 451 | featureCode, |
| 452 | currentPluginPath: this.currentPluginPath |
| 453 | }) |
| 454 | |
| 455 | const pluginInfoFromDB = this.fetchPluginInfoFromDB(pluginPath) |
| 456 | |
| 457 | // 如果当前插件就是这个插件,直接返回 |
| 458 | if (this.currentPluginPath === pluginPath) { |
| 459 | const cached = this.pluginViews.find((v) => v.path === pluginPath) |
| 460 | if (cached) { |
| 461 | // 单例重入:同文本指令 + 同 featureCode → 仅保持当前状态,不重新触发 |
| 462 | if (this.shouldSkipReEnter(pluginPath, featureCode)) { |
| 463 | console.log('[Plugin] 同文本指令重入,跳过 onPluginEnter:', { pluginPath, featureCode }) |
| 464 | this.assemblyCoordinator.abortCurrentSession('singleton-skip-reenter') |
| 465 | return |
| 466 | } |
| 467 | this.assemblyCoordinator.trace('reuse-current-plugin-view', { |
| 468 | assemblyId: assembly.id, |
| 469 | pluginPath, |
| 470 | featureCode |
| 471 | }) |
| 472 | await this.processPluginMode(pluginPath, featureCode, cached.view, assembly) |
| 473 | } |
| 474 | return |
| 475 | } |
| 476 |
no test coverage detected