File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1- import { app , BrowserWindow , shell } from 'electron'
1+ import { app , BrowserWindow , shell , ipcMain } from 'electron'
22import { release } from 'os'
33import { join } from 'path'
44
@@ -71,3 +71,23 @@ app.on('activate', () => {
7171 createWindow ( )
7272 }
7373} )
74+
75+ // new window example arg: new windows url
76+ ipcMain . handle ( "open-win" , ( event , arg ) => {
77+ const childWindow = new BrowserWindow ( {
78+ webPreferences : {
79+ preload : join ( __dirname , "../preload/index.cjs" ) ,
80+ } ,
81+ } ) ;
82+
83+ if ( app . isPackaged ) {
84+ childWindow . loadFile ( join ( __dirname , `../renderer/index.html` ) , {
85+ hash : `${ arg } ` ,
86+ } )
87+ } else {
88+ // 🚧 Use ['ENV_NAME'] avoid vite:define plugin
89+ const url = `http://${ process . env [ "VITE_DEV_SERVER_HOST" ] } :${ process . env [ "VITE_DEV_SERVER_PORT" ] } /#${ arg } `
90+ childWindow . loadURL ( url ) ;
91+ // childWindow.webContents.openDevTools({ mode: "undocked", activate: true })
92+ }
93+ } ) ;
You can’t perform that action at this time.
0 commit comments