fix: 完善接口编辑正在编辑状态离开提示

This commit is contained in:
wenbo.dong 2017-10-12 18:05:35 +08:00
parent c826c747e7
commit 34380c9560
2 changed files with 6 additions and 7 deletions

View File

@ -136,7 +136,6 @@ class Content extends Component {
when={this.state.curtab === 'edit' && this.props.editStatus ? true : false}
message={() => {
// this.showModal();
console.log('e');
return '离开页面会丢失当前编辑的内容,确定要离开吗?';
}}
/>

View File

@ -211,6 +211,8 @@ class InterfaceEditForm extends Component {
req_radio_type: HTTP_METHOD[this.state.method].request_body ? 'req-body' : 'req-query'
})
let that = this, mockPreview, resBodyEditor;
const initReqBody = that.state.req_body_other;
const initResBody = that.state.res_body;
mockEditor({
container: 'req_body_json',
data: that.state.req_body_other,
@ -218,6 +220,7 @@ class InterfaceEditForm extends Component {
that.setState({
req_body_other: d.text
})
EditFormContext.props.changeEditStatus(initReqBody !== d.text);
}
})
@ -231,7 +234,8 @@ class InterfaceEditForm extends Component {
that.setState({
res_body: d.text,
res_body_mock: d.mockText
})
});
EditFormContext.props.changeEditStatus(initResBody !== d.text);
}
})
@ -244,11 +248,7 @@ class InterfaceEditForm extends Component {
let editor = this.editor = new Editor('#desc');
const initEditorHTML = this.state.desc;
editor.customConfig.onchange = function (html) {
if (initEditorHTML === html) {
EditFormContext.props.changeEditStatus(false);
} else {
EditFormContext.props.changeEditStatus(true);
}
EditFormContext.props.changeEditStatus(initEditorHTML !== html);
}
editor.create();
editor.txt.html(this.state.desc)