Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions packages/components/empty/empty.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, defineComponent, h, toRefs } from 'vue';
import { computed, ComputedRef, defineComponent, h, toRefs } from 'vue';
import { isString, isPlainObject } from 'lodash-es';

import { useConfig, useTNodeJSX, usePrefixClass, useCommonClassName } from '@tdesign/shared-hooks';
Expand All @@ -24,38 +24,40 @@ export default defineComponent({
const { SIZE } = useCommonClassName();
const renderTNodeJSX = useTNodeJSX();

const defaultMaps: {
const defaultMaps: ComputedRef<{
[key in TdEmptyProps['type']]?: Pick<TdEmptyProps, 'image' | 'title'>;
} = {
maintenance: {
image: globalConfig.value.image.maintenance || MaintenanceSvg,
title: globalConfig.value.titleText.maintenance,
},
success: {
image: globalConfig.value.image.success || SuccessSvg,
title: globalConfig.value.titleText.success,
},
fail: {
image: globalConfig.value.image.fail || FailSvg,
title: globalConfig.value.titleText.fail,
},
'network-error': {
image: globalConfig.value.image.networkError || NetworkErrorSvg,
title: globalConfig.value.titleText.networkError,
},
empty: {
image: globalConfig.value.image.empty || EmptySvg,
title: globalConfig.value.titleText.empty,
},
};
}> = computed(() => {
return {
maintenance: {
image: globalConfig.value.image.maintenance || MaintenanceSvg,
title: globalConfig.value.titleText.maintenance,
},
success: {
image: globalConfig.value.image.success || SuccessSvg,
title: globalConfig.value.titleText.success,
},
fail: {
image: globalConfig.value.image.fail || FailSvg,
title: globalConfig.value.titleText.fail,
},
'network-error': {
image: globalConfig.value.image.networkError || NetworkErrorSvg,
title: globalConfig.value.titleText.networkError,
},
empty: {
image: globalConfig.value.image.empty || EmptySvg,
title: globalConfig.value.titleText.empty,
},
};
});

const emptyClasses = computed(() => [classPrefix.value, SIZE.value[size.value]]);
const titleClasses = [`${classPrefix.value}__title`];
const imageClasses = [`${classPrefix.value}__image`];
const descriptionClasses = [`${classPrefix.value}__description`];
const actionClass = [`${classPrefix.value}__action`];

const typeImageProps = computed(() => defaultMaps[type.value] ?? null);
const typeImageProps = computed(() => defaultMaps.value[type.value] ?? null);
const showImage = computed(() => propsImage.value || slots?.image?.() || typeImageProps.value?.image);
const showTitle = computed(() => propsTitle.value || slots?.title?.() || typeImageProps.value?.title);
const showDescription = computed(() => propsDescription.value || slots?.description?.());
Expand Down
6 changes: 6 additions & 0 deletions packages/tdesign-vue-next/.changelog/pr-6126.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
pr_number: 6126
contributor: liweijie0812
---

- fix(empty): 修复多语言动态切换响应式无效 @liweijie0812 ([#6126](https://github.com/Tencent/tdesign-vue-next/pull/6126))