Commit d7531554a274ad9d793ea621739dfffdc7f73db8
1 parent
5810078b
fix(i18n): fix useMessage i18n type #262
Showing
1 changed file
with
8 additions
and
4 deletions
src/hooks/web/useMessage.tsx
... | ... | @@ -4,6 +4,7 @@ import { Modal, message as Message, notification } from 'ant-design-vue'; |
4 | 4 | import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue'; |
5 | 5 | |
6 | 6 | import { ArgsProps, ConfigProps } from 'ant-design-vue/lib/notification'; |
7 | +import { useI18n } from './useI18n'; | |
7 | 8 | |
8 | 9 | export interface NotifyApi { |
9 | 10 | info(config: ArgsProps): void; |
... | ... | @@ -62,14 +63,17 @@ function createConfirm(options: ModalOptionsEx): ConfirmOptions { |
62 | 63 | return (Modal.confirm(opt) as unknown) as ConfirmOptions; |
63 | 64 | } |
64 | 65 | |
65 | -const baseOptions = { | |
66 | - okText: '确定', | |
67 | - centered: true, | |
66 | +const getBaseOptions = () => { | |
67 | + const { t } = useI18n(); | |
68 | + return { | |
69 | + okText: t('common.okText'), | |
70 | + centered: true, | |
71 | + }; | |
68 | 72 | }; |
69 | 73 | |
70 | 74 | function createModalOptions(options: ModalOptionsPartial, icon: string): ModalOptionsPartial { |
71 | 75 | return { |
72 | - ...baseOptions, | |
76 | + ...getBaseOptions(), | |
73 | 77 | ...options, |
74 | 78 | content: renderContent(options), |
75 | 79 | icon: getIcon(icon), | ... | ... |