-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70229a4
commit 0c42193
Showing
9 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { app, BrowserWindow, ipcMain } from 'electron' | ||
import path from 'path' | ||
|
||
let initialDeepLinkUri: string | undefined = undefined | ||
let hasDeeplink: boolean = false | ||
|
||
export function registerNeonDeeplink() { | ||
if (process.defaultApp) { | ||
if (process.argv.length >= 2) { | ||
app.setAsDefaultProtocolClient('neon', process.execPath, [path.resolve(process.argv[1])]) | ||
} | ||
} else { | ||
app.setAsDefaultProtocolClient('neon') | ||
} | ||
} | ||
|
||
export function sendDeeplink(mainWindow: BrowserWindow, deeplinkUrl: string | undefined) { | ||
if (deeplinkUrl) { | ||
mainWindow.webContents.send('deeplink', deeplinkUrl) | ||
} | ||
} | ||
|
||
export function setDeeplink(deeplinkUrl: string | undefined) { | ||
initialDeepLinkUri = deeplinkUrl | ||
} | ||
|
||
export function registerOpenUrl(mainWindow: BrowserWindow | null) { | ||
app.on('open-url', (_event, url) => { | ||
if (!mainWindow) { | ||
initialDeepLinkUri = url | ||
hasDeeplink = true | ||
return | ||
} | ||
|
||
mainWindow.webContents.send('deeplink', url) | ||
}) | ||
} | ||
|
||
export function registerDeeplinkHandler() { | ||
ipcMain.handle('getInitialDeepLinkUri', async () => { | ||
const uri = initialDeepLinkUri | ||
initialDeepLinkUri = undefined | ||
hasDeeplink = false | ||
return uri | ||
}) | ||
|
||
ipcMain.handle('hasDeeplink', async () => { | ||
return hasDeeplink | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters