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:
parent
b3da0be465
commit
8678d93583
12
main/app.ts
12
main/app.ts
@ -1,5 +1,5 @@
|
|||||||
import * as path from 'path';
|
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 windowState = require('electron-window-state');
|
||||||
import * as menubar from 'menubar';
|
import * as menubar from 'menubar';
|
||||||
import log from './log';
|
import log from './log';
|
||||||
@ -23,6 +23,16 @@ export class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open() {
|
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.loadURL(`https://${this.account.host}${this.account.default_page}`);
|
||||||
this.win.show();
|
this.win.show();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// import * as Mousetrap from 'mousetrap';
|
import * as Mousetrap from 'mousetrap';
|
||||||
import {Config} from '../main/config';
|
import {Config} from '../main/config';
|
||||||
import * as Ipc from './ipc';
|
import * as Ipc from './ipc';
|
||||||
import log from './log';
|
import log from './log';
|
||||||
|
@ -5,7 +5,7 @@ const ipc = electron.ipcRenderer;
|
|||||||
|
|
||||||
export function on(channel: IpcChannel, callback: Function) {
|
export function on(channel: IpcChannel, callback: Function) {
|
||||||
ipc.on(channel, (...args: any[]) => {
|
ipc.on(channel, (...args: any[]) => {
|
||||||
log.info('IPC: Received from:', channel, args);
|
log.debug('IPC: Received from:', channel, args);
|
||||||
callback(...args);
|
callback(...args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user