1
1
const { app, BrowserWindow, Menu, ipcMain, dialog } = require ( 'electron' )
2
2
const path = require ( 'path' )
3
3
const fs = require ( 'fs' )
4
+ const join = require ( 'path' ) . join
5
+ const openAboutWindow = require ( 'about-window' ) . default
4
6
5
7
let win = null // main window
6
8
@@ -98,11 +100,12 @@ function createWindow () {
98
100
// TODO: Loading splash screen
99
101
100
102
const isMac = process . platform === 'darwin'
103
+ const isDev = ! app . isPackaged
101
104
const template = [
102
105
...( isMac ? [ {
103
106
label : app . name ,
104
107
submenu : [
105
- { role : 'about' } ,
108
+ { role : 'about' } ,
106
109
{ type : 'separator' } ,
107
110
{ role : 'services' } ,
108
111
{ type : 'separator' } ,
@@ -154,7 +157,12 @@ const template = [
154
157
{ role : 'zoomIn' } ,
155
158
{ role : 'zoomOut' } ,
156
159
{ type : 'separator' } ,
157
- { role : 'togglefullscreen' }
160
+ { role : 'togglefullscreen' } ,
161
+ ...( isDev ? [
162
+ { type : 'separator' } ,
163
+ { role : 'toggleDevTools' } ,
164
+ ] :[
165
+ ] )
158
166
]
159
167
} ,
160
168
{
@@ -179,21 +187,53 @@ const template = [
179
187
label : 'Learn More' ,
180
188
click : async ( ) => {
181
189
const { shell } = require ( 'electron' )
182
- await shell . openExternal ( 'https://www. arduino.cc/ ' )
190
+ await shell . openExternal ( 'https://github.com/ arduino/MicroPython_Lab ' )
183
191
}
184
192
} ,
185
193
{
186
- label : 'About ' ,
194
+ label : 'Report an issue ' ,
187
195
click : async ( ) => {
188
196
const { shell } = require ( 'electron' )
189
- await shell . openExternal ( 'https://www. arduino.cc/ ' )
197
+ await shell . openExternal ( 'https://github.com/ arduino/MicroPython_Lab/issues ' )
190
198
}
191
199
} ,
200
+ {
201
+ label :'Info about this app' ,
202
+ click : ( ) => {
203
+ openAboutWindow ( {
204
+ icon_path : join ( __dirname , 'ui/arduino/assets/about_image.png' ) ,
205
+ css_path : join ( __dirname , 'ui/arduino/about.css' ) ,
206
+ copyright : '© Arduino SA 2022' ,
207
+ package_json_dir : __dirname ,
208
+ bug_report_url : "https://github.com/arduino/MicroPython_Lab/issues" ,
209
+ bug_link_text : "report an issue" ,
210
+ homepage : "https://labs.arduino.cc" ,
211
+ use_version_info : false ,
212
+ win_options : {
213
+ parent : win ,
214
+ modal : true ,
215
+ } ,
216
+ show_close_button : 'Close' ,
217
+ } )
218
+ }
219
+ } ,
192
220
]
193
221
}
194
222
]
195
223
196
224
const menu = Menu . buildFromTemplate ( template )
225
+
226
+ app . setAboutPanelOptions ( {
227
+ applicationName : app . name ,
228
+ applicationVersion : app . getVersion ( ) ,
229
+ copyright : app . copyright ,
230
+ credits : '(See "Info about this app" in the Help menu)' ,
231
+ authors : [ 'Arduino' ] ,
232
+ website : 'https://arduino.cc' ,
233
+ iconPath : path . join ( __dirname , '../assets/image.png' ) ,
234
+ } )
235
+
197
236
Menu . setApplicationMenu ( menu )
198
237
238
+
199
239
app . whenReady ( ) . then ( createWindow )
0 commit comments