<script lang="ts" setup>
import type { TransformCellTextProps } from 'ant-design-vue/lib/table/interface'
import { AppProvider } from '@/components/Application'
import { useTitle } from '@/hooks/web/useTitle'
import { useLocale } from '@/locales/useLocale'
import { useAppStore } from '@/store/modules/app'
import { App, ConfigProvider } from 'ant-design-vue'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
import 'dayjs/locale/zh-cn'

// support Multi-language
const { getAntdLocale } = useLocale()
const appStore = useAppStore()
const { themeConfig } = storeToRefs(appStore)

const componentSize = computed(() => appStore.getComponentSize)
// Listening to page changes and dynamically changing site titles
useTitle()

function transformCellText(props: TransformCellTextProps) {
  if (!props.text || (Array.isArray(props.text) && !props.text.length))
    return '-'

  return props.text
}
</script>

<template>
  <ConfigProvider :locale="getAntdLocale" :theme="themeConfig" :component-size="componentSize" :transform-cell-text="transformCellText">
    <App class="h-full w-full">
      <AppProvider>
        <RouterView />
      </AppProvider>
    </App>
  </ConfigProvider>
</template>
