From 93d7f0b2293c103bd68b31fdd9bac22489642060 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 20 May 2023 09:53:01 +0800 Subject: [PATCH] improve uptime and blocks --- src/main.ts | 10 ++++++++-- src/modules/[chain]/block/index.vue | 12 +++++++----- src/modules/[chain]/uptime/index.vue | 11 +++++++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main.ts b/src/main.ts index 08060b8d..64d1539b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,7 @@ import { loadFonts } from '@/plugins/vuetify/webfontloader'; import '@/plugins/vuetify/@core/scss/template/index.scss'; import '@/plugins/vuetify/styles/styles.scss'; import '@/style.css'; -import { createApp } from 'vue'; +import { createApp, ref } from 'vue'; import { createPinia } from 'pinia'; import LazyLoad from 'lazy-load-vue3'; // import router from "@/plugins/vuetify/router"; @@ -32,4 +32,10 @@ app.mount('#app'); // fetch latest block every 6s const blockStore = useBaseStore() -setInterval(() => {blockStore.fetchLatest()}, 6000) +const requestCounter = ref(0) +setInterval(() => { + requestCounter.value += 1 + if(requestCounter.value < 5) { // max allowed request + blockStore.fetchLatest().finally(() => requestCounter.value -= 1) + } +}, 6000) diff --git a/src/modules/[chain]/block/index.vue b/src/modules/[chain]/block/index.vue index 6bfeac4c..da1eea1d 100644 --- a/src/modules/[chain]/block/index.vue +++ b/src/modules/[chain]/block/index.vue @@ -10,7 +10,9 @@ const base = useBaseStore() const format = useFormatter(); const list = computed(() => { - return base.recents.reverse() + // const recents = base.recents + // return recents.sort((a, b) => (Number(b.block.header.height) - Number(a.block.header.height))) + return base.recents })