fix: 添加接口view页

This commit is contained in:
qitmac000249 2017-08-15 12:07:52 +08:00
parent 6a5b588196
commit c56caae762
4 changed files with 101 additions and 10 deletions

View File

@ -9,7 +9,6 @@ import { getMockUrl } from '../../../reducer/modules/news.js'
@connect(
state => {
console.log(state);
return {
uid: state.user.uid + ''
}
@ -51,7 +50,7 @@ class Activity extends Component {
<div className="Mockurl">
<span>Mock地址</span>
<p>{this.state.mockURL}</p>
<Button type="primary">下载Mock数据</Button>
<Button type="primary"><a href = {`/api/project/download?project_id=${this.props.match.params.id}`}>下载Mock数据</a></Button>
</div>
</div>
<TimeTree typeid = {+this.props.match.params.id} />

View File

@ -3,6 +3,7 @@ import { Timeline, Spin } from 'antd'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { formatTime } from '../../../../common.js';
import { Link } from 'react-router-dom'
import { fetchNewsData, fetchMoreNews } from '../../../../reducer/modules/news.js'
function timeago(timestamp) {
@ -93,7 +94,7 @@ class TimeTree extends Component {
this.setState({ loading: true });
this.props.fetchMoreNews(this.props.typeid, 'project', this.props.curpage+1, 8).then(function () {
that.setState({ loading: false });
if (that.props.newsData.total + 1 === that.props.curpage) {
if (that.props.newsData.total === that.props.curpage) {
that.setState({ bidden: "logbidden" })
}
})
@ -101,18 +102,17 @@ class TimeTree extends Component {
}
componentWillMount() {
this.props.fetchNewsData(this.props.typeid, 'project', 1, 8)
}
render() {
let data = this.props.newsData ? this.props.newsData.list : [];
if (data && data.length) {
data = data.map(function (item, i) {
return (<Timeline.Item key={i}>
<span className="logoTimeago">{timeago(item.add_time)}</span>
<span className="logusername">{item.username}</span>
<span className="logusername"><Link to={`/user/profile/${item.uid}`}>{item.username}</Link></span>
<span className="logtype">{item.type}</span>
<span className="logtime">{formatTime(item.add_time)}</span>
<span className="logcontent">{item.content}</span>
@ -121,7 +121,7 @@ class TimeTree extends Component {
} else {
data = "";
}
let pending = this.state.bidden ? <a className={this.state.bidden}>以上为全部内容</a> : <a className="loggetMore" onClick={this.getMore.bind(this)}></a>;
let pending = this.props.newsData.total <= this.props.curpage ? <a className= "logbidden">以上为全部内容</a> : <a className="loggetMore" onClick={this.getMore.bind(this)}></a>;
if (this.state.loading) {
pending = <Spin />
}

View File

@ -1,6 +1,85 @@
import React from 'react'
import '../interface.scss'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import { formatTime } from '../../../../common.js';
export default () => {
return <h1>接口预览</h1>
// import { Card } from 'antd'
// import { getMockUrl } from '../../reducer/modules/news.js'
@connect()
class View extends Component {
constructor(props) {
super(props);
}
static propTypes = {
viewData: PropTypes.object
}
render () {
return <div className="caseContainer">
{/*<Card title={`接口名:${this.props.viewData.casename}`}></Card>*/}
<div className="casename">
<span className="colKey">接口名</span>
<span className="colValue">{this.props.viewData.casename}</span>
</div>
<div className="colTime">
<span className="colKey">添加时间</span>
<span className="colValue">{formatTime(this.props.viewData.add_time/1000)}</span>
</div>
<div className="colTime">
<span className="colKey">更新时间</span>
<span className="colValue">{formatTime(this.props.viewData.up_time/1000)}</span>
</div>
<div className="colEnv">
<span className="colKey">测试环境</span>
<span className="colValue">{this.props.viewData.env}</span>
</div>
<div className="colDomain">
<span className="colKey">域名</span>
<span className="colValue">{this.props.viewData.domain}</span>
</div>
<div className="colPath">
<span className="colKey">路径</span>
<span className="colValue">{this.props.viewData.path}</span>
</div>
<div className="colMethod">
<span className="colKey">请求方法</span>
<span className="colValue">{this.props.viewData.method}</span>
</div>
</div>
}
}
View.defaultProps = {
viewData: {
casename:"caename",
uid: 107,
col_id: 211,
index: 0,
project_id: 112,
add_time: new Date().getTime(),
up_time: new Date().getTime(),
env: "测试环境",
domain: "域名",
path: "路径",
method: "GET",
req_query: [{
name: "String",
value: "String"
}],
req_headers: [{
name: "String",
value: "String"
}],
req_body_type: "json",
res_body_form: [{
name: "String",
value: "String"
}],
res_body_other: "String"
}
}
export default View

View File

@ -64,6 +64,19 @@
}
}
}
.caseContainer{
padding: 24px;
font-size: 12px;
>div{
margin: 8px 0px;
padding: 12px;
background-color: #ececec;
.colKey{
font-weight: bolder;
margin-right: 16px;
}
}
}