Skip to content

Commit 25adf5f

Browse files
authored
Merge pull request YMFE#1 from YMFE/master
test
2 parents 9481694 + e2dfc78 commit 25adf5f

28 files changed

Lines changed: 73 additions & 425 deletions

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
### v1.4.1
1+
### v1.4.2
2+
* 优化数据导入对 headers 处理,如果 requestType 是 json,自动增加header "content-type/json"
3+
* fix: 修改了测试集合有多个项目接口时,切换执行环境相互覆盖不生效的问题 #692
4+
* fix: mongoose warning 'Error: (node:3819) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead'
5+
* opti: 去掉没必要的redux-thunk
6+
* 接口更新没有变化时,不记录日志,避免cron多次导入swagger的接口时,导致动态里展示一大堆的无意义日志
27

8+
### v1.4.1
39

410
* 支持任何人都可以添加分组,只有管理员才能修改项目是否公开
511
* 支持 mongodb 集群

client/containers/Home/Home.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Link } from 'react-router-dom';
55
import { Row, Col, Button, Icon, Card } from 'antd';
66
import PropTypes from 'prop-types';
77
import { withRouter } from 'react-router';
8-
import { getImgPath } from '../../common.js';
98
import LogoSVG from '../../components/LogoSVG/index.js';
109
import { changeMenuItem } from '../../reducer/modules/menu';
1110
const plugin = require('client/plugin.js');
@@ -61,7 +60,7 @@ const HomeGuest = () => (
6160
</Col>
6261
<Col lg={15} xs={0} className="col-img">
6362
<div className="img-container">
64-
<img className="img" src={getImgPath('/image/demo-img', 'jpg')} />
63+
6564
</div>
6665
</Col>
6766
</Row>

client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ class InterfaceColContent extends Component {
179179
return item._id === project_id;
180180
});
181181

182-
// let env = this.props.currProject.env; console.log('env', case_env);
183182
let currDomain = handleCurrDomain(envItem && envItem.env, case_env);
184183
let header = currDomain.header;
185-
// console.log('header', header)
186184
header.forEach(item => {
187185
if (!checkNameIsExistInArray(item.name, req_header)) {
188186
// item.abled = true;
@@ -196,22 +194,21 @@ class InterfaceColContent extends Component {
196194
return req_header;
197195
};
198196

199-
handleColdata = (rows, currColEnvObj=null) => {
197+
handleColdata = (rows, currColEnvObj = {}) => {
200198
let that = this;
201199
let newRows = produce(rows, draftRows => {
202200
draftRows.map(item => {
203201
item.id = item._id;
204202
item._test_status = item.test_status;
205-
if(currColEnvObj[item.project_id]!=null){
203+
if(currColEnvObj[item.project_id]){
206204
item.case_env =currColEnvObj[item.project_id];
207205
}else{
208-
item.case_env=undefined;
206+
delete item.case_env;
209207
}
210208
item.req_headers = that.handleReqHeader(item.project_id, item.req_headers, item.case_env);
211209
return item;
212210
});
213211
});
214-
console.log(newRows)
215212
this.setState({ rows: newRows });
216213
};
217214

@@ -236,7 +233,6 @@ class InterfaceColContent extends Component {
236233
newRows = [].concat([], rows);
237234
newRows[i] = curitem;
238235
this.setState({ rows: newRows });
239-
// console.log('newRows', newRows);
240236
let status = 'error',
241237
result;
242238
try {
@@ -543,7 +539,6 @@ class InterfaceColContent extends Component {
543539
};
544540

545541
render() {
546-
// console.log('rows',this.props.currProject);
547542
const currProjectId = this.props.currProject._id;
548543
const columns = [
549544
{

client/reducer/create.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { createStore as _createStore, applyMiddleware } from 'redux';
2-
import thunkMiddleware from 'redux-thunk';
32
import promiseMiddleware from 'redux-promise';
43
import messageMiddleware from './middleware/messageMiddleware';
54
import reducer from './modules/reducer';
65

76
export default function createStore(initialState = {}) {
8-
const middleware = [thunkMiddleware, promiseMiddleware, messageMiddleware];
7+
const middleware = [promiseMiddleware, messageMiddleware];
98

109
let finalCreateStore;
1110
//if (process.env.NODE_ENV === 'production') {

client/reducer/modules/user.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,9 @@ export default (state = initialState, action) => {
132132

133133
// Action Creators
134134
export function checkLoginState() {
135-
return dispatch => {
136-
axios.get('/api/user/status').then(res => {
137-
dispatch({
138-
type: GET_LOGIN_STATE,
139-
payload: res
140-
});
141-
});
135+
return {
136+
type: GET_LOGIN_STATE,
137+
payload: axios.get('/api/user/status')
142138
};
143139
}
144140

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yapi-vendor",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "YAPI",
55
"main": "server/app.js",
66
"scripts": {
@@ -136,7 +136,6 @@
136136
"redux-devtools-dock-monitor": "^1.1.2",
137137
"redux-devtools-log-monitor": "^1.3.0",
138138
"redux-promise": "^0.5.3",
139-
"redux-thunk": "^2.2.0",
140139
"rewire": "^2.5.2",
141140
"sass-loader": "^7.0.3",
142141
"string-replace-webpack-plugin": "^0.1.3",

server/controllers/interface.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,49 @@ const path = require('path');
1919
// const annotatedCss = require("jsondiffpatch/public/formatters-styles/annotated.css");
2020
// const htmlCss = require("jsondiffpatch/public/formatters-styles/html.css");
2121

22+
23+
function handleHeaders(values){
24+
let isfile = false,
25+
isHavaContentType = false;
26+
if (values.req_body_type === 'form') {
27+
values.req_body_form.forEach(item => {
28+
if (item.type === 'file') {
29+
isfile = true;
30+
}
31+
});
32+
33+
values.req_headers.map(item => {
34+
if (item.name === 'Content-Type') {
35+
item.value = isfile ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
36+
isHavaContentType = true;
37+
}
38+
});
39+
if (isHavaContentType === false) {
40+
values.req_headers.unshift({
41+
name: 'Content-Type',
42+
value: isfile ? 'multipart/form-data' : 'application/x-www-form-urlencoded'
43+
});
44+
}
45+
} else if (values.req_body_type === 'json') {
46+
values.req_headers
47+
? values.req_headers.map(item => {
48+
if (item.name === 'Content-Type') {
49+
item.value = 'application/json';
50+
isHavaContentType = true;
51+
}
52+
})
53+
: [];
54+
if (isHavaContentType === false) {
55+
values.req_headers = values.req_headers || [];
56+
values.req_headers.unshift({
57+
name: 'Content-Type',
58+
value: 'application/json'
59+
});
60+
}
61+
}
62+
}
63+
64+
2265
class interfaceController extends baseController {
2366
constructor(ctx) {
2467
super(ctx);
@@ -183,6 +226,8 @@ class interfaceController extends baseController {
183226
));
184227
}
185228

229+
handleHeaders(params)
230+
186231
params.query_path = {};
187232
params.query_path.path = http_path.pathname;
188233
params.query_path.params = [];
@@ -550,6 +595,8 @@ class interfaceController extends baseController {
550595
// params.res_body_is_json_schema = _.isUndefined (params.res_body_is_json_schema) ? true : params.res_body_is_json_schema;
551596
// params.req_body_is_json_schema = _.isUndefined(params.req_body_is_json_schema) ? true : params.req_body_is_json_schema;
552597

598+
handleHeaders(params)
599+
553600
let interfaceData = await this.Model.get(id);
554601
if (!interfaceData) {
555602
return (ctx.body = yapi.commons.resReturn(null, 400, '不存在的接口'));
@@ -628,6 +675,10 @@ class interfaceController extends baseController {
628675
};
629676

630677
this.catModel.get(interfaceData.catid).then(cate => {
678+
let diffView2 = showDiffMsg(jsondiffpatch, formattersHtml, logData);
679+
if (diffView2.length <= 0) {
680+
return; // 没有变化时,不写日志
681+
}
631682
yapi.commons.saveLog({
632683
content: `<a href="/user/profile/${this.getUid()}">${username}</a>
633684
更新了分类 <a href="/project/${cate.project_id}/interface/api/cat_${

server/utils/db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function connect(callback) {
1616
mongoose.Promise = global.Promise;
1717

1818
let config = yapi.WEBCONFIG;
19-
let options = {useNewUrlParser: true };
19+
let options = {useNewUrlParser: true, useCreateIndex: true};
2020

2121
if (config.db.user) {
2222
options.user = config.db.user;

static/prd/assets.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)