From d8a395bfd1c535db12dccad3e9696c40f822c7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Mon, 17 Mar 2025 09:36:32 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/dict.ts | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/utils/dict.ts b/src/utils/dict.ts index 0575072..eb43d65 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -7,21 +7,20 @@ export const useDict = (...args: string[]): { [key: string]: DictDataOption[] } const res = ref<{ [key: string]: DictDataOption[]; }>({}); - return (() => { - args.forEach(async (dictType) => { - res.value[dictType] = []; - const dicts = useDictStore().getDict(dictType); - if (dicts) { - res.value[dictType] = dicts; - } else { - await getDicts(dictType).then((resp) => { - res.value[dictType] = resp.data.map( - (p): DictDataOption => ({ label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass }) - ); - useDictStore().setDict(dictType, res.value[dictType]); - }); - } - }); - return res.value; - })(); + + args.forEach(async (dictType) => { + res.value[dictType] = []; + const dicts = useDictStore().getDict(dictType); + if (dicts) { + res.value[dictType] = dicts; + } else { + await getDicts(dictType).then((resp) => { + res.value[dictType] = resp.data.map( + (p): DictDataOption => ({ label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass }) + ); + useDictStore().setDict(dictType, res.value[dictType]); + }); + } + }); + return res.value; };