Skip to content

Commit

Permalink
window is dragable & hide dev-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
soliury committed Jun 10, 2020
1 parent d69ab59 commit 1c73a0c
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"cross-spawn": "^6.0.5",
"electron-log": "^4.2.1",
"electron-serve": "^1.0.0",
"electron-settings": "^4.0.0",
"electron-updater": "^4.3.1",
"menubar": "^9.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion vite-web-wallet
14 changes: 14 additions & 0 deletions walletSrc/modules/init/initAPP.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');

const { app } = require('electron');
const Splashscreen = require('@trodi/electron-splashscreen');
const settings = require('electron-settings').default;

// Wallet Window Config
const windowConfig = {
Expand Down Expand Up @@ -46,6 +47,14 @@ function createWindow () {
}
});

settings.get('windowSize').then(data => {
if (data && data.height && data.width) {
global.WALLET_WIN.setSize(data.width, data.height);
} else {
global.WALLET_WIN.maximize();
}
});

global.willQuit = false;

global.WALLET_WIN.on('close', (event) => {
Expand All @@ -58,6 +67,11 @@ function createWindow () {
});

app.on('before-quit', () => {
const sizes = global.WALLET_WIN.getSize();
settings.set('windowSize', {
width: sizes[0],
height: sizes[1]
});
global.willQuit = true;
});

Expand Down
1 change: 0 additions & 1 deletion walletSrc/modules/init/initTray.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = function() {
app.show();
}
},
// { label: 'Auto update', type: 'checkbox'},
{ label: `Version: ${version.version}`, type: 'normal' },
{ label: 'Quit', type: 'normal', click: () => app.quit()}
]);
Expand Down
14 changes: 1 addition & 13 deletions walletSrc/modules/init/initWEB.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ const serve = require('electron-serve');
serve({directory: path.join(global.APP_PATH, 'walletPages')});


const allowHost = [
'https://reward.vite.net',
'https://testnet.vite.net',
'http://132.232.134.168:8080',
'https://vite.net',
'https://vite.org',
'https://github.com',
'https://etherscan.io',
'https://ropsten.etherscan.io',
'http://localhost:8081'
];

function loadWebDom() {
const walletWindow = global.WALLET_WIN;

Expand Down Expand Up @@ -64,7 +52,7 @@ module.exports = function loadWeb() {
let host = `${urlRes.protocol}//${urlRes.host}`;
global.walletLog.info(`Open url: ${host}`);

if (allowHost.indexOf(host) > -1) {
if (host.indexOf('http') > -1) {
shell.openExternal(url);
}
} catch(err) {
Expand Down
18 changes: 11 additions & 7 deletions walletSrc/modules/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ module.exports = function() {
global.WALLET_WIN && global.WALLET_WIN.webContents.reload();
}
},
{
label: 'devtool',
accelerator: 'CmdOrCtrl+Y',
click() {
global.WALLET_WIN && global.WALLET_WIN.webContents.openDevTools();
}
},
{
label: 'log',
accelerator: 'CmdOrCtrl+L',
Expand All @@ -57,5 +50,16 @@ module.exports = function() {
]
}
];
if (process.env.NODE_ENV === 'dev') {
template[2].submenu.push(
{
label: 'devtool',
accelerator: 'CmdOrCtrl+Y',
click() {
global.WALLET_WIN && global.WALLET_WIN.webContents.openDevTools();
}
}
)
}
Menu.setApplicationMenu( Menu.buildFromTemplate(template) );
};
39 changes: 38 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,18 @@ electron-serve@^1.0.0:
resolved "https://registry.yarnpkg.com/electron-serve/-/electron-serve-1.0.0.tgz#babf2f5022102fa300a841d91e4c2e7048ac4b1f"
integrity sha512-Rsm4tjj1eK7NUWKgGw6NjHkjfB+bIXZh0ztybUYzqmwCm1wzb7zv95LERbwricDZfCsKHB0V57NgVvHdi2OOAQ==

electron-settings@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/electron-settings/-/electron-settings-4.0.0.tgz#e30938204ceecf83241a9f70f16395a95705df6e"
integrity sha512-9Msvqk8pu3lT71PUIVfqlzEx9zrXmq+5AYHc7dcftD0gbDzpYP6aBIx6En6rn1352IRTSE6JbnE/ud4SpfU1mg==
dependencies:
lodash.get "^4.4.2"
lodash.has "^4.5.2"
lodash.set "^4.3.2"
lodash.unset "^4.5.2"
mkdirp "^1.0.4"
write-file-atomic "^3.0.3"

electron-updater@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-4.3.1.tgz#9d485b6262bc56fcf7ee62b1dc1b3b105a3e96a7"
Expand Down Expand Up @@ -2956,11 +2968,31 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"

lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=

lodash.has@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862"
integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=

lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=

lodash.unset@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.unset/-/lodash.unset-4.5.2.tgz#370d1d3e85b72a7e1b0cdf2d272121306f23e4ed"
integrity sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0=

lodash@^4.17.10, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
Expand Down Expand Up @@ -3121,6 +3153,11 @@ mkdirp@^0.5.1, mkdirp@^0.5.4:
dependencies:
minimist "^1.2.5"

mkdirp@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mocha@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6"
Expand Down Expand Up @@ -4758,7 +4795,7 @@ wrappy@1:
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

write-file-atomic@^3.0.0:
write-file-atomic@^3.0.0, write-file-atomic@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8"
integrity sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==
Expand Down

0 comments on commit 1c73a0c

Please sign in to comment.