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
@@ -68,3 +68,23 @@ app.on('activate', () => {
6868 createWindow ( )
6969 }
7070} )
71+
72+ // new window example arg: new windows url
73+ ipcMain . handle ( "open-win" , ( event , arg ) => {
74+ const childWindow = new BrowserWindow ( {
75+ webPreferences : {
76+ preload : join ( __dirname , "../preload/index.cjs" ) ,
77+ } ,
78+ } ) ;
79+
80+ if ( app . isPackaged ) {
81+ childWindow . loadFile ( join ( __dirname , `../renderer/index.html` ) , {
82+ hash : `${ arg } ` ,
83+ } )
84+ } else {
85+ // 🚧 Use ['ENV_NAME'] avoid vite:define plugin
86+ const url = `http://${ process . env [ "VITE_DEV_SERVER_HOST" ] } :${ process . env [ "VITE_DEV_SERVER_PORT" ] } /#${ arg . url } `
87+ childWindow . loadURL ( url ) ;
88+ childWindow . webContents . openDevTools ( { mode : "undocked" , activate : true } )
89+ }
90+ } ) ;
You can’t perform that action at this time.
0 commit comments