<template>
  <div>
    <dialog-loading ref="dialogLoading"></dialog-loading>

    <!-- <NuxtLayout v-if="!loading"> -->
    <NuxtLayout>
      <NuxtLoadingIndicator color="#348feb" height="5" />
      <NuxtPage />
    </NuxtLayout>
  </div>
</template>

<script lang="ts" setup>
import DialogLoading from "@/components/DialogLoading.vue";
import { onMounted, ref, watch } from "vue";

import { useInterfaceStore } from "@/stores/interface";
const interfaceStore = useInterfaceStore();
const appConfig = useAppConfig();
const lgScreenWidth = ref(1024);
const screenWidth = ref(window.innerWidth);
const dialogLoading = ref();

const loading = ref(true);

interfaceStore.$subscribe((mutation, state) => {
  console.log("there is a change");
});

const updateScreenWidth = () => {
  screenWidth.value = window.innerWidth;
};

onMounted(() => {
  window.addEventListener("resize", updateScreenWidth);
  dialogLoading.value.showMenu();
  updateScreenWidth();
  setTimeout(() => {
    dialogLoading.value.hideMenu();
    loading.value = false;
  }, 500);
});

// onBeforeUnmount(() => {
//   window.removeEventListener("resize", updateScreenWidth);
// });

const showTheApp = computed(() => {
  return screenWidth.value < lgScreenWidth.value;
});
</script>
