Fixed issue on search

This commit is contained in:
liangping 2022-04-10 18:30:00 +08:00
parent 62643e9e07
commit cddc6906c5
2 changed files with 421 additions and 380 deletions

View File

@ -27,14 +27,18 @@
<b-form-input <b-form-input
v-if="showSearchBar" v-if="showSearchBar"
v-model="searchQuery" v-model="searchQuery"
placeholder="Search Height/Transaction/Address" placeholder="Search Height/Transaction/Account Address"
autofocus autofocus
:state="false"
autocomplete="off" autocomplete="off"
@keyup.enter="doQuery" @keyup.enter="doQuery"
/> />
<b-form-text class="text-danger pl-3">
{{ error }}
</b-form-text>
<div <div
class="search-input-close" class="search-input-close"
@click="showSearchBar = false;" @click="reset()"
> >
<feather-icon icon="XIcon" /> <feather-icon icon="XIcon" />
</div> </div>
@ -43,7 +47,7 @@
</template> </template>
<script> <script>
import { BFormInput } from 'bootstrap-vue' import { BFormInput, BFormText } from 'bootstrap-vue'
import { ref } from '@vue/composition-api' import { ref } from '@vue/composition-api'
import { title } from '@core/utils/filter' import { title } from '@core/utils/filter'
import store from '@/store' import store from '@/store'
@ -51,6 +55,7 @@ import store from '@/store'
export default { export default {
components: { components: {
BFormInput, BFormInput,
BFormText,
}, },
setup() { setup() {
const showSearchBar = ref(false) const showSearchBar = ref(false)
@ -68,13 +73,19 @@ export default {
data() { data() {
return { return {
searchQuery: null, searchQuery: null,
error: null,
} }
}, },
methods: { methods: {
reset() {
this.showSearchBar = false
this.searchQuery = null
this.error = null
},
doQuery() { doQuery() {
const height = /^\d+$/ const height = /^\d+$/
const txhash = /^[A-Z\d]{64}$/ const txhash = /^[A-Z\d]{64}$/
const addr = /^[a-z]{2,6}1[a-z\d]{38}$/ const addr = /^[a-z]+1[a-z\d]{38}$/
const key = this.searchQuery const key = this.searchQuery
const c = store.state.chains.selected const c = store.state.chains.selected
@ -85,7 +96,8 @@ export default {
this.$router.push({ name: 'transaction', params: { chain: c.chain_name, hash: key } }) this.$router.push({ name: 'transaction', params: { chain: c.chain_name, hash: key } })
} else if (addr.test(key)) { } else if (addr.test(key)) {
this.$router.push({ name: 'chain-account', params: { chain: c.chain_name, address: key } }) this.$router.push({ name: 'chain-account', params: { chain: c.chain_name, address: key } })
// console.log('address', key) } else {
this.error = 'The input not recognized'
} }
} }
// this.$router.push('/') // this.$router.push('/')

View File

@ -1,5 +1,6 @@
<template> <template>
<div> <div>
<div v-if="!error">
<b-card <b-card
bg-variant="secondary" bg-variant="secondary"
style="color: #fff" style="color: #fff"
@ -106,7 +107,10 @@
<span class="ml-25">{{ token.percent }}%</span> <span class="ml-25">{{ token.percent }}%</span>
</div> </div>
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<span class="text-right">{{ formatToken(token) }}</span> <span
v-b-tooltip.hover.top="token.denom"
class="text-right"
>{{ formatToken(token) }}</span>
<small class="text-right">{{ currency }}{{ formatNumber(token.currency) }}</small> <small class="text-right">{{ currency }}{{ formatNumber(token.currency) }}</small>
</div> </div>
</div> </div>
@ -385,6 +389,27 @@
/> />
<div id="txevent" /> <div id="txevent" />
</div> </div>
<div v-else>
<div class="misc-inner p-2 p-sm-3">
<div class="w-100 text-center">
<h2 class="mb-1">
Account not found 🕵🏻
</h2>
<p class="mb-2">
Oops! 😖 {{ error }}.
</p>
<b-button
variant="primary"
class="mb-2 btn-sm-block"
:to="{path:'../'}"
>
Back to home
</b-button>
</div>
</div>
</div>
</div>
</template> </template>
<script> <script>
@ -455,6 +480,7 @@ export default {
transactions: [], transactions: [],
stakingParameters: {}, stakingParameters: {},
operationModalType: '', operationModalType: '',
error: null,
} }
}, },
computed: { computed: {
@ -605,7 +631,6 @@ export default {
created() { created() {
this.$http.getAuthAccount(this.address).then(acc => { this.$http.getAuthAccount(this.address).then(acc => {
this.account = acc this.account = acc
})
this.initial() this.initial()
this.$http.getTxsBySender(this.address).then(res => { this.$http.getTxsBySender(this.address).then(res => {
this.transactions = res this.transactions = res
@ -613,6 +638,10 @@ export default {
this.$http.getStakingParameters().then(res => { this.$http.getStakingParameters().then(res => {
this.stakingParameters = res this.stakingParameters = res
}) })
}).catch(err => {
console.log(err)
this.error = err
})
}, },
mounted() { mounted() {
const elem = document.getElementById('txevent') const elem = document.getElementById('txevent')