Skip to content

Commit

Permalink
v1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Xue authored and Gary Xue committed Dec 11, 2019
1 parent ba17e3c commit 5c06f48
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h1 class="hero-title h2-mobile mt-0 is-revealing">
<div class="control control-expanded">
<a
class="button button-primary button-block button-shadow"
href="https://github.com/garyxuehong/postmate/releases/download/v1.2.1/Postmate-1.2.1.dmg"
href="https://github.com/garyxuehong/postmate/releases/download/v1.2.3/Postmate-1.2.3.dmg"
>Download now</a
>
<p style="display:block; margin-top: 20px;">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postmate",
"version": "1.2.2",
"version": "1.2.3",
"private": true,
"main": "public/electron.js",
"homepage": "./",
Expand Down
15 changes: 11 additions & 4 deletions public/electron.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const electron = require("electron");
const { Menu, MenuItem } = electron;
const app = electron.app;
const globalShortcut = electron.globalShortcut;
const shell = electron.shell;
const { ipcMain } = require('electron')
const BrowserWindow = electron.BrowserWindow;
const { getTemplate } = require('./menu');

const https = require("https");
const path = require('path');
Expand All @@ -18,6 +19,14 @@ let mockNodeServer=null;
let mockInfo = {};
let mainWindow;

const menuTemplate = getTemplate({
onFireRequest: () => {
mainWindow && mainWindow.webContents.send("fireRequest");
}
});
const menu = Menu.buildFromTemplate(menuTemplate);
Menu.setApplicationMenu(menu);

async function startMockServer() {
const key = fs.readFileSync(
path.join(__dirname, isDev ? "../certs/key.pem" : "../build/certs/key.pem")
Expand Down Expand Up @@ -92,9 +101,7 @@ async function start() {
() => mainWindow.webContents.send("newVariables", mockInfo),
3000
);
globalShortcut.register('Command+Enter', ()=>{
mainWindow.webContents.send('fireRequest');
});

ipcMain.on('openFile', (_, file)=>{
shell.openItem(path.resolve(file));
});
Expand Down
89 changes: 89 additions & 0 deletions public/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const isMac = process.platform === 'darwin'

module.exports = { getTemplate };

function getTemplate({ onFireRequest }) {
return [
...(isMac
? [
{
label: "Postmate",
submenu: [
{ role: "about" },
{
type: "separator"
},
{ role: "services" },
{
type: "separator"
},
{ role: "hide" },
{
role: "hideothers"
},
{ role: "unhide" },
{
type: "separator"
},
{ role: "quit" }
]
}
]
: []),
{
label: "File",
submenu: [isMac ? { role: "close" } : { role: "quit" }]
},
{
label: "Tools",
submenu: [
{
label: "Fire Request",
accelerator: "CmdOrCtrl+Enter",
click: async () => {
onFireRequest();
}
}
]
},
{
label: "View",
submenu: [
{ role: "reload" },
{ role: "forcereload" },
{ role: "toggledevtools" },
{ type: "separator" },
{ role: "resetzoom" },
{ role: "zoomin" },
{ role: "zoomout" },
{ type: "separator" },
{
role: "togglefullscreen"
}
]
},
{
label: "Window",
submenu: [
{ role: "minimize" },
{ role: "zoom" },
...(isMac
? [
{
type: "separator"
},
{ role: "front" },
{
type: "separator"
},
{ role: "window" }
]
: [{ role: "close" }])
]
},
{
role: "help",
submenu: []
}
];
}

0 comments on commit 5c06f48

Please sign in to comment.