yapi/client/containers/AddInterface/Result/Result.js

51 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-07-18 12:53:53 +08:00
import React, { Component } from 'react'
import { Tabs } from 'antd'
2017-07-24 19:43:13 +08:00
import Mock from 'mockjs'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
2017-07-25 15:11:43 +08:00
console.log('测试')
2017-07-24 19:43:13 +08:00
@connect(
state => {
return {
resParams: state.addInterface.resParams,
reqParams: state.addInterface.reqParams
}
2017-07-18 12:53:53 +08:00
}
2017-07-24 19:43:13 +08:00
)
2017-07-18 12:53:53 +08:00
2017-07-24 19:43:13 +08:00
class Result extends Component {
static propTypes = {
resParams: PropTypes.string,
2017-07-25 14:35:46 +08:00
reqParams: PropTypes.string,
isSave: PropTypes.bool
2017-07-18 12:53:53 +08:00
}
2017-07-24 19:43:13 +08:00
constructor(props) {
super(props)
}
2017-07-18 12:53:53 +08:00
2017-07-24 19:43:13 +08:00
render () {
let TabPane = Tabs.TabPane
let resParams = ''
let json = ''
if(this.props.resParams){
resParams = JSON.parse(this.props.resParams)
json = JSON.stringify(Mock.mock(resParams), null, 2)
}
2017-07-25 14:35:46 +08:00
2017-07-18 12:53:53 +08:00
return (
<div className="result">
<strong className="res-h3">返回示例 :</strong>
2017-07-24 19:43:13 +08:00
<Tabs defaultActiveKey="1">
2017-07-18 12:53:53 +08:00
<TabPane tab="成功结果" key="1">
2017-07-24 19:43:13 +08:00
<pre>{json}</pre>
2017-07-18 12:53:53 +08:00
</TabPane>
</Tabs>
</div>
)
}
}
2017-07-24 19:43:13 +08:00
export default Result