-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathmain.js
113 lines (108 loc) · 3.31 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const { app, BrowserWindow, Menu } = require('electron');
const Update = require('./main/update');
const isMac = process.platform === 'darwin';
const path = require('path');
global.Win = null;
function createWindow() {
// 创建浏览器窗口
let win = new BrowserWindow({
width: 400,
height: 300,
acceptFirstMouse: true,
webPreferences: {
nodeIntegration: true,
preload: path.resolve(__dirname, './renderer/preload.js'),
},
show: false,
backgroundColor: '#24292e',
});
win.once('ready-to-show', function () {
win.show();
Update.check();
});
// 加载index.html文件
win.loadFile('renderer/index.html');
global.Win = win;
}
app.whenReady().then(createWindow);
template = [
...(isMac
? [
{
label: app.name,
submenu: [
{ role: 'about', label: '关于' },
{ type: 'separator' },
{ type: 'separator' },
{ role: 'hide', label: '隐藏' },
{ role: 'hideOthers', label: '隐藏其他' },
{ role: 'unhide', label: '显示' },
{ type: 'separator' },
{ role: 'quit', label: '退出' },
],
},
]
: []),
// { role: 'fileMenu' }
// { role: 'editMenu' }
// {
// label: 'Edit',
// submenu: [
// { role: 'undo' },
// { role: 'redo' },
// { type: 'separator' },
// { role: 'cut' },
// { role: 'copy' },
// { role: 'paste' },
// ...(isMac
// ? [
// { role: 'pasteAndMatchStyle' },
// { role: 'delete' },
// { role: 'selectAll' },
// { type: 'separator' },
// {
// label: 'Speech',
// submenu: [
// { role: 'startSpeaking' },
// { role: 'stopSpeaking' },
// ],
// },
// ]
// : [
// { role: 'delete' },
// { type: 'separator' },
// { role: 'selectAll' },
// ]),
// ],
// },
// { role: 'viewMenu' }
// { role: 'windowMenu' }
{
label: '窗口',
submenu: [
{ role: 'minimize' , label: '最小化'},
{ role: 'zoom', label: '缩放' },
...(isMac
? [
{ type: 'separator' },
{ role: 'front' , label: '前置'},
]
: [{ role: 'close' , label: '关于'}]),
],
},
{
label: '帮助',
role: 'help',
submenu: [
{
label: '了解更多',
click: async () => {
const { shell } = require('electron');
await shell.openExternal('https://focusbe.github.io/tinyImage/');
},
},
],
},
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);