epub-reader/src/tools/window.js

77 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-12-31 12:19:49 +08:00
/**
*
* @author yutent<yutent.io@gmail.com>
* @date 2020/12/10 14:57:49
*/
const { BrowserWindow } = require('electron')
/**
* 应用主窗口
*/
exports.createMainWindow = function(icon) {
var win = new BrowserWindow({
title: '搞基数据',
width: 1024,
height: 540,
frame: false,
titleBarStyle: 'hiddenInset',
resizable: false,
maximizable: false,
icon,
transparent: true,
vibrancy: 'hud',
visualEffectState: 'active',
webPreferences: {
// webSecurity: false,
experimentalFeatures: true,
nodeIntegration: true,
spellcheck: false
},
show: false
})
win.loadURL('app://local/index.html')
// win.on('ready-to-show', _ => {
// win.show()
// win.openDevTools()
// })
win.on('close', ev => {
ev.preventDefault()
win.hide()
})
return win
}
// 创建悬浮窗口
exports.createFloatWindow = function() {
var win = new BrowserWindow({
width: 280,
height: 360,
resizable: false,
maximizable: false,
frame: false,
show: false,
vibrancy: 'hud',
visualEffectState: 'active',
webPreferences: {
experimentalFeatures: true,
nodeIntegration: true,
spellcheck: false
}
})
// win.openDevTools()
win.on('blur', ev => {
win.hide()
})
win.loadURL('app://local/float.html')
return win
}