From 70ddca4693a74ff1c05d54fb4be1d98bad4bbd50 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 11 Sep 2021 11:24:21 +0800 Subject: [PATCH] Show chain status --- src/layouts/components/Navbar.vue | 15 +++++++++++++-- src/views/Home.vue | 7 +++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/layouts/components/Navbar.vue b/src/layouts/components/Navbar.vue index b08d0f2e..7125a20d 100644 --- a/src/layouts/components/Navbar.vue +++ b/src/layouts/components/Navbar.vue @@ -37,13 +37,14 @@ @click="toggleVerticalMenuActive" > @@ -133,6 +134,7 @@ import Locale from '@core/layouts/components/app-navbar/components/Locale.vue' import SearchBar from '@core/layouts/components/app-navbar/components/SearchBar.vue' // import CartDropdown from '@core/layouts/components/app-navbar/components/CartDropdown.vue' import store from '@/store' +import { timeIn, toDay } from '@/libs/data' // import UserDropdown from '@core/layouts/components/app-navbar/components/UserDropdown.vue' export default { @@ -164,7 +166,8 @@ export default { }, data() { return { - // result: {}, + chainVariant: 'success', + tips: 'Synced', } }, computed: { @@ -172,5 +175,13 @@ export default { return store.state.chains.selected }, }, + created() { + this.$http.getLatestBlock().then(block => { + if (timeIn(block.block.header.time, 1, 'm')) { + this.chainVariant = 'danger' + this.tips = `Halted ${toDay(block.block.header.time, 'from')} ` + } + }) + }, } diff --git a/src/views/Home.vue b/src/views/Home.vue index c266afd9..a6686f1e 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -59,10 +59,12 @@ > @@ -93,7 +95,7 @@ import { } from 'bootstrap-vue' import VuexyLogo from '@core/layouts/components/Logo.vue' import store from '@/store/index' -import { toDay } from '@/libs/data' +import { timeIn, toDay } from '@/libs/data' import DarkToggler from '@/@core/layouts/components/app-navbar/components/DarkToggler.vue' import Locale from '@/@core/layouts/components/app-navbar/components/Locale.vue' import AppFooter from '@/@core/layouts/components/AppFooter.vue' @@ -148,6 +150,7 @@ export default { const { header } = b.block this.$set(chain, 'height', header.height) this.$set(chain, 'time', toDay(header.time)) + this.$set(chain, 'variant', timeIn(header, 1, 'm') ? 'danger' : 'success') }) } })