fix: col content request url path bug

This commit is contained in:
suxiaoxin 2017-10-16 15:21:15 +08:00
parent 44173d8add
commit 894c971288
2 changed files with 43 additions and 27 deletions

View File

@ -151,6 +151,7 @@ class InterfaceColContent extends Component {
status = 'invalid'
}
} catch (e) {
console.error(e);
status = 'error';
result = e;
}
@ -174,12 +175,22 @@ class InterfaceColContent extends Component {
interfaceData.req_params.forEach(item => {
path = path.replace(`:${item.name}`, item.value || `:${item.name}`);
});
const domains = currProject.env.concat();
const urlObj = URL.parse(domains.find(item => item.name === case_env).domain);
const domains = currProject.env.concat();
let currDomain = domains.find(item => item.name === case_env);
if(!currDomain){
currDomain = domains[0];
}
const urlObj = URL.parse(currDomain.domain);
if(urlObj.pathname){
if(urlObj.pathname[urlObj.pathname.length - 1] !== '/'){
urlObj.pathname += '/'
}
}
const href = URL.format({
protocol: urlObj.protocol || 'http',
host: urlObj.host,
pathname: urlObj.pathname ? URL.resolve(urlObj.pathname, path) : path,
pathname: urlObj.pathname ? URL.resolve(urlObj.pathname, '.' + path) : path,
query: this.getQueryObj(interfaceData.req_query)
});

View File

@ -69,34 +69,39 @@ class InterfaceEdit extends Component {
curdata: this.props.curdata,
status: 1
})
let s;
//因后端 node 仅支持 ws 暂不支持 wss
let wsProtocol = location.protocol === 'https' ? 'ws' : 'ws';
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
})
try{
s = new WebSocket( wsProtocol + '://' + 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.onerror = () => {
console.error('websocket connect failed.')
}
}catch(e){
console.error(e);
}
s.onerror = () => {
console.error('websocket connect failed.')
}
}
render() {