Skip to content

Commit

Permalink
perf(electron): openElectronWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Sep 20, 2024
1 parent e3d0837 commit 2059082
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/shared/src/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ export interface OpenElectronWindowOptions {
* Work electron and browser,
* if in electron, open a new window, otherwise open a new tab
*/
export const openElectronWindow = (url: string, options: OpenElectronWindowOptions = {}) => {
if ("electron" in window) {
export const openElectronWindow = (() => ("electron" in window)
? ((url: string, options: OpenElectronWindowOptions = {}) => {
const urlObject = new URL(url)
const { searchParams } = urlObject

searchParams.set(ELECTRON_QUERY_KEY, encodeURIComponent(JSON.stringify(options)))

window.open(urlObject.toString())
} else {
})
: ((url: string) => {
// eslint-disable-next-line no-restricted-globals
window.open(url.replace(DEEPLINK_SCHEME, `${location.origin}/`))
}
}
}))()

export const extractElectronWindowOptions = (url: string): OpenElectronWindowOptions => {
try {
Expand Down

0 comments on commit 2059082

Please sign in to comment.