fix: 接口编辑白屏问题

This commit is contained in:
suxiaoxin 2018-04-28 18:24:05 +08:00
parent 18d220f738
commit 5cd010f6a0
4 changed files with 35 additions and 25 deletions

View File

@ -68,9 +68,20 @@ class InterfaceEdit extends Component {
componentDidMount() {
let domain = location.hostname + (location.port !== "" ? ":" + location.port : "");
let s;
let s, initData = false;
//因后端 node 仅支持 ws 暂不支持 wss
let wsProtocol = location.protocol === 'https' ? 'ws' : 'ws';
setTimeout(()=>{
if(initData === false){
this.setState({
curdata: this.props.curdata,
status: 1
})
initData = true;
}
}, 3000)
try {
s = new WebSocket(wsProtocol + '://' + domain + '/api/interface/solve_conflict?id=' + this.props.match.params.actionId);
s.onopen = () => {
@ -78,6 +89,7 @@ class InterfaceEdit extends Component {
}
s.onmessage = (e) => {
initData = true;
let result = JSON.parse(e.data);
if (result.errno === 0) {
this.setState({
@ -131,6 +143,9 @@ class InterfaceEdit extends Component {
</div>
:
null}
{
this.state.status === 0 && '正在加载,请耐心等待...'
}
</div>
}

View File

@ -1,6 +1,6 @@
{
"name": "yapi",
"version": "1.3.13",
"version": "1.3.14",
"description": "YAPI",
"main": "index.js",
"scripts": {

View File

@ -30,14 +30,9 @@ class baseController {
'/api/user/avatar',
'/api/user/login_by_ldap'
];
//let openApiRouter = /^\/api\/open\/.*/
if (ignoreRouter.indexOf(ctx.path) > -1) {
this.$auth = true;
}
// else if(openApiRouter.test(ctx.path)){
// this.$auth = true;
// }
else {
}else {
await this.checkLogin(ctx);
}
@ -49,15 +44,16 @@ class baseController {
'/api/interface/up',
'/api/interface/add_cat'
]
let token = ctx.query.token || ctx.request.body.token;
let params = Object.assign({}, ctx.query, ctx.request.body)
let token = params.token ;
if(token && openApiRouter.indexOf(ctx.path) > -1){
if(this.$auth){
ctx.params.project_id = await this.getProjectIdByToken(token)
this.$tokenAuth = true;
}
if(!token){
return
return this.$tokenAuth = true;
}
let checkId = await this.getProjectIdByToken(token);
let projectData = await this.projectModel.get(checkId);
if(projectData) {
@ -72,7 +68,6 @@ class baseController {
this.$auth = true
};
}
}
async getProjectIdByToken(token){

View File

@ -425,18 +425,18 @@ exports.createAction = (
ctx.request.body,
ctx.params
);
// let validResult = yapi.commons.validateParams(
// inst.schemaMap[action],
// ctx.params
// );
let validResult = yapi.commons.validateParams(
inst.schemaMap[action],
ctx.params
);
// if (!validResult.valid) {
// return (ctx.body = yapi.commons.resReturn(
// null,
// 400,
// validResult.message
// ));
// }
if (!validResult.valid) {
return (ctx.body = yapi.commons.resReturn(
null,
400,
validResult.message
));
}
}
if (inst.$auth === true) {
await inst[action].call(inst, ctx);