This commit is contained in:
liangping 2023-06-13 20:20:07 +08:00
parent 63f86a5b6a
commit 6437369d84

View File

@ -14,7 +14,7 @@ const props = defineProps(['height', 'chain']);
const store = useBaseStore(); const store = useBaseStore();
const format = useFormatter() const format = useFormatter()
const current = ref({} as Block) const current = ref({} as Block)
const target =ref(Number(props.height||0)) const target = ref(Number(props.height || 0))
const height = computed(() => { const height = computed(() => {
return Number(current.value.block?.header?.height || props.height || 0); return Number(current.value.block?.header?.height || props.height || 0);
@ -23,8 +23,8 @@ const height = computed(() => {
const isFutureBlock = computed({ const isFutureBlock = computed({
get: () => { get: () => {
const latest = store.latest?.block?.header.height const latest = store.latest?.block?.header.height
const isFuture = latest ? target.value > Number(latest): true const isFuture = latest ? target.value > Number(latest) : true
if(!isFuture && !current.value.block_id) store.fetchBlock(target.value).then(x => current.value = x) if (!isFuture && !current.value.block_id) store.fetchBlock(target.value).then(x => current.value = x)
return isFuture return isFuture
}, },
set: val => { set: val => {
@ -63,36 +63,44 @@ onBeforeRouteUpdate(async (to, from, next) => {
<template> <template>
<div> <div>
<div v-if="isFutureBlock" class="text-center pt-28"> <div v-if="isFutureBlock" class="text-center pt-28">
<Countdown :time="estimateTime" css="text-5xl font-sans md:mx-5"/> <div v-if="remainingBlocks > 0">
<div class="my-5">Estimated Time: <span class="text-xl font-bold">{{ format.toLocaleDate(estimateDate) }}</span></div> <Countdown :time="estimateTime" css="text-5xl font-sans md:mx-5" />
<div class="pt-10 flex justify-center"> <div class="my-5">Estimated Time: <span class="text-xl font-bold">{{ format.toLocaleDate(estimateDate) }}</span>
<table class="table table-compact rounded-lg"> </div>
<tbody> <div class="pt-10 flex justify-center">
<tr class="hover cursor-pointer" @click="edit = !edit"> <table class="table table-compact rounded-lg">
<td>Countdown For Block:</td><td class="text-right"><span class=" ml-40">{{ target }}</span></td> <tbody>
</tr> <tr class="hover cursor-pointer" @click="edit = !edit">
<tr v-if="edit"> <td>Countdown For Block:</td>
<td colspan="2" class="text-center"> <td class="text-right"><span class=" ml-40">{{ target }}</span></td>
<h3 class="text-lg font-bold">Input A New Target Block Number</h3> </tr>
<p class="py-4"> <tr v-if="edit">
<td colspan="2" class="text-center">
<h3 class="text-lg font-bold">Input A New Target Block Number</h3>
<p class="py-4">
<div class="join"> <div class="join">
<input class="input input-bordered join-item" v-model="newHeight" type="number" /> <input class="input input-bordered join-item" v-model="newHeight" type="number" />
<button class="btn btn-primary join-item" @click="updateTarget()">Update</button> <button class="btn btn-primary join-item" @click="updateTarget()">Update</button>
</div> </div>
</p> </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Current Height:</td><td class="text-right">#{{ store.latest?.block?.header.height }}</td> <td>Current Height:</td>
</tr> <td class="text-right">#{{ store.latest?.block?.header.height }}</td>
<tr> </tr>
<td>Remaining Blocks:</td><td class="text-right">{{ remainingBlocks }}</td> <tr>
</tr> <td>Remaining Blocks:</td>
<tr> <td class="text-right">{{ remainingBlocks }}</td>
<td>Average Block Time:</td><td class="text-right">{{ (store.blocktime/1000).toFixed(1) }}s</td> </tr>
</tr> <tr>
</tbody> <td>Average Block Time:</td>
</table> <td class="text-right">{{ (store.blocktime / 1000).toFixed(1) }}s</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
<div v-else> <div v-else>
@ -129,6 +137,5 @@ onBeforeRouteUpdate(async (to, from, next) => {
<h2 class="card-title flex flex-row justify-between">Last Commit</h2> <h2 class="card-title flex flex-row justify-between">Last Commit</h2>
<DynamicComponent :value="current.block?.last_commit" /> <DynamicComponent :value="current.block?.last_commit" />
</div> </div>
</div>
</div> </div>
</template> </div></template>