Skip to content

Commit

Permalink
support context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
osdio committed Jul 17, 2020
1 parent 30c2bff commit c85698b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion vite-web-wallet
6 changes: 5 additions & 1 deletion walletSrc/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ module.exports = {
'autoUpdateRelease': 'Get Stable Version Only',
'enableTouchID': 'Enable TouchID',
'enableTouchIDMessage': 'Enabling TouchID does not improve security. No matter whether it is enabled or not, the Vite Wallet will not store the password in KeyStore. The password is only stored in memory. This feature is to prevent potential asset loss by mistake in case the wallet is unlocked.',
'net': 'Net Type'
'net': 'Net Type',
'copy': 'Copy',
'cut': 'Cut',
'paste': 'Paste',
'selectAll': 'Select All'
};
6 changes: 5 additions & 1 deletion walletSrc/i18n/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ module.exports = {
'autoUpdateRelease': '仅更新正式版',
'enableTouchID': '启用指纹解锁',
'enableTouchIDMessage': '请注意:无论是否启用指纹解锁,Vite Wallet 都不会把密码存储到 KeyStore,只会存储到内存。启用该功能,是为了防止在钱包解锁情况下,非钱包持有人误操作导致资产损失。',
'net': '网络类型'
'net': '网络类型',
'copy': '复制',
'cut': '剪切',
'paste': '粘贴',
'selectAll': '全选'
};
8 changes: 5 additions & 3 deletions walletSrc/modules/init/preload.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const { remote, ipcRenderer } = require('electron');
const {
appLocalStorage, appI18n, touchID
appLocalStorage, appI18n, webUtils
} = remote.require('./walletSrc/modules/toWeb.js');


window.viteWalletStorage = appLocalStorage;
window.viteWalletI18n = appI18n;
window.DESKTOP = true;
window.ipcRenderer = ipcRenderer;
window.desktopUtils = webUtils;


if (process.platform === 'darwin') {
window.touchID = touchID;
}
window.touchID = webUtils;
}
4 changes: 2 additions & 2 deletions walletSrc/modules/toWeb.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

const appLocalStorage = require('./localStorage.js');
const touchID = require('../utils/touchId');
const webUtils = require('../utils/webUtils');

module.exports = {
appLocalStorage,
appI18n: global.$i18n,
touchID
webUtils,
};
13 changes: 0 additions & 13 deletions walletSrc/utils/touchId.js

This file was deleted.

22 changes: 22 additions & 0 deletions walletSrc/utils/webUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { systemPreferences, MenuItem, Menu } = require('electron');

const menu = new Menu();
menu.append(new MenuItem({ label: global.$t('copy'), role: 'copy' }));
menu.append(new MenuItem({ label: global.$t('cut'), role: 'cut' }));
menu.append(new MenuItem({ label: global.$t('paste'), role: 'paste' }));
menu.append(new MenuItem({ label: global.$t('selectAll'), role: 'selectall' }));

exports.promptTouchID = (msg) => {
if (process.platform === 'darwin' && systemPreferences.canPromptTouchID()) {
return systemPreferences.promptTouchID(msg);
}
return Promise.resolve();
};

exports.isEnableTouchID = () => {
return global.settingsStore.get('enableTouchID');
};

exports.popupMenu = function() {
menu.popup(global.WALLET_WIN);
};

0 comments on commit c85698b

Please sign in to comment.