mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
feat: add websocket
This commit is contained in:
parent
22b59964b2
commit
e0e364c4f0
@ -61,27 +61,27 @@ class InterfaceEdit extends Component {
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
// let domain = location.hostname + (location.port !== "" ? ":" + location.port : "");
|
||||
// let s = new WebSocket('ws://' + domain + '/api/interface/solve_conflict?id=' + this.props.match.params.actionId);
|
||||
// s.onopen = () => {
|
||||
// this.WebSocket = s;
|
||||
// }
|
||||
let domain = location.hostname + (location.port !== "" ? ":" + location.port : "");
|
||||
let s = new WebSocket('ws://' + domain + '/api/interface/solve_conflict?id=' + this.props.match.params.actionId);
|
||||
s.onopen = () => {
|
||||
this.WebSocket = s;
|
||||
}
|
||||
|
||||
// s.onmessage = (e) => {
|
||||
// let result = JSON.parse(e.data);
|
||||
// if (result.errno === 0) {
|
||||
// this.setState({
|
||||
// curdata: result.data,
|
||||
// status: 1
|
||||
// })
|
||||
// } else {
|
||||
// this.setState({
|
||||
// curdata: result.data,
|
||||
// status: 2
|
||||
// })
|
||||
// }
|
||||
s.onmessage = (e) => {
|
||||
let result = JSON.parse(e.data);
|
||||
if (result.errno === 0) {
|
||||
this.setState({
|
||||
curdata: result.data,
|
||||
status: 1
|
||||
})
|
||||
} else {
|
||||
this.setState({
|
||||
curdata: result.data,
|
||||
status: 2
|
||||
})
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user