Skip to content

Commit bc97133

Browse files
author
liyuan-meng
committed
[Modal]添加 infoText 参数
1 parent 49bde5c commit bc97133

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/components/modal/demos/info.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ModalDemo extends React.Component {
2525
Modal.info({
2626
title: '提醒类弹窗',
2727
body: '正文文案',
28+
infoText: '去配置',
2829
onCancel: () => {}
2930
});
3031
};

src/components/modal/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Modal.warning(config)
6666
| body | 提示信息内容, 支持 jsx 语法直接传入 dom 节点 | any | `--` |
6767
| okText | 确定按钮自定义文本 | string | `确定` |
6868
| cancelText | 取消按钮自定义文本 | string | `取消` |
69+
| infoText | 使用 `Modal.info` `Modal.success` `Modal.error` `Modal.warning` 时按钮自定义文本 | string | `知道了` |
6970
| onOk | 确定按钮回调函数,仅`Modal.confirm()`函数支持 | function | `--` |
7071
| onClose | 取消按钮回调函数 | function | `--` |
7172
| className | 设置弹出框样式名称 | string | - |

src/components/modal/modal.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import classnames from 'classnames';
4-
import {
5-
prefixCls, getCssText, noop, sandboxSelector,
6-
} from '@utils';
4+
import { prefixCls, getCssText, noop, sandboxSelector } from '@utils';
75
import ContextProvider from '@contexts/context-provider';
86
import { CSSTransition } from 'react-transition-group';
97

@@ -312,6 +310,7 @@ class Notification extends Component {
312310
onOk,
313311
onClose,
314312
onCancel,
313+
infoText,
315314
} = this.props;
316315

317316
if (!visible && !this.state.preVisible) {
@@ -401,6 +400,7 @@ class Notification extends Component {
401400
cancelText={cancelText}
402401
disabledOk={disabledOk}
403402
showConfirmLoading={showConfirmLoading}
403+
infoText={infoText}
404404
/>
405405
</div>
406406
</CSSTransition>
@@ -480,6 +480,7 @@ function ModalFooter({
480480
footer,
481481
okText,
482482
cancelText,
483+
infoText,
483484
okBtnOpts,
484485
cancelBtnOpts,
485486
hasFooter,
@@ -516,7 +517,7 @@ function ModalFooter({
516517
return (
517518
<footer style={style} className={footerClass}>
518519
<Button type="primary" size="large" onClick={cancel}>
519-
知道了
520+
{infoText || '知道了'}
520521
</Button>
521522
</footer>
522523
);

src/components/modal/prompt.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class Prompt extends React.Component {
153153
okBtnOpts,
154154
cancelBtnOpts,
155155
title,
156+
infoText,
156157
} = this.props;
157158
const promptStyle = {
158159
...style,
@@ -188,6 +189,7 @@ class Prompt extends React.Component {
188189
showConfirmLoading={this.state.showConfirmLoading}
189190
hasFooter={this.props.hasFooter}
190191
className={this.props.className}
192+
infoText={infoText}
191193
>
192194
<div>
193195
<header className="info-area">
@@ -241,6 +243,7 @@ function prompt({
241243
title,
242244
hasFooter,
243245
className,
246+
infoText,
244247
}) {
245248
// 创建一个关联id
246249
const rootDocument = getRootWindow().document;
@@ -264,6 +267,7 @@ function prompt({
264267
className={className}
265268
okText={okText}
266269
cancelText={cancelText}
270+
infoText={infoText}
267271
okBtnOpts={okBtnOpts}
268272
cancelBtnOpts={cancelBtnOpts}
269273
onOk={onOk}

0 commit comments

Comments
 (0)