修正了Login.vue里"renewing"的问题,但仍然不能调用 randomSecword(),这句导致报错 "window is not defined"。猜测是 bitcore-mnemonic 不能在前端页面里使用。
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Crypto as ticCrypto } from 'tic.common'
|
import { Crypto as ticCrypto } from 'tic.common'
|
||||||
|
|
||||||
export const secword2PubKey = secword => ticCrypto.seckey2pubkey(secword)
|
export const seckey2pubkey = seckey => ticCrypto.seckey2pubkey(seckey)
|
||||||
export const secword2Address = secword => ticCrypto.secword2address(secword)
|
export const secword2address = secword => ticCrypto.secword2address(secword)
|
||||||
export const isAddress = address => ticCrypto.isAddress(address)
|
export const secword2account = secword => ticCrypto.secword2account(secword)
|
||||||
export const secword2Account = secword => ticCrypto.secword2account(secword)
|
|
||||||
export const randomSecword = lang => ticCrypto.randomSecword(lang)
|
export const randomSecword = lang => ticCrypto.randomSecword(lang)
|
||||||
|
export const isAddress = address => ticCrypto.isAddress(address)
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import * as worker from 'workerize-loader!./tic-bg'
|
|||||||
const instance = worker()
|
const instance = worker()
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
secword2PubKey: async secword => instance.secword2PubKey(secword),
|
seckey2pubkey: async seckey => instance.seckey2pubkey(seckey),
|
||||||
secword2Address: async secword => instance.secword2Address(secword),
|
secword2address: async secword => instance.secword2address(secword),
|
||||||
isAddress: async address => instance.isAddress(address),
|
isAddress: async address => instance.isAddress(address),
|
||||||
secword2Account: async secword => instance.secword2Account(secword),
|
secword2account: async secword => instance.secword2account(secword),
|
||||||
randomSecword: async lang => instance.randomSecword(lang),
|
randomSecword: async lang => instance.randomSecword(lang),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
// import app from './app'
|
// import app from './app'
|
||||||
|
|
||||||
// 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台,或者访问用户自己设置的主机。
|
// 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台,或者访问用户自己设置的主机。
|
||||||
axios.defaults.baseURL = 'http://localhost:6842/api/'
|
axios.defaults.baseURL = `http://${window.location.hostname}:6842/api/`
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export default {
|
|||||||
mnemonic: '',
|
mnemonic: '',
|
||||||
errorMnemonic: '',
|
errorMnemonic: '',
|
||||||
signing: false,
|
signing: false,
|
||||||
|
renewing: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
@@ -36,7 +37,7 @@ export default {
|
|||||||
actions: {
|
actions: {
|
||||||
async login({ state, commit }) {
|
async login({ state, commit }) {
|
||||||
commit('updateSign', true)
|
commit('updateSign', true)
|
||||||
const account = (await ticApi.secword2Account(state.mnemonic)) || {}
|
const account = (await ticApi.secword2account(state.mnemonic)) || {}
|
||||||
console.log(account)
|
console.log(account)
|
||||||
commit('updateSign', false)
|
commit('updateSign', false)
|
||||||
if (await ticApi.isAddress(account.address)) {
|
if (await ticApi.isAddress(account.address)) {
|
||||||
@@ -48,7 +49,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async createSecword({ state, commit }) {
|
async createSecword({ state, commit }) {
|
||||||
alert('entering createSecword')
|
alert('entering createSecword')
|
||||||
let secword = await ticApi.randomSecword('English')
|
let secword = await ticApi.randomSecword() // 这句导致报错 "window is not defined"。猜测是 bitcore-mnemonic 不能在前端页面里使用。
|
||||||
alert('after secword')
|
alert('after secword')
|
||||||
console.info('secword=' + secword)
|
console.info('secword=' + secword)
|
||||||
alert('secword=' + secword)
|
alert('secword=' + secword)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
:error-messages="errorMnemonic"
|
:error-messages="errorMnemonic"
|
||||||
:value="mnemonic"
|
:value="mnemonic"
|
||||||
:loading="signing"
|
:loading="signing"
|
||||||
|
:renewing="renewing"
|
||||||
@input="updateMnemonic"
|
@input="updateMnemonic"
|
||||||
@keyup.13="login"
|
@keyup.13="login"
|
||||||
:label="$t('login.inputLabel')" />
|
:label="$t('login.inputLabel')" />
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
item-text="label"
|
item-text="label"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-btn :loading="renewing" dark large color="transparent" @click="createSecword">
|
<v-btn :renewing="renewing" dark large color="transparent" @click="createSecword">
|
||||||
{{ $t('login.secwordBtn') }}
|
{{ $t('login.secwordBtn') }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ export default {
|
|||||||
'mnemonic',
|
'mnemonic',
|
||||||
'errorMnemonic',
|
'errorMnemonic',
|
||||||
'signing',
|
'signing',
|
||||||
|
'renewing',
|
||||||
]),
|
]),
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'inputError',
|
'inputError',
|
||||||
|
|||||||
Reference in New Issue
Block a user