mirror of
https://github.com/YMFE/yapi.git
synced 2025-04-06 15:00:26 +08:00
feat: advMock suuport json-schema
This commit is contained in:
parent
e3aa95d1a2
commit
159b833a1f
@ -8,6 +8,7 @@ import { fetchMockCol } from 'client/reducer/modules/mockCol'
|
||||
import { formatTime } from 'client/common.js';
|
||||
import constants from 'client/constants/variable.js'
|
||||
import CaseDesModal from './CaseDesModal';
|
||||
import { json5_parse } from '../../../client/common';
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
@ -44,6 +45,22 @@ export default class MockCol extends Component {
|
||||
this.props.fetchMockCol(interfaceId);
|
||||
}
|
||||
|
||||
openModal = (record, isAdd)=>{
|
||||
return async ()=>{
|
||||
if(this.props.currInterface.res_body_is_json_schema && isAdd){
|
||||
let result = await axios.post('/api/interface/schema2json', {
|
||||
schema: json5_parse(this.props.currInterface.res_body)
|
||||
})
|
||||
record.res_body = JSON.stringify(result.data)
|
||||
}
|
||||
this.setState({
|
||||
isAdd: isAdd,
|
||||
caseDesModalVisible: true,
|
||||
caseData: record
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
handleOk = async (caseData) => {
|
||||
|
||||
if(!caseData){
|
||||
@ -83,12 +100,6 @@ export default class MockCol extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
// saveFormRef = (form) => {
|
||||
// console.log(form.handleOk)
|
||||
// console.log(form)
|
||||
// this.form = form;
|
||||
// }
|
||||
|
||||
render() {
|
||||
|
||||
const { list: data, currInterface } = this.props;
|
||||
@ -155,11 +166,7 @@ export default class MockCol extends Component {
|
||||
return (
|
||||
<div>
|
||||
<span style={{marginRight: 5}}>
|
||||
<Button size="small" onClick={() => this.setState({
|
||||
isAdd: false,
|
||||
caseDesModalVisible: true,
|
||||
caseData: recode
|
||||
})}>编辑</Button>
|
||||
<Button size="small" onClick={ this.openModal(recode) }>编辑</Button>
|
||||
</span>
|
||||
<span>
|
||||
<Popconfirm
|
||||
@ -179,11 +186,7 @@ export default class MockCol extends Component {
|
||||
return (
|
||||
<div>
|
||||
<div style={{marginBottom: 8}}>
|
||||
<Button type="primary" onClick={() => this.setState({
|
||||
isAdd: true,
|
||||
caseDesModalVisible: true,
|
||||
caseData: initCaseData
|
||||
})}>添加期望</Button>
|
||||
<Button type="primary" onClick={this.openModal(initCaseData, true)}>添加期望</Button>
|
||||
<a target="_blank" rel="noopener noreferrer" href={constants.docHref.adv_mock_case} style={{marginLeft: 8}} >
|
||||
<Tooltip title="点击查看文档"><Icon type="question-circle-o" /></Tooltip>
|
||||
</a>
|
||||
|
@ -9,7 +9,8 @@
|
||||
"dev-client": "ykit s -p 4000",
|
||||
"dev": "npm run dev-server & npm run dev-client",
|
||||
"start": " node server/app.js",
|
||||
"test": "ava"
|
||||
"test": "ava",
|
||||
"build-client":"NODE_ENV=production ykit pack -m"
|
||||
},
|
||||
"scripts-info": {
|
||||
"start": "运行生产环境服务器",
|
||||
|
Loading…
x
Reference in New Issue
Block a user