fix: 修改冲突

This commit is contained in:
gaoxiaolin.gao 2018-07-18 19:30:05 +08:00
commit ca59016279
9 changed files with 102 additions and 74 deletions

View File

@ -1,3 +1,11 @@
### v1.3.20
#### Bug Fixed
* 修复 ykit 打包代码问题
* 修复 swagger url 导入选中后再切换其他数据方式时拖拽区域不出现问题
* 修复 wiki controller 后端报错问题
### v1.3.19
* 增加项目文档记录wiki

View File

@ -191,7 +191,8 @@ class ProjectData extends Component {
handleImportType = val => {
this.setState({
curImportType: val
curImportType: val,
isSwaggerUrl: false
});
};

View File

@ -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') {

View File

@ -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
{

View File

@ -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;

View File

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

View File

@ -133,8 +133,8 @@ yapi update -v v1.1.0 //升级到指定版本
<span class="token punctuation">}</span>
</code></pre>
<h2 id="版本通知v1.3.19+">版本通知(v1.3.19+)</h2>
<p>在 config.json 添加 <code>&quot;versionNotify&quot;: true</code> 配置项,就可以开启版本通知功能,默认为 <code>false</code>,修改完成后,请重启 yapi 服务器。</p>
<h2 id="版本通知">版本通知</h2>
<p>v1.3.19+ 增加)在 config.json 添加 <code>&quot;versionNotify&quot;: true</code> 配置项,就可以开启版本通知功能,默认为 <code>false</code>,修改完成后,请重启 yapi 服务器。</p>
<pre><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"port"</span><span class="token operator">:</span> <span class="token string">"******"</span><span class="token punctuation">,</span>
<span class="token property">"adminAccount"</span><span class="token operator">:</span> <span class="token string">"*****"</span><span class="token punctuation">,</span>

View File

@ -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"
}
]
}

View File

@ -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);
}