Skip to content

Commit

Permalink
fix: curseforge & modrinth page cannot be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Oct 29, 2023
1 parent 1496328 commit 2a292c8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions xmcl-electron-app/main/ElectronController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ export class ElectronController implements LauncherAppController {
private settings: Settings | undefined

private windowOpenHandler: Parameters<WebContents['setWindowOpenHandler']>[0] = (detail: HandlerDetails) => {
if (detail.frameName === 'browser' || detail.disposition === 'background-tab') {
shell.openExternal(detail.url)
} else if (detail.frameName === '' || detail.frameName === 'app') {
const url = new URL(detail.url)
if (url.host === 'app' || detail.frameName === '' || detail.frameName === 'app') {
const man = this.activatedManifest!
return {
action: 'allow',
Expand All @@ -81,6 +80,8 @@ export class ElectronController implements LauncherAppController {
},
}
}

shell.openExternal(detail.url)
return { action: 'deny' }
}

Expand All @@ -95,10 +96,7 @@ export class ElectronController implements LauncherAppController {
}

private onWebContentWillNavigate = (event: Event, url: string) => {
if (!IS_DEV) {
event.preventDefault()
shell.openExternal(url)
} else if (!url.startsWith('http://localhost') && !url.startsWith('http://app')) {
if (!url.startsWith(IS_DEV ? 'http://localhost' : 'http://app')) {
event.preventDefault()
shell.openExternal(url)
}
Expand Down

0 comments on commit 2a292c8

Please sign in to comment.