diff --git a/src/views/server/bigbrother/index.vue b/src/views/server/bigbrother/index.vue index 6ec5506..37ee0f2 100644 --- a/src/views/server/bigbrother/index.vue +++ b/src/views/server/bigbrother/index.vue @@ -154,7 +154,9 @@ @@ -204,7 +206,25 @@ import { BigBrotherApi, BigBrotherVO } from '@/api/server/bigbrother' import { getAllocation, getSimpleUserList } from '@/api/system/user' import { useCache } from '@/hooks/web/useCache' import BigBrotherForm from './BigBrotherForm.vue' +import { useDictStore } from '@/store/modules/dict' // 如果你项目里有字典 store +const dictStore = useDictStore?.() // 有就用;没有的话把 dictStore 相关行删掉 +// 统一用字符串比较,自动识别并翻译 i18n key +function dictLabelI18n(type: string, val: any) { + const v = val == null ? '' : String(val) + + // 优先从 store 取;若没有,就从你现有的工具取(getIntDictOptions / getStrDictOptions) + const opts = + (dictStore?.getDictOptions?.(type) as any[]) || + getIntDictOptions(type) || + getStrDictOptions(type) || + [] + + const hit = opts.find(o => String(o.value) === v) + const label = hit?.label ?? '' + // 形如 a.b 或包含点号的,大概率是 i18n key,则用 t() 翻 + return label && label.includes('.') ? t(label) : label +} const { wsCache } = useCache() /** 大哥数据 列表 */ defineOptions({ name: 'BigBrother' })