From 38938d54d10f26a4416d9a77550ecbad7522aab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E7=BF=95=E7=84=B6?= Date: Sun, 15 Dec 2024 01:29:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3dict=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=9C=A8=E6=89=93=E5=8C=85android=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=EF=BC=8C=E4=BC=9A=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/dict.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/dict.ts b/src/utils/dict.ts index 6519ce6..b3f3905 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -3,7 +3,14 @@ */ import { useDictStore } from '@/store' -const dictStore = useDictStore() +let cachedDictStore = null + +const getDictStore = () => { + if (!cachedDictStore) { + cachedDictStore = useDictStore() + } + return cachedDictStore +} /** * 获取 dictType 对应的数据字典数组 * @@ -27,6 +34,7 @@ export interface StringDictDataType extends DictDataType { } export const getDictOptions = (dictType: string) => { + const dictStore = getDictStore() // 确保仅在第一次调用时初始化 return dictStore.getDictByType(dictType) || [] } -- Gitee