diff --git a/client/common.js b/client/common.js
index 7de153f7..d99ab1ff 100644
--- a/client/common.js
+++ b/client/common.js
@@ -1,5 +1,6 @@
-import React from 'react'
-import moment from 'moment'
+import React from 'react';
+import moment from 'moment';
+import constants from './constants/variable';
exports.formatTime = (timestamp) => {
@@ -86,7 +87,7 @@ exports.handlePath = (path) => {
return path;
}
-// 名称限制 20 字符
+// 名称限制 constants.NAME_LIMIT 字符
exports.nameLengthLimit = (type) => {
// 返回字符串长度,汉字计数为2
const strLength = (str) => {
@@ -101,10 +102,10 @@ exports.nameLengthLimit = (type) => {
required: true,
validator(rule, value, callback) {
const len = value ? strLength(value) : 0;
- if (len > 20) {
- callback('请输入' + type + '名称,长度不超过20字符(中文算作2字符)!');
+ if (len > constants.NAME_LIMIT) {
+ callback('请输入' + type + '名称,长度不超过' + constants.NAME_LIMIT + '字符(中文算作2字符)!');
} else if (len === 0) {
- callback('请输入' + type + '名称,长度不超过20字符(中文算作2字符)!');
+ callback('请输入' + type + '名称,长度不超过' + constants.NAME_LIMIT + '字符(中文算作2字符)!');
} else {
return callback();
}
diff --git a/client/containers/Project/Interface/InterfaceList/mockEditor.js b/client/containers/Project/Interface/InterfaceList/mockEditor.js
index d02c239e..662c6e5f 100644
--- a/client/containers/Project/Interface/InterfaceList/mockEditor.js
+++ b/client/containers/Project/Interface/InterfaceList/mockEditor.js
@@ -65,13 +65,13 @@ function run(options) {
var curData = mockEditor.curData;
try {
curData.text = json;
- var obj = json5.parse(json);
+ var obj = json5.parse(json);
curData.format = true;
curData.jsonData = obj;
curData.mockData = Mock.mock(MockExtra(obj, {}));
curData.mockText = JSON.stringify(curData.mockData, null, " ");
} catch (e) {
-
+
curData.format = e.message;
}
}
@@ -114,7 +114,10 @@ function run(options) {
rhymeCompleter = {
identifierRegexps: [/[@]/],
getCompletions: function (editor, session, pos, prefix, callback) {
- if (prefix.length === 0) { callback(null, []); return }
+ if (prefix.length === 0) {
+ callback(null, []);
+ return;
+ }
callback(null, wordList.map(function (ea) {
return { name: ea.mock, value: ea.mock, score: ea.mock, meta: ea.name }
}));
@@ -153,4 +156,4 @@ function run(options) {
}
})
*/
-module.exports = run;
\ No newline at end of file
+module.exports = run;
diff --git a/server/controllers/follow.js b/server/controllers/follow.js
index ce68c092..30ff2419 100644
--- a/server/controllers/follow.js
+++ b/server/controllers/follow.js
@@ -23,9 +23,10 @@ class followController extends baseController {
*/
async list(ctx) {
- let uid = this.getUid(),
- page = ctx.request.query.page || 1,
- limit = ctx.request.query.limit || 10;
+ let uid = this.getUid();
+ // 关注列表暂时不分页 page & limit 为分页配置
+ // page = ctx.request.query.page || 1,
+ // limit = ctx.request.query.limit || 10;
if (!uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '用户id不能为空');
@@ -49,7 +50,7 @@ class followController extends baseController {
* @method POST
* @category follow
* @foldnumber 10
- * @param {Number} projectid
+ * @param {Number} projectid
* @returns {Object}
* @example /follow/del
*/
diff --git a/server/controllers/interface.js b/server/controllers/interface.js
index c0e7b902..1979071a 100644
--- a/server/controllers/interface.js
+++ b/server/controllers/interface.js
@@ -44,8 +44,8 @@ class interfaceController extends baseController {
* @param {String} [req_body_other] 非form类型的请求参数可保存到此字段
* @param {String} [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
* @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
- * @param {String} [desc] 接口描述
- * @returns {Object}
+ * @param {String} [desc] 接口描述
+ * @returns {Object}
* @example ./api/interface/add.json
*/
async add(ctx) {
@@ -153,7 +153,7 @@ class interfaceController extends baseController {
// this.sendNotice(params.project_id, {
// title: `${username} 新增了接口 ${data.title}`,
// content: `
${username}新增了接口(${data.title})
- //
项目名:${project.name}
+ //
项目名:${project.name}
//
修改用户: "${username}"
//
接口名: ${data.title}
//
接口路径: [${data.method}]${data.path}
`
@@ -173,7 +173,7 @@ class interfaceController extends baseController {
* @category interface
* @foldnumber 10
* @param {Number} id 接口id,不能为空
- * @returns {Object}
+ * @returns {Object}
* @example ./api/interface/get.json
*/
async get(ctx) {
@@ -198,7 +198,7 @@ class interfaceController extends baseController {
* @category interface
* @foldnumber 10
* @param {Number} project_id 项目id,不能为空
- * @returns {Object}
+ * @returns {Object}
* @example ./api/interface/list.json
*/
async list(ctx) {
@@ -275,8 +275,8 @@ class interfaceController extends baseController {
* @param {String} [req_body_other] 非form类型的请求参数可保存到此字段
* @param {String} [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
* @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
- * @param {String} [desc] 接口描述
- * @returns {Object}
+ * @param {String} [desc] 接口描述
+ * @returns {Object}
* @example ./api/interface/up.json
*/
@@ -432,7 +432,7 @@ class interfaceController extends baseController {
* @category interface
* @foldnumber 10
* @param {Number} id 接口id,不能为空
- * @returns {Object}
+ * @returns {Object}
* @example ./api/interface/del.json
*/
@@ -478,7 +478,8 @@ class interfaceController extends baseController {
try {
let id = parseInt(ctx.query.id, 10), result, userInst, userinfo, data;
if (!id) return ctx.websocket.send("id 参数有误");
- result = await this.Model.get(id), userinfo;
+ await this.Model.get(id);
+ result = userinfo;
if (result.edit_uid !== 0 && result.edit_uid !== this.getUid()) {
userInst = yapi.getInst(userModel);
userinfo = await userInst.findById(result.edit_uid);
@@ -603,7 +604,8 @@ class interfaceController extends baseController {
typeid: catData.project_id
});
- let result = await this.catModel.del(id);
+ // no used variable 'result'
+ // let result = await this.catModel.del(id);
let r = await this.Model.delByCatid(id);
return ctx.body = yapi.commons.resReturn(r);
} catch (e) {
@@ -619,7 +621,7 @@ class interfaceController extends baseController {
* @category interface
* @foldnumber 10
* @param {Number} project_id 项目id,不能为空
- * @returns {Object}
+ * @returns {Object}
* @example ./api/interface/getCatMenu
*/
@@ -659,4 +661,4 @@ class interfaceController extends baseController {
}
-module.exports = interfaceController;
\ No newline at end of file
+module.exports = interfaceController;
diff --git a/server/middleware/mockServer.js b/server/middleware/mockServer.js
index 14664ac3..64e03a11 100644
--- a/server/middleware/mockServer.js
+++ b/server/middleware/mockServer.js
@@ -22,8 +22,9 @@ function matchApi(apiPath, apiRule) {
}
module.exports = async (ctx, next) => {
- let hostname = ctx.hostname;
- let config = yapi.WEBCONFIG;
+ // no used variable 'hostname' & 'config'
+ // let hostname = ctx.hostname;
+ // let config = yapi.WEBCONFIG;
let path = ctx.path;
@@ -52,7 +53,7 @@ module.exports = async (ctx, next) => {
return ctx.body = yapi.commons.resReturn(null, 400, '不存在的项目');
}
- let interfaceData, newData, newpath;
+ let interfaceData, newpath;
let interfaceInst = yapi.getInst(interfaceModel);
try {
diff --git a/server/models/interface.js b/server/models/interface.js
index 98341d2a..69314498 100644
--- a/server/models/interface.js
+++ b/server/models/interface.js
@@ -55,7 +55,7 @@ class interfaceModel extends baseModel {
enum: ['json', 'text', 'xml', 'raw']
},
res_body: String
- };
+ };
}
save(data) {
@@ -72,7 +72,7 @@ class interfaceModel extends baseModel {
getBaseinfo(id){
return this.model.findOne({
- _id: id,
+ _id: id
}).select('path method uid title project_id cat_id status').exec()
}
@@ -151,7 +151,7 @@ class interfaceModel extends baseModel {
upEditUid(id, uid){
return this.model.update({
_id: id
- },
+ },
{edit_uid: uid},
{runValidators: true });
}
diff --git a/server/plugin.js b/server/plugin.js
index aeb1ce45..4d3163ad 100644
--- a/server/plugin.js
+++ b/server/plugin.js
@@ -21,7 +21,7 @@ function bindHook(name, listener){
}else{
hooks[name].listener = listener;
}
-
+
}
function emitHook(name){
@@ -29,7 +29,7 @@ function emitHook(name){
if(name in hooks === false){
throw new Error('不存在的hookname');
}
-
+
if(hooks[name] && typeof hooks[name] === 'object'){
if(hooks[name].type === 'single' && typeof hooks[name].listener === 'function'){
return hooks[name].listener.apply(yapi, Array.prototype.slice.call(arguments, 1));
@@ -50,11 +50,11 @@ module.exports = function(){
if(yapi.WEBCONFIG.plugins && Array.isArray(yapi.WEBCONFIG.plugins)){
yapi.WEBCONFIG.plugins.forEach(plugin=>{
if(!yapi.commons.fileExist(yapi.path.join(plugin_path, 'yapi-plugin-' + plugin + '/server.js'))){
- throw new Error(`config.json配置了插件${plugin},但plugins目录没有找到此插件,请安装此插件?`);
+ console.error(`config.json配置了插件${plugin},但plugins目录没有找到此插件,请安装此插件?`);
process.exit();
}
let pluginModule = require(yapi.path.join(plugin_path, 'yapi-plugin-' + plugin + '/server.js'));
pluginModule.apply(yapi)
})
}
-}
\ No newline at end of file
+}
diff --git a/ykit.js b/ykit.js
index 71675071..4f7a3f54 100644
--- a/ykit.js
+++ b/ykit.js
@@ -14,7 +14,7 @@ var compressPlugin = new CompressionPlugin({
algorithm: "gzip",
test: /\.(js|css)$/,
threshold: 10240,
- minRatio: 0.8,
+ minRatio: 0.8
});
function fileExist (filePath){
@@ -50,7 +50,7 @@ function handleCommonsChunk(webpackConfig) {
'moment'
],
- lib2: [
+ lib2: [
'brace',
'mockjs',
'json5'
@@ -122,7 +122,7 @@ module.exports = {
exports: [
'./index.js'
],
- modifyWebpackConfig: function (baseConfig) {
+ modifyWebpackConfig: function (baseConfig) {
var ENV_PARAMS = {};
switch (this.env) {
@@ -194,4 +194,4 @@ module.exports = {
},
hooks: {},
commands: []
-};
\ No newline at end of file
+};