mirror of
https://github.com/zadam/trilium.git
synced 2024-11-11 18:08:13 +08:00
fix closing new window, closes #2502
This commit is contained in:
parent
003fec4b11
commit
faf81ae056
1 changed files with 9 additions and 2 deletions
|
@ -16,7 +16,10 @@ let mainWindow;
|
||||||
let setupWindow;
|
let setupWindow;
|
||||||
|
|
||||||
async function createExtraWindow(notePath, hoistedNoteId = 'root') {
|
async function createExtraWindow(notePath, hoistedNoteId = 'root') {
|
||||||
|
const spellcheckEnabled = optionService.getOptionBool('spellCheckEnabled');
|
||||||
|
|
||||||
const {BrowserWindow} = require('electron');
|
const {BrowserWindow} = require('electron');
|
||||||
|
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 800,
|
height: 800,
|
||||||
|
@ -25,7 +28,7 @@ async function createExtraWindow(notePath, hoistedNoteId = 'root') {
|
||||||
enableRemoteModule: true,
|
enableRemoteModule: true,
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
spellcheck: optionService.getOptionBool('spellCheckEnabled')
|
spellcheck: spellcheckEnabled
|
||||||
},
|
},
|
||||||
frame: optionService.getOptionBool('nativeTitleBarVisible'),
|
frame: optionService.getOptionBool('nativeTitleBarVisible'),
|
||||||
icon: getIcon()
|
icon: getIcon()
|
||||||
|
@ -33,6 +36,8 @@ async function createExtraWindow(notePath, hoistedNoteId = 'root') {
|
||||||
|
|
||||||
win.setMenuBarVisibility(false);
|
win.setMenuBarVisibility(false);
|
||||||
win.loadURL('http://127.0.0.1:' + await port + '/?extra=1&extraHoistedNoteId=' + hoistedNoteId + '#' + notePath);
|
win.loadURL('http://127.0.0.1:' + await port + '/?extra=1&extraHoistedNoteId=' + hoistedNoteId + '#' + notePath);
|
||||||
|
|
||||||
|
configureWebContents(win.webContents, spellcheckEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on('create-extra-window', (event, arg) => {
|
ipcMain.on('create-extra-window', (event, arg) => {
|
||||||
|
@ -74,8 +79,10 @@ async function createMainWindow() {
|
||||||
mainWindow.loadURL('http://127.0.0.1:' + await port);
|
mainWindow.loadURL('http://127.0.0.1:' + await port);
|
||||||
mainWindow.on('closed', () => mainWindow = null);
|
mainWindow.on('closed', () => mainWindow = null);
|
||||||
|
|
||||||
const {webContents} = mainWindow;
|
configureWebContents(mainWindow.webContents, spellcheckEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureWebContents(webContents, spellcheckEnabled) {
|
||||||
require("@electron/remote/main").enable(webContents);
|
require("@electron/remote/main").enable(webContents);
|
||||||
|
|
||||||
webContents.on('new-window', (e, url) => {
|
webContents.on('new-window', (e, url) => {
|
||||||
|
|
Loading…
Reference in a new issue