<template>
  <AdaptiveContainer
    v-if="runSelf"
    :options="{ width: width, height: height }"
    style="overflow-y: hidden"
  >
    <ConfigProvider :locale="getAntdLocale" :theme="themeConfig" prefixCls="vMonitor">
      <AppProvider>
        <RouterView />
      </AppProvider>
    </ConfigProvider>
  </AdaptiveContainer>
  <ConfigProvider v-else :locale="getAntdLocale" :theme="themeConfig" prefixCls="vMonitor">
    <AppProvider>
      <RouterView />
    </AppProvider>
  </ConfigProvider>
</template>

<script lang="ts" setup>
  import { AppProvider } from '@/components/Application';
  import { useTitle } from '@/hooks/web/useTitle';
  import { useLocale } from '@/locales/useLocale';
  import { ConfigProvider } from 'ant-design-vue';
  import AdaptiveContainer from '/@/components/Container/src/Adaptive.vue';
  import { useDarkModeTheme } from '@/hooks/setting/useDarkModeTheme';
  import 'dayjs/locale/zh-cn';
  import { computed, ref } from 'vue';

  // support Multi-language
  const { getAntdLocale } = useLocale();
  const width = ref(1920);
  const height = ref(928);
  const { isDark, darkTheme } = useDarkModeTheme();
  const runSelf = ref(true);

  const themeConfig = computed(() =>
    Object.assign(
      {
        token: {
          colorPrimary: '#0960bd',
          colorSuccess: '#55D187',
          colorWarning: '#EFBD47',
          colorError: '#ED6F6F',
          colorInfo: '#0960bd',
        },
      },
      isDark.value ? darkTheme : {},
    ),
  );

  // Listening to page changes and dynamically changing site titles
  useTitle();
</script>
