fix: 接口tag可多选

This commit is contained in:
gaoxiaolin.gao 2018-08-16 17:25:22 +08:00
parent fbb013925d
commit b47609c061
12 changed files with 28 additions and 17 deletions

View File

@ -1,5 +1,8 @@
### v1.3.23
* 接口tag功能
#### Bug Fixed
* 接口path中写入 ?name=xxx bug

View File

@ -45,6 +45,10 @@ function isJson5(json) {
return false;
}
}
exports.safeArray = function(arr) {
return Array.isArray(arr) ? arr : [];
};
exports.json5_parse = function(json) {
try {

View File

@ -142,7 +142,6 @@ class InterfaceEdit extends Component {
}
onTagClick = () => {
console.log(111);
this.setState({
visible: true
});

View File

@ -859,7 +859,7 @@ class InterfaceEditForm extends Component {
</FormItem>
<FormItem className="interface-edit-item" {...formItemLayout} label="Tag">
{getFieldDecorator('tag', { initialValue: this.state.tag })(
<Select placeholder="请选择 tag ">
<Select placeholder="请选择 tag " mode="multiple">
{projectMsg.tag.map(item => {
return (
<Option value={item.name} key={item._id}>

View File

@ -296,12 +296,12 @@ class InterfaceList extends Component {
key: 'tag',
width: 14,
render: text => {
// const key = record.key;
return <div>{text || '未设置'}</div>;
let textMsg = text.length > 0 ? text.join('\n') : '未设置';
return <div className="table-desc">{textMsg}</div>
},
filters: filter,
onFilter: (value, record) => {
return record.tag && record.tag.indexOf(value) === 0;
return record.tag.indexOf(value) >= 0;
}
}
];

View File

@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { Table, Icon, Row, Col, Tooltip, message } from 'antd';
import { Link } from 'react-router-dom';
import AceEditor from 'client/components/AceEditor/AceEditor';
import { formatTime } from '../../../../common.js';
import { formatTime, safeArray } from '../../../../common.js';
import ErrMsg from '../../../../components/ErrMsg/ErrMsg.js';
import variable from '../../../../constants/variable';
import constants from '../../../../constants/variable.js';
@ -372,6 +372,8 @@ class View extends Component {
methodColor = 'get';
}
const {tag, up_time, title, uid, username} = this.props.curData
let res = (
<div className="caseContainer">
<h2 className="interface-title" style={{ marginTop: 0 }}>
@ -383,15 +385,15 @@ class View extends Component {
接口名称
</Col>
<Col span={8} className="colName">
{this.props.curData.title}
{title}
</Col>
<Col span={4} className="colKey">
&ensp;&ensp;
</Col>
<Col span={8} className="colValue">
<Link className="user-name" to={'/user/profile/' + this.props.curData.uid}>
<img src={'/api/user/avatar?uid=' + this.props.curData.uid} className="user-img" />
{this.props.curData.username}
<Link className="user-name" to={'/user/profile/' + uid}>
<img src={'/api/user/avatar?uid=' + uid} className="user-img" />
{username}
</Link>
</Col>
</Row>
@ -405,15 +407,15 @@ class View extends Component {
<Col span={4} className="colKey">
更新时间
</Col>
<Col span={8}>{formatTime(this.props.curData.up_time)}</Col>
<Col span={8}>{formatTime(up_time)}</Col>
</Row>
{this.props.curData.tag && (
{safeArray(tag) && safeArray(tag).length>0 && (
<Row className="row remark">
<Col span={4} className="colKey">
Tag
</Col>
<Col span={18} className="colValue">
{this.props.curData.tag}
{tag.join(' ,')}
</Col>
</Row>
)}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -105,7 +105,7 @@ class interfaceController extends baseController {
catid: 'number',
switch_notice: 'boolean',
message: minLengthStringField,
tag: 'string'
tag: 'array'
},
addAndUpCommonField
),

View File

@ -94,7 +94,7 @@ class interfaceModel extends baseModel {
field3: String,
api_opened: { type: Boolean, default: false },
index: { type: Number, default: 0 },
tag: String
tag: Array
};
}

View File

@ -8,6 +8,9 @@
<input type="text" class="input js-input" placeholder="搜索" />
<div class="m-search-result js-search-result"></div>
</div></div><nav class="m-header-nav js-nav"><ul class="m-header-items"><li class="item active"><a class="href" href="index.html">教程</a></li><li class="item "><a class="href" href="../devops/index.html">内网部署</a></li></ul></nav><div id="js-nav-btn" class="m-header-btn ui-font-ydoc"></div></header><div class="m-content" id="js-content"><div id="markdown-body" class="m-content-container markdown-body"><h3 id="v1.3.23">v1.3.23</h3>
<ul>
<li>接口tag功能</li>
</ul>
<h4>Bug Fixed</h4>
<ul>
<li>接口path中写入 ?name=xxx bug</li>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1202,7 +1202,7 @@ window.ydoc_plugin_search_json = {
{
"title": "v1.3.23",
"url": "/documents/CHANGELOG.html#v1.3.23",
"content": "v1.3.23Bug Fixed接口path中写入 ?name=xxx bug\n"
"content": "v1.3.23接口tag功能\nBug Fixed接口path中写入 ?name=xxx bug\n"
},
{
"title": "v1.3.22",
@ -1384,7 +1384,7 @@ window.ydoc_plugin_search_json = {
{
"title": "v1.3.23",
"url": "/documents/CHANGELOG.html#v1.3.23",
"content": "v1.3.23Bug Fixed接口path中写入 ?name=xxx bug\n"
"content": "v1.3.23接口tag功能\nBug Fixed接口path中写入 ?name=xxx bug\n"
},
{
"title": "v1.3.22",