mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-27 05:30:14 +08:00
fix: 完善接口编辑正在编辑状态离开提示
This commit is contained in:
parent
c826c747e7
commit
34380c9560
@ -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 '离开页面会丢失当前编辑的内容,确定要离开吗?';
|
||||
}}
|
||||
/>
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user