Skip to content

Commit

Permalink
fix(i18n): fix useMessage i18n type #262
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Feb 9, 2021
1 parent 5810078 commit d753155
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/hooks/web/useMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Modal, message as Message, notification } from 'ant-design-vue';
import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue';

import { ArgsProps, ConfigProps } from 'ant-design-vue/lib/notification';
import { useI18n } from './useI18n';

export interface NotifyApi {
info(config: ArgsProps): void;
Expand Down Expand Up @@ -62,14 +63,17 @@ function createConfirm(options: ModalOptionsEx): ConfirmOptions {
return (Modal.confirm(opt) as unknown) as ConfirmOptions;
}

const baseOptions = {
okText: '确定',
centered: true,
const getBaseOptions = () => {
const { t } = useI18n();
return {
okText: t('common.okText'),
centered: true,
};
};

function createModalOptions(options: ModalOptionsPartial, icon: string): ModalOptionsPartial {
return {
...baseOptions,
...getBaseOptions(),
...options,
content: renderContent(options),
icon: getIcon(icon),
Expand Down

1 comment on commit d753155

@zieru
Copy link

@zieru zieru commented on d753155 Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks !!!

Please sign in to comment.