diff --git a/dashboard/src/Index.vue b/dashboard/src/Index.vue index ec98c4921..ae1c80ef8 100644 --- a/dashboard/src/Index.vue +++ b/dashboard/src/Index.vue @@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n'; const i18n = useI18n(); const t = i18n.t; -import { onMounted, ref, useTemplateRef, provide } from 'vue'; +import { onMounted, onUnmounted, ref, useTemplateRef, provide } from 'vue'; import { Notification, fetcher } from '@cloudron/pankow'; import { setLanguage } from './i18n.js'; import { API_ORIGIN, TOKEN_TYPES } from './constants.js'; @@ -393,14 +393,22 @@ async function onOnline() { await refreshConfigAndFeatures(); // reload dashboard if needed after an update } +const isMobile = ref(window.innerWidth <= 576); +function checkForMobile() { + isMobile.value = window.innerWidth <= 576; +} + provide('subscriptionRequiredDialog', subscriptionRequiredDialog); provide('features', features); provide('profile', profile); provide('refreshProfile', refreshProfile); provide('refreshFeatures', refreshConfigAndFeatures); provide('dashboardDomain', dashboardDomain); +provide('isMobile', isMobile); onMounted(async () => { + window.addEventListener('resize', checkForMobile); + const [error, result] = await provisionModel.status(); if (error) return window.cloudron.onError(error); @@ -434,6 +442,10 @@ onMounted(async () => { ready.value = true; }); +onUnmounted(() => { + window.removeEventListener('resize', checkForMobile); +}); +