1
0
mirror of https://github.com/rhysd/Mstdn.git synced 2025-02-02 06:52:13 +01:00

avoid crash problem at preventing 'new-window' event (#1)

https://github.com/electron/electron/issues/9230
This commit is contained in:
rhysd 2017-04-20 00:06:23 +09:00
parent 952be70e4d
commit 4169bcf902
3 changed files with 10 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import {app} from 'electron';
export const IS_DEBUG = process.env.NODE_ENV === 'development'; export const IS_DEBUG = process.env.NODE_ENV === 'development';
export const IS_DARWIN = process.platform === 'darwin'; export const IS_DARWIN = process.platform === 'darwin';
export const IS_WINDOWS = process.platform === 'win32'; export const IS_WINDOWS = process.platform === 'win32';
export const IS_LINUX = process.platform === 'linux';
export const APP_ICON = path.join(__dirname, '..', 'resources', 'icon', 'icon.png'); export const APP_ICON = path.join(__dirname, '..', 'resources', 'icon', 'icon.png');
export const PRELOAD_JS = path.join(__dirname, '..', 'renderer', 'preload.js'); export const PRELOAD_JS = path.join(__dirname, '..', 'renderer', 'preload.js');
export const DATA_DIR = app.getPath('userData'); export const DATA_DIR = app.getPath('userData');

View File

@ -4,7 +4,9 @@ import * as menubar from 'menubar';
import {Config, Account} from './config'; import {Config, Account} from './config';
import {partitionForAccount} from './account_switcher'; import {partitionForAccount} from './account_switcher';
import log from './log'; import log from './log';
import {IS_DEBUG, IS_DARWIN, IS_WINDOWS, APP_ICON, PRELOAD_JS, trayIcon} from './common'; import {IS_DEBUG, IS_DARWIN, IS_WINDOWS, IS_LINUX, APP_ICON, PRELOAD_JS, trayIcon} from './common';
const ELECTRON_ISSUE_9230 = IS_WINDOWS || IS_LINUX;
export default class Window { export default class Window {
static create(account: Account, config: Config, mb: Menubar.MenubarApp | null = null) { static create(account: Account, config: Config, mb: Menubar.MenubarApp | null = null) {
@ -34,9 +36,10 @@ export default class Window {
log.debug('Opened URL with external browser (will-navigate)', url); log.debug('Opened URL with external browser (will-navigate)', url);
}); });
browser.webContents.on('new-window', (e, url) => { browser.webContents.on('new-window', (e, url) => {
if (IS_WINDOWS) { if (ELECTRON_ISSUE_9230) {
// XXX: // XXX:
// On Windows, rel="noopener" lets app crash on preventing the event. // On Windows or Linux, rel="noopener" lets app crash on preventing the event.
// Issue: https://github.com/electron/electron/issues/9230
return; return;
} }
e.preventDefault(); e.preventDefault();

View File

@ -37,12 +37,12 @@
}, },
"homepage": "https://github.com/rhysd/Mstdn#readme", "homepage": "https://github.com/rhysd/Mstdn#readme",
"devDependencies": { "devDependencies": {
"@types/electron": "^1.4.35", "@types/electron": "^1.4.37",
"@types/electron-window-state": "^2.0.28", "@types/electron-window-state": "^2.0.28",
"@types/loglevel": "^1.4.29", "@types/loglevel": "^1.4.29",
"@types/menubar": "^5.1.3", "@types/menubar": "^5.1.3",
"@types/mousetrap": "^1.5.33", "@types/mousetrap": "^1.5.33",
"@types/node": "^7.0.12", "@types/node": "^7.0.13",
"browserify": "^14.3.0", "browserify": "^14.3.0",
"electron-packager": "^8.6.0", "electron-packager": "^8.6.0",
"npm-run-all": "^4.0.2", "npm-run-all": "^4.0.2",
@ -50,7 +50,7 @@
"typescript": "^2.2.2" "typescript": "^2.2.2"
}, },
"dependencies": { "dependencies": {
"electron": "^1.6.2", "electron": "^1.6.5",
"electron-window-state": "^4.1.1", "electron-window-state": "^4.1.1",
"loglevel": "^1.4.1", "loglevel": "^1.4.1",
"menubar": "github:rhysd/menubar#mstdn", "menubar": "github:rhysd/menubar#mstdn",