update: 字典loading

This commit is contained in:
dap 2025-04-07 17:20:41 +08:00
parent 5b72d9b79d
commit 92fe406ae9
2 changed files with 13 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import type { DictData } from '#/api/system/dict/dict-data-model';
import { computed } from 'vue'; import { computed } from 'vue';
import { Tag } from 'ant-design-vue'; import { Spin, Tag } from 'ant-design-vue';
import { tagTypes } from './data'; import { tagTypes } from './data';
@ -41,12 +41,22 @@ const label = computed<number | string>(() => {
}); });
const tagComponent = computed(() => (color.value ? Tag : 'div')); const tagComponent = computed(() => (color.value ? Tag : 'div'));
const loading = computed(() => {
return props.dicts?.length === 0;
});
</script> </script>
<template> <template>
<div> <div>
<component :is="tagComponent" :class="cssClass" :color="color"> <component
v-if="!loading"
:is="tagComponent"
:class="`${cssClass} enter-x`"
:color="color"
>
{{ label }} {{ label }}
</component> </component>
<Spin v-else :spinning="true" size="small" />
</div> </div>
</template> </template>

View File

@ -59,6 +59,7 @@ export const useDictStore = defineStore('app-dict', () => {
} }
function resetCache() { function resetCache() {
dictRequestCache.clear();
dictOptionsMap.clear(); dictOptionsMap.clear();
/** /**
* dictRequestCache /key * dictRequestCache /key