Skip to content

Electron 应用动态切换加载不同的页面的最佳实践 #2609

Answered by yantze
PerfectPan asked this question in Q&A
Discussion options

You must be logged in to vote

编辑器在不同的窗口使用不同的模块,是可以用 URL 去判断的,不需要修改 Electron 主进程的逻辑。你可以在 Browser 层的 ClientApp 初始化的时候,根据 URL 的不同去引入不同的 modules 做判断就行

import { ClientApp } from '@opensumi/ide-core-browser/lib/bootstrap/app';

export const CodeBrowserModules: ConstructorOf<BrowserModule>[] = [
  ...CommonBrowserModules,
  O2StorageModule,
];

if (window.metadata?.isRemote) {
  CodeBrowserModules.push(...[
    ExpressFileServerModule,
  ]);
}

const opts: IClientAppOpts = {
  modules:CodeBrowserModules,
  layoutConfig,
};
const app = new ClientApp(opts);

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@PerfectPan
Comment options

@yantze
Comment options

@PerfectPan
Comment options

@yantze
Comment options

Answer selected by PerfectPan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants