king
2019-12-12 f22bb55c4ff50a8a63c795487b057c0cebdae649
src/views/login/loginform.jsx
@@ -16,7 +16,10 @@
    platName: PropTypes.string
  }
  state = {}
  state = {
    username: '',
    password: ''
  }
  handleConfirm = () => {
    // 表单提交时检查输入值是否正确
@@ -52,9 +55,32 @@
  }
  componentDidMount () {
    const input = document.getElementById('username')
    if (input) {
      input.focus()
    let _url = window.location.href.split('#')[0]
    let _user = localStorage.getItem(_url)
    if (_user) {
      try {
        _user = JSON.parse(window.decodeURIComponent(window.atob(_user)))
      } catch {
        _user = ''
      }
    }
    if (_user) {
      this.setState({
        username: _user.username,
        password: _user.password
      }, () => {
        const input = document.getElementById('username')
        if (input) {
          input.focus()
        }
      })
    } else {
      const input = document.getElementById('username')
      if (input) {
        input.focus()
      }
    }
  }
@@ -67,7 +93,7 @@
        <Form.Item>
          {getFieldDecorator('username', {
            rules: [{ required: true, message: this.props.dict['login.username.empty'] }],
            initialValue: localStorage.getItem('username') || '',
            initialValue: this.state.username || '',
          })(
            <Input
              prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
@@ -77,7 +103,7 @@
        </Form.Item>
        <Form.Item>
          {getFieldDecorator('password', {
            initialValue: localStorage.getItem('password') || '',
            initialValue: this.state.password || '',
            rules: [
              {
                required: true,