From 1be17b9144dc2f7eeb7382458a032ac435f277b2 Mon Sep 17 00:00:00 2001 From: qitmac000249 Date: Fri, 18 Aug 2017 11:34:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0ErrMsg=E5=88=B0log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/containers/Project/Activity/Timeline/Timeline.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/containers/Project/Activity/Timeline/Timeline.js b/client/containers/Project/Activity/Timeline/Timeline.js index 6fda188c..bf643947 100644 --- a/client/containers/Project/Activity/Timeline/Timeline.js +++ b/client/containers/Project/Activity/Timeline/Timeline.js @@ -5,6 +5,7 @@ import { connect } from 'react-redux' import { formatTime } from '../../../../common.js'; import { Link } from 'react-router-dom' import { fetchNewsData, fetchMoreNews } from '../../../../reducer/modules/news.js' +import ErrMsg from '../../../../components/ErrMsg/ErrMsg.js'; function timeago(timestamp) { let minutes, hours, days, seconds, mouth, year; @@ -130,7 +131,7 @@ class TimeTree extends Component { } return (
- {data ? {data} : "还没有任何动态"} + {data ? {data} : }
) } From 68af11e6f29ffce319d3d4381c50e124beacf005 Mon Sep 17 00:00:00 2001 From: qitmac000249 Date: Fri, 18 Aug 2017 17:49:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E5=8A=A0=E8=BD=BD=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Project/Activity/Timeline/Timeline.js | 1 + .../Project/Interface/InterfaceList/View.js | 112 +++++++----------- client/reducer/modules/interface.js | 4 +- 3 files changed, 46 insertions(+), 71 deletions(-) diff --git a/client/containers/Project/Activity/Timeline/Timeline.js b/client/containers/Project/Activity/Timeline/Timeline.js index bf643947..69531050 100644 --- a/client/containers/Project/Activity/Timeline/Timeline.js +++ b/client/containers/Project/Activity/Timeline/Timeline.js @@ -57,6 +57,7 @@ function timeago(timestamp) { @connect( state => { + console.log(state); return { newsData: state.news.newsData, curpage: state.news.curpage, diff --git a/client/containers/Project/Interface/InterfaceList/View.js b/client/containers/Project/Interface/InterfaceList/View.js index 166405ba..b9c5c7c8 100644 --- a/client/containers/Project/Interface/InterfaceList/View.js +++ b/client/containers/Project/Interface/InterfaceList/View.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types' import { Table } from 'antd' const mockEditor = require('./mockEditor.js') import { formatTime } from '../../../../common.js'; - +import ErrMsg from '../../../../components/ErrMsg/ErrMsg.js'; // import { Card } from 'antd' // import { getMockUrl } from '../../reducer/modules/news.js' @@ -18,6 +18,9 @@ import { formatTime } from '../../../../common.js'; class View extends Component { constructor(props) { super(props); + this.state = { + init: true + } } static propTypes = { curData: PropTypes.object @@ -25,12 +28,6 @@ class View extends Component { req_body_form(req_body_type,req_body_form){ if(req_body_type === 'json'){ - mockEditor({ - container: 'vreq_body_json', - data: req_body_form, - readOnly:true, - onChange: function () {} - }) return
请求Body:
@@ -74,14 +71,14 @@ class View extends Component { return
请求Body: -
file
+
{this.props.curData.req_body_other}
}else if(req_body_type === 'raw'){ return
请求Body: -
raw
+
{this.props.curData.req_body_other}
} } @@ -91,50 +88,7 @@ class View extends Component { 返回Body:
- - }else if(res_body_type === 'form'){ - - const columns = [{ - title: '参数名称', - dataIndex: 'name', - key: 'name' - }, { - title: '参数值', - dataIndex: 'value', - key: 'value' - }, { - title: '备注', - dataIndex: 'required', - key: 'required', - width: '45%' - }]; - - const dataSource = []; - if(res_body&&res_body.length){ - res_body.map((item,i)=>{ - dataSource.push({ - key: i, - name: item.name, - value: item.desc, - required: item.required?"必须":"非必须" - }) - }) - } - - return
- 返回Body: - - - - }else if(res_body_type === 'file'){ - - return
- 返回Body: -
{res_body}
-
- }else if(res_body_type === 'raw'){ - return
返回Body:
{res_body}
@@ -172,16 +126,18 @@ class View extends Component { return
; } - componentDidUpdate(){ - if(this.props.curData.req_body_type === "json"){ + + + bindAceEditor(){ + if(!this.state.init&&(this.props.curData.req_body_type === "json"&&this.props.curData.title)){ mockEditor({ container: 'vreq_body_json', - data: this.props.curData.req_body_form, + data: this.props.curData.req_body_other, readOnly:true, onChange: function () {} }) } - if(this.props.curData.res_body_type === "json"){ + if(!this.state.init&&(this.props.curData.res_body_type === "json"&&this.props.curData.title)){ mockEditor({ container: 'vres_body_json', data: this.props.curData.res_body, @@ -190,8 +146,20 @@ class View extends Component { }) } } + componentDidMount(){ + if(!this.state.init){ + this.bindAceEditor.bind(this)(); + } + } + componentDidUpdate(){ + this.bindAceEditor.bind(this)(); + } + componentWillUpdate(){ + if(!this.props.curData.title&&this.state.init){ + this.setState({init: false}); + } + } render () { - const dataSource = []; if(this.props.curData.req_headers&&this.props.curData.req_headers.length){ this.props.curData.req_headers.map((item,i)=>{ @@ -218,8 +186,11 @@ class View extends Component { key: 'required', width: '45%' }]; - - return this.props.curData.title?
+ let status = { + undone: "未完成", + done: "完成" + } + let res =
接口名: {this.props.curData.title} @@ -234,7 +205,7 @@ class View extends Component {
状态: - {this.props.curData.status} + {status[this.props.curData.status]}
创建时间: @@ -260,18 +231,21 @@ class View extends Component { 请求Body类型: {this.props.curData.req_body_type}
- {this.req_body_form("form",this.props.curData.req_body_form)} + {this.req_body_form(this.props.curData.req_body_type,this.props.curData.req_body_form)}
返回Body类型: - {this.props.curData.req_body_type} + {this.props.curData.res_body_type}
- {this.res_body("json",this.props.curData.res_body)} - {/*{this.res_body("file",[{ - name: "key", - desc: "123", - required: 0 - }])}*/} -
:
接口不存在
; + {this.res_body(this.props.curData.res_body_type,this.props.curData.res_body)} +
; + if(!this.props.curData.title){ + if(this.state.init){ + res =
; + }else{ + res = ; + } + } + return res; } } diff --git a/client/reducer/modules/interface.js b/client/reducer/modules/interface.js index ad1fb5e8..95a67c55 100644 --- a/client/reducer/modules/interface.js +++ b/client/reducer/modules/interface.js @@ -53,8 +53,8 @@ export default (state = initialState, action) => { case FETCH_INTERFACE_LIST: return { ...state, - list: action.payload.data, - curdata: {} + list: action.payload.data + // curdata: {} } default: return state