diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 36a4e8ee..a5d00398 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -2,6 +2,7 @@ import { createI18n } from 'vue-i18n'; import pinia from '/@/stores/index'; import { storeToRefs } from 'pinia'; import { useThemeConfig } from '/@/stores/themeConfig'; +import { info } from '/@/api/admin/i18n' // 定义语言国际化内容 @@ -20,7 +21,7 @@ import zhcnLocale from 'element-plus/lib/locale/lang/zh-cn'; // 定义变量内容 const messages = {}; const element = { en: enLocale, 'zh-cn': zhcnLocale}; -const itemize = { en: [], 'zh-cn': [] }; +const itemize = { en: [] as any[], 'zh-cn': [] as any[] }; const modules: Record = import.meta.glob('./**/*.ts', { eager: true }); const pages: Record = import.meta.glob('./../../**/**/**/i18n/*.ts', { eager: true }); @@ -44,15 +45,23 @@ function mergeArrObj(list: T, key: string) { }); return obj; } +// 从后台获取数据 +info().then((res: any) => { + itemize["zh-cn"].push(...res.data['zh-cn']) + itemize.en.push(...res.data.en) +}).finally(() => { + // 处理最终格式 + for (const key in itemize) { + messages[key] = { + name: key, + el: element[key].el, + ...mergeArrObj(itemize, key), + }; + } + console.log(messages,'message') +}) + -// 处理最终格式 -for (const key in itemize) { - messages[key] = { - name: key, - el: element[key].el, - ...mergeArrObj(itemize, key), - }; -} // 读取 pinia 默认语言 const stores = useThemeConfig(pinia); diff --git a/src/views/admin/i18n/form.vue b/src/views/admin/i18n/form.vue new file mode 100644 index 00000000..062c9ab5 --- /dev/null +++ b/src/views/admin/i18n/form.vue @@ -0,0 +1,118 @@ + + + diff --git a/src/views/admin/i18n/i18n/en.ts b/src/views/admin/i18n/i18n/en.ts new file mode 100644 index 00000000..1ac7f3e5 --- /dev/null +++ b/src/views/admin/i18n/i18n/en.ts @@ -0,0 +1,24 @@ +export default { + sysi18n: { + index: 'index', + importsysI18nTip: 'import SysI18n', + id: 'id', + name: 'name', + zhCn: 'zh-cn', + en: 'en', + createBy: 'createBy', + createTime: 'createTime', + updateBy: 'updateBy', + updateTime: 'updateTime', + delFlag: 'delFlag', + inputIdTip: 'input id', + inputKeyTip: 'input key', + inputZhCnTip: 'input zh-cn', + inputEnTip: 'input en', + inputCreateByTip: 'input createBy', + inputCreateTimeTip: 'input createTime', + inputUpdateByTip: 'input updateBy', + inputUpdateTimeTip: 'input updateTime', + inputDelFlagTip: 'input delFlag', + } +} diff --git a/src/views/admin/i18n/i18n/zh-cn.ts b/src/views/admin/i18n/i18n/zh-cn.ts new file mode 100644 index 00000000..fd57fdea --- /dev/null +++ b/src/views/admin/i18n/i18n/zh-cn.ts @@ -0,0 +1,24 @@ +export default { + i18n: { + index: '序号', + id: 'id', + name: '名称', + zhCn: '中文', + en: '英文', + createBy: '创建人', + createTime: '创建时间', + updateBy: '修改人', + updateTime: '更新时间', + delFlag: '删除标记', + inputIdTip: '请输入id', + inputKeyTip: '请输入key', + inputZhCnTip: '请输入中文', + inputEnTip: '请输入英文', + inputCreateByTip: '请输入创建人', + inputCreateTimeTip: '请输入创建时间', + inputUpdateByTip: '请输入修改人', + inputUpdateTimeTip: '请输入更新时间', + inputDelFlagTip: '请输入删除标记', + importsysI18nTip: '导入系统表-国际化', + } +} diff --git a/src/views/admin/i18n/index.vue b/src/views/admin/i18n/index.vue new file mode 100644 index 00000000..c4d0ff77 --- /dev/null +++ b/src/views/admin/i18n/index.vue @@ -0,0 +1,150 @@ + + +