forked from LaconicNetwork/cosmos-explorer
Finish search bar
This commit is contained in:
+26
-14
@@ -66,24 +66,36 @@ export default {
|
||||
],
|
||||
}
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
const { height } = to.params
|
||||
if (height > 0 && height !== from.params.height) {
|
||||
this.initData(height)
|
||||
next()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const { height } = this.$route.params
|
||||
this.$http.getBlockByHeight(height).then(res => {
|
||||
this.block = res
|
||||
const { txs } = res.block.data
|
||||
const array = []
|
||||
for (let i = 0; i <= txs.length; i += 1) {
|
||||
try {
|
||||
const origin = decodeTxRaw(fromBase64(txs[i]))
|
||||
const tx = Tx.create(origin)
|
||||
tx.setHash(txs[i])
|
||||
array.push(tx)
|
||||
} catch (e) {
|
||||
this.initData(height)
|
||||
},
|
||||
methods: {
|
||||
initData(height) {
|
||||
this.$http.getBlockByHeight(height).then(res => {
|
||||
this.block = res
|
||||
const { txs } = res.block.data
|
||||
const array = []
|
||||
for (let i = 0; i <= txs.length; i += 1) {
|
||||
try {
|
||||
const origin = decodeTxRaw(fromBase64(txs[i]))
|
||||
const tx = Tx.create(origin)
|
||||
tx.setHash(txs[i])
|
||||
array.push(tx)
|
||||
} catch (e) {
|
||||
// catch errors
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array.length > 0) this.txs = array
|
||||
})
|
||||
if (array.length > 0) this.txs = array
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
<b-tr>
|
||||
<b-td>
|
||||
{{ 'height' }}
|
||||
</b-td><b-td>{{ tx.height }}</b-td>
|
||||
</b-td><b-td>
|
||||
<router-link :to="`../blocks/${tx.height}`">
|
||||
{{ tx.height }}
|
||||
</router-link></b-td>
|
||||
</b-tr>
|
||||
<b-tr>
|
||||
<b-td>
|
||||
@@ -103,6 +106,16 @@ export default {
|
||||
tx: { tx: {} },
|
||||
}
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
const { hash } = to.params
|
||||
console.log(hash !== from.params.hash, hash, from.params)
|
||||
if (hash !== from.params.hash) {
|
||||
this.$http.getTxs(hash).then(res => {
|
||||
this.tx = res
|
||||
})
|
||||
next()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const { hash } = this.$route.params
|
||||
this.$http.getTxs(hash).then(res => {
|
||||
|
||||
Reference in New Issue
Block a user