| | |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | const { confirm } = Modal |
| | | |
| | | class KeyInterface extends Component { |
| | | static propTpyes = { |
| | |
| | | |
| | | if (this.state.key && _setting && typeof(_setting) === 'string') { |
| | | _setting = this.decrypt(this.state.key, _setting) |
| | | |
| | | if (!_setting) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '信息解析失败!', |
| | | duration: 5 |
| | | }) |
| | | this.props.onChange('') |
| | | } |
| | | } |
| | | |
| | | this.setState({visible: true, setting: _setting || {}}) |
| | |
| | | |
| | | setting = JSON.parse(window.decodeURIComponent(window.atob(setting))) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '信息解析失败!', |
| | | duration: 5 |
| | | }) |
| | | setting = {} |
| | | setting = null |
| | | } |
| | | |
| | | return setting |
| | |
| | | let _setting = this.state.setting |
| | | if (_setting && typeof(_setting) === 'string') { |
| | | _setting = this.decrypt(key, _setting) |
| | | |
| | | if (!_setting) { |
| | | const that = this |
| | | confirm({ |
| | | title: '信息解析失败!', |
| | | content: '点击确定会清除配置信息,点击取消可重新输入appkey。', |
| | | onOk() { |
| | | that.setState({key: key, setting: {}, url: ''}) |
| | | that.props.onChange('') |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | this.setState({key: key, setting: _setting}) |
| | | return |
| | |
| | | this.props.onChange(content) |
| | | |
| | | this.setState({setting: message, url: values.interface, visible: false}) |
| | | |
| | | if (this.props.type !== 'develop') { |
| | | this.setState({key: ''}) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | delKey = () => { |
| | | const { url } = this.state |
| | | const { type } = this.props |
| | | |
| | | if (!url) return |
| | | |
| | | if (type === 'develop') { |
| | | this.setState({setting: null, url: ''}) |
| | |
| | | this.props.onChange('') |
| | | } |
| | | |
| | | cancel = () => { |
| | | const { type } = this.props |
| | | |
| | | if (type !== 'develop') { |
| | | this.setState({key: ''}) |
| | | } |
| | | this.setState({visible: false}) |
| | | } |
| | | |
| | | render() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const { url, visible, setting, key } = this.state |
| | |
| | | return ( |
| | | <div className="mk-key-wrap"> |
| | | <TextArea value={url} rows={2} readOnly={true}/> |
| | | <div className="mk-key-edit"><EditOutlined onClick={this.editKey}/><DeleteOutlined onClick={this.delKey}/></div> |
| | | <div className="mk-key-edit"> |
| | | <EditOutlined onClick={this.editKey}/> |
| | | <DeleteOutlined className={!url ? 'disable' : ''} onClick={this.delKey}/> |
| | | </div> |
| | | <Modal |
| | | wrapClassName='mk-key-modal' |
| | | visible={visible} |
| | |
| | | maskClosable={false} |
| | | width={650} |
| | | onOk={this.handleConfirm} |
| | | onCancel={() => this.setState({visible: false})} |
| | | onCancel={this.cancel} |
| | | destroyOnClose |
| | | > |
| | | {key && setting ? |
| | |
| | | message: '不可小于16位!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="请输入appkey" autoComplete="off" />)} |
| | | })(<Input placeholder="请输入目标系统appkey" autoComplete="off" />)} |
| | | </Form.Item> |
| | | <Form.Item label="用户名"> |
| | | {getFieldDecorator('username', { |
| | |
| | | </Form.Item> |
| | | </Form> : null} |
| | | {!key ? <Form style={{marginTop: '20px', marginBottom: '50px'}}> |
| | | <Form.Item label="apptoken"> |
| | | <Form.Item label="appkey"> |
| | | {getFieldDecorator('apptoken', { |
| | | initialValue: '', |
| | | rules: [ |