I finally found a way to achieve this.
A BrowserWindow can have a BrowserView attached to it.
So when I create a BrowserWindow, I pass an additional argument like so :
var win = new BrowserWindow({
webPreferences:{
additionalArguments: ['mainbrowserwindow']
}
})
//Then I load my index.html file for this BrowserWindow
win.loadFile('/path/to/index.html');
This will tell to my Front-End that this instance is generated by a "Main Window" view. This way I can use a single index.html file for every part of my application. I just need a little bit of routing based on this additional Arguments.
After that, I create a new BrowserView, I pass it another additional Argument to tell it to load a specific page of my application (let say a user-info tab)
var view = new BrowserView({
webPreferences: {
additionalArguments:['page=userinfo']
}
})
//Then I load the same index.html for this view
view.loadFile('/path/to/index.html')
I finally add my BrowserView to my BrowserWindow
win.setBrowserView(view)
In my front-end side, the route 'mainbrowserwindow' will only generate the tabs of my application. The 'userinfo' route is the content of the tab.
Now I can create another BrowserWindow, and fill it the 'userinfo' view with the same command.
win2.setBrowserView(view)
This will move the first userinfo page to the other browserwindow without losing the data in memory.
In theory this should work. But there is obviously a lot more to do (IPC communication to synchronize the tabs between multiples BrowserWindow, be sure an empty tab cannot exist, destroy a tab completely to avoid a memory leak). And, of course, the application will render & hold in memory a lot of pages, and I don't think it's possible to serialize a BrowserView inside a file.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…