From 1c73a0c9ac3c50fa6130c129ae4765d6de33caf4 Mon Sep 17 00:00:00 2001 From: soliury Date: Wed, 10 Jun 2020 21:33:16 +0800 Subject: [PATCH] window is dragable & hide dev-tools --- package.json | 1 + vite-web-wallet | 2 +- walletSrc/modules/init/initAPP.js | 14 +++++++++++ walletSrc/modules/init/initTray.js | 1 - walletSrc/modules/init/initWEB.js | 14 +---------- walletSrc/modules/menus.js | 18 ++++++++------ yarn.lock | 39 +++++++++++++++++++++++++++++- 7 files changed, 66 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 0f25280..47488d6 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/vite-web-wallet b/vite-web-wallet index 053169a..ac4ac71 160000 --- a/vite-web-wallet +++ b/vite-web-wallet @@ -1 +1 @@ -Subproject commit 053169a123263ffdece4d64aec8889739a803c70 +Subproject commit ac4ac71e37f93cdb3ab0ea480a21337d3d6a6752 diff --git a/walletSrc/modules/init/initAPP.js b/walletSrc/modules/init/initAPP.js index 989f359..902927b 100644 --- a/walletSrc/modules/init/initAPP.js +++ b/walletSrc/modules/init/initAPP.js @@ -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 = { @@ -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) => { @@ -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; }); diff --git a/walletSrc/modules/init/initTray.js b/walletSrc/modules/init/initTray.js index 064990e..72a05d3 100644 --- a/walletSrc/modules/init/initTray.js +++ b/walletSrc/modules/init/initTray.js @@ -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()} ]); diff --git a/walletSrc/modules/init/initWEB.js b/walletSrc/modules/init/initWEB.js index f47d0a0..c68ed0f 100644 --- a/walletSrc/modules/init/initWEB.js +++ b/walletSrc/modules/init/initWEB.js @@ -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; @@ -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) { diff --git a/walletSrc/modules/menus.js b/walletSrc/modules/menus.js index fdf253b..da8cc44 100644 --- a/walletSrc/modules/menus.js +++ b/walletSrc/modules/menus.js @@ -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', @@ -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) ); }; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index bdedc3a..f84d278 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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" @@ -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==