mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
feat: 代码优化
This commit is contained in:
parent
abc947df2c
commit
505cceb98c
@ -85,8 +85,7 @@ export default class InterfaceTest extends Component {
|
||||
data: {
|
||||
a:1
|
||||
},
|
||||
success: (res, header) => {
|
||||
console.log(header)
|
||||
success: (res) => {
|
||||
this.setState({res})
|
||||
}
|
||||
})
|
||||
|
@ -24,7 +24,7 @@ class MockUrl extends Component {
|
||||
clipboard () {
|
||||
const btn = document.querySelector('#mock-clipboard')
|
||||
const txt = document.querySelector('#mock-p').innerHTML
|
||||
console.log('txt', txt)
|
||||
|
||||
new Clipboard(btn, {
|
||||
text: () => txt,
|
||||
target () {
|
||||
|
@ -6,7 +6,8 @@ import { autobind } from 'core-decorators'
|
||||
import {
|
||||
reqTagValue,
|
||||
reqHeaderValue,
|
||||
deleteReqHeader
|
||||
deleteReqHeader,
|
||||
addReqHeader
|
||||
} from '../../../actions/addInterface.js'
|
||||
|
||||
@connect(
|
||||
@ -20,7 +21,8 @@ import {
|
||||
{
|
||||
reqTagValue,
|
||||
reqHeaderValue,
|
||||
deleteReqHeader
|
||||
deleteReqHeader,
|
||||
addReqHeader
|
||||
}
|
||||
)
|
||||
|
||||
@ -30,6 +32,7 @@ class ReqList extends Component {
|
||||
reqTagValue: PropTypes.func,
|
||||
reqHeaderValue: PropTypes.func,
|
||||
deleteReqHeader: PropTypes.func,
|
||||
addReqHeader: PropTypes.func,
|
||||
_id: PropTypes.number,
|
||||
dataNum: PropTypes.number,
|
||||
value: PropTypes.object
|
||||
@ -43,12 +46,20 @@ class ReqList extends Component {
|
||||
handleChange (value) {
|
||||
const dir = 'AddInterface/edit'
|
||||
const url = location.href
|
||||
const newObject = []
|
||||
|
||||
if (url.includes(dir)) {
|
||||
const { seqGroup, value: { id } } = this.props
|
||||
seqGroup[id].name = value
|
||||
seqGroup.forEach(v => {
|
||||
const {id, name, value} = v
|
||||
newObject.push({id, name, value})
|
||||
})
|
||||
this.props.addReqHeader( newObject )
|
||||
} else {
|
||||
const { seqGroup, dataNum } = this.props
|
||||
seqGroup[dataNum].name = value
|
||||
this.props.addReqHeader(Object.create(seqGroup))
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +67,13 @@ class ReqList extends Component {
|
||||
handleBlur (e) {
|
||||
const value = e.target.value
|
||||
const { seqGroup, value: { id } } = this.props
|
||||
const newObject = []
|
||||
seqGroup[id].value = value
|
||||
seqGroup.forEach(v => {
|
||||
const {id, name, value} = v
|
||||
newObject.push({id, name, value})
|
||||
})
|
||||
this.props.addReqHeader(newObject)
|
||||
}
|
||||
|
||||
@autobind
|
||||
@ -82,7 +99,7 @@ class ReqList extends Component {
|
||||
return (
|
||||
<li>
|
||||
<em className="title">头部标签</em>
|
||||
<Select defaultValue={name} style={{ width: 220 }} onChange={this.handleChange} size="large">
|
||||
<Select value={name} style={{ width: 220 }} onChange={this.handleChange} size="large">
|
||||
<Option value="">选择请求头</Option>
|
||||
<Option value="Accept">Accept</Option>
|
||||
<Option value="Accept-Charset">Accept-Charset</Option>
|
||||
|
@ -58,6 +58,7 @@ class ReqMethod extends Component {
|
||||
render () {
|
||||
const { Option } = Select
|
||||
const { url, interfaceName, method } = this.props
|
||||
|
||||
return (
|
||||
<table>
|
||||
<tbody>
|
||||
@ -65,7 +66,7 @@ class ReqMethod extends Component {
|
||||
<th>协议 :</th>
|
||||
<td>
|
||||
<span className="h3">请求方式</span>
|
||||
<Select defaultValue={method} style={{ width: 220 }} onChange={this.handleChange} size="large">
|
||||
<Select value={method} style={{ width: 220 }} onChange={this.handleChange} size="large">
|
||||
<Option value="POST">POST</Option>
|
||||
<Option value="GET">GET</Option>
|
||||
<Option value="PUT">PUT</Option>
|
||||
|
@ -27,7 +27,7 @@ class Result extends Component {
|
||||
render () {
|
||||
const TabPane = Tabs.TabPane
|
||||
const { mockJson } = this.props
|
||||
console.log('mockJson', typeof mockJson, mockJson)
|
||||
|
||||
return (
|
||||
<div className="result">
|
||||
<Tabs defaultActiveKey="1">
|
||||
|
@ -58,7 +58,7 @@ class Interface extends Component {
|
||||
.then(result => {
|
||||
result = result.data.data
|
||||
result.map(value => {
|
||||
value.add_time = moment(value.add_time).format('YYYY-MM-DD HH:mm:ss')
|
||||
value.add_time = moment(value.add_time*1000).format('YYYY-MM-DD HH:mm:ss')
|
||||
return value
|
||||
})
|
||||
this.props.fetchInterfaceData(result)
|
||||
|
@ -81,7 +81,6 @@ class InterfaceTable extends Component {
|
||||
title: '功能',
|
||||
'key': 'action',
|
||||
render: (data) => {
|
||||
// const deleteInterface = this.deleteInterface.bind(this, data._id)
|
||||
const confirm = this.confirm.bind(this, data._id)
|
||||
return (
|
||||
<span>
|
||||
|
Loading…
Reference in New Issue
Block a user