-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#10 fix save file and read code from file issue
- Loading branch information
Showing
5 changed files
with
138 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,124 @@ | ||
import { app, Menu, MenuItemConstructorOptions } from 'electron'; | ||
import { app, Menu, MenuItemConstructorOptions, BrowserWindow } from 'electron'; | ||
|
||
const menuTemplate = [ | ||
{ | ||
label: 'dockit', | ||
submenu: [ | ||
{ | ||
label: 'About dockit', | ||
selector: 'dockit:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Services', | ||
submenu: [], | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Hide App', | ||
accelerator: 'CmdOrCtrl+H', | ||
selector: 'hide:', | ||
}, | ||
{ | ||
label: 'Hide Others', | ||
accelerator: 'CmdOrCtrl+Shift+H', | ||
selector: 'hideOtherApplications:', | ||
}, | ||
{ | ||
label: 'Show All', | ||
selector: 'unhideAllApplications:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Quit', | ||
accelerator: 'Command+Q', | ||
click: () => app.quit(), | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'File', | ||
submenu: [ | ||
{ | ||
label: 'Save', | ||
accelerator: 'CmdOrCtrl+S', | ||
selector: 'save:', | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Edit', | ||
submenu: [ | ||
{ | ||
label: 'Undo', | ||
accelerator: 'CmdOrCtrl+Z', | ||
selector: 'undo:', | ||
}, | ||
{ | ||
label: 'Redo', | ||
accelerator: 'Shift+CmdOrCtrl+Z', | ||
selector: 'redo:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Cut', | ||
accelerator: 'CmdOrCtrl+X', | ||
selector: 'cut:', | ||
}, | ||
{ | ||
label: 'Copy', | ||
accelerator: 'CmdOrCtrl+C', | ||
selector: 'copy:', | ||
}, | ||
{ | ||
label: 'Paste', | ||
accelerator: 'CmdOrCtrl+V', | ||
selector: 'paste:', | ||
}, | ||
{ | ||
label: 'Select All', | ||
accelerator: 'CmdOrCtrl+A', | ||
selector: 'selectAll:', | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Window', | ||
submenu: [ | ||
{ | ||
label: 'Minimize', | ||
accelerator: 'Command+M', | ||
selector: 'performMiniaturize:', | ||
}, | ||
{ | ||
label: 'Close', | ||
accelerator: 'Command+W', | ||
selector: 'performClose:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Bring All to Front', | ||
selector: 'arrangeInFront:', | ||
}, | ||
], | ||
}, | ||
] as Array<MenuItemConstructorOptions>; | ||
const buildMenuTemplate = (mainWindow: BrowserWindow) => | ||
[ | ||
{ | ||
label: 'dockit', | ||
submenu: [ | ||
{ | ||
label: 'About dockit', | ||
selector: 'dockit:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Services', | ||
submenu: [], | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Hide App', | ||
accelerator: 'CmdOrCtrl+H', | ||
selector: 'hide:', | ||
}, | ||
{ | ||
label: 'Hide Others', | ||
accelerator: 'CmdOrCtrl+Shift+H', | ||
selector: 'hideOtherApplications:', | ||
}, | ||
{ | ||
label: 'Show All', | ||
selector: 'unhideAllApplications:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Quit', | ||
accelerator: 'Command+Q', | ||
click: () => app.quit(), | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'File', | ||
submenu: [ | ||
{ | ||
label: 'Save', | ||
accelerator: 'CmdOrCtrl+S', | ||
selector: 'save:', | ||
click: () => { | ||
mainWindow.webContents.send('save-shortcout', {}); | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Edit', | ||
submenu: [ | ||
{ | ||
label: 'Undo', | ||
accelerator: 'CmdOrCtrl+Z', | ||
selector: 'undo:', | ||
}, | ||
{ | ||
label: 'Redo', | ||
accelerator: 'Shift+CmdOrCtrl+Z', | ||
selector: 'redo:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Cut', | ||
accelerator: 'CmdOrCtrl+X', | ||
selector: 'cut:', | ||
}, | ||
{ | ||
label: 'Copy', | ||
accelerator: 'CmdOrCtrl+C', | ||
selector: 'copy:', | ||
}, | ||
{ | ||
label: 'Paste', | ||
accelerator: 'CmdOrCtrl+V', | ||
selector: 'paste:', | ||
}, | ||
{ | ||
label: 'Select All', | ||
accelerator: 'CmdOrCtrl+A', | ||
selector: 'selectAll:', | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Window', | ||
submenu: [ | ||
{ | ||
label: 'Minimize', | ||
accelerator: 'Command+M', | ||
selector: 'performMiniaturize:', | ||
}, | ||
{ | ||
label: 'Close', | ||
accelerator: 'Command+W', | ||
selector: 'performClose:', | ||
}, | ||
{ | ||
type: 'separator', | ||
}, | ||
{ | ||
label: 'Bring All to Front', | ||
selector: 'arrangeInFront:', | ||
}, | ||
], | ||
}, | ||
] as Array<MenuItemConstructorOptions>; | ||
|
||
export const createMenu = () => { | ||
const menu = Menu.buildFromTemplate(menuTemplate); | ||
export const createMenu = (mainWindow: BrowserWindow) => { | ||
const menu = Menu.buildFromTemplate(buildMenuTemplate(mainWindow)); | ||
Menu.setApplicationMenu(menu); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters