From 3c934baa07596904de4a88cef972a050e2ad3533 Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Sat, 17 Nov 2018 16:10:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86Login.vue?= =?UTF-8?q?=E9=87=8C"renewing"=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E4=BB=8D=E7=84=B6=E4=B8=8D=E8=83=BD=E8=B0=83=E7=94=A8?= =?UTF-8?q?=20randomSecword()=EF=BC=8C=E8=BF=99=E5=8F=A5=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20"window=20is=20not=20defined"=E3=80=82?= =?UTF-8?q?=E7=8C=9C=E6=B5=8B=E6=98=AF=20bitcore-mnemonic=20=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=9C=A8=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=E9=87=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/api/tic-bg.js | 8 ++++---- src/services/api/tic.js | 6 +++--- src/services/axios.js | 2 +- src/store/modules/login.js | 5 +++-- src/views/Login.vue | 4 +++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/services/api/tic-bg.js b/src/services/api/tic-bg.js index 618c15c..0f4c64b 100644 --- a/src/services/api/tic-bg.js +++ b/src/services/api/tic-bg.js @@ -1,7 +1,7 @@ import { Crypto as ticCrypto } from 'tic.common' -export const secword2PubKey = secword => ticCrypto.seckey2pubkey(secword) -export const secword2Address = secword => ticCrypto.secword2address(secword) -export const isAddress = address => ticCrypto.isAddress(address) -export const secword2Account = secword => ticCrypto.secword2account(secword) +export const seckey2pubkey = seckey => ticCrypto.seckey2pubkey(seckey) +export const secword2address = secword => ticCrypto.secword2address(secword) +export const secword2account = secword => ticCrypto.secword2account(secword) export const randomSecword = lang => ticCrypto.randomSecword(lang) +export const isAddress = address => ticCrypto.isAddress(address) diff --git a/src/services/api/tic.js b/src/services/api/tic.js index dfa2ffd..adcd1c1 100644 --- a/src/services/api/tic.js +++ b/src/services/api/tic.js @@ -4,9 +4,9 @@ import * as worker from 'workerize-loader!./tic-bg' const instance = worker() export default { - secword2PubKey: async secword => instance.secword2PubKey(secword), - secword2Address: async secword => instance.secword2Address(secword), + seckey2pubkey: async seckey => instance.seckey2pubkey(seckey), + secword2address: async secword => instance.secword2address(secword), isAddress: async address => instance.isAddress(address), - secword2Account: async secword => instance.secword2Account(secword), + secword2account: async secword => instance.secword2account(secword), randomSecword: async lang => instance.randomSecword(lang), } diff --git a/src/services/axios.js b/src/services/axios.js index ced9f1d..ee10e01 100644 --- a/src/services/axios.js +++ b/src/services/axios.js @@ -2,4 +2,4 @@ // import app from './app' // 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台,或者访问用户自己设置的主机。 -axios.defaults.baseURL = 'http://localhost:6842/api/' +axios.defaults.baseURL = `http://${window.location.hostname}:6842/api/` diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 2f360be..60545b2 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -10,6 +10,7 @@ export default { mnemonic: '', errorMnemonic: '', signing: false, + renewing: false, }, getters: { @@ -36,7 +37,7 @@ export default { actions: { async login({ state, commit }) { commit('updateSign', true) - const account = (await ticApi.secword2Account(state.mnemonic)) || {} + const account = (await ticApi.secword2account(state.mnemonic)) || {} console.log(account) commit('updateSign', false) if (await ticApi.isAddress(account.address)) { @@ -48,7 +49,7 @@ export default { }, async createSecword({ state, commit }) { alert('entering createSecword') - let secword = await ticApi.randomSecword('English') + let secword = await ticApi.randomSecword() // 这句导致报错 "window is not defined"。猜测是 bitcore-mnemonic 不能在前端页面里使用。 alert('after secword') console.info('secword=' + secword) alert('secword=' + secword) diff --git a/src/views/Login.vue b/src/views/Login.vue index 2007258..37a29dc 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -12,6 +12,7 @@ :error-messages="errorMnemonic" :value="mnemonic" :loading="signing" + :renewing="renewing" @input="updateMnemonic" @keyup.13="login" :label="$t('login.inputLabel')" /> @@ -26,7 +27,7 @@ item-text="label" /> - + {{ $t('login.secwordBtn') }} @@ -53,6 +54,7 @@ export default { 'mnemonic', 'errorMnemonic', 'signing', + 'renewing', ]), ...mapGetters([ 'inputError', From 1214c9156d7f86eb490f5dd4ec79e9d5021cf4f0 Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Sun, 18 Nov 2018 16:40:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20httpall=20=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E8=BE=93=E5=87=BA=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index f93cd05..74e5a51 100644 --- a/server.js +++ b/server.js @@ -101,14 +101,14 @@ async function init(){ /*** 设置全局对象 ***/ }else if ('httpall'===wo.Config.protocol) { let portHttp=wo.Config.port?wo.Config.port:80 // 如果port参数已设置,使用它;否则默认为80 require('http').createServer(server).listen(portHttp, function(err) { - console.log('Server listening on %s://%s:%d for %s environment', wo.Config.protocol, wo.Config.host, portHttp, server.settings.env) + console.log('Server listening on %s://%s:%d for %s environment', 'httpall:http', wo.Config.host, portHttp, server.settings.env) }) let portHttps=(wo.Config.port && wo.Config.port!==80)?wo.Config.port+443:443 // 如果port参数已设置,使用它+443;否则默认为443 require('https').createServer({ key: fs.readFileSync(wo.Config.sslKey), cert: fs.readFileSync(wo.Config.sslCert) // , ca: [ fs.readFileSync(wo.Config.sslCA) ] // https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener }, server).listen(portHttps, function(err){ - console.log('Server listening on %s://%s:%d for %s environment', wo.Config.protocol, wo.Config.host, portHttps, server.settings.env) + console.log('Server listening on %s://%s:%d for %s environment', 'httpall:https', wo.Config.host, portHttps, server.settings.env) }) }