From 842dde07069d72cc010d274233325f4dc3e0f35b Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 30 Dec 2021 16:00:10 +0800 Subject: [PATCH] refactor: notification --- components/components.ts | 1 + components/config-provider/index.tsx | 13 ++++ components/notification/demo/custom-icon.vue | 2 +- components/notification/demo/placement.vue | 3 +- components/notification/demo/update.vue | 35 ++++++++-- components/notification/index.en-US.md | 19 +++-- components/notification/index.tsx | 73 ++++++++++++++++---- components/notification/index.zh-CN.md | 19 +++-- components/vc-notification/Notification.tsx | 1 + 9 files changed, 130 insertions(+), 36 deletions(-) diff --git a/components/components.ts b/components/components.ts index 73b862305..45a9c4ab7 100644 --- a/components/components.ts +++ b/components/components.ts @@ -114,6 +114,7 @@ export { default as Modal } from './modal'; export type { StatisticProps } from './statistic'; export { default as Statistic, StatisticCountdown } from './statistic'; +export type { NotificationPlacement } from './notification'; export { default as notification } from './notification'; export type { PageHeaderProps } from './page-header'; diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index 07ba5f5c4..6dd282e64 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -9,6 +9,8 @@ import type { TransformCellTextProps } from '../table/interface'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import type { RequiredMark } from '../form/Form'; import type { MaybeRef } from '../_util/type'; +import message from '../message'; +import notification from '../notification'; export type SizeType = 'small' | 'middle' | 'large' | undefined; @@ -248,6 +250,17 @@ const ConfigProvider = defineComponent({ ); }; + watchEffect(() => { + if (props.direction) { + message.config({ + rtl: props.direction === 'rtl', + }); + notification.config({ + rtl: props.direction === 'rtl', + }); + } + }); + return () => ( renderProvider(legacyLocale as Locale)} /> ); diff --git a/components/notification/demo/custom-icon.vue b/components/notification/demo/custom-icon.vue index 892d35e21..8f6eae1fa 100644 --- a/components/notification/demo/custom-icon.vue +++ b/components/notification/demo/custom-icon.vue @@ -31,7 +31,7 @@ export default defineComponent({ message: 'Notification Title', description: 'This is the content of the notification. This is the content of the notification. This is the content of the notification.', - icon: h(SmileOutlined, { style: 'color: #108ee9' }), + icon: () => h(SmileOutlined, { style: 'color: #108ee9' }), }); }; diff --git a/components/notification/demo/placement.vue b/components/notification/demo/placement.vue index 6a6bbfc54..4e400515e 100644 --- a/components/notification/demo/placement.vue +++ b/components/notification/demo/placement.vue @@ -46,6 +46,7 @@ import { } from '@ant-design/icons-vue'; import { notification } from 'ant-design-vue'; import { defineComponent } from 'vue'; +import type { NotificationPlacement } from 'ant-design-vue'; export default defineComponent({ components: { RadiusUpleftOutlined, @@ -54,7 +55,7 @@ export default defineComponent({ RadiusBottomrightOutlined, }, setup() { - const openNotification = (placement: string) => { + const openNotification = (placement: NotificationPlacement) => { notification.open({ message: `Notification ${placement}`, description: diff --git a/components/notification/demo/update.vue b/components/notification/demo/update.vue index 69d5c215b..6b0dd9938 100644 --- a/components/notification/demo/update.vue +++ b/components/notification/demo/update.vue @@ -1,27 +1,34 @@ --- -order: 7 -title: - zh-CN: 更新消息内容 +order: 7 +title: + zh-CN: 更新消息内容 en-US: Update Message Content --- ## zh-CN -可以通过唯一的 key 来更新内容。 +可以通过唯一的 key 来更新内容, 或者通过响应式数据更新。 ## en-US -Update content with unique key. +Update content with unique key, or use reactive data.