mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
接口ui修改
This commit is contained in:
parent
9e6f7d5caf
commit
b31460bfb5
@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { autobind } from 'core-decorators'
|
import { autobind } from 'core-decorators'
|
||||||
import { Button, Tabs } from 'antd'
|
import { Button, Tabs, message } from 'antd'
|
||||||
import ReqMethod from './ReqMethod/ReqMethod.js'
|
import ReqMethod from './ReqMethod/ReqMethod.js'
|
||||||
import ReqHeader from './ReqHeader/ReqHeader.js'
|
import ReqHeader from './ReqHeader/ReqHeader.js'
|
||||||
import ReqParams from './ReqParams/ReqParams.js'
|
import ReqParams from './ReqParams/ReqParams.js'
|
||||||
@ -19,6 +19,10 @@ import {
|
|||||||
pushInterfaceName
|
pushInterfaceName
|
||||||
} from '../../actions/addInterface.js'
|
} from '../../actions/addInterface.js'
|
||||||
|
|
||||||
|
const success = () => {
|
||||||
|
message.success('保存成功!')
|
||||||
|
}
|
||||||
|
|
||||||
@connect(
|
@connect(
|
||||||
state => {
|
state => {
|
||||||
return {
|
return {
|
||||||
@ -59,7 +63,8 @@ class AddInterface extends Component {
|
|||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: ''
|
isLoading: '',
|
||||||
|
isSave: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,15 +113,6 @@ class AddInterface extends Component {
|
|||||||
props.addReqHeader(req_headers)
|
props.addReqHeader(req_headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
editState2 () {
|
|
||||||
const props = this.props
|
|
||||||
props.pushInputValue(props.url)
|
|
||||||
// props.pushInterfaceName(title)
|
|
||||||
// props.getReqParams(req_params_other)
|
|
||||||
props.getResParams(props.resParams)
|
|
||||||
// props.addReqHeader(req_headers)
|
|
||||||
}
|
|
||||||
|
|
||||||
initInterfaceData (interfaceId) {
|
initInterfaceData (interfaceId) {
|
||||||
const params = { id: interfaceId }
|
const params = { id: interfaceId }
|
||||||
|
|
||||||
@ -146,6 +142,12 @@ class AddInterface extends Component {
|
|||||||
location.href = `${origin}${pathname}#/interface`
|
location.href = `${origin}${pathname}#/interface`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeState (ifTrue) {
|
||||||
|
this.setState({
|
||||||
|
isSave: ifTrue
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
saveForms () {
|
saveForms () {
|
||||||
let postURL = undefined
|
let postURL = undefined
|
||||||
@ -174,10 +176,10 @@ class AddInterface extends Component {
|
|||||||
this.setLoading(true)
|
this.setLoading(true)
|
||||||
|
|
||||||
axios.post(postURL, params)
|
axios.post(postURL, params)
|
||||||
.then(data => {
|
.then(() => {
|
||||||
console.log(data)
|
|
||||||
this.setLoading()
|
this.setLoading()
|
||||||
this.editState2()
|
success()
|
||||||
|
this.changeState(true)
|
||||||
// this.routerPage()
|
// this.routerPage()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
@ -187,7 +189,7 @@ class AddInterface extends Component {
|
|||||||
|
|
||||||
render () {
|
render () {
|
||||||
const TabPane = Tabs.TabPane
|
const TabPane = Tabs.TabPane
|
||||||
const isLoading = this.state.isLoading
|
const { isLoading, isSave } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="add-interface-box">
|
<section className="add-interface-box">
|
||||||
@ -199,7 +201,7 @@ class AddInterface extends Component {
|
|||||||
<ReqHeader />
|
<ReqHeader />
|
||||||
<ReqParams data={this.props} />
|
<ReqParams data={this.props} />
|
||||||
<ResParams />
|
<ResParams />
|
||||||
<Result />
|
<Result isSave={isSave} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="Mock" key="2">mock</TabPane>
|
<TabPane tab="Mock" key="2">mock</TabPane>
|
||||||
<TabPane tab="测试" key="3">测试</TabPane>
|
<TabPane tab="测试" key="3">测试</TabPane>
|
||||||
|
@ -38,6 +38,7 @@ class ResParams extends Component {
|
|||||||
const reg = /(<p>)|(<\/p>)| |(<br>)|\s+|<div>|<\/div>/g
|
const reg = /(<p>)|(<\/p>)| |(<br>)|\s+|<div>|<\/div>/g
|
||||||
editor.customConfig.menus = []
|
editor.customConfig.menus = []
|
||||||
editor.customConfig.onchange = html => {
|
editor.customConfig.onchange = html => {
|
||||||
|
console.log(html)
|
||||||
html = html.match(/{.*}/g)[0]
|
html = html.match(/{.*}/g)[0]
|
||||||
html = html.replace(reg, '')
|
html = html.replace(reg, '')
|
||||||
console.log(html)
|
console.log(html)
|
||||||
|
@ -16,7 +16,8 @@ import PropTypes from 'prop-types'
|
|||||||
class Result extends Component {
|
class Result extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
resParams: PropTypes.string,
|
resParams: PropTypes.string,
|
||||||
reqParams: PropTypes.string
|
reqParams: PropTypes.string,
|
||||||
|
isSave: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -24,16 +25,15 @@ class Result extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
console.log(1)
|
|
||||||
let TabPane = Tabs.TabPane
|
let TabPane = Tabs.TabPane
|
||||||
let resParams = ''
|
let resParams = ''
|
||||||
let json = ''
|
let json = ''
|
||||||
|
|
||||||
if(this.props.resParams){
|
if(this.props.resParams){
|
||||||
console.log(this.props.resParams)
|
|
||||||
resParams = JSON.parse(this.props.resParams)
|
resParams = JSON.parse(this.props.resParams)
|
||||||
json = JSON.stringify(Mock.mock(resParams), null, 2)
|
json = JSON.stringify(Mock.mock(resParams), null, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="result">
|
<div className="result">
|
||||||
<strong className="res-h3">返回示例 :</strong>
|
<strong className="res-h3">返回示例 :</strong>
|
||||||
|
@ -18,8 +18,10 @@
|
|||||||
"@qnpm/ykit-config-qunar": "^0.8.2",
|
"@qnpm/ykit-config-qunar": "^0.8.2",
|
||||||
"axios": "^0.16.2",
|
"axios": "^0.16.2",
|
||||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||||
|
"copy-webpack-plugin": "^4.0.1",
|
||||||
"core-decorators": "^0.17.0",
|
"core-decorators": "^0.17.0",
|
||||||
"fs-extra": "^3.0.1",
|
"fs-extra": "^3.0.1",
|
||||||
|
"jsoneditor": "^5.9.3",
|
||||||
"jsonwebtoken": "^7.4.1",
|
"jsonwebtoken": "^7.4.1",
|
||||||
"koa": "^2.0.0",
|
"koa": "^2.0.0",
|
||||||
"koa-bodyparser": "^3.2.0",
|
"koa-bodyparser": "^3.2.0",
|
||||||
@ -33,11 +35,13 @@
|
|||||||
"mock": "^0.1.1",
|
"mock": "^0.1.1",
|
||||||
"mockjs": "^1.0.1-beta3",
|
"mockjs": "^1.0.1-beta3",
|
||||||
"moment": "^2.18.1",
|
"moment": "^2.18.1",
|
||||||
|
"monaco-editor": "^0.9.0",
|
||||||
"mongoose": "4.10.8",
|
"mongoose": "4.10.8",
|
||||||
"mongoose-auto-increment": "^5.0.1",
|
"mongoose-auto-increment": "^5.0.1",
|
||||||
"node-sass-china": "^4.5.0",
|
"node-sass-china": "^4.5.0",
|
||||||
"nodemailer": "^4.0.1",
|
"nodemailer": "^4.0.1",
|
||||||
"prop-types": "^15.5.10",
|
"prop-types": "^15.5.10",
|
||||||
|
"react-monaco-editor": "^0.8.1",
|
||||||
"redux": "^3.7.1",
|
"redux": "^3.7.1",
|
||||||
"redux-promise": "^0.5.3",
|
"redux-promise": "^0.5.3",
|
||||||
"redux-thunk": "^2.2.0",
|
"redux-thunk": "^2.2.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user