ソースを参照

fix: 接入i18n 列表

sheldon 1 週間 前
コミット
93dcaa733f
2 ファイル変更30 行追加6 行削除
  1. 5 0
      src/api/modules/anycallService.ts
  2. 25 6
      src/components/LangSelector.vue

+ 5 - 0
src/api/modules/anycallService.ts

@@ -76,3 +76,8 @@ export function updateAgentLLm(params: {
 }){
   return request(`/anycall/admin/updateAgentLLm`, {cloneId: params.cloneId, llmId: params.llmId})
 }
+
+
+export function getI18nList(){
+  return request<{name: string, value: string}[]>(`/anycall/admin/selectI18n`)
+}

+ 25 - 6
src/components/LangSelector.vue

@@ -1,6 +1,5 @@
 <script setup lang="ts">
-import { languageList } from '@/constant/languageList'
-
+import { getI18nList } from '@/api/modules/anycallService'
 
 // 定义组件属性
 interface Props {
@@ -39,10 +38,30 @@ watch(
 )
 
 
-const options = ref<Array<{value: string, name: string}>>(languageList.map(item => ({
-  value: item.countryCode,
-  name: item.chineseName
-})))
+const options = ref<Array<{value: string, name: string}>>([])
+
+const fetchData = async () => {
+  try {
+    const res = await getI18nList()
+    if (res.code === 0) {
+      console.log(res.data,3333)
+      options.value = res.data
+      // // 将API返回的数据转换为select需要的格式
+      // options.value = res.data.content.map((item: any) => ({
+      //   value: item.id,
+      //   name: item.name
+      // }))
+    } else {
+      console.error('获取 I18n 失败:', res.msg)
+    }
+  } catch (error) {
+    console.error('获取 I18n 失败:', error)
+  }
+}
+
+onMounted(() => {
+  fetchData()
+})
 
 </script>