字典国际化

This commit is contained in:
liuhanqing
2025-08-07 16:38:32 +08:00
parent 689792e285
commit 766eb3be1f
10 changed files with 140 additions and 61 deletions

View File

@@ -2,6 +2,7 @@ import Vue from 'vue'
import store from '@/store'
import DataDict from '@/utils/dict'
import { getDicts as getDicts } from '@/api/system/dict/data'
import i18n from "@/lang";
function searchDictByKey(dict, key) {
if (key == null && key == "") {
@@ -31,8 +32,14 @@ function install() {
} else {
return new Promise((resolve, reject) => {
getDicts(dictMeta.type).then(res => {
store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data })
resolve(res.data)
//console.log(res.data)
const translatedData = res.data.map(item => ({
...item,
dictLabel: i18n.t(item.dictLabel) || item.dictLabel
}))
//console.log(translatedData)
store.dispatch('dict/setDict', { key: dictMeta.type, value: translatedData })
resolve(translatedData)
}).catch(error => {
reject(error)
})
@@ -46,4 +53,4 @@ function install() {
export default {
install,
}
}