king
2022-10-04 41c55c1f103658b997f7a828a7067bdb228f1df0
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,8 @@
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    remember: false,
    username: '',
    password: ''
    password: '',
    delay: +sessionStorage.getItem('mkDelay')
  }
  UNSAFE_componentWillMount () {
@@ -85,17 +88,20 @@
  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 +117,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>
    )
  }