/**
* 窗口基類,封裝通用的窗口操作
*/
const { BrowserWindow } = require('electron');
/**
* 基本窗口樣式
* @type {{width: number, height: number, resizable: boolean, frame: boolean, parent: object, modal: boolean}}
*/
const windowStyle = {
title: '雲', // 窗口標題
width: 800, // 寬
height: 600, // 高
resizable: true, // 窗口大小是否可變
// frame: false, // 是否帶邊框
parent: null, // 父窗口
modal: false, // 是否模態窗口
show: false, // 是否顯示窗口
};
/**
* 窗口類,繼承electron的BrowserWindow
* @extends BrowserWindow
*/
class EucWindow extends BrowserWindow {
/**
* 窗口類,繼承electron的BrowserWindow
* @param style 窗口樣式
* @param url
* @param win
*/
constructor(style, url, win) {
const myStyle = Object.assign({}, windowStyle, style);
super(myStyle);
win = this;
// 阻止跳轉鏈接
this.webContents.on( 'will-navigate', (event)=>{
event.preventDefault();
});
win.webContents.openDevTools({detach:true});
// 加載網頁
this.loadURL(url);
this.on('closed', function() {
win = null;
});
}
}
module.exports = EucWindow;
