<template>
  <ClientOnly>
    <a-config-provider :locale="zhCN">
      <NuxtLayout>
        <NuxtRouteAnnouncer />
        <NuxtPage />
      </NuxtLayout>
    </a-config-provider>
  </ClientOnly>
</template>

<script lang="ts" setup>
import { getCurrentEnv } from '@/config/setting'
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'

// 设置 dayjs 默认语言为中文
dayjs.locale('zh-cn')

// 初始化时同步环境设置到 Cookie，确保服务器端代理能正确识别
if (import.meta.client) {
  const env = getCurrentEnv()
  const cookieValue = env === 'dev' ? 'dev' : 'prod'
  document.cookie = `websopy_api_env=${cookieValue}; path=/; max-age=31536000`
}
</script>
