Skip to content

Commit

Permalink
add menu
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn committed Aug 23, 2017
1 parent 7ea3fef commit 5683629
Showing 1 changed file with 104 additions and 3 deletions.
107 changes: 104 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ function updateTray(unread = 0) {
mainWindow.webContents.send('hide-tray');
}
},
{ label: 'Quit weweChat',
{
label: 'Quit weweChat',
accelerator: 'Command+Q',
selector: 'terminate:',
click() {
Expand Down Expand Up @@ -114,6 +115,103 @@ function updateTray(unread = 0) {
updateTray.lastUnread = unread;
}

function createMenu() {
var menu = Menu.buildFromTemplate([
{
label: pkg.name,
submenu: [
{
label: `About ${pkg.name}`,
click() {
shell.openExternal('https://github.com/trazyn/weweChat');
}
},
{
type: 'separator'
},
{
role: 'hide'
},
{
role: 'hideothers'
},
{
role: 'unhide'
},
{
type: 'separator'
},
{
label: 'Quit weweChat',
accelerator: 'Command+Q',
selector: 'terminate:',
click() {
forceQuit = true;
mainWindow = null;
app.quit();
}
}
]
},
{
label: 'Edit',
submenu: [
{
role: 'undo'
},
{
role: 'redo'
},
{
type: 'separator'
},
{
role: 'cut'
},
{
role: 'copy'
},
{
role: 'paste'
},
{
role: 'pasteandmatchstyle'
},
{
role: 'delete'
},
{
role: 'selectall'
}
]
},
{
role: 'window',
submenu: [
{
role: 'minimize'
},
{
role: 'close'
}
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click() {
shell.openExternal('https://github.com/trazyn/weweChat/issues');
}
}
]
}
]);

Menu.setApplicationMenu(menu);
}

const createMainWindow = () => {
var mainWindowState = windowStateKeeper({
defaultWidth: 1024,
Expand Down Expand Up @@ -225,13 +323,16 @@ const createMainWindow = () => {
event.preventDefault();
shell.openExternal(map);
});

createMenu();
};

app.setName(pkg.name);
app.dock.setIcon(`${__dirname}/src/assets/images/dock.png`);

app.on('ready', createMainWindow);
app.on('activate', e => {
if (!mainWindow.isVisible()) {
mainWindow.show();
}
});
app.setName(pkg.name);
app.dock.setIcon(`${__dirname}/src/assets/images/dock.png`);

0 comments on commit 5683629

Please sign in to comment.