chore: 字典相关逻辑

This commit is contained in:
dap 2024-10-12 14:10:19 +08:00
parent 329b41bc44
commit 89047a7dde
2 changed files with 20 additions and 15 deletions

View File

@ -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);

View File

@ -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;