Skip to content
Permalink
Browse files

feat(electron): add consistent cross-platform about dialog

  • Loading branch information...
devinus committed Sep 12, 2018
1 parent 30db60e commit cea3f4bcd91de9006466661a2867d0aea60014b0
Showing with 55 additions and 19 deletions.
  1. +1 −3 ember-electron/assets.js
  2. +39 −10 ember-electron/window.js
  3. +8 −3 package.json
  4. +7 −3 yarn.lock
@@ -19,8 +19,6 @@ const fs = Promise.promisifyAll(require('graceful-fs'), {
},
});

const { app } = require('electron');

const log = require('electron-log');
const { download } = require('electron-dl');

@@ -109,7 +107,7 @@ const downloadAsset = async (sender, url, onStarted, onProgress) => {
await extractAsset(savePath, extractDir, onProgress);
await del(savePath, { force: true });

const dataPath = path.normalize(app.getPath('userData'));
const dataPath = path.normalize(global.dataPath);
await cpy('*', dataPath, { cwd: extractDir });
await del(extractDir, { force: true });

@@ -3,13 +3,14 @@ const path = require('path');
const electron = require('electron');
const log = require('electron-log');
const windowState = require('electron-window-state');
const { default: aboutWindow } = require('about-window');
const { is } = require('electron-util');

const {
version,
productName,
homepage,
author: { email },
copyright,
bugs,
} = require('../package');

const {
@@ -58,13 +59,33 @@ const createWindow = () => {
tabbingIdentifier: productName,
webPreferences: {
webviewTag: false,
disableBlinkFeatures: 'Auxclick',
},
});

win.setAutoHideMenuBar(true);
win.setMenuBarVisibility(false);
mainWindowState.manage(win);

const aboutMenu = {
label: `About ${productName}`,
click() {
return aboutWindow({
copyright,
icon_path: icon,
open_devtools: false,
use_version_info: false,
win_options: {
webPreferences: {
devTools: false,
webviewTag: false,
disableBlinkFeatures: 'Auxclick',
},
},
});
},
};

const template = [
{ role: 'editMenu' },
{
@@ -78,38 +99,46 @@ const createWindow = () => {
{ role: 'windowMenu' },
{
role: 'help',
submenu: [
submenu: [].concat(is.macos ? [] : aboutMenu, [
{
label: 'Learn More',
label: 'Report Issue',
click() {
return shell.openExternal(homepage);
return shell.openExternal(bugs.url);
},
},
{
label: 'Report Issue',
label: 'Request Help',
click() {
const subject = `${productName} Issue Report`;
const subject = `${productName} Support Request`;
const body = `Version: ${version}\r\nPlatform: ${process.platform}`;
const url = `mailto:${email}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
const url = `mailto:${bugs.email}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
return shell.openExternal(url);
},
},
{ type: 'separator' },
{
label: 'View Logs',
click() {
const { file } = log.transports.file;
return shell.showItemInFolder(file);
},
},
],
{
label: 'Open Data Folder',
click() {
const dataPath = path.normalize(global.dataPath);
return shell.showItemInFolder(dataPath);
},
},
]),
},
];

if (is.macos) {
template.unshift({
label: productName,
submenu: [
{ role: 'about' },
aboutMenu,
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
@@ -7,10 +7,14 @@
"license": "BSD-2-Clause",
"author": {
"name": "Nano Wallet Company",
"email": "desktop@nanowalletcompany.com"
"email": "team@nanowalletcompany.com"
},
"homepage": "https://nanowalletcompany.com/",
"copyright": "Copyright © 2018, Nano Wallet Company <team@nanowalletcompany.com>",
"copyright": "Copyright © 2018, Nano Wallet Company",
"bugs": {
"url": "https://github.com/nano-wallet-company/nano-wallet-desktop/issues",
"email": "support@nanowalletcompany.com"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nano-wallet-company/nano-wallet-desktop.git"
@@ -68,6 +72,7 @@
}
},
"dependencies": {
"about-window": "^1.12.1",
"bluebird": "^3.5.2",
"connect": "^3.6.6",
"cors": "^2.8.4",
@@ -87,7 +92,7 @@
"electron-store": "^2.0.0",
"electron-unhandled": "^1.1.0",
"electron-util": "^0.9.1",
"electron-window-state": "^5.0.0",
"electron-window-state": "^5.0.1",
"express-jwt": "^5.3.1",
"extract-zip": "^1.6.7",
"get-port": "^4.0.0",
@@ -1175,6 +1175,10 @@ abortcontroller-polyfill@^1.1.9:
version "1.1.9"
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.1.9.tgz#9fefe359fda2e9e0932dc85e6106453ac393b2da"

about-window@^1.12.1:
version "1.12.1"
resolved "https://registry.yarnpkg.com/about-window/-/about-window-1.12.1.tgz#b81c10f6de58d38bce2aa5f31f61a82e6c3d6c2b"

accepts@~1.3.4, accepts@~1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2"
@@ -6155,9 +6159,9 @@ electron-util@^0.9.1:
dependencies:
electron-is-dev "^0.3.0"

electron-window-state@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/electron-window-state/-/electron-window-state-5.0.0.tgz#5e7bab7c6a609b5f04311a8eb7bcf30f4199307e"
electron-window-state@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/electron-window-state/-/electron-window-state-5.0.1.tgz#ebda7b789e4bd2ab5c439c22090b159effe6a12d"
dependencies:
deep-equal "^1.0.1"
jsonfile "^4.0.0"

0 comments on commit cea3f4b

Please sign in to comment.
You can’t perform that action at this time.