<template>
    <el-config-provider :locale="language">
        <RouterView />
    </el-config-provider>
</template>

<script setup>
import { provide, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import useSettingsStore from '@/store/modules/settings';
import { handleThemeStyle } from '@/utils/theme';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import ko from 'element-plus/es/locale/lang/ko';
import { useLanguageStore } from '@/store/modules/language.js';
import { TUITranslateService } from '@tencentcloud/chat-uikit-engine-lite';
// change language to chinese
TUITranslateService.changeLanguage('zh');

const languagestore = useLanguageStore();

const language = computed(() => {
    return languagestore.language === 'zh-CN' ? zhCn : ko;
});
const i18n = useI18n();

// 提供响应式的 t 函数
provide('t', (key, ...args) => {
    return i18n.t(key, ...args); // 自动响应语言切换
});

onMounted(() => {
    nextTick(() => {
        // 初始化主题样式
        handleThemeStyle(useSettingsStore().theme);
    });
});
</script>

<style lang="scss"></style>
