+ beautifier
* version info
This commit is contained in:
@@ -1,103 +1,99 @@
|
||||
const {app, dialog, ipcMain} = require('electron');
|
||||
const admZip = require('adm-zip');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
const {app, dialog, ipcMain} = require("electron");
|
||||
const admZip = require("adm-zip");
|
||||
const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
const os = require("os");
|
||||
|
||||
class Accounts {
|
||||
constructor() {
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
getKeyStoreLocation() {
|
||||
switch(os.type()) {
|
||||
case "Darwin":
|
||||
return path.join(os.homedir(), 'Library', 'Ether1', 'keystore');
|
||||
break;
|
||||
default:
|
||||
return path.join(process.env.APPDATA, 'Ether1', 'keystore');
|
||||
}
|
||||
switch (os.type()) {
|
||||
case "Darwin":
|
||||
return path.join(os.homedir(), "Library", "Ether1", "keystore");
|
||||
break;
|
||||
default:
|
||||
return path.join(process.env.APPDATA, "Ether1", "keystore");
|
||||
}
|
||||
}
|
||||
|
||||
exportAccounts() {
|
||||
var savePath = dialog.showSaveDialog({
|
||||
defaultPath: path.join(app.getPath('documents'), 'accounts.zip')
|
||||
defaultPath: path.join(app.getPath("documents"), "accounts.zip")
|
||||
});
|
||||
|
||||
if (savePath) {
|
||||
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||
|
||||
fs.readdir(accPath, function(err, files) {
|
||||
var zip = new admZip();
|
||||
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||
|
||||
for(let filePath of files) {
|
||||
zip.addFile(filePath, fs.readFileSync(path.join(accPath, filePath)));
|
||||
}
|
||||
fs.readdir(accPath, function (err, files) {
|
||||
var zip = new admZip();
|
||||
|
||||
// store zip to path
|
||||
zip.writeZip(savePath);
|
||||
});
|
||||
for (let filePath of files) {
|
||||
zip.addFile(filePath, fs.readFileSync(path.join(accPath, filePath)));
|
||||
}
|
||||
|
||||
// store zip to path
|
||||
zip.writeZip(savePath);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
importAccounts(accountsFile) {
|
||||
importAccounts(accountsFile) {
|
||||
var extName = path.extname(accountsFile).toUpperCase();
|
||||
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||
|
||||
if (extName == '.ZIP') {
|
||||
var zip = new admZip(accountsFile);
|
||||
zip.extractAllTo(accPath, true);
|
||||
return { success: true, text: "Accounts ware successfully imported."};
|
||||
if (extName == ".ZIP") {
|
||||
var zip = new admZip(accountsFile);
|
||||
zip.extractAllTo(accPath, true);
|
||||
return {success: true, text: "Accounts ware successfully imported."};
|
||||
} else {
|
||||
try {
|
||||
fs.copySync(accountsFile, path.join(accPath, path.basename(accountsFile)));
|
||||
return { success: true, text: "Account was successfully imported."};
|
||||
} catch (err) {
|
||||
return { success: false, text: err};
|
||||
}
|
||||
try {
|
||||
fs.copySync(accountsFile, path.join(accPath, path.basename(accountsFile)));
|
||||
return {success: true, text: "Account was successfully imported."};
|
||||
} catch (err) {
|
||||
return {success: false, text: err};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saveAccount(account) {
|
||||
fs.writeFile(path.join(tEthoAccountshis.getKeyStoreLocation(), '0x' + account.address), JSON.stringify(account), 'utf8', function() {
|
||||
// file was written
|
||||
saveAccount(account) {
|
||||
fs.writeFile(path.join(tEthoAccountshis.getKeyStoreLocation(), "0x" + account.address), JSON.stringify(account), "utf8", function () {
|
||||
// file was written
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.on('exportAccounts', (event, arg) => {
|
||||
EthoAccounts.exportAccounts();
|
||||
});
|
||||
|
||||
ipcMain.on('importAccounts', (event, arg) => {
|
||||
var openPath = dialog.showOpenDialog({
|
||||
defaultPath: app.getPath('documents'),
|
||||
"filters":
|
||||
[
|
||||
{
|
||||
"name": "archive",
|
||||
"extensions": ["zip"]
|
||||
},
|
||||
{
|
||||
"name": "json",
|
||||
"extensions": ["json"]
|
||||
},
|
||||
{
|
||||
"name": "All",
|
||||
"extensions": ["*.*"]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
if (openPath) {
|
||||
event.returnValue = EthoAccounts.importAccounts(openPath[0]);
|
||||
} else {
|
||||
event.returnValue = {};
|
||||
}
|
||||
ipcMain.on("exportAccounts", (event, arg) => {
|
||||
EthoAccounts.exportAccounts();
|
||||
});
|
||||
|
||||
ipcMain.on('saveAccount', (event, arg) => {
|
||||
EthoAccounts.saveAccount(arg);
|
||||
event.returnValue = true;
|
||||
ipcMain.on("importAccounts", (event, arg) => {
|
||||
var openPath = dialog.showOpenDialog({
|
||||
defaultPath: app.getPath("documents"),
|
||||
filters: [
|
||||
{
|
||||
name: "archive",
|
||||
extensions: ["zip"]
|
||||
}, {
|
||||
name: "json",
|
||||
extensions: ["json"]
|
||||
}, {
|
||||
name: "All",
|
||||
extensions: ["*.*"]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
if (openPath) {
|
||||
event.returnValue = EthoAccounts.importAccounts(openPath[0]);
|
||||
} else {
|
||||
event.returnValue = {};
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on("saveAccount", (event, arg) => {
|
||||
EthoAccounts.saveAccount(arg);
|
||||
event.returnValue = true;
|
||||
});
|
||||
|
||||
EthoAccounts = new Accounts();
|
||||
@@ -1,50 +1,59 @@
|
||||
const {app, dialog, ipcMain} = require('electron');
|
||||
const storage = require('electron-storage');
|
||||
const datastore = require('nedb');
|
||||
const moment = require('moment');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const {app, dialog, ipcMain} = require("electron");
|
||||
const storage = require("electron-storage");
|
||||
const datastore = require("nedb");
|
||||
const moment = require("moment");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const os = require("os");
|
||||
|
||||
const dbPath = path.join(app.getPath('userData'), 'storage.db');
|
||||
const db = new datastore({ filename: dbPath });
|
||||
db.loadDatabase(function (err) {
|
||||
const dbPath = path.join(app.getPath("userData"), "storage.db");
|
||||
const db = new datastore({filename: dbPath});
|
||||
db.loadDatabase(function (err) {
|
||||
// Now commands will be executed
|
||||
});
|
||||
|
||||
// index the block field
|
||||
db.ensureIndex({ fieldName: 'block' }, function (err) {
|
||||
db.ensureIndex({
|
||||
fieldName: "block"
|
||||
}, function (err) {
|
||||
// If there was an error, err is not null
|
||||
});
|
||||
|
||||
// index the txhash field
|
||||
db.ensureIndex({ fieldName: 'txhash', unique: true }, function (err) {
|
||||
db.ensureIndex({
|
||||
fieldName: "txhash",
|
||||
unique: true
|
||||
}, function (err) {
|
||||
// If there was an error, err is not null
|
||||
});
|
||||
|
||||
ipcMain.on('storeTransaction', (event, arg) => {
|
||||
db.update({ txhash: arg.txhash }, arg, { upsert: true }, function (err, numReplaced, upsert) {
|
||||
|
||||
ipcMain.on("storeTransaction", (event, arg) => {
|
||||
db.update({
|
||||
txhash: arg.txhash
|
||||
}, arg, {
|
||||
upsert: true
|
||||
}, function (err, numReplaced, upsert) {
|
||||
// do nothing for now
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('getTransactions', (event, arg) => {
|
||||
|
||||
ipcMain.on("getTransactions", (event, arg) => {
|
||||
db.find({}).exec(function (err, docs) {
|
||||
ResultData = [];
|
||||
|
||||
|
||||
// sort the data
|
||||
docs.sort((a, b)=>{
|
||||
if ((!b.block) && (a.block)) {
|
||||
docs.sort((a, b) => {
|
||||
if (!b.block && a.block) {
|
||||
return 1;
|
||||
} else if ((b.block) && (!a.block)) {
|
||||
} else if (b.block && !a.block) {
|
||||
return -1;
|
||||
} else if ((!b.block) && (!a.block)) {
|
||||
return moment(b.timestamp, "YYYY-MM-DD HH:mm:ss").toDate() - moment(a.timestamp, "YYYY-MM-DD HH:mm:ss").toDate();
|
||||
} else if (!b.block && !a.block) {
|
||||
return (moment(b.timestamp, "YYYY-MM-DD HH:mm:ss").toDate() - moment(a.timestamp, "YYYY-MM-DD HH:mm:ss").toDate());
|
||||
} else {
|
||||
return b.block - a.block;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
for (i = 0; i < Math.min(docs.length, 500); i++) {
|
||||
ResultData.push([
|
||||
docs[i].block,
|
||||
@@ -59,73 +68,93 @@ ipcMain.on('getTransactions', (event, arg) => {
|
||||
event.returnValue = ResultData;
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('getJSONFile', (event, arg) => {
|
||||
|
||||
ipcMain.on("getJSONFile", (event, arg) => {
|
||||
storage.get(arg, (err, data) => {
|
||||
if (err) {
|
||||
event.returnValue = null;
|
||||
} else {
|
||||
event.returnValue = data;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('setJSONFile', (event, arg) => {
|
||||
storage.set(arg.file, arg.data, (err) => {
|
||||
ipcMain.on("setJSONFile", (event, arg) => {
|
||||
storage.set(arg.file, arg.data, err => {
|
||||
if (err) {
|
||||
event.returnValue = { success: false, error: err };
|
||||
event.returnValue = {
|
||||
success: false,
|
||||
error: err
|
||||
};
|
||||
} else {
|
||||
event.returnValue = { success: true, error: null };
|
||||
event.returnValue = {
|
||||
success: true,
|
||||
error: null
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('deleteTransactions', (event, arg) => {
|
||||
fs.unlink(dbPath, (err) => {
|
||||
ipcMain.on("deleteTransactions", (event, arg) => {
|
||||
fs.unlink(dbPath, err => {
|
||||
if (err) {
|
||||
event.returnValue = { success: false, error: err };
|
||||
event.returnValue = {
|
||||
success: false,
|
||||
error: err
|
||||
};
|
||||
} else {
|
||||
event.returnValue = { success: true, error: null };
|
||||
event.returnValue = {
|
||||
success: true,
|
||||
error: null
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('deleteWalletData', (event, arg) => {
|
||||
fs.unlink(path.join(app.getPath('userData'), 'wallets.json'), (err) => {
|
||||
ipcMain.on("deleteWalletData", (event, arg) => {
|
||||
fs.unlink(path.join(app.getPath("userData"), "wallets.json"), err => {
|
||||
if (err) {
|
||||
event.returnValue = { success: false, error: err };
|
||||
event.returnValue = {
|
||||
success: false,
|
||||
error: err
|
||||
};
|
||||
} else {
|
||||
event.returnValue = { success: true, error: null };
|
||||
event.returnValue = {
|
||||
success: true,
|
||||
error: null
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('deleteBlockchainData', (event, arg) => {
|
||||
var deleteFolderRecursive = function(path) {
|
||||
if( fs.existsSync(path) ) {
|
||||
fs.readdirSync(path).forEach(function(file,index){
|
||||
ipcMain.on("deleteBlockchainData", (event, arg) => {
|
||||
var deleteFolderRecursive = function (path) {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.readdirSync(path).forEach(function (file, index) {
|
||||
var curPath = path + "/" + file;
|
||||
if(fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
// recurse
|
||||
deleteFolderRecursive(curPath);
|
||||
} else { // delete file
|
||||
} else {
|
||||
// delete file
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
function getBlockchainDataLocation() {
|
||||
switch(os.type()) {
|
||||
case "Darwin":
|
||||
return path.join(os.homedir(), 'Library', 'Ether1', 'geth');
|
||||
break;
|
||||
default:
|
||||
return path.join(process.env.APPDATA, 'Ether1', 'geth');
|
||||
}
|
||||
switch (os.type()) {
|
||||
case "Darwin":
|
||||
return path.join(os.homedir(), "Library", "Ether1", "geth");
|
||||
break;
|
||||
default:
|
||||
return path.join(process.env.APPDATA, "Ether1", "geth");
|
||||
}
|
||||
}
|
||||
|
||||
// delete folder in a synchronous recursive maner
|
||||
deleteFolderRecursive(getBlockchainDataLocation());
|
||||
event.returnValue = true;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,47 +1,44 @@
|
||||
const {app, dialog, ipcMain} = require('electron');
|
||||
const child_process = require('child_process');
|
||||
const appRoot = require('app-root-path');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
|
||||
const {app, dialog, ipcMain} = require("electron");
|
||||
const child_process = require("child_process");
|
||||
const appRoot = require("app-root-path");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const os = require("os");
|
||||
|
||||
class Geth {
|
||||
constructor() {
|
||||
this.gethProcess = null;
|
||||
this.logGethEvents = false;
|
||||
// create the user data dir (needed for MacOS)
|
||||
if (!fs.existsSync(app.getPath('userData'))) {
|
||||
fs.mkdirSync(app.getPath('userData'));
|
||||
}
|
||||
|
||||
if (this.logGethEvents) {
|
||||
this.logStream = fs.createWriteStream(path.join(app.getPath('userData'), 'gethlog.txt'), { flags: 'a' });
|
||||
if (!fs.existsSync(app.getPath("userData"))) {
|
||||
fs.mkdirSync(app.getPath("userData"));
|
||||
}
|
||||
|
||||
if (appRoot.path.indexOf('app.asar') > -1) {
|
||||
if (this.logGethEvents) {
|
||||
this.logStream = fs.createWriteStream(path.join(app.getPath("userData"), "gethlog.txt"), {flags: "a"});
|
||||
}
|
||||
|
||||
if (appRoot.path.indexOf("app.asar") > -1) {
|
||||
this.rootPath = path.dirname(appRoot.path);
|
||||
} else {
|
||||
this.rootPath = appRoot.path;
|
||||
}
|
||||
|
||||
switch(os.type()) {
|
||||
switch (os.type()) {
|
||||
case "Linux":
|
||||
this.binaries = path.join(this.rootPath, 'bin', 'linux');
|
||||
this.binaries = path.join(this.rootPath, "bin", "linux");
|
||||
break;
|
||||
case "Darwin":
|
||||
this.binaries = path.join(this.rootPath, 'bin', 'macos');
|
||||
this.binaries = path.join(this.rootPath, "bin", "macos");
|
||||
break;
|
||||
case "Windows_NT":
|
||||
this.binaries = path.join(this.rootPath, 'bin', 'win');
|
||||
this.binaries = path.join(this.rootPath, "bin", "win");
|
||||
break;
|
||||
default:
|
||||
this.binaries = path.join(this.rootPath, 'bin', 'win');
|
||||
}
|
||||
|
||||
|
||||
this.binaries = path.join(this.rootPath, "bin", "win");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_writeLog(text) {
|
||||
if (this.logGethEvents) {
|
||||
this.logStream.write(text);
|
||||
@@ -51,23 +48,33 @@ class Geth {
|
||||
startGeth() {
|
||||
// get the path of get and execute the child process
|
||||
try {
|
||||
const gethPath = path.join(this.binaries, 'geth');
|
||||
this.gethProcess = child_process.spawn(gethPath, ['--ws', '--wsorigins', '*', '--wsaddr', '127.0.0.1', '--wsport', '8546', '--wsapi', 'admin,db,eth,net,miner,personal,web3']);
|
||||
const gethPath = path.join(this.binaries, "geth");
|
||||
this.gethProcess = child_process.spawn(gethPath, [
|
||||
"--ws",
|
||||
"--wsorigins",
|
||||
"*",
|
||||
"--wsaddr",
|
||||
"127.0.0.1",
|
||||
"--wsport",
|
||||
"8546",
|
||||
"--wsapi",
|
||||
"admin,db,eth,net,miner,personal,web3"
|
||||
]);
|
||||
|
||||
if (!this.gethProcess) {
|
||||
dialog.showErrorBox("Error starting application", "Geth failed to start!");
|
||||
app.quit();
|
||||
} else {
|
||||
this.gethProcess.on('error', function(err) {
|
||||
this.gethProcess.on("error", function (err) {
|
||||
dialog.showErrorBox("Error starting application", "Geth failed to start!");
|
||||
app.quit();
|
||||
});
|
||||
this.gethProcess.stderr.on('data', function(data) {
|
||||
EthoGeth._writeLog(data.toString() + '\n');
|
||||
this.gethProcess.stderr.on("data", function (data) {
|
||||
EthoGeth._writeLog(data.toString() + "\n");
|
||||
});
|
||||
this.gethProcess.stdout.on("data", function (data) {
|
||||
EthoGeth._writeLog(data.toString() + "\n");
|
||||
});
|
||||
this.gethProcess.stdout.on('data', function(data) {
|
||||
EthoGeth._writeLog(data.toString() + '\n');
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
dialog.showErrorBox("Error starting application", err.message);
|
||||
@@ -75,18 +82,18 @@ class Geth {
|
||||
}
|
||||
}
|
||||
|
||||
stopGeth() {
|
||||
stopGeth() {
|
||||
if (os.type() == "Windows_NT") {
|
||||
const gethWrapePath = path.join(this.binaries, 'WrapGeth.exe');
|
||||
child_process.spawnSync(gethWrapePath, [this.gethProcess.pid]);
|
||||
const gethWrapePath = path.join(this.binaries, "WrapGeth.exe");
|
||||
child_process.spawnSync(gethWrapePath, [this.gethProcess.pid]);
|
||||
} else {
|
||||
this.gethProcess.kill('SIGTERM');
|
||||
this.gethProcess.kill("SIGTERM");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.on('stopGeth', (event, arg) => {
|
||||
ipcMain.on("stopGeth", (event, arg) => {
|
||||
EthoGeth.stopGeth();
|
||||
});
|
||||
});
|
||||
|
||||
EthoGeth = new Geth();
|
||||
294
modules/menu.js
294
modules/menu.js
@@ -1,202 +1,170 @@
|
||||
const {app, Menu, ipcMain} = require('electron');
|
||||
const {app, Menu, ipcMain} = require("electron");
|
||||
const open = require("open");
|
||||
|
||||
const template = [
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
{
|
||||
label:'Exit',
|
||||
click() {
|
||||
app.quit()
|
||||
} }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
{
|
||||
label: "File",
|
||||
submenu: [
|
||||
{
|
||||
role: 'undo'
|
||||
},
|
||||
{
|
||||
role: 'redo'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'cut'
|
||||
},
|
||||
{
|
||||
role: 'copy'
|
||||
},
|
||||
{
|
||||
role: 'paste'
|
||||
},
|
||||
{
|
||||
role: 'delete'
|
||||
},
|
||||
{
|
||||
role: 'selectall'
|
||||
label: "Exit",
|
||||
click() {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'View',
|
||||
}, {
|
||||
label: "Edit",
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) focusedWindow.reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) focusedWindow.webContents.toggleDevTools()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'resetzoom'
|
||||
},
|
||||
{
|
||||
role: 'zoomin'
|
||||
},
|
||||
{
|
||||
role: 'zoomout'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'togglefullscreen'
|
||||
role: "undo"
|
||||
}, {
|
||||
role: "redo"
|
||||
}, {
|
||||
type: "separator"
|
||||
}, {
|
||||
role: "cut"
|
||||
}, {
|
||||
role: "copy"
|
||||
}, {
|
||||
role: "paste"
|
||||
}, {
|
||||
role: "delete"
|
||||
}, {
|
||||
role: "selectall"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'window',
|
||||
}, {
|
||||
label: "View",
|
||||
submenu: [
|
||||
{
|
||||
role: 'minimize'
|
||||
},
|
||||
{
|
||||
role: 'close'
|
||||
label: "Reload",
|
||||
accelerator: "CmdOrCtrl+R",
|
||||
click(item, focusedWindow) {
|
||||
if (focusedWindow)
|
||||
focusedWindow.reload();
|
||||
}
|
||||
}, {
|
||||
label: "Toggle Developer Tools",
|
||||
accelerator: process.platform === "darwin"
|
||||
? "Alt+Command+I"
|
||||
: "Ctrl+Shift+I",
|
||||
click(item, focusedWindow) {
|
||||
if (focusedWindow)
|
||||
focusedWindow.webContents.toggleDevTools();
|
||||
}
|
||||
}, {
|
||||
type: "separator"
|
||||
}, {
|
||||
role: "resetzoom"
|
||||
}, {
|
||||
role: "zoomin"
|
||||
}, {
|
||||
role: "zoomout"
|
||||
}, {
|
||||
type: "separator"
|
||||
}, {
|
||||
role: "togglefullscreen"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
}, {
|
||||
role: "window",
|
||||
submenu: [
|
||||
{
|
||||
label: 'About Ether1 wallet',
|
||||
click () {
|
||||
var infoData = {};
|
||||
infoData.version = app.getVersion();
|
||||
mainWindow.webContents.send('showAboutDialog', infoData);
|
||||
}
|
||||
},
|
||||
role: "minimize"
|
||||
}, {
|
||||
role: "close"
|
||||
}
|
||||
]
|
||||
}, {
|
||||
role: "help",
|
||||
submenu: [
|
||||
{
|
||||
label: 'Ether1 documentation',
|
||||
click () {
|
||||
open("https://docs.ether1.org");
|
||||
label: "About Ether1 wallet",
|
||||
click() {
|
||||
var infoData = {};
|
||||
infoData.version = app.getVersion();
|
||||
mainWindow.webContents.send("showAboutDialog", infoData);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Report issue on GitHub',
|
||||
click () {
|
||||
open("https://github.com/taeguscromis/Ether1DesktopWallet/issues");
|
||||
}, {
|
||||
label: "Ether1 documentation",
|
||||
click() {
|
||||
open("https://docs.ether1.org");
|
||||
}
|
||||
}, {
|
||||
label: "Report issue on GitHub",
|
||||
click() {
|
||||
open("https://github.com/taeguscromis/Ether1DesktopWallet/issues");
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
const name = app.getName()
|
||||
if (process.platform === "darwin") {
|
||||
const name = app.getName();
|
||||
template.unshift({
|
||||
label: name,
|
||||
submenu: [
|
||||
{
|
||||
role: 'about'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'services',
|
||||
role: "about"
|
||||
}, {
|
||||
type: "separator"
|
||||
}, {
|
||||
role: "services",
|
||||
submenu: []
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'hide'
|
||||
},
|
||||
{
|
||||
role: 'hideothers'
|
||||
},
|
||||
{
|
||||
role: 'unhide'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'quit'
|
||||
}, {
|
||||
type: "separator"
|
||||
}, {
|
||||
role: "hide"
|
||||
}, {
|
||||
role: "hideothers"
|
||||
}, {
|
||||
role: "unhide"
|
||||
}, {
|
||||
type: "separator"
|
||||
}, {
|
||||
role: "quit"
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
// Edit menu.
|
||||
template[1].submenu.push(
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{
|
||||
role: 'startspeaking'
|
||||
},
|
||||
{
|
||||
role: 'stopspeaking'
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
template[1].submenu.push({
|
||||
type: "separator"
|
||||
}, {
|
||||
label: "Speech",
|
||||
submenu: [
|
||||
{
|
||||
role: "startspeaking"
|
||||
}, {
|
||||
role: "stopspeaking"
|
||||
}
|
||||
]
|
||||
});
|
||||
// Window menu.
|
||||
template[3].submenu = [
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: 'CmdOrCtrl+W',
|
||||
role: 'close'
|
||||
},
|
||||
{
|
||||
label: 'Minimize',
|
||||
accelerator: 'CmdOrCtrl+M',
|
||||
role: 'minimize'
|
||||
},
|
||||
{
|
||||
label: 'Zoom',
|
||||
role: 'zoom'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Bring All to Front',
|
||||
role: 'front'
|
||||
label: "Close",
|
||||
accelerator: "CmdOrCtrl+W",
|
||||
role: "close"
|
||||
}, {
|
||||
label: "Minimize",
|
||||
accelerator: "CmdOrCtrl+M",
|
||||
role: "minimize"
|
||||
}, {
|
||||
label: "Zoom",
|
||||
role: "zoom"
|
||||
}, {
|
||||
type: "separator"
|
||||
}, {
|
||||
label: "Bring All to Front",
|
||||
role: "front"
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
ipcMain.on('openURL', (event, arg) => {
|
||||
open(arg);
|
||||
ipcMain.on("openURL", (event, arg) => {
|
||||
open(arg);
|
||||
});
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
Reference in New Issue
Block a user