From b35e3f0bacdbadf5823e06fe8dc6e047089aae38 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 19 一月 2020 00:25:45 +0800
Subject: [PATCH] 2020-01-19

---
 src/components/header/loginform.jsx |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/components/header/loginform.jsx b/src/components/header/loginform.jsx
index 680c392..e887b12 100644
--- a/src/components/header/loginform.jsx
+++ b/src/components/header/loginform.jsx
@@ -27,10 +27,20 @@
     })
   }
 
-  handleSubmit = e => {
-    // 鐧诲綍鍙傛暟妫�楠�
+  handleSubmit = (e, key) => {
     e.preventDefault()
-    this.props.handleSubmit()
+    if (e.target.value) {
+      if (!this.props.form.getFieldValue(key)) {
+        const input = document.getElementById(key)
+        if (input) {
+          input.focus()
+        }
+        return
+      }
+      this.props.handleSubmit()
+    } else {
+      this.handleConfirm()
+    }
   }
 
   componentDidMount () {
@@ -54,7 +64,7 @@
               prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
               placeholder={this.state.dict['login.username']}
               autoComplete="off"
-              onPressEnter={this.handleSubmit}
+              onPressEnter={(e) => {this.handleSubmit(e, 'password')}}
             />
           )}
         </Form.Item>
@@ -67,7 +77,7 @@
                 message: this.state.dict['login.password.empty'],
               }
             ]
-          })(<Input.Password onPressEnter={this.handleSubmit} placeholder={this.state.dict['login.password']} prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
+          })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'username')}} placeholder={this.state.dict['login.password']} prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
         </Form.Item>
       </Form>
     )

--
Gitblit v1.8.0