cosmos-explorer/src/App.vue

102 lines
3.0 KiB
Vue
Raw Normal View History

2021-07-21 14:07:38 +00:00
<template>
<div
id="app"
class="h-100"
:class="[skinClasses]"
>
<component :is="layout">
<router-view />
</component>
</div>
</template>
<script>
// This will be populated in `beforeCreate` hook
import { $themeColors, $themeBreakpoints, $themeConfig } from '@themeConfig'
import { provideToast } from 'vue-toastification/composition'
import { watch } from '@vue/composition-api'
import useAppConfig from '@core/app-config/useAppConfig'
import { useWindowSize, useCssVar } from '@vueuse/core'
import store from '@/store'
const LayoutVertical = () => import('@/layouts/vertical/LayoutVertical.vue')
const LayoutFull = () => import('@/layouts/full/LayoutFull.vue')
export default {
components: {
// Layouts
LayoutVertical,
LayoutFull,
},
2022-05-19 13:14:02 +00:00
setup() {
const { skin, skinClasses } = useAppConfig()
// If skin is dark when initialized => Add class to body
if (skin.value === 'dark') document.body.classList.add('dark-layout')
2021-07-22 02:38:16 +00:00
2022-05-19 13:14:02 +00:00
// Provide toast for Composition API usage
// This for those apps/components which uses composition API
// Demos will still use Options API for ease
provideToast({
hideProgressBar: true,
closeOnClick: false,
closeButton: false,
icon: false,
timeout: 3000,
transition: 'Vue-Toastification__fade',
})
// Set Window Width in store
store.commit('app/UPDATE_WINDOW_WIDTH', window.innerWidth)
const { width: windowWidth } = useWindowSize()
watch(windowWidth, val => {
store.commit('app/UPDATE_WINDOW_WIDTH', val)
})
return {
skinClasses,
}
},
2021-07-21 14:07:38 +00:00
// ! We can move this computed: layout & contentLayoutType once we get to use Vue 3
// Currently, router.currentRoute is not reactive and doesn't trigger any change
computed: {
layout() {
2022-03-14 12:59:02 +00:00
if (!this.$route.name || this.$route.meta.layout === 'full') return 'layout-full'
2021-07-21 14:07:38 +00:00
return `layout-${this.contentLayoutType}`
},
contentLayoutType() {
return this.$store.state.appConfig.layout.type
},
},
beforeCreate() {
// Set colors in theme
const colors = ['primary', 'secondary', 'success', 'info', 'warning', 'danger', 'light', 'dark']
// eslint-disable-next-line no-plusplus
for (let i = 0, len = colors.length; i < len; i++) {
$themeColors[colors[i]] = useCssVar(`--${colors[i]}`, document.documentElement).value.trim()
}
// Set Theme Breakpoints
2022-05-05 04:01:00 +00:00
const breakpoints = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']
2021-07-21 14:07:38 +00:00
// eslint-disable-next-line no-plusplus
for (let i = 0, len = breakpoints.length; i < len; i++) {
2022-03-14 12:59:02 +00:00
$themeBreakpoints[breakpoints[i]] = Number(
useCssVar(`--breakpoint-${breakpoints[i]}`, document.documentElement).value.slice(0, -2),
)
2021-07-21 14:07:38 +00:00
}
// Set RTL
const { isRTL } = $themeConfig.layout
document.documentElement.setAttribute('dir', isRTL ? 'rtl' : 'ltr')
},
2022-04-05 15:31:06 +00:00
created() {
store.dispatch('chains/getQuotes')
store.dispatch('chains/getAllIBCDenoms', this)
},
2021-07-21 14:07:38 +00:00
}
</script>