在 webworker (services/api) 里调用 randomSecword 导致出错 "window is not defined"。因此直接调用 ticCrypto.randomSecword。
登录后刷新地址和余额。
This commit is contained in:
@@ -3,5 +3,5 @@
|
||||
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 randomSecword = lang => ticCrypto.randomSecword(lang)
|
||||
export const isAddress = address => ticCrypto.isAddress(address)
|
||||
|
||||
@@ -8,5 +8,5 @@ export default {
|
||||
secword2address: async secword => instance.secword2address(secword),
|
||||
isAddress: async address => instance.isAddress(address),
|
||||
secword2account: async secword => instance.secword2account(secword),
|
||||
randomSecword: async lang => instance.randomSecword(lang),
|
||||
// randomSecword: async lang => instance.randomSecword(lang),
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import router from '../../router'
|
||||
import { i18n } from '../../i18n'
|
||||
import _ from 'lodash'
|
||||
import ticCrypto from 'tic.crypto'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
@@ -38,7 +39,6 @@ export default {
|
||||
async login({ state, commit }) {
|
||||
commit('updateSign', true)
|
||||
const account = (await ticApi.secword2account(state.mnemonic)) || {}
|
||||
console.log(account)
|
||||
commit('updateSign', false)
|
||||
if (await ticApi.isAddress(account.address)) {
|
||||
commit('updateAccount', _.omit(account, 'seckey'), { root: true })
|
||||
@@ -48,11 +48,8 @@ export default {
|
||||
}
|
||||
},
|
||||
async createSecword({ state, commit }) {
|
||||
alert('entering createSecword')
|
||||
let secword = await ticApi.randomSecword() // 这句导致报错 "window is not defined"。猜测是 bitcore-mnemonic 不能在前端页面里使用。
|
||||
alert('after secword')
|
||||
console.info('secword=' + secword)
|
||||
alert('secword=' + secword)
|
||||
let secword = ticCrypto.randomSecword() // 不能用 webworker 里的randomSecword,会导致报错 "window is not defined"。猜测是 bitcore-mnemonic 用到了window。
|
||||
commit('updateMnemonic', secword)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ export default {
|
||||
fetching: false,
|
||||
filter: '',
|
||||
balance: 0,
|
||||
address: '',
|
||||
},
|
||||
|
||||
mutations: {
|
||||
@@ -40,6 +41,10 @@ export default {
|
||||
updateBalance(state, balance) {
|
||||
state.balance = balance
|
||||
},
|
||||
|
||||
updateAddress(state, address) {
|
||||
state.address = address
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
@@ -47,6 +52,7 @@ export default {
|
||||
let account = sessionStorage.getItem('KEY_ACCOUNT')
|
||||
try {
|
||||
account = JSON.parse(account)
|
||||
commit('updateAddress', account.address)
|
||||
const result = await axios.post('Account/getBalance', {
|
||||
Account: { address: account.address },
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<div class="owner-page">
|
||||
<div class="card-content">
|
||||
<div class="app-card elevation-1">
|
||||
<div>主人地址为 {{ address }}</div>
|
||||
<div>余额为 {{ balance }}</div>
|
||||
</div>
|
||||
<div class="app-sep"></div>
|
||||
@@ -68,6 +69,7 @@ export default {
|
||||
'fetching',
|
||||
'filter',
|
||||
'balance',
|
||||
'address',
|
||||
]),
|
||||
...mapGetters([]),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user