update: 字典loading
This commit is contained in:
parent
5b72d9b79d
commit
92fe406ae9
@ -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>
|
||||||
|
@ -59,6 +59,7 @@ export const useDictStore = defineStore('app-dict', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetCache() {
|
function resetCache() {
|
||||||
|
dictRequestCache.clear();
|
||||||
dictOptionsMap.clear();
|
dictOptionsMap.clear();
|
||||||
/**
|
/**
|
||||||
* 不需要清空dictRequestCache 每次请求成功/失败都清空key
|
* 不需要清空dictRequestCache 每次请求成功/失败都清空key
|
||||||
|
Loading…
Reference in New Issue
Block a user