From 89047a7dde220116bd9cd5b4c5677ae9836057a8 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Sat, 12 Oct 2024 14:10:19 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=AD=97=E5=85=B8=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/tenant-toggle/src/index.vue | 1 - apps/web-antd/src/utils/dict.ts | 34 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/apps/web-antd/src/components/tenant-toggle/src/index.vue b/apps/web-antd/src/components/tenant-toggle/src/index.vue index 513340ff..0a1569a5 100644 --- a/apps/web-antd/src/components/tenant-toggle/src/index.vue +++ b/apps/web-antd/src/components/tenant-toggle/src/index.vue @@ -75,7 +75,6 @@ const onSelected: SelectHandler = async (tenantId: string, option: any) => { async function onDeselect() { await tenantDynamicClear(); - dictStore.resetCache(); message.success($t('component.tenantToggle.reset')); lastSelected.value = ''; close(false); diff --git a/apps/web-antd/src/utils/dict.ts b/apps/web-antd/src/utils/dict.ts index be574ded..9e4388c0 100644 --- a/apps/web-antd/src/utils/dict.ts +++ b/apps/web-antd/src/utils/dict.ts @@ -12,13 +12,16 @@ export function getDict(dictName: string): DictData[] { if (dictList.length === 0 && !dictRequestCache.has(dictName)) { dictRequestCache.set( dictName, - dictDataInfo(dictName).then((resp) => { - // 缓存到store 这样就不用重复获取了 - // 内部处理了push的逻辑 这里不用push - setDictInfo(dictName, resp); - // 移除请求状态缓存 - dictRequestCache.delete(dictName); - }), + dictDataInfo(dictName) + .then((resp) => { + // 缓存到store 这样就不用重复获取了 + // 内部处理了push的逻辑 这里不用push + setDictInfo(dictName, resp); + }) + .finally(() => { + // 移除请求状态缓存 + dictRequestCache.delete(dictName); + }), ); } return dictList; @@ -31,13 +34,16 @@ export function getDictOptions(dictName: string): Option[] { if (dictOptionList.length === 0 && !dictRequestCache.has(dictName)) { dictRequestCache.set( dictName, - dictDataInfo(dictName).then((resp) => { - // 缓存到store 这样就不用重复获取了 - // 内部处理了push的逻辑 这里不用push - setDictInfo(dictName, resp); - // 移除请求状态缓存 - dictRequestCache.delete(dictName); - }), + dictDataInfo(dictName) + .then((resp) => { + // 缓存到store 这样就不用重复获取了 + // 内部处理了push的逻辑 这里不用push + setDictInfo(dictName, resp); + }) + .finally(() => { + // 移除请求状态缓存 + dictRequestCache.delete(dictName); + }), ); } return dictOptionList;