Merge pull request #147 from ente-io/open-external-link-in-browser
open non desktop specific URLs in external browser
This commit is contained in:
commit
fe65252a5e
2 changed files with 13 additions and 0 deletions
|
@ -14,6 +14,7 @@ import {
|
||||||
handleDockIconHideOnAutoLaunch,
|
handleDockIconHideOnAutoLaunch,
|
||||||
handleUpdates,
|
handleUpdates,
|
||||||
logSystemInfo,
|
logSystemInfo,
|
||||||
|
handleExternalLinks,
|
||||||
} from './utils/main';
|
} from './utils/main';
|
||||||
import { initSentry } from './services/sentry';
|
import { initSentry } from './services/sentry';
|
||||||
import { setupLogging } from './utils/logging';
|
import { setupLogging } from './utils/logging';
|
||||||
|
@ -79,6 +80,7 @@ if (!gotTheLock) {
|
||||||
setupIpcComs(tray, mainWindow, watcher);
|
setupIpcComs(tray, mainWindow, watcher);
|
||||||
handleUpdates(mainWindow);
|
handleUpdates(mainWindow);
|
||||||
handleDownloads(mainWindow);
|
handleDownloads(mainWindow);
|
||||||
|
handleExternalLinks(mainWindow);
|
||||||
addAllowOriginHeader(mainWindow);
|
addAllowOriginHeader(mainWindow);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -104,3 +104,14 @@ export function logSystemInfo() {
|
||||||
const osRelease = os.release();
|
const osRelease = os.release();
|
||||||
ElectronLog.info({ osName, osRelease, systemVersion });
|
ElectronLog.info({ osName, osRelease, systemVersion });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function handleExternalLinks(mainWindow: BrowserWindow) {
|
||||||
|
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
||||||
|
if (!url.startsWith(PROD_HOST_URL)) {
|
||||||
|
require('electron').shell.openExternal(url);
|
||||||
|
return { action: 'deny' };
|
||||||
|
} else {
|
||||||
|
return { action: 'allow' };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue