forked from OtterMind/Chat2DB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.js
More file actions
148 lines (146 loc) · 4 KB
/
Copy pathmenu.js
File metadata and controls
148 lines (146 loc) · 4 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const { shell, app, dialog, BrowserWindow, Menu } = require('electron');
const os = require('os');
const path = require('path');
const { isMac } = require('./utils');
const registerAppMenu = (mainWindow, orgs) => {
if (!isMac) {
Menu.setApplicationMenu(null);
return;
}
const menuBar = [
{
label: 'Chat2DB',
submenu: [
{
label: '关于Chat2DB',
click() {
dialog.showMessageBox({
title: '关于Chat2DB',
message: `关于Chat2DB v${orgs?.version || app.getVersion()}`,
detail:
// An intelligent database client and smart BI reporting tool with integrated AI capabilities.
'一个集成AI能力的智能数据库客户端和智能BI报表工具。',
icon: './logo/icon.png',
});
},
},
{ type: 'separator' },
{
label: '重新启动',
click() {
// 退出程序
app.relaunch();
app.quit();
},
},
{
label: '退出',
accelerator: process.platform === 'darwin' ? 'Cmd+Q' : 'Alt+F4',
click() {
// 退出程序
app.quit();
},
},
],
},
{
label: '编辑',
submenu: [
{ label: '撤销', role: 'undo' },
{ label: '重做', role: 'redo' },
{ type: 'separator' },
{ label: '剪切', role: 'cut' },
{ label: '复制', role: 'copy' },
{ label: '粘贴', role: 'paste' },
{ label: '全选', role: 'selectAll' },
],
},
{
// label: i18n('menu.edit'),
label: '视图',
submenu: [
// {
// label: '刷新',
// accelerator: 'CmdOrCtrl+Shift+R',
// click() {
// const focusedWindow = BrowserWindow.getFocusedWindow();
// if (focusedWindow) {
// focusedWindow.reload();
// }
// },
// },
{ type: 'separator' },
{
label: '放大',
accelerator: 'CmdOrCtrl+=',
role: 'zoomIn',
},
{
label: '缩小',
accelerator: 'CmdOrCtrl+-',
role: 'zoomOut',
},
{
label: '重置',
accelerator: 'CmdOrCtrl+0',
role: 'resetZoom',
},
{ type: 'separator' },
{ label: '全屏', role: 'togglefullscreen' },
],
},
{
label: '窗口',
role: 'window',
submenu: [
{ label: '最小化', role: 'minimize', accelerator: 'Command+W' },
{ label: '关闭', role: 'close' },
],
},
{
label: '帮助',
submenu: [
{
label: '打开日志',
accelerator: process.platform === 'darwin' ? 'Cmd+Shift+T' : 'Ctrl+Shift+T',
click() {
const fileName = '.chat2db/logs/application.log';
const url = path.join(os.homedir(), fileName);
shell.openPath(url).then((str) => console.log('err:', str));
},
},
{
label: '打开控制台',
accelerator: process.platform === 'darwin' ? 'Cmd+Shift+I' : 'Ctrl+Shift+I',
click() {
const focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow && focusedWindow.toggleDevTools();
},
},
{
label: '访问官网',
click() {
const url = 'https://www.sqlgpt.cn/zh';
shell.openExternal(url);
},
},
{
label: '查看文档',
click() {
const url = 'https://doc.sqlgpt.cn/zh/';
shell.openExternal(url);
},
},
{
label: '查看更新日志',
click() {
const url = 'https://doc.sqlgpt.cn/zh/changelog/';
shell.openExternal(url);
},
},
],
},
];
Menu.setApplicationMenu(Menu.buildFromTemplate(menuBar));
};
module.exports = registerAppMenu;