| | |
| | | platName: PropTypes.string |
| | | } |
| | | |
| | | state = {} |
| | | state = { |
| | | username: '', |
| | | password: '' |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | // 表单提交时检查输入值是否正确 |
| | |
| | | } |
| | | |
| | | 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() |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | <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)' }} />} |
| | |
| | | </Form.Item> |
| | | <Form.Item> |
| | | {getFieldDecorator('password', { |
| | | initialValue: localStorage.getItem('password') || '', |
| | | initialValue: this.state.password || '', |
| | | rules: [ |
| | | { |
| | | required: true, |