-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
58 lines (47 loc) · 1.22 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
const { app, shell, BrowserWindow, Menu } = require('electron')
const { currentEnv } = require('./config/menu')
const { getUrl } = require('./utils');
const { checkForUpdate } = require('./auto_updater');
let win = null;
// 菜单栏配置
function createWindow() {
// 创建浏览器窗口
win = new BrowserWindow({
width: 1200,
height: 800,
minWidth: 320,
minHeight: 568,
webPreferences: {
nodeIntegration: true
},
enableRemoteModule: false,
})
// 客户端userAgent
const userAgent = `${win.webContents.userAgent} VikaDesktop/${process.env['npm_package_version']}`;
win.loadURL(getUrl(currentEnv), {
userAgent,
})
win.webContents.once('dom-ready', () => {
// 检查更新
checkForUpdate()
})
}
app.on('ready', createWindow)
app.setAppUserModelId("维格表")
//当所有窗口都被关闭后退出
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
app.on('web-contents-created', (e, webContents) => {
webContents.on('new-window', (event, url) => {
event.preventDefault();
shell.openExternal(url);
});
});