ctrl+w=close window & minor fixes
This commit is contained in:
parent
17ac77ce9e
commit
1750909f24
5 changed files with 26 additions and 19 deletions
|
|
@ -1,4 +1,4 @@
|
|||
var {app, Menu, shell} = require('electron'),
|
||||
var {app, Menu, shell, BrowserWindow} = require('electron'),
|
||||
settings = require('./settings'),
|
||||
infos = require('../package.json')
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ var template = [{
|
|||
}]
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
// Add app menu (OS X)
|
||||
// Add app menu (macOs)
|
||||
template.unshift({
|
||||
label: settings.read('appName'),
|
||||
submenu: [
|
||||
|
|
@ -54,7 +54,7 @@ if (process.platform === 'darwin') {
|
|||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
accelerator: 'Command+Q',
|
||||
accelerator: 'CmdOrCtrl+Q',
|
||||
click: ()=>app.quit()
|
||||
}
|
||||
]
|
||||
|
|
@ -72,10 +72,21 @@ if (process.platform === 'darwin') {
|
|||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: 'CmdOrCtrl+W',
|
||||
click: ()=>{
|
||||
var win = BrowserWindow.getFocusedWindow()
|
||||
if (win) win.close()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Bring All to Front',
|
||||
role: 'front'
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,16 +57,8 @@ module.exports = function(options={}) {
|
|||
shell.openExternal(url)
|
||||
})
|
||||
|
||||
// window.webContents.on('dom-ready', ()=>{
|
||||
// window.webContents.executeJavaScript(`
|
||||
// window.ELECTRON = true
|
||||
// `)
|
||||
// })
|
||||
|
||||
if (options.zoom === false) {
|
||||
window.webContents.setVisualZoomLevelLimits(1, 1)
|
||||
}
|
||||
|
||||
window.webContents.setVisualZoomLevelLimits(1, 1)
|
||||
|
||||
window.on('closed', function() {
|
||||
window = null
|
||||
|
|
@ -76,6 +68,13 @@ module.exports = function(options={}) {
|
|||
|
||||
window.loadURL(options.address)
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
// already registered in app menu on macOs
|
||||
shortcut.register(window,'CmdOrCtrl+W',function(){
|
||||
window.close()
|
||||
})
|
||||
}
|
||||
|
||||
if (options.shortcuts) {
|
||||
|
||||
shortcut.register(window,'CmdOrCtrl+R',function(){
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ function openClient() {
|
|||
address += settings.read('urlOptions')
|
||||
|
||||
var launch = ()=>{
|
||||
var win = require('./electron-window')({address:address, shortcuts:true, zoom:false, fullscreen: settings.read('fullScreen')})
|
||||
var win = require('./electron-window')({address:address, shortcuts:true, fullscreen: settings.read('fullScreen')})
|
||||
win.on('error', ()=>{
|
||||
console.log('ERR')
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue