cosmos-explorer/src/main.ts
2023-06-12 17:04:14 +08:00

32 lines
800 B
TypeScript

// import 'ping-widget';
import App from '@/App.vue';
import i18n from '@/plugins/i18n';
import '@/style.css';
import { createApp, ref } from 'vue';
import { createPinia } from 'pinia';
import LazyLoad from 'lazy-load-vue3';
import router from './router';
import { useBaseStore } from './stores/useBaseStore';
// Create vue app
const app = createApp(App);
// Use plugins
app.use(i18n);
app.use(createPinia());
app.use(router);
app.use(LazyLoad, { component: true });
// Mount vue app
app.mount('#app');
// fetch latest block every 6s
const blockStore = useBaseStore();
const requestCounter = ref(0);
setInterval(() => {
requestCounter.value += 1;
if (requestCounter.value < 5) {
// max allowed request
blockStore.fetchLatest().finally(() => (requestCounter.value -= 1));
}
}, 6000);