<template>
  <el-config-provider :locale="elLocale">
    <router-view />
  </el-config-provider>
</template>

<script setup>
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
// 引入 Element Plus 的语言包
import zhCnLocale from 'element-plus/dist/locale/zh-cn.mjs'
import enLocale from 'element-plus/dist/locale/en.mjs'
import thLocale from 'element-plus/dist/locale/th.mjs'

const { locale } = useI18n()

// 计算属性：根据当前 i18n 的语言，返回对应的 Element Plus 语言包
const elLocale = computed(() => {
  switch (locale.value) {
    case 'zh-CN': return zhCnLocale
    case 'en': return enLocale
    case 'th': return thLocale
    default: return zhCnLocale
  }
})
</script>