@@ -19,6 +19,7 @@ import useServices from '@/database/useServices'
19
19
import { dialog } from 'electron'
20
20
import ORMConfig from './database/database.config'
21
21
import version from '@/version'
22
+ import { initialize } from '@electron/remote/main'
22
23
23
24
declare const __static : string
24
25
@@ -39,8 +40,6 @@ let menu: Menu | null
39
40
// Scheme must be registered before the app is ready
40
41
protocol . registerSchemesAsPrivileged ( [ { scheme : 'app' , privileges : { secure : true , standard : true } } ] )
41
42
42
- app . allowRendererProcessReuse = false
43
-
44
43
const { ConnectionInit, ConnectionDestroy } = useConnection ( )
45
44
46
45
function handleIpcMessages ( ) {
@@ -170,7 +169,6 @@ async function createWindow() {
170
169
webPreferences : {
171
170
devTools : isDevelopment ,
172
171
webSecurity : false ,
173
- enableRemoteModule : true ,
174
172
nodeIntegration : true ,
175
173
contextIsolation : false ,
176
174
} ,
@@ -179,6 +177,12 @@ async function createWindow() {
179
177
icon : `${ __static } /app.ico` ,
180
178
} )
181
179
180
+ // 初始化 @electron/remote
181
+ initialize ( )
182
+ if ( win ) {
183
+ require ( '@electron/remote/main' ) . enable ( win . webContents )
184
+ }
185
+
182
186
// Restore window state
183
187
restoreWindowState ( win )
184
188
@@ -268,12 +272,9 @@ app.on('activate', () => {
268
272
269
273
// Disabled create new window
270
274
app . on ( 'web-contents-created' , ( event , contents ) => {
271
- // tslint:disable-next-line:no-shadowed-variable
272
- contents . on ( 'new-window' , async ( event , navigationUrl ) => {
273
- // In this example, we'll ask the operating system
274
- // to open this event's url in the default browser.
275
- event . preventDefault ( )
276
- await shell . openExternal ( navigationUrl )
275
+ contents . setWindowOpenHandler ( ( { url } ) => {
276
+ shell . openExternal ( url )
277
+ return { action : 'deny' }
277
278
} )
278
279
} )
279
280
0 commit comments