How to create mutli windows app even with different icons


#1

I am new to electron and wants to create a complete software package that contains about 6 different app. I was wondering on internet that is there way to create this kind of software. I have some questions:

  • is there any way to create an electron app that have multiple windows(sub app) all with different icons, titles etc but common main process.
  • if no then will I have to create multiple app for this package. I mean all the dists of electron have a lot of common files can i share these file between all the apps of that package.

#2
  • is there any way to create an electron app that have multiple windows(sub app) all with different icons, titles etc but common main process.

You can not do that (I mean different icons). Although in Windows/Linux you can use browserWindow.setIcon, but it has no effect in Mac.

But you can have a shared main process for sub-apps. Check my answer below.

  • if no then will I have to create multiple app for this package. I mean all the dists of electron have a lot of common files can i share these file between all the apps of that package.

You can achieve this by the following steps:

  1. Electron itself is an example that it has a default_app to transfer it into different apps: https://github.com/electron/electron/tree/master/default_app, you can use the same way to boot your sub apps, just write your share code (common main process) in your default_app. (The key point is the loadApplicationPackage function: https://github.com/electron/electron/blob/master/default_app/main.js#L242)

  2. use child_process.spawn to spawn a electron.app.getPath('exe'). This will eventually go to the default_app in step 1, then parse the process.argv and extract your sub-app argument from it. (Well, i think how to boot it is up to you, you can skip this step)

  3. Since you are boot your sub-app through default_app, you can change the app’s icon through app.dock.setIcon in Mac,