From 0d3ba6256c69344789a505372fabb5dd98fc47a7 Mon Sep 17 00:00:00 2001 From: ocean-gao Date: Thu, 26 Dec 2024 17:16:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Drawer=E3=80=81Tool?= =?UTF-8?q?tip=20=E7=BB=84=E4=BB=B6=E9=BB=98=E8=AE=A4=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=9A=84=E5=9B=BD=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drawer/drawer.tsx | 7 +++++-- components/drawer/props.ts | 10 ++-------- components/locales/lang/enUS.ts | 8 ++++++++ components/locales/lang/zhCN.ts | 8 ++++++++ components/locales/lang/zr.ts | 8 ++++++++ components/tooltip/tooltip.tsx | 11 +++++++---- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/components/drawer/drawer.tsx b/components/drawer/drawer.tsx index d23c97049..ea68aa977 100644 --- a/components/drawer/drawer.tsx +++ b/components/drawer/drawer.tsx @@ -19,6 +19,7 @@ import { useConfig } from '../config-provider'; import { useTheme } from '../_theme/useTheme'; import { pxfy } from '../_util/utils'; import useEsc from '../_util/use/useEsc'; +import { useLocale } from '../config-provider/useLocale'; import { useResizable } from './useResizable'; import { COMPONENT_NAME, prefixCls } from './const'; import { @@ -63,6 +64,8 @@ const Drawer = defineComponent({ () => props.getContainer || config.getContainer?.value, ); + const { t } = useLocale(); + function handleCancel(event: MouseEvent | KeyboardEvent) { ctx.emit(UPDATE_SHOW_EVENT, false); ctx.emit(CANCEL_EVENT, event); @@ -120,11 +123,11 @@ const Drawer = defineComponent({ onClick={handleOk} loading={props.okLoading} > - {props.okText} + {props.okText || t('drawer.okText')} {props.showCancel && ( - {props.cancelText} + {props.cancelText || t('drawer.cancelText')} )} diff --git a/components/drawer/props.ts b/components/drawer/props.ts index b7c129321..42ef0482c 100644 --- a/components/drawer/props.ts +++ b/components/drawer/props.ts @@ -36,15 +36,9 @@ export const drawerProps = { default: false, }, title: String, - okText: { - type: String, - default: '确定', - }, + okText: String, okLoading: Boolean, - cancelText: { - type: String, - default: '取消', - }, + cancelText: String, showCancel: { type: Boolean, default: true, diff --git a/components/locales/lang/enUS.ts b/components/locales/lang/enUS.ts index 9afac52eb..960b19310 100644 --- a/components/locales/lang/enUS.ts +++ b/components/locales/lang/enUS.ts @@ -99,4 +99,12 @@ export default { okText: 'Confirm', cancelText: 'Cancel', }, + drawer: { + okText: 'Confirm', + cancelText: 'Cancel', + }, + tooltip: { + okText: 'Confirm', + cancelText: 'Cancel', + }, }; diff --git a/components/locales/lang/zhCN.ts b/components/locales/lang/zhCN.ts index f7cc66c85..a33dc12c4 100644 --- a/components/locales/lang/zhCN.ts +++ b/components/locales/lang/zhCN.ts @@ -98,4 +98,12 @@ export default { okText: '确定', cancelText: '取消', }, + drawer: { + okText: '确定', + cancelText: '取消', + }, + tooltip: { + okText: '确定', + cancelText: '取消', + }, }; diff --git a/components/locales/lang/zr.ts b/components/locales/lang/zr.ts index 2b33b7e00..9a2d0788e 100644 --- a/components/locales/lang/zr.ts +++ b/components/locales/lang/zr.ts @@ -99,4 +99,12 @@ export default { okText: 'تأكيد', cancelText: 'إلغاء', }, + drawer: { + okText: 'تأكيد', + cancelText: 'إلغاء', + }, + tooltip: { + okText: 'تأكيد', + cancelText: 'إلغاء', + }, }; diff --git a/components/tooltip/tooltip.tsx b/components/tooltip/tooltip.tsx index 4d2d9464a..be6cc1f5e 100644 --- a/components/tooltip/tooltip.tsx +++ b/components/tooltip/tooltip.tsx @@ -15,12 +15,13 @@ import FButton from '../button/button'; import { popperProps } from '../popper/props'; import { CANCEL_EVENT, OK_EVENT, UPDATE_MODEL_EVENT } from '../_util/constants'; import type { ExtractPublicPropTypes } from '../_util/interface'; +import { useLocale } from '../config-provider/useLocale'; const prefixCls = getPrefixCls('tooltip'); const defaultConfirmOption = { - okText: '确定', - cancelText: '取消', + okText: '', + cancelText: '', showOk: true, showCancel: true, icon: , @@ -64,6 +65,8 @@ export default defineComponent({ currentValue.value = val; }; + const { t } = useLocale(); + const popperElRef = ref(null); function getPopperSlots() { @@ -134,7 +137,7 @@ export default defineComponent({ size="small" type="primary" > - {mergeOpt.okText} + {mergeOpt.okText || t('tooltip.okText')} )} { @@ -146,7 +149,7 @@ export default defineComponent({ } size="small" > - {mergeOpt.cancelText} + {mergeOpt.cancelText || t('tooltip.cancelText')} ) }