1
0
mirror of https://github.com/rhysd/Mstdn.git synced 2025-01-20 19:52:10 +01:00

open external URLs in external browser

This commit is contained in:
rhysd 2017-04-16 02:57:54 +09:00
parent b3da0be465
commit 8678d93583
3 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import * as path from 'path';
import {app, BrowserWindow, globalShortcut, Tray} from 'electron';
import {app, BrowserWindow, globalShortcut, Tray, shell} from 'electron';
import windowState = require('electron-window-state');
import * as menubar from 'menubar';
import log from './log';
@ -23,6 +23,16 @@ export class App {
}
open() {
this.win.webContents.on('will-navigate', (e, url) => {
if (!url.startsWith(`https://${this.account.host}`)) {
e.preventDefault();
shell.openExternal(url);
}
});
this.win.webContents.on('new-window', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});
this.win.loadURL(`https://${this.account.host}${this.account.default_page}`);
this.win.show();
}

View File

@ -1,4 +1,4 @@
// import * as Mousetrap from 'mousetrap';
import * as Mousetrap from 'mousetrap';
import {Config} from '../main/config';
import * as Ipc from './ipc';
import log from './log';

View File

@ -5,7 +5,7 @@ const ipc = electron.ipcRenderer;
export function on(channel: IpcChannel, callback: Function) {
ipc.on(channel, (...args: any[]) => {
log.info('IPC: Received from:', channel, args);
log.debug('IPC: Received from:', channel, args);
callback(...args);
});
}