mirror of
https://github.com/rhysd/Mstdn.git
synced 2025-01-21 20:52:11 +01:00
do not crash on external link on Windows
This commit is contained in:
parent
1fd663a93c
commit
edfe81e06a
@ -3,6 +3,7 @@ import {app} from 'electron';
|
||||
|
||||
export const IS_DEBUG = process.env.NODE_ENV === 'development';
|
||||
export const IS_DARWIN = process.platform === 'darwin';
|
||||
export const IS_WINDOWS = process.platform === 'win32';
|
||||
export const APP_ICON = path.join(__dirname, '..', 'resources', 'icon', 'icon.png');
|
||||
export const PRELOAD_JS = path.join(__dirname, '..', 'renderer', 'preload.js');
|
||||
export const DATA_DIR = app.getPath('userData');
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {app, systemPreferences, dialog, shell} from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import log from './log';
|
||||
import {CONFIG_FILE} from './common';
|
||||
import {CONFIG_FILE, IS_DARWIN, IS_WINDOWS} from './common';
|
||||
|
||||
export interface Account {
|
||||
host: string;
|
||||
@ -20,8 +20,8 @@ export interface Config {
|
||||
}
|
||||
|
||||
function makeDefaultConfig(): Config {
|
||||
const IsDarkMode = (process.platform === 'darwin') && systemPreferences.isDarkMode();
|
||||
const menubarBroken = process.platform === 'win32';
|
||||
const IsDarkMode = IS_DARWIN && systemPreferences.isDarkMode();
|
||||
const menubarBroken = IS_WINDOWS;
|
||||
|
||||
return {
|
||||
hot_key: 'CmdOrCtrl+Shift+S',
|
||||
|
@ -4,7 +4,7 @@ import * as menubar from 'menubar';
|
||||
import {Config, Account} from './config';
|
||||
import {partitionForAccount} from './account_switcher';
|
||||
import log from './log';
|
||||
import {IS_DEBUG, IS_DARWIN, APP_ICON, PRELOAD_JS, trayIcon} from './common';
|
||||
import {IS_DEBUG, IS_DARWIN, IS_WINDOWS, APP_ICON, PRELOAD_JS, trayIcon} from './common';
|
||||
|
||||
export default class Window {
|
||||
static create(account: Account, config: Config, mb: Menubar.MenubarApp | null = null) {
|
||||
@ -34,6 +34,11 @@ export default class Window {
|
||||
log.debug('Opened URL with external browser (will-navigate)', url);
|
||||
});
|
||||
browser.webContents.on('new-window', (e, url) => {
|
||||
if (IS_WINDOWS) {
|
||||
// XXX:
|
||||
// On Windows, rel="noopener" lets app crash on preventing the event.
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
shell.openExternal(url);
|
||||
log.debug('Opened URL with external browser (new-window)', url);
|
||||
|
Loading…
x
Reference in New Issue
Block a user