fix: 修复一些bug

This commit is contained in:
gaoxiaolin.gao 2018-01-25 14:32:30 +08:00
parent 74955c3d34
commit c8ec820cb0
7 changed files with 40 additions and 18 deletions

View File

@ -1,9 +1,16 @@
### v1.3.5
#### Feature
* 数据导入同步
#### Bug Fixed
* 修复离开接口编辑页面的 confirm 框有时候会触发两次 & confirm 的 X 按钮无效
* 修复添加集合后测试集合list不更新问题
* 测试集合点击对应接口侧边栏不切换
* 测试集合处,点击删除不成功
* 修改编辑接口后,再回到测试集合处数据不更新问题
### v1.3.4

View File

@ -114,6 +114,7 @@ export default class Run extends Component {
if (!this.checkInterfaceData(data)) {
return null;
}
this.setState({
...this.state,
...data,
@ -138,6 +139,7 @@ export default class Run extends Component {
}
componentWillMount() {
this._crossRequestInterval = initCrossRequest((hasPlugin) => {
this.setState({
hasPlugin: hasPlugin
@ -153,8 +155,11 @@ export default class Run extends Component {
componentWillReceiveProps(nextProps) {
if (this.checkInterfaceData(nextProps.data) && this.checkInterfaceData(this.props.data)) {
if (nextProps.data._id !== this.props.data._id) {
this.initState(nextProps.data)
}else if(nextProps.data.interface_up_time !== this.props.data.interface_up_time){
this.initState(nextProps.data)
}
if (nextProps.data.env !== this.props.data.env) {
this.initEnvState(nextProps.data.env)

View File

@ -65,9 +65,9 @@ class Interface extends Component {
constructor(props) {
super(props)
this.state = {
curkey: this.props.match.params.action === 'api' ? 'api' : 'colOrCase'
}
// this.state = {
// curkey: this.props.match.params.action === 'api' ? 'api' : 'colOrCase'
// }
}
onChange = (action) => {
@ -76,9 +76,7 @@ class Interface extends Component {
action = this.props.isShowCol ? 'col' : 'case';
}
this.props.history.push('/project/' + params.id + '/interface/' + action)
this.setState({
curkey: action === 'api' ? 'api' : 'colOrCase'
})
}
componentWillMount(){
this.props.setColData({
@ -87,9 +85,10 @@ class Interface extends Component {
// this.props.getProject(this.props.match.params.id)
}
render() {
//const { action } = this.props.match.params;
const activeKey = this.state.curkey;
// console.log(matchPath(this.props.location.pathname, contentRouter));
const { action } = this.props.match.params;
// const activeKey = this.state.curkey;
const activeKey = action === 'api' ? 'api' : 'colOrCase'
return (
<Layout style={{minHeight: 'calc(100vh - 156px)', marginLeft: '24px', marginTop: '24px'}}>
<Sider style={{ height: '100%' }} width={300}>

View File

@ -9,7 +9,7 @@ import { fetchInterfaceColList, setColData, fetchCaseData, fetchCaseList } from
import { Postman } from '../../../../components'
import './InterfaceCaseContent.scss'
@connect(
state => {
return {
@ -68,6 +68,7 @@ export default class InterfaceCaseContent extends Component {
}
async componentWillMount() {
const result = await this.props.fetchInterfaceColList(this.props.match.params.id)
let { currCaseId } = this.props;
const params = this.props.match.params;
@ -85,13 +86,16 @@ export default class InterfaceCaseContent extends Component {
const newCaseId = nextProps.match.params.actionId
const { interfaceColList } = nextProps;
let currColId = this.getColId(interfaceColList, newCaseId);
if (oldCaseId !== newCaseId) {
await this.props.fetchCaseData(newCaseId);
this.props.setColData({ currCaseId: +newCaseId, currColId, isShowCol: false })
this.setState({ editCasename: this.props.currCase.casename })
this.setState({ editCasename: nextProps.currCase.casename })
}
}
savePostmanRef = (postman) => {
this.postman = postman;
}
@ -117,7 +121,7 @@ export default class InterfaceCaseContent extends Component {
let params = {
id,
casename,
case_env,
case_env,
req_params,
req_query,
req_headers,
@ -132,7 +136,7 @@ export default class InterfaceCaseContent extends Component {
const res = await axios.post('/api/col/up_case', params);
if (this.props.currCase.casename !== casename) {
this.props.fetchInterfaceColList(this.props.match.params.id);
}
if (res.data.errcode) {
@ -164,7 +168,7 @@ export default class InterfaceCaseContent extends Component {
pre_script: currProject.pre_script,
after_script: currProject.after_script
}, { _id: currCase._id });
return (
<div style={{ padding: '6px 0' }} className="case-content">
<div className="case-title">
@ -180,7 +184,7 @@ export default class InterfaceCaseContent extends Component {
</span>
</div>
<div>
{Object.keys(currCase).length > 0 &&
{Object.keys(currCase).length > 0 &&
<Postman data={data} type="case" saveTip="更新保存修改" save={this.updateCase} ref={this.savePostmanRef} />
}
</div>

View File

@ -96,7 +96,14 @@ export default class InterfaceColMenu extends Component {
componentWillMount() {
this.getList()
}
componentWillReceiveProps(nextProps) {
if (this.props.interfaceColList !== nextProps.interfaceColList) {
this.setState({
list: nextProps.interfaceColList
})
}
}
async getList() {
@ -235,12 +242,12 @@ export default class InterfaceColMenu extends Component {
const res = await axios.get('/api/col/del_case?caseid=' + caseId)
if (!res.data.errcode) {
message.success('删除用例成功');
that.getList()
// 如果删除当前选中 case切换路由到集合
if (+caseId === +that.props.currCaseId) {
that.props.history.push('/project/' + params.id + '/interface/col/')
} else {
// that.props.fetchInterfaceColList(that.props.match.params.id);
that.getList()
that.props.setColData({ isRander: true })
}
} else {

View File

@ -148,7 +148,7 @@ class InterfaceEditForm extends Component {
handleSubmit = (e) => {
e.preventDefault();
this.setState({
this.setState({
submitStatus: true
})
try {

View File

@ -579,7 +579,7 @@ class interfaceColController extends baseController {
result.req_body_form = this.handleParamsValue(data.req_body_form, result.req_body_form)
result.req_query = this.handleParamsValue(data.req_query, result.req_query)
result.req_params = this.handleParamsValue(data.req_params, result.req_params)
result.interface_up_time = data.up_time;
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 400, e.message)