diff --git a/CHANGELOG.md b/CHANGELOG.md index 56b328e0..6b00ecbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +### v1.3.20 + +#### Bug Fixed +* 修复 ykit 打包代码问题 +* 修复 swagger url 导入选中后再切换其他数据方式时拖拽区域不出现问题 +* 修复 wiki controller 后端报错问题 + + ### v1.3.19 * 增加项目文档记录wiki diff --git a/client/containers/Project/Setting/ProjectData/ProjectData.js b/client/containers/Project/Setting/ProjectData/ProjectData.js index 5339bae3..05bd81f8 100755 --- a/client/containers/Project/Setting/ProjectData/ProjectData.js +++ b/client/containers/Project/Setting/ProjectData/ProjectData.js @@ -191,7 +191,8 @@ class ProjectData extends Component { handleImportType = val => { this.setState({ - curImportType: val + curImportType: val, + isSwaggerUrl: false }); }; diff --git a/common/postmanLib.js b/common/postmanLib.js index 143f7a8e..bc414640 100644 --- a/common/postmanLib.js +++ b/common/postmanLib.js @@ -128,7 +128,7 @@ function checkNameIsExistInArray(name, arr) { function handleCurrDomain(domains, case_env) { let currDomain = _.find(domains, item => item.name === case_env); - + if (!currDomain) { currDomain = domains[0]; } @@ -192,7 +192,7 @@ function sandboxByBrowser(context = {}, script) { `; err.message = `Script: ${message} message: ${err.message}`; - + throw err; } return context; @@ -207,22 +207,22 @@ async function crossRequest(defaultOptions, preScript, afterScript) { get href() { return urlObj.href; }, - set href(val){ - throw new Error('context.href 不能被赋值') + set href(val) { + throw new Error('context.href 不能被赋值'); }, get hostname() { return urlObj.hostname; }, - set hostname(val){ - throw new Error('context.hostname 不能被赋值') + set hostname(val) { + throw new Error('context.hostname 不能被赋值'); }, get caseId() { return options.caseId; }, - set caseId(val){ - throw new Error('context.caseId 不能被赋值') + set caseId(val) { + throw new Error('context.caseId 不能被赋值'); }, method: options.method, @@ -244,7 +244,7 @@ async function crossRequest(defaultOptions, preScript, afterScript) { sha512: utils.sha512, unbase64: utils.unbase64, axios: axios - }) + }); if (preScript) { context = await sandbox(context, preScript); @@ -361,35 +361,31 @@ function handleParams(interfaceData, handleValue, requestParams) { }; // 对 raw 类型的 form 处理 - try{ - - if(interfaceRunData.req_body_type === 'raw'){ - if(headers && headers['Content-Type']){ - if(headers['Content-Type'].indexOf('application/x-www-form-urlencoded')>=0) { + try { + if (interfaceRunData.req_body_type === 'raw') { + if (headers && headers['Content-Type']) { + if (headers['Content-Type'].indexOf('application/x-www-form-urlencoded') >= 0) { interfaceRunData.req_body_type = 'form'; let reqData = json_parse(interfaceRunData.req_body_other); - if(reqData && typeof reqData === 'object'){ + if (reqData && typeof reqData === 'object') { interfaceRunData.req_body_form = []; - Object.keys(reqData).forEach(key=>{ + Object.keys(reqData).forEach(key => { interfaceRunData.req_body_form.push({ name: key, type: 'text', value: JSON.stringify(reqData[key]), - enable:true - }) - }) + enable: true + }); + }); } - - } else if(headers['Content-Type'].indexOf('application/json')>=0) { - interfaceRunData.req_body_type = 'json'; + } else if (headers['Content-Type'].indexOf('application/json') >= 0) { + interfaceRunData.req_body_type = 'json'; } } } - - }catch(e){ - console.log('err',e); + } catch (e) { + console.log('err', e); } - if (HTTP_METHOD[interfaceRunData.method].request_body) { if (interfaceRunData.req_body_type === 'form') { diff --git a/docs/devops/index.md b/docs/devops/index.md index a2512aee..48152310 100755 --- a/docs/devops/index.md +++ b/docs/devops/index.md @@ -148,8 +148,8 @@ node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置 ``` -## 版本通知(v1.3.19+) -在 config.json 添加 `"versionNotify": true` 配置项,就可以开启版本通知功能,默认为 `false`,修改完成后,请重启 yapi 服务器。 +## 版本通知 +(v1.3.19+ 增加)在 config.json 添加 `"versionNotify": true` 配置项,就可以开启版本通知功能,默认为 `false`,修改完成后,请重启 yapi 服务器。 ```json { diff --git a/exts/yapi-plugin-wiki/controller.js b/exts/yapi-plugin-wiki/controller.js index 1d893b4c..1be468bd 100644 --- a/exts/yapi-plugin-wiki/controller.js +++ b/exts/yapi-plugin-wiki/controller.js @@ -111,10 +111,7 @@ class wikiController extends baseController { 'utf8' ); let htmlCss = fs.readFileSync( - path.resolve( - yapi.WEBROOT, - 'node_modules/jsondiffpatch/dist/formatters-styles/html.css' - ), + path.resolve(yapi.WEBROOT, 'node_modules/jsondiffpatch/dist/formatters-styles/html.css'), 'utf8' ); let project = await this.projectModel.getBaseInfo(params.project_id); @@ -176,38 +173,9 @@ class wikiController extends baseController { return ctx.websocket.send('id 参数有误'); } result = await this.Model.get(id); - - switch (message) { - case 'start': - if (result && result.edit_uid === this.getUid()) { - await this.Model.upEditUid(result._id, 0); - } - break; - case 'editor': - let userInst, userinfo, data; - if (result && result.edit_uid !== 0 && result.edit_uid !== this.getUid()) { - userInst = yapi.getInst(userModel); - userinfo = await userInst.findById(result.edit_uid); - data = { - errno: result.edit_uid, - data: { uid: result.edit_uid, username: userinfo.username } - }; - } else { - if (result) { - await this.Model.upEditUid(result._id, this.getUid()); - } - data = { - errno: 0, - data: result - }; - } - ctx.websocket.send(JSON.stringify(data)); - break; - case 'end': - await this.Model.upEditUid(result._id, 0); - break; - default: - break; + let data = await this.websocketMsgMap(message, result); + if(data) { + ctx.websocket.send(JSON.stringify(data)); } }); ctx.websocket.on('close', async () => {}); @@ -215,6 +183,54 @@ class wikiController extends baseController { yapi.commons.log(err, 'error'); } } + + + websocketMsgMap(msg, result) { + const map = { + start: this.startFunc.bind(this), + end: this.endFunc.bind(this), + editor: this.editorFunc.bind(this) + }; + + return map[msg](result); + } + + // socket 开始链接 + async startFunc(result) { + + if (result && result.edit_uid === this.getUid()) { + await this.Model.upEditUid(result._id, 0); + } + } + + // socket 结束链接 + async endFunc(result) { + if(result) { + await this.Model.upEditUid(result._id, 0); + } + } + + // 正在编辑 + async editorFunc(result) { + let userInst, userinfo, data; + if (result && result.edit_uid !== 0 && result.edit_uid !== this.getUid()) { + userInst = yapi.getInst(userModel); + userinfo = await userInst.findById(result.edit_uid); + data = { + errno: result.edit_uid, + data: { uid: result.edit_uid, username: userinfo.username } + }; + } else { + if (result) { + await this.Model.upEditUid(result._id, this.getUid()); + } + data = { + errno: 0, + data: result + }; + } + return data; + } } module.exports = wikiController; diff --git a/package.json b/package.json index 4fd7aecf..e8197eb2 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yapi", - "version": "1.3.19", + "version": "1.3.20", "description": "YAPI", "main": "index.js", "scripts": { diff --git a/static/doc/devops/index.html b/static/doc/devops/index.html index e78aea3b..33b87f4f 100644 --- a/static/doc/devops/index.html +++ b/static/doc/devops/index.html @@ -133,8 +133,8 @@ yapi update -v v1.1.0 //升级到指定版本 } -
在 config.json 添加 "versionNotify": true
配置项,就可以开启版本通知功能,默认为 false
,修改完成后,请重启 yapi 服务器。
(v1.3.19+ 增加)在 config.json 添加 "versionNotify": true
配置项,就可以开启版本通知功能,默认为 false
,修改完成后,请重启 yapi 服务器。
{
"port": "******",
"adminAccount": "*****",
diff --git a/static/doc/search_json.js b/static/doc/search_json.js
index 43051e6a..133393d6 100644
--- a/static/doc/search_json.js
+++ b/static/doc/search_json.js
@@ -1521,9 +1521,9 @@ window.ydoc_plugin_search_json = {
"content": "禁止注册在 config.json 添加 closeRegister:true 配置项,就可以禁止用户注册 yapi 平台,修改完成后,请重启 yapi 服务器。{ \"port\": \"*****\",\n \"closeRegister\":true\n}\n\n"
},
{
- "title": "版本通知(v1.3.19+)",
- "url": "/devops/index.html#版本通知v1.3.19+",
- "content": "版本通知(v1.3.19+)在 config.json 添加 \"versionNotify\": true 配置项,就可以开启版本通知功能,默认为 false,修改完成后,请重启 yapi 服务器。{ \"port\": \"******\",\n \"adminAccount\": \"*****\",\n \"versionNotify\": true\n}\n\n"
+ "title": "版本通知",
+ "url": "/devops/index.html#版本通知",
+ "content": "版本通知(v1.3.19+ 增加)在 config.json 添加 \"versionNotify\": true 配置项,就可以开启版本通知功能,默认为 false,修改完成后,请重启 yapi 服务器。{ \"port\": \"******\",\n \"adminAccount\": \"*****\",\n \"versionNotify\": true\n}\n\n"
}
]
},
@@ -1578,9 +1578,9 @@ window.ydoc_plugin_search_json = {
"content": "禁止注册在 config.json 添加 closeRegister:true 配置项,就可以禁止用户注册 yapi 平台,修改完成后,请重启 yapi 服务器。{ \"port\": \"*****\",\n \"closeRegister\":true\n}\n\n"
},
{
- "title": "版本通知(v1.3.19+)",
- "url": "/devops/index.html#版本通知v1.3.19+",
- "content": "版本通知(v1.3.19+)在 config.json 添加 \"versionNotify\": true 配置项,就可以开启版本通知功能,默认为 false,修改完成后,请重启 yapi 服务器。{ \"port\": \"******\",\n \"adminAccount\": \"*****\",\n \"versionNotify\": true\n}\n\n"
+ "title": "版本通知",
+ "url": "/devops/index.html#版本通知",
+ "content": "版本通知(v1.3.19+ 增加)在 config.json 添加 \"versionNotify\": true 配置项,就可以开启版本通知功能,默认为 false,修改完成后,请重启 yapi 服务器。{ \"port\": \"******\",\n \"adminAccount\": \"*****\",\n \"versionNotify\": true\n}\n\n"
}
]
}
diff --git a/ykit.config.js b/ykit.config.js
index 9f67e0b8..a20cd32d 100755
--- a/ykit.config.js
+++ b/ykit.config.js
@@ -192,6 +192,13 @@ module.exports = {
});
if (this.env == 'prd') {
+ baseConfig.plugins.push(
+ new this.webpack.optimize.UglifyJsPlugin({
+ compress: {
+ warnings: false
+ }
+ })
+ );
baseConfig.plugins.push(assetsPluginInstance);
baseConfig.plugins.push(compressPlugin);
}