diff --git a/src/layouts/components/NavbarSearch.vue b/src/layouts/components/NavbarSearch.vue index 9cc1b6f6..d4202878 100644 --- a/src/layouts/components/NavbarSearch.vue +++ b/src/layouts/components/NavbarSearch.vue @@ -31,7 +31,7 @@ function confirm() { } const height = /^\d+$/; const txhash = /^[A-Z\d]{64}$/; - const addr = /^[a-z]+1[a-z\d]{38,58}$/; + const addr = /^[a-z\d]+1[a-z\d]{38,58}$/; const current = blockStore?.current?.chainName || ''; const routeParams = vueRouters?.currentRoute?.value; diff --git a/src/modules/[chain]/consensus/index.vue b/src/modules/[chain]/consensus/index.vue index 6e55dbb0..97f5e267 100644 --- a/src/modules/[chain]/consensus/index.vue +++ b/src/modules/[chain]/consensus/index.vue @@ -20,7 +20,7 @@ let rate = ref(''); let height = ref(''); let round = ref(''); let step = ref(''); -let timer = null; +let timer = null as any; let updatetime = ref(new Date()); let positions = ref([]); let validatorsData = ref([] as any); @@ -28,16 +28,21 @@ onMounted(async () => { // stakingStore.init(); validatorsData.value = await stakingStore.fetchAcitveValdiators(); rpc.value = rpcList.value[0].address + '/consensus_state'; - fetchPosition(); + await fetchPosition(); update(); + clearTime() timer = setInterval(() => { update(); }, 6000); }); onUnmounted(() => { - timer = null; + clearTime(); }); +function clearTime() { + clearInterval(timer); + timer = null; +} const newTime = computed(() => { return format.toDay(updatetime.value, 'time'); }); @@ -75,12 +80,12 @@ function color(i: number, txt: string) { } return txt === 'nil-Vote' ? 'gray-700' : 'success'; } -function onChange() { +async function onChange () { httpstatus.value = 200; httpStatusText.value = ''; roundState.value = {}; - timer = null; - fetchPosition(); + clearTime(); + await fetchPosition(); update(); timer = setInterval(() => { update(); @@ -94,6 +99,7 @@ async function fetchPosition() { if (!response.ok) { throw new Error(`HTTP error: ${response.status}`); } + httpstatus.value = response.status; httpStatusText.value = response.statusText; @@ -110,6 +116,7 @@ async function fetchPosition() { async function update() { rate.value = '0%'; updatetime.value = new Date(); + console.log(httpstatus, 'httpstatus') if (httpstatus.value === 200) { fetch(rpc.value) .then((data) => {