-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
61 lines (52 loc) · 1.4 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* electron load js
* @authors Orz
* @date 2016-04-18 15:30:58
* @version $Id$
*/
'use strict';
global.ROOT = __dirname;
const electron = require('electron');
const {BrowserWindow} = electron;
const {app} = electron;
const ipcMain = require('electron').ipcMain;
var mainWindow = null;
// 生成窗口
app.on('ready', function() {
mainWindow = new BrowserWindow({
height: 800,
width: 600,
autoHideMenuBar: true,
useContentSize: true,
frame: false,
resizable: true,
title: "翰林浏览器",
});
// 载入主显示文件
mainWindow.loadURL('file://' + __dirname + '/views/index.html');
mainWindow.center();
});
// 获取窗口大小
ipcMain.on('get-window-size', function (event, arg) {
event.returnValue = mainWindow.getSize();
});
// 关闭窗口
ipcMain.on('close-main-window', function (event) {
mainWindow.close();
});
// 最小化窗口
ipcMain.on('minimize-main-window', function (event) {
mainWindow.minimize();
});
// 最大化窗口
ipcMain.on('maximize-main-window', function (event) {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize();
}else {
mainWindow.maximize();
}
});
// 获取版本号
ipcMain.on('get-pro-version', function (event, arg) {
event.returnValue = app.getVersion();
});