-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenuTemplate.js
64 lines (59 loc) · 1.7 KB
/
menuTemplate.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
const { BrowserWindow, ipcMain } = require("electron");
const path = require("path");
const Store = require("electron-store");
const store = new Store();
const renderTemplate = (mainWindow) => [
{
label: "帮助",
submenu: [
{
label: "查看输出的html",
accelerator: "CmdOrCtrl+F1",
click: () => {
let htmlStrWindow = new BrowserWindow({
width: 600,
height: 400,
parent: mainWindow,
modal: true,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
mainWindow.webContents.send("getCurHtmlStr", "start");
ipcMain.on("setCurHtmlStr", (e, m) => {
store.set("htmlStr", m);
const filePath = path.join(__dirname, "./src/htmlStr.html");
htmlStrWindow.loadFile(`${filePath}`);
// fix: object has been destroyed
htmlStrWindow.on("close", function (event) {
htmlStrWindow.hide();
event.preventDefault();
});
});
},
},
{
label: "使用文档",
accelerator: "CmdOrCtrl+F2",
click: () => {
const helpWindow = new BrowserWindow({
width: 600,
height: 400,
parent: mainWindow,
modal: true,
autoHideMenuBar: true,
});
helpWindow.loadURL("https://clydee-geng.github.io/gengEditor/");
},
},
{
role: "toggleDevTools",
label: "开发者工具",
accelerator: "CmdOrCtrl+F12",
},
],
},
];
module.exports = renderTemplate;