cosmos-explorer/src/main.ts

32 lines
800 B
TypeScript
Raw Normal View History

2023-06-12 09:04:14 +00:00
// import 'ping-widget';
2023-04-24 15:12:08 +00:00
import App from '@/App.vue';
import i18n from '@/plugins/i18n';
import '@/style.css';
2023-05-20 01:53:01 +00:00
import { createApp, ref } from 'vue';
2023-04-24 15:12:08 +00:00
import { createPinia } from 'pinia';
2023-05-10 17:53:59 +00:00
import LazyLoad from 'lazy-load-vue3';
2023-05-27 14:39:43 +00:00
2023-04-24 15:12:08 +00:00
import router from './router';
import { useBaseStore } from './stores/useBaseStore';
2023-04-03 09:08:02 +00:00
// Create vue app
const app = createApp(App);
// Use plugins
2023-04-24 15:12:08 +00:00
app.use(i18n);
2023-04-03 09:08:02 +00:00
app.use(createPinia());
app.use(router);
2023-05-10 17:53:59 +00:00
app.use(LazyLoad, { component: true });
2023-04-03 09:08:02 +00:00
// Mount vue app
2023-04-24 15:12:08 +00:00
app.mount('#app');
2023-04-03 09:08:02 +00:00
// fetch latest block every 6s
2023-05-27 14:39:43 +00:00
const blockStore = useBaseStore();
const requestCounter = ref(0);
2023-05-20 01:53:01 +00:00
setInterval(() => {
2023-05-27 14:39:43 +00:00
requestCounter.value += 1;
if (requestCounter.value < 5) {
// max allowed request
blockStore.fetchLatest().finally(() => (requestCounter.value -= 1));
}
}, 6000);