From cdd5b449130ea4d7223fde4f414a11a7d0c33d6d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 三月 2024 17:52:16 +0800
Subject: [PATCH] 2024-03-07

---
 src/components/header/loginform.jsx |   53 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/src/components/header/loginform.jsx b/src/components/header/loginform.jsx
index 78b4e82..95e702f 100644
--- a/src/components/header/loginform.jsx
+++ b/src/components/header/loginform.jsx
@@ -1,6 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Icon, Input, Checkbox } from 'antd'
+import { Form, Input, Checkbox } from 'antd'
+import { UserOutlined, LockOutlined } from '@ant-design/icons'
+
 import zhCN from '@/locales/zh-CN/login.js'
 import enUS from '@/locales/en-US/login.js'
 import './index.scss'
@@ -14,7 +16,9 @@
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     remember: false,
     username: '',
-    password: ''
+    password: '',
+    oripassword: '',
+    delay: +sessionStorage.getItem('mkDelay')
   }
 
   UNSAFE_componentWillMount () {
@@ -35,18 +39,29 @@
       localStorage.removeItem(_url)
     }
 
-    this.setState({
-      remember: _user ? true : false,
-      username: _user ? _user.username : '',
-      password: _user ? _user.password : ''
-    })
+    if (_user) {
+      this.setState({
+        remember: true,
+        username: _user.username,
+        password: _user.password ? '*********' : '',
+        oripassword: _user.password
+      })
+    }
   }
 
   handleConfirm = () => {
+    const { oripassword } = this.state
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
+          if (oripassword && values.password === '*********') {
+            values.password = oripassword
+          }
+          
+          values.username = values.username.replace(/\t+|\v+|\s+/g, '')
+          values.password = values.password.replace(/\t+|\v+|\s+/g, '')
+
           resolve(values)
         } else {
           reject(err)
@@ -79,23 +94,33 @@
   }
 
   componentDidMount () {
-    const input = document.getElementById('username')
-    input && input.focus()
+    const { username, password } = this.state
+
+    if (username && !password) {
+      const input = document.getElementById('password')
+      input && input.focus()
+    } else {
+      const input = document.getElementById('username')
+      input && input.focus()
+    }
   }
 
   render() {
     const { getFieldDecorator } = this.props.form
-    const { remember, username, password } = this.state
+    const { remember, username, password, delay } = this.state
 
     return (
       <Form style={{margin: '0px 10px'}}>
+        {delay > 1000 ? <Form.Item style={{marginBottom: '0px', marginTop: '-10px'}}>
+          鍗囩骇鍒�<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">浼佷笟鐗�</a>锛岃幏寰楁洿楂樻晥鐨勫紑鍙戜綋楠屻��
+        </Form.Item> : null}
         <Form.Item style={{marginBottom: '0px', height: '60px'}}>
           {getFieldDecorator('username', {
             rules: [{ required: true, message: this.state.dict['login.username.empty'] }],
             initialValue: username,
           })(
             <Input
-              prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
+              prefix={<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }}/>}
               placeholder={this.state.dict['login.username']}
               autoComplete="off"
               onPressEnter={(e) => {this.handleSubmit(e, 'password')}}
@@ -111,15 +136,15 @@
                 message: this.state.dict['login.password.empty'],
               }
             ]
-          })(<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)' }} />} />)}
+          })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'username')}} placeholder={this.state.dict['login.password']} prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
         </Form.Item>
-        <Form.Item style={{marginBottom: '10px'}}>
+        {window.GLOB.keepKey ? <Form.Item style={{marginBottom: '10px'}}>
           {getFieldDecorator('remember', {
             valuePropName: 'checked',
             initialValue: remember,
           })(
           <Checkbox onChange={this.rememberChange}>璁颁綇瀵嗙爜</Checkbox>)}
-        </Form.Item>
+        </Form.Item> : <div style={{height: '20px'}}></div>}
       </Form>
     )
   }

--
Gitblit v1.8.0