From 63f86a5b6aad0f781a7274edd4756ffd80fae41e Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 13 Jun 2023 20:18:24 +0800 Subject: [PATCH] feat: add future blocks --- src/modules/[chain]/block/[height].vue | 37 +++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/modules/[chain]/block/[height].vue b/src/modules/[chain]/block/[height].vue index 4ec73fa2..3203f4d5 100644 --- a/src/modules/[chain]/block/[height].vue +++ b/src/modules/[chain]/block/[height].vue @@ -14,6 +14,7 @@ const props = defineProps(['height', 'chain']); const store = useBaseStore(); const format = useFormatter() const current = ref({} as Block) +const target =ref(Number(props.height||0)) const height = computed(() => { return Number(current.value.block?.header?.height || props.height || 0); @@ -22,8 +23,8 @@ const height = computed(() => { const isFutureBlock = computed({ get: () => { const latest = store.latest?.block?.header.height - const isFuture = latest ? Number(props.height) > Number(latest): true - if(!isFuture) store.fetchBlock(props.height).then(x => current.value = x) + const isFuture = latest ? target.value > Number(latest): true + if(!isFuture && !current.value.block_id) store.fetchBlock(target.value).then(x => current.value = x) return isFuture }, set: val => { @@ -33,7 +34,7 @@ const isFutureBlock = computed({ const remainingBlocks = computed(() => { const latest = store.latest?.block?.header.height - return latest ? Number(props.height) - Number(latest) : 0 + return latest ? Number(target.value) - Number(latest) : 0 }) const estimateTime = computed(() => { @@ -45,6 +46,13 @@ const estimateDate = computed(() => { return new Date(new Date().getTime() + estimateTime.value) }) +const edit = ref(false) +const newHeight = ref(props.height) +function updateTarget() { + target.value = Number(newHeight.value) + console.log(target.value) +} + onBeforeRouteUpdate(async (to, from, next) => { if (from.path !== to.path) { store.fetchBlock(String(to.params.height)).then(x => current.value = x); @@ -56,20 +64,31 @@ onBeforeRouteUpdate(async (to, from, next) => {
Countdown For Block: | #{{ height }} | +
Countdown For Block: | {{ target }} |
+ Input A New Target Block Number++
+
+
+
+
+ |
+ |
Current Height: | #{{ store.latest?.block?.header.height }} |
Remaining Blocks: | {{ remainingBlocks }} |
Average Block Time: | {{ (store.blocktime/1000).toFixed(1) }}s |