From 189e6c5c599b1cf23570d15b016704ec36793056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sun, 5 Aug 2018 11:30:11 +0800 Subject: [PATCH] Features: add buttonText on Login.Captcha --- .gitignore | 2 +- src/components/Login/LoginItem.js | 8 ++++++-- src/components/Login/index.d.ts | 1 + src/components/Login/index.en-US.md | 1 + src/components/Login/index.zh-CN.md | 1 + src/components/PageHeader/index.js | 6 ++++-- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c8978582..e0a60f36 100755 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules +**/node_modules # roadhog-api-doc ignore /src/utils/request-temp.js _roadhog-api-doc diff --git a/src/components/Login/LoginItem.js b/src/components/Login/LoginItem.js index 2412ff01..05d94638 100644 --- a/src/components/Login/LoginItem.js +++ b/src/components/Login/LoginItem.js @@ -15,6 +15,10 @@ function generator({ defaultProps, defaultRules, type }) { updateActive: PropTypes.func, }; + static defaultProps = { + buttonText: '获取验证码', + }; + constructor(props) { super(props); this.state = { @@ -55,7 +59,7 @@ function generator({ defaultProps, defaultRules, type }) { const { getFieldDecorator } = form; const options = {}; let otherProps = {}; - const { onChange, defaultValue, rules, name, ...restProps } = this.props; + const { onChange, defaultValue, buttonText, rules, name, ...restProps } = this.props; const { count } = this.state; options.rules = rules || defaultRules; if (onChange) { @@ -82,7 +86,7 @@ function generator({ defaultProps, defaultRules, type }) { size="large" onClick={this.onGetCaptcha} > - {count ? `${count} s` : '获取验证码'} + {count ? `${count} s` : buttonText} diff --git a/src/components/Login/index.d.ts b/src/components/Login/index.d.ts index cd88a8b6..9c072867 100644 --- a/src/components/Login/index.d.ts +++ b/src/components/Login/index.d.ts @@ -19,6 +19,7 @@ export interface LoginItemProps { style?: React.CSSProperties; onGetCaptcha?: () => void; placeholder?: string; + buttonText?: React.ReactNode; } export class LoginItem extends React.Component {} diff --git a/src/components/Login/index.en-US.md b/src/components/Login/index.en-US.md index bc38579f..42b5b219 100644 --- a/src/components/Login/index.en-US.md +++ b/src/components/Login/index.en-US.md @@ -39,6 +39,7 @@ Apart from the above properties, Login.Username also support all properties of a Property | Description | Type | Default ----|------|-----|------ onGetCaptcha | callback on getting a new Captcha | () => void | - +buttonText | text on getting a new Captcha | ReactNode | - Apart from the above properties, _Login.Captcha_ support the same properties with _Login.UserName_. diff --git a/src/components/Login/index.zh-CN.md b/src/components/Login/index.zh-CN.md index 98f0f624..2ae84ceb 100644 --- a/src/components/Login/index.zh-CN.md +++ b/src/components/Login/index.zh-CN.md @@ -40,6 +40,7 @@ rules | 校验规则,同 Form getFieldDecorator(id, options) 中 [option.rules 参数 | 说明 | 类型 | 默认值 ----|------|-----|------ onGetCaptcha | 点击获取校验码的回调 | () => void | - +buttonText | 点击获取校验码的说明文字 | ReactNode | - 除上述属性以外,Login.Captcha 支持的属性与 Login.UserName 相同。 diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js index 59d56fc5..7a602da0 100644 --- a/src/components/PageHeader/index.js +++ b/src/components/PageHeader/index.js @@ -221,14 +221,16 @@ export default class PageHeader extends PureComponent { - {(tabList && tabList.length) ? ( + {tabList && tabList.length ? ( - {tabList.map(item => )} + {tabList.map(item => ( + + ))} ) : null} -- GitLab