Refactor(Window): Automatically show application
Automatically show application when opening the tool from a browser
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { app, shell, BrowserWindow, ipcMain, webContents } from 'electron'
|
import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||||
import icon from '../../resources/logo.ico?asset'
|
import icon from '../../resources/logo.ico?asset'
|
||||||
@@ -31,10 +31,9 @@ const handleArgv = (argv: string[]) => {
|
|||||||
|
|
||||||
const handleUrl = (url: string) => {
|
const handleUrl = (url: string) => {
|
||||||
const { hostname, pathname } = new URL(url)
|
const { hostname, pathname } = new URL(url)
|
||||||
if (hostname === 'openurl') {
|
if (hostname === 'openurl' && mainWindow) {
|
||||||
webContents.getAllWebContents().forEach((webContent) => {
|
mainWindow.webContents.send('open-url', pathname)
|
||||||
webContent.send('open-url', pathname)
|
mainWindow.show()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user