瀏覽代碼

Features: add buttonText on Login.Captcha

陈帅 7 年之前
父節點
當前提交
189e6c5c59

+ 1 - 1
.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

+ 6 - 2
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}
                   </Button>
                 </Col>
               </Row>

+ 1 - 0
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<LoginItemProps, any> {}

+ 1 - 0
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_.
 

+ 1 - 0
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 相同。
 

+ 4 - 2
src/components/PageHeader/index.js

@@ -221,14 +221,16 @@ export default class PageHeader extends PureComponent {
             </div>
           </div>
         </div>
-        {(tabList && tabList.length) ? (
+        {tabList && tabList.length ? (
           <Tabs
             className={styles.tabs}
             {...activeKeyProps}
             onChange={this.onChange}
             tabBarExtraContent={tabBarExtraContent}
           >
-            {tabList.map(item => <TabPane tab={item.tab} key={item.key} />)}
+            {tabList.map(item => (
+              <TabPane tab={item.tab} key={item.key} />
+            ))}
           </Tabs>
         ) : null}
       </div>