yapi/client/containers/AddInterface/ReqParams/ReqParams.js

54 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-07-18 12:53:53 +08:00
import React, { Component } from 'react'
2017-07-19 15:12:10 +08:00
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
2017-07-20 14:48:29 +08:00
import wangEditor from 'wangeditor'
import { getReqParams } from '../../../actions/addInterface.js'
2017-07-19 19:29:18 +08:00
2017-07-19 15:12:10 +08:00
@connect(
state => {
return {
2017-07-19 19:29:18 +08:00
reqParams: state.addInterface.reqParams
2017-07-19 15:12:10 +08:00
}
},
{
2017-07-20 14:48:29 +08:00
getReqParams
2017-07-19 15:12:10 +08:00
}
)
2017-07-18 12:53:53 +08:00
class ReqParams extends Component {
2017-07-19 15:12:10 +08:00
static propTypes = {
2017-07-20 14:48:29 +08:00
reqParams: PropTypes.string,
getReqParams: PropTypes.func
2017-07-19 15:12:10 +08:00
}
2017-07-18 12:53:53 +08:00
constructor(props) {
super(props)
}
2017-07-20 14:48:29 +08:00
componentDidMount () {
const reg = /(<p>)|(<\/p>)|&nbsp;|(<br>)|\s+/g
const E = wangEditor
const editor = new E('#req-cover')
editor.customConfig.menus = []
editor.customConfig.onchange = html => {
html = html.replace(reg, '')
2017-07-20 19:26:04 +08:00
console.log(html)
2017-07-20 14:48:29 +08:00
this.props.getReqParams(html)
2017-07-19 15:12:10 +08:00
}
2017-07-20 14:48:29 +08:00
editor.create()
2017-07-19 15:12:10 +08:00
}
2017-07-20 14:48:29 +08:00
2017-07-18 12:53:53 +08:00
render () {
return (
<section>
<div className="req-params">
<strong className="req-h3">请求参数 :</strong>
2017-07-20 14:48:29 +08:00
<div id="req-cover"></div>
2017-07-18 12:53:53 +08:00
</div>
</section>
)
}
}
2017-07-20 14:48:29 +08:00
export default ReqParams