diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js b/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js index 23b62ae0..c1dfea9f 100644 --- a/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js +++ b/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js @@ -14,9 +14,9 @@ const TreeNode = Tree.TreeNode; @connect( - + state => { - + return { list: state.inter.list, inter: state.inter.curdata, @@ -174,12 +174,12 @@ class InterfaceMenu extends Component { title: '您确认删除此接口', content: '温馨提示:接口删除后,无法恢复', async onOk() { - + await that.props.deleteInterfaceData(id, that.props.projectId) await that.getList() ref.destroy() that.props.history.push('/project/' + that.props.match.params.id + '/interface/api') - + }, async onCancel() { ref.destroy() @@ -227,8 +227,8 @@ class InterfaceMenu extends Component { const matchParams = this.props.match.params; let menuList = this.state.list; const searchBox =
- - this.changeModal('add_cat_modal_visible', true)} style={{ marginLeft: "16px" }} > + + this.changeModal('add_cat_modal_visible', true)} className="btn-filter" > this.changeModal('change_cat_modal_visible', false)} + onCancel={() => this.changeModal('change_cat_modal_visible', false)} footer={null} > this.changeModal('change_cat_modal_visible', false)} onSubmit={this.handleChangeInterfaceCat} /> @@ -297,7 +297,7 @@ class InterfaceMenu extends Component { // case 'DELETE': color = 'red'; break; // default: color = "yellow"; // } - return this.enterItem(item._id)} onMouseLeave={this.leaveItem} > {item.title} { this.showConfirm(item._id) }} style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }} /> @@ -335,7 +335,7 @@ class InterfaceMenu extends Component { let currentKes = defaultExpandedKeys(); - + if (this.state.filter) { let arr = []; menuList = menuList.filter( (item) => { @@ -343,12 +343,12 @@ class InterfaceMenu extends Component { if (item.name.indexOf(this.state.filter) === -1) { item.list = item.list.filter(inter=>{ if(inter.title.indexOf(this.state.filter) === -1 && inter.path.indexOf(this.state.filter)){ - return false; + return false; } //arr.push('cat_' + inter.catid) interfaceFilter = true; return true; - + }) return interfaceFilter === true } @@ -379,7 +379,7 @@ class InterfaceMenu extends Component {
} - key={'cat_' + item._id} + key={'cat_' + item._id} className={`interface-item-nav ${item.list.length?"":"cat_switch_hidden"}`} > {item.list.map(item_interface_create)} diff --git a/client/containers/Project/Interface/InterfaceList/View.js b/client/containers/Project/Interface/InterfaceList/View.js index d3c0b0bf..d4dea2bd 100644 --- a/client/containers/Project/Interface/InterfaceList/View.js +++ b/client/containers/Project/Interface/InterfaceList/View.js @@ -250,7 +250,7 @@ class View extends Component { if(!methodColor) methodColor = "get"; let res =
- 接口名: + 接口名称: {this.props.curData.title}
@@ -262,7 +262,7 @@ class View extends Component { {this.props.currProject.basepath}{this.props.curData.path}
- 状态: + 状  态: {status[this.props.curData.status]}
diff --git a/client/containers/Project/Interface/interface.scss b/client/containers/Project/Interface/interface.scss index 5b93f045..5ee7b73e 100644 --- a/client/containers/Project/Interface/interface.scss +++ b/client/containers/Project/Interface/interface.scss @@ -42,13 +42,23 @@ height: 40px; line-height: 31px; } - + .ant-input { + width: 100%; + } .interface-filter{ + padding-top:7px; padding-left: 10px; + padding-right: 50px; height:45px; line-height: 32px; - padding-top:7px; - background-color: #efefef + background-color: #efefef; + position: relative; + } + .btn-filter { + position: absolute; + right: 0; + top: 50%; + transform: translateY(-50%); } .interface-list{ .cat_switch_hidden{ @@ -56,7 +66,7 @@ visibility: hidden; } } - + a{ color: #333 @@ -71,7 +81,6 @@ } .interface-item{ display: inline-block; - width: 180px; overflow: hidden; top: 0px; line-height: 100%; @@ -94,7 +103,7 @@ } } } - + .right-content{ margin:3px; min-height: 5rem; diff --git a/static/doc/api.html b/static/doc/api.html index 39101a4c..51555d49 100644 --- a/static/doc/api.html +++ b/static/doc/api.html @@ -899,7 +899,7 @@

源码位置: - ./server/controllers/group.js:290 + ./server/controllers/group.js:303

@@ -971,7 +971,7 @@

源码位置: - ./server/controllers/group.js:330 + ./server/controllers/group.js:343

@@ -3511,7 +3511,7 @@

源码位置: - ./server/controllers/interface.js:168 + ./server/controllers/interface.js:181

@@ -3576,7 +3576,7 @@

源码位置: - ./server/controllers/interface.js:193 + ./server/controllers/interface.js:206

@@ -3641,7 +3641,7 @@

源码位置: - ./server/controllers/interface.js:255 + ./server/controllers/interface.js:268

@@ -3874,7 +3874,7 @@

源码位置: - ./server/controllers/interface.js:427 + ./server/controllers/interface.js:440

@@ -3946,7 +3946,7 @@

源码位置: - ./server/controllers/interface.js:615 + ./server/controllers/interface.js:628

diff --git a/static/doc/index-使用mock功能.html b/static/doc/index-使用mock功能.html index ba442ea5..67a097cf 100644 --- a/static/doc/index-使用mock功能.html +++ b/static/doc/index-使用mock功能.html @@ -144,14 +144,14 @@
mockd地址: http://yapi.corp.qunar.com/mock/29/api/hackathon/login
 

注:项目id可以在项目设置里查看到

定义mock数据示例 #

{
-    "status|0-1": 0, //接口状态
+    "status|0-1": 0, //接口状态
     "message": "请求完成", //消息提示
     "data": {
         "counts":"@integer", //统计数量
-        "totalSubjectType|4-10": [
+        "totalSubjectType|4-10": [
             { 
-              "subjectName|regexp": "大数据|机器学习|工具", //主题名
-              "subjectType|+1": 1 //类型
+              "subjectName|regexp": "大数据|机器学习|工具", //主题名
+              "subjectType|+1": 1 //类型
             }
         ],
         "data":[
@@ -164,8 +164,8 @@
 }
 

yapiMock跟mockjs区别 #

因为yapi基于json定义mock,无法使用mockjs原有的函数功能,正则表达式需要基于rule书写,示例如下:

{
-  "name|regexp": "[a-z0-9_]+?",
-  "type|regexp": "json|text|xml" //枚举数据类型可这样实现
+  "name|regexp": "[a-z0-9_]+?",
+  "type|regexp": "json|text|xml" //枚举数据类型可这样实现
 }
 

如何使用Mock? #

1 在js代码直接请求yapi提供的mock地址(不用担心跨域问题) #

在代码直接请求yapi提供的mock地址,以jQuery为例:

let prefix = 'http://yapi.local.qunar.com:3000/mock/2817'
@@ -196,9 +196,9 @@ $.post2. 数据占位符定义规范(Data Placeholder Definition,DPD)

数据模板定义规范(Data Template Definition,DTD) #

数据模板中的每个属性由 3 部分构成:属性名、生成规则、属性值:

-
// 属性名   name (与生成规则之间用 "|" 隔开)
-// 生成规则 rule(生成规则有7种详见下面的生成规则)
-// 属性值   value(可以含有 "@占位符" 同时也指定了最终值的初始值和类型)
+
// 属性名   name (与生成规则之间用 "|" 隔开)
+// 生成规则 rule(生成规则有7种详见下面的生成规则)
+// 属性值   value(可以含有 "@占位符" 同时也指定了最终值的初始值和类型)
 
 'name|rule': value
 
diff --git a/static/doc/source/app.js b/static/doc/source/app.js
index 2a53b85a..24b1b76c 100644
--- a/static/doc/source/app.js
+++ b/static/doc/source/app.js
@@ -8,7 +8,6 @@ $(document).ready(function() {
     var $versionSelector = $('.version-selector');
     var $versionMask = $('.m-version-mask');
     var isPanelHide = true;
-    var winWidth = $(window).width();
     var h2 = $('.content-right').find('h2');
     var h3 = $('.content-right').find('h3');
     var a = $('.content-left').find('a');
diff --git a/static/doc/static/server/controllers/group.js.html b/static/doc/static/server/controllers/group.js.html
index afde93c7..792a32e1 100644
--- a/static/doc/static/server/controllers/group.js.html
+++ b/static/doc/static/server/controllers/group.js.html
@@ -309,7 +309,20 @@ class groupController extends baseController {
         try {
             var groupInst = yapi.getInst(groupModel);
             let result = await groupInst.list();
-            ctx.body = yapi.commons.resReturn(result);
+            let newResult = [];
+            if(result && result.length > 0){
+                for(let i=0; i< result.length; i++){
+                    result[i] = result[i].toObject();
+                    result[i].role = await this.checkAuth(result[i]._id, 'group', 'edit');
+                    if(result[i].role){
+                        newResult.unshift(result[i]);
+                    }else{
+                        newResult.push(result[i]);
+                    }
+                }
+            }
+          
+            ctx.body = yapi.commons.resReturn(newResult);
         } catch (e) {
             ctx.body = yapi.commons.resReturn(null, 402, e.message);
         }
diff --git a/static/doc/static/server/controllers/interface.js.html b/static/doc/static/server/controllers/interface.js.html
index b6e75131..ab322515 100644
--- a/static/doc/static/server/controllers/interface.js.html
+++ b/static/doc/static/server/controllers/interface.js.html
@@ -103,9 +103,22 @@ class interfaceController extends baseController {
             return ctx.body = yapi.commons.resReturn(null, 400, '接口请求路径不能为空');
         }
 
-        if (!yapi.commons.verifyPath(params.path)) {
+        let http_path = url.parse(params.path, true);
+        params.path = http_path.pathname;
+
+        if (!yapi.commons.verifyPath(http_path.pathname)) {
             return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/');
         }
+        
+        if(!params.req_query){
+            params.req_query = [];
+            Object.keys(http_path.query).forEach((item)=>{
+                params.req_query.push({
+                    name: item
+                })
+            })
+        }
+        
 
         let checkRepeat = await this.Model.checkRepeat(params.project_id, params.path, params.method);