mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
Merge branch 'dev' of http://gitlab.corp.qunar.com/mfe/yapi into dev
This commit is contained in:
commit
890fdd44f8
@ -1,7 +1,7 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { Button, Input, Select, Card, Alert } from 'antd'
|
import { Button, Input, Select, Card, Alert, Spin } 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';
|
||||||
@ -111,7 +111,8 @@ export default class InterfaceTest extends Component {
|
|||||||
params,
|
params,
|
||||||
paramsNotJson,
|
paramsNotJson,
|
||||||
headers,
|
headers,
|
||||||
currDomain: domains.prd
|
currDomain: domains.prd,
|
||||||
|
loading: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +129,8 @@ export default class InterfaceTest extends Component {
|
|||||||
query
|
query
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setState({ loading: true })
|
||||||
|
|
||||||
crossRequest({
|
crossRequest({
|
||||||
url: href,
|
url: href,
|
||||||
method,
|
method,
|
||||||
@ -135,7 +138,18 @@ export default class InterfaceTest extends Component {
|
|||||||
data: params,
|
data: params,
|
||||||
success: (res, header) => {
|
success: (res, header) => {
|
||||||
console.log(header)
|
console.log(header)
|
||||||
|
try {
|
||||||
|
res = JSON.parse(res);
|
||||||
|
} catch (e) {
|
||||||
|
null;
|
||||||
|
}
|
||||||
this.setState({res})
|
this.setState({res})
|
||||||
|
this.setState({ loading: false })
|
||||||
|
},
|
||||||
|
error: (err, header) => {
|
||||||
|
console.log(header)
|
||||||
|
this.setState({res: err || '请求失败'})
|
||||||
|
this.setState({ loading: false })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -219,7 +233,12 @@ export default class InterfaceTest extends Component {
|
|||||||
</Select>
|
</Select>
|
||||||
<Input value={pathname+search} disabled style={{display: 'inline-block', width: 300}} />
|
<Input value={pathname+search} disabled style={{display: 'inline-block', width: 300}} />
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
<Button onClick={this.testInterface} type="primary" style={{marginLeft: 10}}>发送</Button>
|
<Button
|
||||||
|
onClick={this.testInterface}
|
||||||
|
type="primary"
|
||||||
|
style={{marginLeft: 10}}
|
||||||
|
loading={this.state.loading}
|
||||||
|
>发送</Button>
|
||||||
</div>
|
</div>
|
||||||
<Card title="HEADERS" noHovering style={{marginTop: 10}} className={Object.keys(headers).length ? '' : 'hidden'}>
|
<Card title="HEADERS" noHovering style={{marginTop: 10}} className={Object.keys(headers).length ? '' : 'hidden'}>
|
||||||
<div className="req-row headers">
|
<div className="req-row headers">
|
||||||
@ -272,15 +291,17 @@ export default class InterfaceTest extends Component {
|
|||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
<Card title="返回结果" noHovering style={{marginTop: 10}}>
|
<Card title="返回结果" noHovering style={{marginTop: 10}}>
|
||||||
|
<Spin spinning={this.state.loading}>
|
||||||
<div className="res-part">
|
<div className="res-part">
|
||||||
<div>
|
<div>
|
||||||
<TextArea
|
<TextArea
|
||||||
value={this.state.res ? JSON.stringify(this.state.res, 2) : ''}
|
value={typeof this.state.res === 'object' ? JSON.stringify(this.state.res, null, 2) : this.state.res.toString()}
|
||||||
style={{margin: 10}}
|
style={{margin: 10}}
|
||||||
autosize={{ minRows: 2, maxRows: 6 }}
|
autosize={{ minRows: 2, maxRows: 6 }}
|
||||||
></TextArea>
|
></TextArea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</Spin>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -19,8 +19,6 @@ const deleteConfirm = (id, props) => {
|
|||||||
const { delProject, currGroup, fetchProjectList } = props;
|
const { delProject, currGroup, fetchProjectList } = props;
|
||||||
const handle = () => {
|
const handle = () => {
|
||||||
delProject(id).then((res) => {
|
delProject(id).then((res) => {
|
||||||
console.log(res);
|
|
||||||
console.log(fetchProjectList, currGroup._id);
|
|
||||||
if (res.payload.data.errcode == 0) {
|
if (res.payload.data.errcode == 0) {
|
||||||
message.success('删除成功!')
|
message.success('删除成功!')
|
||||||
fetchProjectList(currGroup._id).then((res) => {
|
fetchProjectList(currGroup._id).then((res) => {
|
||||||
@ -43,6 +41,13 @@ const getColumns = (data, props) => {
|
|||||||
render: (text, record) => {
|
render: (text, record) => {
|
||||||
return <Link to={`/Interface/${record._id}`}>{text}</Link>
|
return <Link to={`/Interface/${record._id}`}>{text}</Link>
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
title: 'Mock链接',
|
||||||
|
key: 'domain',
|
||||||
|
render: (item) => {
|
||||||
|
return 'http://'+ item.prd_host + item.basepath;
|
||||||
|
}
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
title: '创建人',
|
title: '创建人',
|
||||||
dataIndex: 'owner',
|
dataIndex: 'owner',
|
||||||
|
@ -26,7 +26,8 @@ export default (state = initialState, action) => {
|
|||||||
isLogin: (action.payload.data.errcode == 0),
|
isLogin: (action.payload.data.errcode == 0),
|
||||||
loginState: (action.payload.data.errcode == 0)?MEMBER_STATUS:GUEST_STATUS,
|
loginState: (action.payload.data.errcode == 0)?MEMBER_STATUS:GUEST_STATUS,
|
||||||
userName: action.payload.data.data ? action.payload.data.data.username : null,
|
userName: action.payload.data.data ? action.payload.data.data.username : null,
|
||||||
uid: action.payload.data.data ? action.payload.data.data._id : null
|
uid: action.payload.data.data ? action.payload.data.data._id : null,
|
||||||
|
server_ip: action.payload.data.data.server_ip
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case LOGIN: {
|
case LOGIN: {
|
||||||
@ -36,7 +37,8 @@ export default (state = initialState, action) => {
|
|||||||
isLogin: true,
|
isLogin: true,
|
||||||
loginState: MEMBER_STATUS,
|
loginState: MEMBER_STATUS,
|
||||||
uid: action.payload.data.data.uid,
|
uid: action.payload.data.data.uid,
|
||||||
userName: action.payload.data.data.username
|
userName: action.payload.data.data.username,
|
||||||
|
server_ip: action.payload.data.data.server_ip
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return state;
|
return state;
|
||||||
|
@ -26,7 +26,8 @@ export default (state = initialState, action) => {
|
|||||||
isLogin: (action.payload.data.errcode == 0),
|
isLogin: (action.payload.data.errcode == 0),
|
||||||
loginState: (action.payload.data.errcode == 0)?MEMBER_STATUS:GUEST_STATUS,
|
loginState: (action.payload.data.errcode == 0)?MEMBER_STATUS:GUEST_STATUS,
|
||||||
userName: action.payload.data.data ? action.payload.data.data.username : null,
|
userName: action.payload.data.data ? action.payload.data.data.username : null,
|
||||||
uid: action.payload.data.data ? action.payload.data.data._id : null
|
uid: action.payload.data.data ? action.payload.data.data._id : null,
|
||||||
|
server_ip: action.payload.data.data.server_ip
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case LOGIN: {
|
case LOGIN: {
|
||||||
@ -36,7 +37,8 @@ export default (state = initialState, action) => {
|
|||||||
isLogin: true,
|
isLogin: true,
|
||||||
loginState: MEMBER_STATUS,
|
loginState: MEMBER_STATUS,
|
||||||
uid: action.payload.data.data.uid,
|
uid: action.payload.data.data.uid,
|
||||||
userName: action.payload.data.data.username
|
userName: action.payload.data.data.username,
|
||||||
|
server_ip: action.payload.data.data.server_ip
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return state;
|
return state;
|
||||||
|
@ -60,7 +60,9 @@ class baseController {
|
|||||||
|
|
||||||
async getLoginStatus(ctx) {
|
async getLoginStatus(ctx) {
|
||||||
if (await this.checkLogin(ctx) === true) {
|
if (await this.checkLogin(ctx) === true) {
|
||||||
return ctx.body = yapi.commons.resReturn(yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time']));
|
let result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time']);
|
||||||
|
result.server_ip = yapi.WEBCONFIG.server_ip;
|
||||||
|
return ctx.body = yapi.commons.resReturn(result);
|
||||||
}
|
}
|
||||||
return ctx.body = yapi.commons.resReturn(null, 300, 'Please login.');
|
return ctx.body = yapi.commons.resReturn(null, 300, 'Please login.');
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,8 @@ class userController extends baseController {
|
|||||||
uid: result._id,
|
uid: result._id,
|
||||||
email: result.email,
|
email: result.email,
|
||||||
add_time: result.add_time,
|
add_time: result.add_time,
|
||||||
up_time: result.up_time
|
up_time: result.up_time,
|
||||||
|
server_ip: yapi.WEBCONFIG.server_ip
|
||||||
|
|
||||||
}, 0, 'logout success...');
|
}, 0, 'logout success...');
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,6 +154,7 @@ var baseController = function () {
|
|||||||
key: 'getLoginStatus',
|
key: 'getLoginStatus',
|
||||||
value: function () {
|
value: function () {
|
||||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||||
|
var result;
|
||||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (_context3.prev = _context3.next) {
|
switch (_context3.prev = _context3.next) {
|
||||||
@ -165,16 +166,19 @@ var baseController = function () {
|
|||||||
_context3.t0 = _context3.sent;
|
_context3.t0 = _context3.sent;
|
||||||
|
|
||||||
if (!(_context3.t0 === true)) {
|
if (!(_context3.t0 === true)) {
|
||||||
_context3.next = 5;
|
_context3.next = 7;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(_yapi2.default.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time'])));
|
result = _yapi2.default.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time']);
|
||||||
|
|
||||||
case 5:
|
result.server_ip = _yapi2.default.WEBCONFIG.server_ip;
|
||||||
|
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result));
|
||||||
|
|
||||||
|
case 7:
|
||||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 300, 'Please login.'));
|
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 300, 'Please login.'));
|
||||||
|
|
||||||
case 6:
|
case 8:
|
||||||
case 'end':
|
case 'end':
|
||||||
return _context3.stop();
|
return _context3.stop();
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,8 @@ var userController = function (_baseController) {
|
|||||||
uid: result._id,
|
uid: result._id,
|
||||||
email: result.email,
|
email: result.email,
|
||||||
add_time: result.add_time,
|
add_time: result.add_time,
|
||||||
up_time: result.up_time
|
up_time: result.up_time,
|
||||||
|
server_ip: _yapi2.default.WEBCONFIG.server_ip
|
||||||
|
|
||||||
}, 0, 'logout success...'));
|
}, 0, 'logout success...'));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user