@@ -61,51 +61,9 @@ if (!gotTheLock) {
6161 }
6262 }
6363
64- // Register protocol
65- app . setAsDefaultProtocolClient ( 'webcatalog' ) ;
66-
6764 loadListeners ( ) ;
6865 loadInvokers ( ) ;
6966
70- // mock app.whenReady
71- let trulyReady = false ;
72- ipcMain . once ( 'truly-ready' , ( ) => { trulyReady = true ; } ) ;
73- const whenTrulyReady = ( ) => {
74- if ( trulyReady ) return Promise . resolve ( ) ;
75- return new Promise ( ( resolve ) => {
76- ipcMain . once ( 'truly-ready' , ( ) => {
77- trulyReady = true ;
78- resolve ( ) ;
79- } ) ;
80- } ) ;
81- } ;
82-
83- const handleOpenUrl = ( urlStr ) => {
84- whenTrulyReady ( )
85- . then ( ( ) => {
86- if ( urlStr . startsWith ( 'webcatalog://catalog/' ) ) {
87- let appId ;
88- try {
89- appId = urlStr . replace ( 'webcatalog://catalog/' , '' ) ;
90- } catch ( err ) {
91- // eslint-disable-next-line no-console
92- console . log ( err ) ;
93- }
94- if ( appId ) {
95- mainWindow . send ( 'open-dialog-catalog-app-details' , appId ) ;
96- }
97- }
98- } ) ;
99- } ;
100-
101- const handleArgv = ( argv ) => {
102- if ( argv . length <= 1 ) return ;
103- const urlStr = argv . find ( ( a ) => a . startsWith ( 'webcatalog:' ) ) ;
104- if ( urlStr ) {
105- handleOpenUrl ( urlStr ) ;
106- }
107- } ;
108-
10967 app . on ( 'ready' , ( ) => {
11068 // https://github.com/electron/electron/issues/23757
11169 protocol . registerFileProtocol ( 'file' , ( request , callback ) => {
@@ -136,12 +94,6 @@ if (!gotTheLock) {
13694 // trigger whenFullyReady
13795 ipcMain . emit ( 'truly-ready' ) ;
13896
139- // handle protocols on Windows & Linux
140- // on macOS, use 'open-url' event
141- if ( process . platform !== 'darwin' ) {
142- handleArgv ( process . argv ) ;
143- }
144-
14597 const win = mainWindow . get ( ) ;
14698 mainWindow . get ( ) . on ( 'focus' , ( ) => {
14799 win . send ( 'log-focus' ) ;
@@ -193,23 +145,11 @@ if (!gotTheLock) {
193145 . then ( ( ) => mainWindow . show ( ) ) ;
194146 } ) ;
195147
196- app . on ( 'open-url' , ( e , urlStr ) => {
197- e . preventDefault ( ) ;
198-
199- handleOpenUrl ( urlStr ) ;
200- } ) ;
201-
202- app . on ( 'second-instance' , ( e , argv ) => {
148+ app . on ( 'second-instance' , ( ) => {
203149 const win = mainWindow . get ( ) ;
204150 if ( win != null ) {
205151 if ( win . isMinimized ( ) ) win . restore ( ) ;
206152 win . show ( ) ;
207153 }
208-
209- // handle protocols on Windows & Linux
210- // on macOS, use 'open-url' event
211- if ( process . platform !== 'darwin' ) {
212- handleArgv ( argv ) ;
213- }
214154 } ) ;
215155}
0 commit comments