1- import { computed , defineComponent , h , toRefs } from 'vue' ;
1+ import { computed , ComputedRef , defineComponent , h , toRefs } from 'vue' ;
22import { isString , isPlainObject } from 'lodash-es' ;
33
44import { useConfig , useTNodeJSX , usePrefixClass , useCommonClassName } from '@tdesign/shared-hooks' ;
@@ -24,38 +24,40 @@ export default defineComponent({
2424 const { SIZE } = useCommonClassName ( ) ;
2525 const renderTNodeJSX = useTNodeJSX ( ) ;
2626
27- const defaultMaps : {
27+ const defaultMaps : ComputedRef < {
2828 [ key in TdEmptyProps [ 'type' ] ] ?: Pick < TdEmptyProps , 'image' | 'title' > ;
29- } = {
30- maintenance : {
31- image : globalConfig . value . image . maintenance || MaintenanceSvg ,
32- title : globalConfig . value . titleText . maintenance ,
33- } ,
34- success : {
35- image : globalConfig . value . image . success || SuccessSvg ,
36- title : globalConfig . value . titleText . success ,
37- } ,
38- fail : {
39- image : globalConfig . value . image . fail || FailSvg ,
40- title : globalConfig . value . titleText . fail ,
41- } ,
42- 'network-error' : {
43- image : globalConfig . value . image . networkError || NetworkErrorSvg ,
44- title : globalConfig . value . titleText . networkError ,
45- } ,
46- empty : {
47- image : globalConfig . value . image . empty || EmptySvg ,
48- title : globalConfig . value . titleText . empty ,
49- } ,
50- } ;
29+ } > = computed ( ( ) => {
30+ return {
31+ maintenance : {
32+ image : globalConfig . value . image . maintenance || MaintenanceSvg ,
33+ title : globalConfig . value . titleText . maintenance ,
34+ } ,
35+ success : {
36+ image : globalConfig . value . image . success || SuccessSvg ,
37+ title : globalConfig . value . titleText . success ,
38+ } ,
39+ fail : {
40+ image : globalConfig . value . image . fail || FailSvg ,
41+ title : globalConfig . value . titleText . fail ,
42+ } ,
43+ 'network-error' : {
44+ image : globalConfig . value . image . networkError || NetworkErrorSvg ,
45+ title : globalConfig . value . titleText . networkError ,
46+ } ,
47+ empty : {
48+ image : globalConfig . value . image . empty || EmptySvg ,
49+ title : globalConfig . value . titleText . empty ,
50+ } ,
51+ } ;
52+ } ) ;
5153
5254 const emptyClasses = computed ( ( ) => [ classPrefix . value , SIZE . value [ size . value ] ] ) ;
5355 const titleClasses = [ `${ classPrefix . value } __title` ] ;
5456 const imageClasses = [ `${ classPrefix . value } __image` ] ;
5557 const descriptionClasses = [ `${ classPrefix . value } __description` ] ;
5658 const actionClass = [ `${ classPrefix . value } __action` ] ;
5759
58- const typeImageProps = computed ( ( ) => defaultMaps [ type . value ] ?? null ) ;
60+ const typeImageProps = computed ( ( ) => defaultMaps . value [ type . value ] ?? null ) ;
5961 const showImage = computed ( ( ) => propsImage . value || slots ?. image ?.( ) || typeImageProps . value ?. image ) ;
6062 const showTitle = computed ( ( ) => propsTitle . value || slots ?. title ?.( ) || typeImageProps . value ?. title ) ;
6163 const showDescription = computed ( ( ) => propsDescription . value || slots ?. description ?.( ) ) ;
0 commit comments