mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
feat: run
This commit is contained in:
parent
57f2b872c3
commit
129708f264
@ -5,7 +5,7 @@ import { Button, Input, Select, Card, Alert, Spin, Icon, message } from 'antd'
|
|||||||
import { autobind } from 'core-decorators';
|
import { autobind } from 'core-decorators';
|
||||||
import crossRequest from 'cross-request';
|
import crossRequest from 'cross-request';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
import axios from 'axios';
|
// import axios from 'axios';
|
||||||
import URL from 'url';
|
import URL from 'url';
|
||||||
|
|
||||||
// import {
|
// import {
|
||||||
@ -19,25 +19,27 @@ const Option = Select.Option;
|
|||||||
|
|
||||||
@connect(
|
@connect(
|
||||||
state => ({
|
state => ({
|
||||||
reqParams: state.addInterface.reqParams,
|
currInterface: state.inter.curdata,
|
||||||
method: state.addInterface.method,
|
currProject: state.project.currProject
|
||||||
url: state.addInterface.url,
|
// reqParams: state.addInterface.reqParams,
|
||||||
seqGroup: state.addInterface.seqGroup,
|
// method: state.addInterface.method,
|
||||||
interfaceName: state.addInterface.interfaceName,
|
// url: state.addInterface.url,
|
||||||
interfaceProject: state.addInterface.project
|
// seqGroup: state.addInterface.seqGroup,
|
||||||
|
// interfaceName: state.addInterface.interfaceName,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@withRouter
|
@withRouter
|
||||||
export default class InterfaceTest extends Component {
|
export default class InterfaceTest extends Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
reqParams: PropTypes.string,
|
|
||||||
method: PropTypes.string,
|
|
||||||
url: PropTypes.string,
|
|
||||||
interfaceName: PropTypes.string,
|
|
||||||
seqGroup: PropTypes.array,
|
|
||||||
match: PropTypes.object,
|
match: PropTypes.object,
|
||||||
interfaceProject: PropTypes.object
|
currProject: PropTypes.object,
|
||||||
|
currInterface: PropTypes.object,
|
||||||
|
reqParams: PropTypes.string,
|
||||||
|
// method: PropTypes.string,
|
||||||
|
// url: PropTypes.string,
|
||||||
|
interfaceName: PropTypes.string
|
||||||
|
// seqGroup: PropTypes.array,
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@ -68,8 +70,11 @@ export default class InterfaceTest extends Component {
|
|||||||
@autobind
|
@autobind
|
||||||
getInterfaceState(nextProps) {
|
getInterfaceState(nextProps) {
|
||||||
const props = nextProps || this.props;
|
const props = nextProps || this.props;
|
||||||
const { method, url, seqGroup, interfaceProject } = props;
|
const { currInterface, currProject } = props;
|
||||||
const { prd_host, basepath, protocol, env } = interfaceProject;
|
console.log('currInterface', currInterface)
|
||||||
|
console.log('currProject', currProject)
|
||||||
|
const { method, path: url, req_headers } = currInterface;
|
||||||
|
const { prd_host, basepath, protocol, env } = currProject;
|
||||||
const pathname = (basepath + url).replace(/\/+/g, '/');
|
const pathname = (basepath + url).replace(/\/+/g, '/');
|
||||||
|
|
||||||
const domains = {prd: protocol + '://' + prd_host};
|
const domains = {prd: protocol + '://' + prd_host};
|
||||||
@ -104,7 +109,7 @@ export default class InterfaceTest extends Component {
|
|||||||
|
|
||||||
const headers = []
|
const headers = []
|
||||||
let contentTypeIndex = -1;
|
let contentTypeIndex = -1;
|
||||||
seqGroup.forEach((headerItem, index) => {
|
req_headers.forEach((headerItem, index) => {
|
||||||
if (headerItem.name) {
|
if (headerItem.name) {
|
||||||
// TODO 'Content-Type' 排除大小写不同格式影响
|
// TODO 'Content-Type' 排除大小写不同格式影响
|
||||||
if (headerItem.name === 'Content-Type'){
|
if (headerItem.name === 'Content-Type'){
|
||||||
@ -350,10 +355,6 @@ export default class InterfaceTest extends Component {
|
|||||||
const hasPlugin = this.hasCrossRequestPlugin();
|
const hasPlugin = this.hasCrossRequestPlugin();
|
||||||
const search = decodeURIComponent(URL.format({query: this.getQueryObj(query)}));
|
const search = decodeURIComponent(URL.format({query: this.getQueryObj(query)}));
|
||||||
|
|
||||||
console.log(axios)
|
|
||||||
window.axios = axios
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="interface-test">
|
<div className="interface-test">
|
||||||
<div style={{padding: '0 20%'}}>
|
<div style={{padding: '0 20%'}}>
|
||||||
|
@ -8,7 +8,7 @@ const PROJECT_DEL = 'yapi/project/PROJECT_DEL';
|
|||||||
const CHANGE_UPDATE_MODAL = 'yapi/project/CHANGE_UPDATE_MODAL';
|
const CHANGE_UPDATE_MODAL = 'yapi/project/CHANGE_UPDATE_MODAL';
|
||||||
const CHANGE_TABLE_LOADING = 'yapi/project/CHANGE_TABLE_LOADING';
|
const CHANGE_TABLE_LOADING = 'yapi/project/CHANGE_TABLE_LOADING';
|
||||||
const PROJECT_UPDATE = 'yapi/project/PROJECT_UPDATE';
|
const PROJECT_UPDATE = 'yapi/project/PROJECT_UPDATE';
|
||||||
const GET_CUR_PROJECT = 'yapi/project/GET_CUR_PROJECT'
|
const GET_CURR_PROJECT = 'yapi/project/GET_CURR_PROJECT'
|
||||||
|
|
||||||
// Reducer
|
// Reducer
|
||||||
const initialState = {
|
const initialState = {
|
||||||
@ -19,15 +19,15 @@ const initialState = {
|
|||||||
tableLoading: true,
|
tableLoading: true,
|
||||||
total: 0,
|
total: 0,
|
||||||
currPage: 1,
|
currPage: 1,
|
||||||
curProject: {}
|
currProject: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (state = initialState, action) => {
|
export default (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case GET_CUR_PROJECT: {
|
case GET_CURR_PROJECT: {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
curProject: action.payload.data
|
currProject: action.payload.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case CHANGE_UPDATE_MODAL: {
|
case CHANGE_UPDATE_MODAL: {
|
||||||
@ -136,7 +136,7 @@ export function getProject(id){
|
|||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
let result = await axios.get('/api/project/get?id=' + id);
|
let result = await axios.get('/api/project/get?id=' + id);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: GET_CUR_PROJECT,
|
type: GET_CURR_PROJECT,
|
||||||
payload: result.data
|
payload: result.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user