dubbo文档操作接口和页面

This commit is contained in:
暮光:城中城
2019-02-14 22:38:18 +08:00
parent e42ad1b3eb
commit 6c936d46b4
10 changed files with 583 additions and 266 deletions

View File

@@ -5,6 +5,7 @@ import com.alibaba.dubbo.rpc.service.GenericService;
import com.alibaba.fastjson.JSON;
import com.zyplayer.doc.core.json.DocResponseJson;
import com.zyplayer.doc.dubbo.controller.param.DubboRequestParam;
import com.zyplayer.doc.dubbo.controller.vo.DubboInfoVo;
import com.zyplayer.doc.dubbo.framework.bean.DubboDocInfo;
import com.zyplayer.doc.dubbo.framework.bean.DubboInfo;
import com.zyplayer.doc.dubbo.framework.bean.NacosDubboInfo;
@@ -20,7 +21,7 @@ import org.apache.curator.retry.ExponentialBackoffRetry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -55,7 +56,7 @@ public class DubboController {
* @author 暮光:城中城
* @since 2019年2月10日
**/
@GetMapping(value = "/reloadService")
@PostMapping(value = "/reloadService")
public DocResponseJson loadService() throws Exception {
List<DubboInfo> providerList;
if (StringUtils.isBlank(zookeeperUrl)) {
@@ -77,7 +78,7 @@ public class DubboController {
* @author 暮光:城中城
* @since 2019年2月10日
**/
@GetMapping(value = "/request")
@PostMapping(value = "/request")
public DocResponseJson request(DubboRequestParam param) {
DubboInfo.DubboNodeInfo dubboNodeInfo = new DubboInfo.DubboNodeInfo();
dubboNodeInfo.setIp(param.getIp());
@@ -101,22 +102,22 @@ public class DubboController {
* @author 暮光:城中城
* @since 2019年2月10日
**/
@GetMapping(value = "/getDocList")
@PostMapping(value = "/getDocList")
public DocResponseJson getDocList() {
String dubboServiceList = mgDubboStorageService.get(StorageKeys.DUBBO_SERVICE_LIST);
String dubboServiceDoc = mgDubboStorageService.get(StorageKeys.DUBBO_SERVICE_DOC);
if (StringUtils.isBlank(dubboServiceList)) {
return DocResponseJson.ok();
}
DubboInfoVo dubboInfoVo = new DubboInfoVo();
List<DubboInfo> providerList = JSON.parseArray(dubboServiceList, DubboInfo.class);
dubboInfoVo.setServerList(providerList);
if (StringUtils.isNotBlank(dubboServiceDoc)) {
List<DubboDocInfo> docInfoList = JSON.parseArray(dubboServiceDoc, DubboDocInfo.class);
Map<String, DubboDocInfo> docInfoMap = docInfoList.stream().collect(Collectors.toMap(DubboDocInfo::getService, val -> val));
for (DubboInfo dubboInfo : providerList) {
dubboInfo.setDocInfo(docInfoMap.get(dubboInfo.getInterfaceX()));
}
Map<String, DubboDocInfo> docInfoMap = docInfoList.stream().collect(Collectors.toMap(DubboDocInfo::getFunction, val -> val));
dubboInfoVo.setDocMap(docInfoMap);
}
return DocResponseJson.ok(providerList);
return DocResponseJson.ok(dubboInfoVo);
}
/**
@@ -125,15 +126,16 @@ public class DubboController {
* @author 暮光:城中城
* @since 2019年2月10日
**/
@GetMapping(value = "/saveDoc")
public DocResponseJson saveDoc(DubboDocInfo param) {
@PostMapping(value = "/saveDoc")
public DocResponseJson saveDoc(DubboDocInfo param, String paramsJson) {
String dubboServiceDoc = mgDubboStorageService.get(StorageKeys.DUBBO_SERVICE_DOC);
Map<String, DubboDocInfo> docInfoMap = new HashMap<>();
if (StringUtils.isNotBlank(dubboServiceDoc)) {
List<DubboDocInfo> docInfoList = JSON.parseArray(dubboServiceDoc, DubboDocInfo.class);
docInfoMap = docInfoList.stream().collect(Collectors.toMap(DubboDocInfo::getService, val -> val));
docInfoMap = docInfoList.stream().collect(Collectors.toMap(DubboDocInfo::getFunction, val -> val));
}
DubboDocInfo dubboDocInfo = docInfoMap.get(param.getService());
String function = param.getService() + "." + param.getMethod();
DubboDocInfo dubboDocInfo = docInfoMap.get(function);
if (dubboDocInfo != null) {
Integer newVersion = Optional.ofNullable(param.getVersion()).orElse(1);
Integer oldVersion = Optional.ofNullable(dubboDocInfo.getVersion()).orElse(1);
@@ -141,13 +143,24 @@ public class DubboController {
return DocResponseJson.warn("已有用户在您之前修改过文档,请刷新后再修改");
}
param.setVersion(oldVersion + 1);
if (StringUtils.isEmpty(param.getExplain())) {
param.setExplain(dubboDocInfo.getExplain());
}
if (StringUtils.isEmpty(param.getResult())) {
param.setResult(dubboDocInfo.getResult());
}
param.setParams(dubboDocInfo.getParams());
} else {
param.setVersion(1);
}
docInfoMap.put(param.getService(), param);
if (StringUtils.isNotBlank(paramsJson)) {
param.setParams(JSON.parseArray(paramsJson, DubboDocInfo.DubboDocParam.class));
}
param.setFunction(function);
docInfoMap.put(function, param);
List<DubboDocInfo> docInfoList = new ArrayList<>(docInfoMap.values());
mgDubboStorageService.put(StorageKeys.DUBBO_SERVICE_DOC, JSON.toJSONString(docInfoList));
return DocResponseJson.ok();
return DocResponseJson.ok(param);
}
/**
@@ -231,6 +244,7 @@ public class DubboController {
dubboInfo.setNodeList(nodeList);
providerList.add(dubboInfo);
}
client.close();
return providerList;
}
}

View File

@@ -0,0 +1,32 @@
package com.zyplayer.doc.dubbo.controller.vo;
import com.zyplayer.doc.dubbo.framework.bean.DubboDocInfo;
import com.zyplayer.doc.dubbo.framework.bean.DubboInfo;
import java.util.List;
import java.util.Map;
/**
* @author 暮光:城中城
* @since 2019年1月10日
**/
public class DubboInfoVo {
private List<DubboInfo> serverList;
private Map<String, DubboDocInfo> docMap;
public List<DubboInfo> getServerList() {
return serverList;
}
public void setServerList(List<DubboInfo> serverList) {
this.serverList = serverList;
}
public Map<String, DubboDocInfo> getDocMap() {
return docMap;
}
public void setDocMap(Map<String, DubboDocInfo> docMap) {
this.docMap = docMap;
}
}

View File

@@ -11,11 +11,13 @@ import java.util.List;
public class DubboDocInfo {
private String service;
private String method;
private String function;
private String explain;
private String result;
private Integer version;
private List<DubboDocParam> params;
public class DubboDocParam {
public static class DubboDocParam {
private String paramName;
private String paramType;
private String paramDesc;
@@ -101,4 +103,20 @@ public class DubboDocInfo {
public void setParams(List<DubboDocParam> params) {
this.params = params;
}
public String getFunction() {
return function;
}
public void setFunction(String function) {
this.function = function;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
}

View File

@@ -11,7 +11,6 @@ import java.util.List;
public class DubboInfo {
@JSONField(name = "interface")
private String interfaceX;
private DubboDocInfo docInfo;
private List<DubboNodeInfo> nodeList;
public static class DubboNodeInfo {
@@ -79,11 +78,4 @@ public class DubboInfo {
this.interfaceX = interfaceX;
}
public DubboDocInfo getDocInfo() {
return docInfo;
}
public void setDocInfo(DubboDocInfo docInfo) {
this.docInfo = docInfo;
}
}

View File

@@ -6,31 +6,40 @@
<title>dubbo文档管理系统</title>
<link rel="shortcut icon" href="webjars/doc-dubbo/img/api.ico"/>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<link rel="stylesheet" href="webjars/doc-dubbo/css/doc-dubbo.css" />
</head>
<body>
<div id="app">
<el-container style="height: 100%;">
<el-aside width="auto" style="height: 100%;padding-top: 10px;">
<el-row><el-button type="primary" v-on:click="reloadService">重新加载服务列表</el-button></el-row>
<el-row><el-switch v-model="isCollapse"></el-switch></el-row>
<el-menu default-active="" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
<el-submenu index="1">
<template slot="title">
<i class="el-icon-location"></i>
<span slot="title">导航一</span>
</template>
<el-submenu index="1-4">
<span slot="title">选项4</span>
<el-menu-item index="1-4-1">选项1</el-menu-item>
</el-submenu>
</el-submenu>
</el-menu>
<el-tree :data="pathIndex" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
<el-aside width="auto" style="height: 100%;">
<div style="background: linear-gradient(-90deg, #03DDE4 0%, #30AFED 51%, #8755FF 100%);width: 100%; height:60px;line-height:60px;font-size: 25px;color: #fff;text-align: center;">
zyplayer-doc-dubbo
</div>
<div style="padding: 10px;">
<div align="center"><el-button type="primary" v-on:click="reloadService" icon="el-icon-refresh" style="width: 100%;">重新加载服务列表</el-button></div>
<!--<el-row><el-switch v-model="isCollapse"></el-switch></el-row>-->
<el-input v-model="searchKeywords" placeholder="搜索文档" style="margin: 10px 0;">
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywords"></el-button>
</el-input>
<!--<el-menu default-active="" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">-->
<!--<el-submenu index="1">-->
<!--<template slot="title">-->
<!--<i class="el-icon-setting"></i>-->
<!--<span slot="title">文档管理</span>-->
<!--</template>-->
<!--<el-menu-item index="1-1">管理服务列表</el-menu-item>-->
<!--</el-submenu>-->
<!--</el-menu>-->
<el-tree :data="pathIndex" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</div>
</el-aside>
<el-container>
<el-tabs type="border-card" style="width: 100%;">
<el-tab-pane label="接口说明">
<el-form label-width="80px">
<div v-if="!dubboInfo.interface">
请先选择服务
</div>
<el-form v-else label-width="80px">
<el-form-item label="服务:">
{{dubboInfo.interface}}
</el-form-item>
@@ -38,18 +47,90 @@
{{dubboInfo.method}}
</el-form-item>
<el-form-item label="说明:">
<div v-if="dubboInfoExplainShow">
<pre>{{dubboInfo.docInfo.explain}}<el-button @click.prevent="dubboInfoExplainShow = false;" style="float: right;">编辑</el-button></pre>
</div>
<div v-else>
<el-input type="textarea" :rows="4" placeholder="请输入说明内容" v-model="docInfoExplainInput"></el-input>
<el-button @click.prevent="dubboInfoExplainShow = true;" style="float: right;margin: 5px;">取消</el-button>
<el-button type="primary" @click.prevent="saveDocInfoExplain" style="float: right;margin: 5px;">保存</el-button>
</div>
</el-form-item>
<el-form-item label="节点:">
<el-table :data="dubboInfo.nodeList" border style="width: 100%">
<el-table-column prop="application" label="应用"></el-table-column>
<el-table-column prop="ip" label="IP"></el-table-column>
<el-table-column prop="port" label="端口"></el-table-column>
</el-table>
</el-form-item>
<el-form-item label="参数:">
<el-table :data="docParamList" border style="width: 100%; margin-bottom: 5px;">
<el-table-column label="顺序" width="100">
<template slot-scope="scope">{{scope.$index + 1}}</template>
</el-table-column>
<el-table-column label="类型" width="200">
<template slot-scope="scope">
<el-select v-model="scope.row.paramType" clearable placeholder="请选择">
<el-option v-for="item in paramTypeOptions" :key="item.value" :label="item.value" :value="item.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="说明">
<template slot-scope="scope">
<el-input v-model="scope.row.paramDesc"></el-input>
</template>
</el-table-column>
</el-table>
<el-button @click.prevent="saveDocInfoParam" style="float: right;margin: 5px;">保存</el-button>
<el-button @click.prevent="addDocParam" style="float: right;margin: 5px;">添加</el-button>
</el-form-item>
<el-form-item label="结果:">
<div v-if="dubboInfoResultShow">
<pre>{{dubboInfo.docInfo.result}}<el-button @click.prevent="dubboInfoResultShow = false;" style="float: right;">编辑</el-button></pre>
</div>
<div v-else>
<el-input type="textarea" :rows="4" placeholder="请输入说明内容" v-model="docInfoResultInput"></el-input>
<el-button @click.prevent="dubboInfoResultShow = true;" style="float: right;margin: 5px;">取消</el-button>
<el-button type="primary" @click.prevent="saveDocInfoResult" style="float: right;margin: 5px;">保存</el-button>
</div>
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="在线调试">
在线调试页面
<div v-if="!dubboInfo.interface">
请先选择服务
</div>
<div v-else>
<el-input placeholder="请输入内容" v-model="dubboInfo.function" class="input-with-select">
<el-select v-model="requestHostValue" slot="prepend" placeholder="请选择" style="width: 200px;">
<el-option v-for="item in requestHostOptions" :key="item.value" :label="item.value" :value="item.value"></el-option>
</el-select>
<el-button slot="append" @click.prevent="requestExecute">执行</el-button>
</el-input>
<el-form label-width="100px"label-position="top">
<el-form-item label="请求参数:">
<el-table :data="docParamRequestList" border style="width: 100%; margin: 10px 0;">
<el-table-column label="顺序" width="100">
<template slot-scope="scope">{{scope.$index + 1}}</template>
</el-table-column>
<el-table-column label="类型" width="200">
<template slot-scope="scope">{{scope.row.paramType}}</template>
</el-table-column>
<el-table-column label="参数值" width="300">
<template slot-scope="scope">
<el-input v-model="scope.row.paramValue"></el-input>
</template>
</el-table-column>
<el-table-column label="说明">
<template slot-scope="scope">{{scope.row.paramDesc}}</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item label="请求结果:">
<div v-html="requestResult"></div>
</el-form-item>
</el-form>
</div>
</el-tab-pane>
</el-tabs>
</el-container>
@@ -60,6 +141,8 @@
<script type="text/javascript" src="https://unpkg.com/element-ui/lib/index.js"></script>
<script type="text/javascript" src="webjars/doc-dubbo/js/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="webjars/doc-dubbo/js/common.js"></script>
<script type="text/javascript" src="webjars/doc-dubbo/js/toast.js"></script>
<script type="text/javascript" src="webjars/doc-dubbo/js/formatjson.js"></script>
<script type="text/javascript" src="webjars/doc-dubbo/js/doc-dubbo-tree.js"></script>
<script>
@@ -75,21 +158,41 @@
},
// 展示的信息
dubboInfo: {},
// 树的下表
projectTreeIdIndex: 1,
dubboInfoExplainShow: true,
docInfoExplainInput: "",
dubboInfoResultShow: true,
docInfoResultInput: "",
// 请求的IP端口下拉选项
requestHostOptions: [],
requestHostValue: "",
requestResult: "",
// 依据目录树存储的map全局对象
treePathDataMap: new Map(),
// dubbo列表
dubboDocList: [],
dubboDocMap: [],
// 搜索的输入内容
searchKeywords: "",
docParamList: [],
docParamRequestList: [],
// 参数类型选项
paramTypeOptions: [{
value: 'java.lang.String'
}, {
value: 'java.lang.Long'
}, {
value: 'java.lang.Integer'
}, {
value: 'other'
}],
paramTypeValue: "java.lang.String",
}
},
mounted: function(){
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/getDocList", "get", "json", {}, function (json) {
if (validateResult(json)) {
dubboDocList = json.data || [];
app.pathIndex = createTreeViewByTree(dubboDocList);
}
});
watch: {
},
mounted: function () {
this.doGetServiceList();
},
methods: {
handleOpen(key, keyPath) {
@@ -103,17 +206,152 @@
var path = data.interface;
var dubboInfo = app.treePathDataMap.get(path);
dubboInfo.method = data.method;
dubboInfo.function = path;
dubboInfo.docInfo = app.dubboDocMap[path] || {};
// 清空再赋值才会重新渲染
app.dubboInfo = {};
app.dubboInfo = dubboInfo;
console.log(data);
app.docInfoExplainInput = dubboInfo.docInfo.explain;
app.docParamList = [];
app.docParamList = dubboInfo.docInfo.params || [];
this.createDocParamRequestList();
// 请求相关
app.requestResult = "";
app.requestHostValue = "";
app.requestHostOptions = [];
for (var i = 0; i < dubboInfo.nodeList.length; i++) {
var item = dubboInfo.nodeList[i];
app.requestHostOptions.push({
value: item.ip + ":" + item.port
});
}
if (app.requestHostOptions.length > 0) {
app.requestHostValue = app.requestHostOptions[0].value;
}
//console.log(app.dubboInfo);
}
},
reloadService(){
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/reloadService", "get", "json", {}, function (json) {
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/reloadService", "post", "json", {}, function (json) {
if (validateResult(json)) {
app.$message({
message: '加载成功!',
type: 'success'
});
app.doGetServiceList();
}
});
},
searchByKeywords() {
app.pathIndex = createTreeViewByTreeWithMerge(app.dubboDocList, app.searchKeywords);
},
doGetServiceList() {
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/getDocList", "post", "json", {}, function (json) {
if (validateResult(json)) {
app.dubboDocList = json.data.serverList || [];
app.dubboDocMap = json.data.docMap || {};
app.pathIndex = createTreeViewByTreeWithMerge(app.dubboDocList);
}
});
},
saveDocInfoExplain(){
this.doSaveDocInfo(app.docInfoExplainInput, null, null);
},
saveDocInfoResult(){
this.doSaveDocInfo(null, null, app.docInfoResultInput);
},
saveDocInfoParam() {
var docParamList = [];
for (var i = 0; i < app.docParamList.length; i++) {
var item = app.docParamList[i];
if (isNotEmpty(item.paramType) || isNotEmpty(item.paramDesc)) {
docParamList.push(item);
}
}
var paramsJson = JSON.stringify(docParamList);
this.doSaveDocInfo(null, paramsJson, null);
},
createDocParamRequestList() {
var docParamList = [];
for (var i = 0; i < app.docParamList.length; i++) {
var item = app.docParamList[i];
if (isNotEmpty(item.paramType) || isNotEmpty(item.paramDesc)) {
docParamList.push(item);
}
}
app.docParamRequestList = docParamList;
},
doSaveDocInfo(explain, params, result){
var param = {
service: app.dubboInfo.interface,
method: app.dubboInfo.method,
version: app.dubboInfo.docInfo.version || 0,
explain: explain,
result: result,
paramsJson: params,
};
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/saveDoc", "post", "json", param, function (json) {
if (validateResult(json)) {
app.dubboDocMap[json.data.function] = json.data;
app.dubboInfo.docInfo = json.data;
app.dubboInfoExplainShow = true;
app.dubboInfoResultShow = true;
app.docParamList = json.data.params || [];
app.createDocParamRequestList();
}
});
},
addDocParam() {
var leadAdd = app.docParamList.length <= 0;
if (!leadAdd) {
var last = app.docParamList[app.docParamList.length - 1];
if (isNotEmpty(last.paramType) || isNotEmpty(last.paramDesc)) {
leadAdd = true;
}
}
if (leadAdd) {
app.docParamList.push({
paramType: '',
paramDesc: '',
paramValue: '',
});
}
},
requestExecute() {
var fuc = app.dubboInfo.function;
var hostValue = app.requestHostValue;
var service = fuc.substring(0, fuc.lastIndexOf("."));
var method = fuc.substring(fuc.lastIndexOf(".") + 1, fuc.length);
var ip = hostValue.substring(0, hostValue.lastIndexOf(":"));
var port = hostValue.substring(hostValue.lastIndexOf(":") + 1, hostValue.length);
var paramTypes = [];
var params = [];
for (var i = 0; i < app.docParamList.length; i++) {
var item = app.docParamList[i];
if (isNotEmpty(item.paramType) && isNotEmpty(item.paramValue)) {
paramTypes.push(item.paramType);
params.push(item.paramValue);
}
}
var param = {
service: service,
method: method,
ip: ip,
port: port,
paramTypes: paramTypes,
params: params,
};
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/request", "post", "json", param, function (json) {
if (validateResult(json)) {
try {
app.requestResult = Formatjson.processObjectToHtmlPre(JSON.parse(json.data), 0, false, false, false, false);
} catch (e) {
try {
app.requestResult = Formatjson.processObjectToHtmlPre(json.data, 0, false, false, false, false);
} catch (e) {
app.requestResult = json.data;
}
}
}
});
}
@@ -133,12 +371,15 @@
.el-tree-node__content{
padding-right: 20px;
}
.el-tabs--border-card>.el-tabs__content{
height: calc(100vh - 70px);overflow-y: auto;
}
html,body,#app {
margin: 0;
padding: 0;
height: 100%;
}
pre{margin: 0;}
</style>
</html>

View File

@@ -1,133 +1,18 @@
body{width: 100%;height: 100%;margin: 0;padding: 0;}
a:focus{outline:none;}
ul{list-style: none;list-style-type: none;}
.tree li a{white-space: nowrap;}
.tree-menu li > ul{background-color: #f1f1f1;}
.tree-menu li li li li a{padding-left: 68px;}
.tree-menu li li li li li a{padding-left: 88px;}
.tree-menu li li li li li li a{padding-left: 108px;}
.tree-menu li li li li li li li a{padding-left: 128px;}
.tree-menu li li li li li li li li a{padding-left: 148px;}
.tree-menu li li li li li li li li li a{padding-left: 168px;}
.tree-menu li li li li li li li li li li a{padding-left: 188px;}
.table td, .table th {vertical-align: middle;}
.dropdown-menu>li>a{max-width: 100%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
#tabDocInfo{position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;}
#tabOnlineDebug .param-response-box{position: absolute; bottom: 0;top: 100px;overflow-y: auto; right: 0; left: 10px;padding-right: 10px;}
#tabOnlineDebug .panel{margin-bottom: 10px;}
#requestParamForm .nav > li > a{padding: 6px 15px;}
.local-storage{display: none;}
.choice-location-list{margin-bottom: 10px; width: 100%;}
.choice-location-list .btn.dropdown-toggle{width: 100%; text-align: left;}
.choice-location-list .dropdown-menu{width: 100%;}
.choice-location-list .choice-text{max-width: calc(100% - 15px);overflow: hidden;float: left;white-space: nowrap;text-overflow: ellipsis;}
.choice-location-list .caret{float: right;margin-top: 8px;}
/**lable的覆盖样式*/
.label{font-size: 100%;}
.label-warning {background-color: #f9f5ee; color: #f1a325;}
label{font-weight: normal;}
.overwrite-label{margin-bottom: 0;}
.nav.gray{background-color: #f1f1f1;margin-bottom: 10px;}
.doc-table tr .info{text-align: right; width: 100px;}
.setting-table tr .info{text-align: right; max-width: 150px;}
.show-doc span{color: #aaa;}
.mgresizableW{z-index: 90;height: 100%; width: 10px; cursor: e-resize;}
.ui-resizable-handle {display: block;font-size: 0.1px;position: absolute;}
#resizableLeftRight{left: 360px;}
.unselect{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}
#homePageDashboard{overflow-y: auto;bottom: 0;top: 0;right: 0;left: 0;position: absolute;overflow-x: hidden;padding: 10px;}
#homePageDashboard .panel-body{padding: 10px;}
.content.about{line-height: 30px;}
#homePageLi{margin-top: 5px;}
.left-body{
width: 360px; height:100%; position: fixed; top: 0; bottom: 0; left: 0;
}
.left-header{
background: linear-gradient(-90deg, #03DDE4 0%, #30AFED 51%, #8755FF 100%);width: 100%; height:60px;line-height:60px;
position: absolute; top: 0; bottom: 0; left: 0;text-align: center;
}
.left-header .logo{
font-size: 30px;color: #fff;
}
.left-header .icon-bars{
font-size: 24px;float: right;margin: 18px 18px 0 0;color: #fff;cursor: pointer;
}
.left-container{
width: 100%;position: absolute;background: #f1f1f1;color: rgba(163, 175, 183, .9);
top: 60px; bottom: 0; left: 0; overflow-y: auto; padding: 10px;
}
.left-container .projects{border: 0px; border-radius: 0px;}
.right-container{
position: fixed;top: 0px; bottom: 0; left: 360px; right: 0;padding: 10px;
}
#docResponseModel td:first-child{width: 100px;}
#docResponseExample td:first-child{width: 100px;}
.modal-table-box{margin-top: 10px; max-height: 500px;overflow-y: auto;}
.modal-table-box{list-style: none;}
.modal-table-box ul{padding-left: 10px;}
.modal-table-box li{padding: 10px 15px; margin: 0 10px 10px 0; background-color: #f1f1f1;cursor: pointer;}
.modal-table-box li.checked{background-color: #8666b8;color:#fff;}
#exportDocumentText{height: 350px;}
#rightContentMask{background-color: rgba(0, 0, 0, 0);padding: 0;z-index:9999; height: 100%;display: none;position: absolute;top: 0;bottom: 0;left:0;right: 0;}
#rightZpages{height: 100%;position: relative;top: 0;bottom: 0;left:0;right: 0;}
/* 在线调试框样式 */
#tabParamBody .tab-content{padding-top: 10px;}
.post-url-box{padding: 10px 0;}
.post-url-box .input-group-btn:nth-child(2) button{border-left: 0;border-right: 0;border-radius: 0;}
.post-url-box .send-request .hide{display: none;}
.param-box{}
.param-box .panel-collapse{padding: 10px 10px 0 10px;}
.param-box .nav{background-color: #f1f1f1;}
.param-box .table{margin-bottom: 0;}
/* .param-box .nav > li > *{padding: 8px 25px;} */
.param-box .nav > li > span{position: relative; display: block;background-color: #ccc;padding: 9px 25px;}
.param-box .nav > .form-to-url{position: relative; display: block;padding: 8px 0 0 25px;}
.param-box .nav > .form-to-url label{margin: 0;}
.param-box .nav > .form-to-url input{margin: 0;}
.param-box .tab-content .tab-param-pane{padding: 10px 10px 0 10px;}
.param-box .table.param-table td, .param-box .table.param-table th{padding: 4px 5px;}
.param-box .param-table tbody td:nth-child(4){border-right: 0;}
.param-box .param-table tbody td:nth-child(5){border-left: 0;padding: 0 10px 0 0;width: 10px;}
.param-box .param-table tbody td:nth-child(5) i{cursor: pointer;color: #ccc;}
.param-box .param-table tbody td:nth-child(5) i:hover{color: #888;}
.param-box .param-table tbody tr.base td:last-child i{display: none;}
#bulkEditHeaderCheck{margin: 0 0 0 10px;}
#bulkEditHeader,#bulkEditForm{display: none;}
.response-box{margin-top: 10px;}
.response-box .nav > li > *{padding: 8px 25px;}
.response-box .nav > li span{position: relative; display: block;padding: 9px 25px;}
.response-box .nav > li.info span{background-color: #ccc;}
.response-box .nav > li.right{float: right;}
.response-box .nav > li.right i{color: #3280fc;}
.response-box .nav{background-color: #f1f1f1;}
.response-box .tab-content .tab-response-pane{padding: 10px;}
#responseBodyJsonIframe{width: 100%;height: 300px;border: 0;}
/* S-模拟请求 */
#tabSimulationResult{padding: 0 10px 0 0;position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;}
/* E-模拟请求 */
/* S-JSON展示的样式 */
pre.json{margin-top:0px;margin-bottom:0px;}
pre.json {
display: block;
padding: 9.5px;
margin: 0 0 0 10px;
font-size: 12px;
line-height: 1.38461538;
color: #333;
word-break: break-all;
word-wrap: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
}
pre.json .canvas{font:10pt georgia;background-color:#ececec;color:#000000;border:1px solid #cecece;}
pre.json .object-brace{color:#00aa00;font-weight:bold;}
pre.json .array-brace{color:#0033ff;font-weight:bold;}

View File

@@ -0,0 +1,144 @@
body{width: 100%;height: 100%;margin: 0;padding: 0;}
a:focus{outline:none;}
ul{list-style: none;list-style-type: none;}
.tree li a{white-space: nowrap;}
.tree-menu li > ul{background-color: #f1f1f1;}
.tree-menu li li li li a{padding-left: 68px;}
.tree-menu li li li li li a{padding-left: 88px;}
.tree-menu li li li li li li a{padding-left: 108px;}
.tree-menu li li li li li li li a{padding-left: 128px;}
.tree-menu li li li li li li li li a{padding-left: 148px;}
.tree-menu li li li li li li li li li a{padding-left: 168px;}
.tree-menu li li li li li li li li li li a{padding-left: 188px;}
.table td, .table th {vertical-align: middle;}
.dropdown-menu>li>a{max-width: 100%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
#tabDocInfo{position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;}
#tabOnlineDebug .param-response-box{position: absolute; bottom: 0;top: 100px;overflow-y: auto; right: 0; left: 10px;padding-right: 10px;}
#tabOnlineDebug .panel{margin-bottom: 10px;}
#requestParamForm .nav > li > a{padding: 6px 15px;}
.local-storage{display: none;}
.choice-location-list{margin-bottom: 10px; width: 100%;}
.choice-location-list .btn.dropdown-toggle{width: 100%; text-align: left;}
.choice-location-list .dropdown-menu{width: 100%;}
.choice-location-list .choice-text{max-width: calc(100% - 15px);overflow: hidden;float: left;white-space: nowrap;text-overflow: ellipsis;}
.choice-location-list .caret{float: right;margin-top: 8px;}
/**lable的覆盖样式*/
.label{font-size: 100%;}
.label-warning {background-color: #f9f5ee; color: #f1a325;}
label{font-weight: normal;}
.overwrite-label{margin-bottom: 0;}
.nav.gray{background-color: #f1f1f1;margin-bottom: 10px;}
.doc-table tr .info{text-align: right; width: 100px;}
.setting-table tr .info{text-align: right; max-width: 150px;}
.show-doc span{color: #aaa;}
.mgresizableW{z-index: 90;height: 100%; width: 10px; cursor: e-resize;}
.ui-resizable-handle {display: block;font-size: 0.1px;position: absolute;}
#resizableLeftRight{left: 360px;}
.unselect{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}
#homePageDashboard{overflow-y: auto;bottom: 0;top: 0;right: 0;left: 0;position: absolute;overflow-x: hidden;padding: 10px;}
#homePageDashboard .panel-body{padding: 10px;}
.content.about{line-height: 30px;}
#homePageLi{margin-top: 5px;}
.left-body{
width: 360px; height:100%; position: fixed; top: 0; bottom: 0; left: 0;
}
.left-header{
background: linear-gradient(-90deg, #03DDE4 0%, #30AFED 51%, #8755FF 100%);width: 100%; height:60px;line-height:60px;
position: absolute; top: 0; bottom: 0; left: 0;text-align: center;
}
.left-header .logo{
font-size: 30px;color: #fff;
}
.left-header .icon-bars{
font-size: 24px;float: right;margin: 18px 18px 0 0;color: #fff;cursor: pointer;
}
.left-container{
width: 100%;position: absolute;background: #f1f1f1;color: rgba(163, 175, 183, .9);
top: 60px; bottom: 0; left: 0; overflow-y: auto; padding: 10px;
}
.left-container .projects{border: 0px; border-radius: 0px;}
.right-container{
position: fixed;top: 0px; bottom: 0; left: 360px; right: 0;padding: 10px;
}
#docResponseModel td:first-child{width: 100px;}
#docResponseExample td:first-child{width: 100px;}
.modal-table-box{margin-top: 10px; max-height: 500px;overflow-y: auto;}
.modal-table-box{list-style: none;}
.modal-table-box ul{padding-left: 10px;}
.modal-table-box li{padding: 10px 15px; margin: 0 10px 10px 0; background-color: #f1f1f1;cursor: pointer;}
.modal-table-box li.checked{background-color: #8666b8;color:#fff;}
#exportDocumentText{height: 350px;}
#rightContentMask{background-color: rgba(0, 0, 0, 0);padding: 0;z-index:9999; height: 100%;display: none;position: absolute;top: 0;bottom: 0;left:0;right: 0;}
#rightZpages{height: 100%;position: relative;top: 0;bottom: 0;left:0;right: 0;}
/* 在线调试框样式 */
#tabParamBody .tab-content{padding-top: 10px;}
.post-url-box{padding: 10px 0;}
.post-url-box .input-group-btn:nth-child(2) button{border-left: 0;border-right: 0;border-radius: 0;}
.post-url-box .send-request .hide{display: none;}
.param-box{}
.param-box .panel-collapse{padding: 10px 10px 0 10px;}
.param-box .nav{background-color: #f1f1f1;}
.param-box .table{margin-bottom: 0;}
/* .param-box .nav > li > *{padding: 8px 25px;} */
.param-box .nav > li > span{position: relative; display: block;background-color: #ccc;padding: 9px 25px;}
.param-box .nav > .form-to-url{position: relative; display: block;padding: 8px 0 0 25px;}
.param-box .nav > .form-to-url label{margin: 0;}
.param-box .nav > .form-to-url input{margin: 0;}
.param-box .tab-content .tab-param-pane{padding: 10px 10px 0 10px;}
.param-box .table.param-table td, .param-box .table.param-table th{padding: 4px 5px;}
.param-box .param-table tbody td:nth-child(4){border-right: 0;}
.param-box .param-table tbody td:nth-child(5){border-left: 0;padding: 0 10px 0 0;width: 10px;}
.param-box .param-table tbody td:nth-child(5) i{cursor: pointer;color: #ccc;}
.param-box .param-table tbody td:nth-child(5) i:hover{color: #888;}
.param-box .param-table tbody tr.base td:last-child i{display: none;}
#bulkEditHeaderCheck{margin: 0 0 0 10px;}
#bulkEditHeader,#bulkEditForm{display: none;}
.response-box{margin-top: 10px;}
.response-box .nav > li > *{padding: 8px 25px;}
.response-box .nav > li span{position: relative; display: block;padding: 9px 25px;}
.response-box .nav > li.info span{background-color: #ccc;}
.response-box .nav > li.right{float: right;}
.response-box .nav > li.right i{color: #3280fc;}
.response-box .nav{background-color: #f1f1f1;}
.response-box .tab-content .tab-response-pane{padding: 10px;}
#responseBodyJsonIframe{width: 100%;height: 300px;border: 0;}
/* S-模拟请求 */
#tabSimulationResult{padding: 0 10px 0 0;position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;}
/* E-模拟请求 */
/* S-JSON展示的样式 */
pre.json{margin-top:0px;margin-bottom:0px;}
pre.json .canvas{font:10pt georgia;background-color:#ececec;color:#000000;border:1px solid #cecece;}
pre.json .object-brace{color:#00aa00;font-weight:bold;}
pre.json .array-brace{color:#0033ff;font-weight:bold;}
pre.json .property-name{color:#cc0000;font-weight:bold;}
pre.json .string{color:#007777;}
pre.json .number{color:#aa00aa;}
pre.json .boolean{color:#0000ff;}
pre.json .function{color:#aa6633;text-decoration:italic;}
pre.json .null{color:#0000ff;}
pre.json .comma{color:#000000;font-weight:bold;}
pre.json .annotation{color:#aaa;}
pre img{cursor: pointer;}
/* E-JSON展示的样式 */

View File

@@ -175,7 +175,7 @@ function getObjectFirstAttributeIfOnly(data) {
/**
* ajax处理事件模板
*
*
* @url 后台处理的url即action
* @dataSentType 数据发送的方式有postget方式
* @dataReceiveType 数据接收格式有html json text等
@@ -189,6 +189,7 @@ function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction
sync : false,
type : dataSentType, // 数据发送方式
dataType : dataReceiveType, // 接受数据格式
traditional: true,
data : eval(paramsStr),
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
success : function(msg) {
@@ -395,4 +396,4 @@ function deleteStorage(key, success, fail) {
*/
function getExport(){
return window.parent.window.exports;
}
}

View File

@@ -20,6 +20,7 @@ function createTreeViewByTree(json, keywords) {
return;
}
//console.log(paths);
var lastId = "";
for (var i = 0; i < json.length; i++) {
var interface = json[i].interface;
//console.log(key, paths[key]);
@@ -40,39 +41,30 @@ function createTreeViewByTree(json, keywords) {
return;
}
var nowPath = val;
// if(nowPathObj == null) {
// nowPathObj = [];
// var temp = nowPathObj[0] = {};
// temp[nowPath] = findNode(pathIndex, nowPath);
// if (temp[nowPath] == null) {
// temp[nowPath] = {};
// pathIndex.push(nowPathObj);
// }
// }
// var tempPathObj = findNode(nowPathObj, nowPath);
// if(isEmpty(tempPathObj)) {
// var temp = [];
// tempPathObj = temp[0] = {};
// nowPathObj.push(temp);
// }
// nowPathObj = tempPathObj;
// nowPathObj.label = nowPath;
if (nowPathObj == null) {
nowPathObj = findNode(pathIndex, nowPath);
if (nowPathObj == null) {
nowPathObj = {label: nowPath, children: []};
nowPathObj = {
id: pathIndex.length,
label: nowPath, children: []
};
pathIndex.push(nowPathObj);
}
lastId = nowPathObj.id;
nowPathObj = nowPathObj.children;
} else {
var tempPathObj = findNode(nowPathObj, nowPath);
if(tempPathObj == null) {
tempPathObj = {label: nowPath, children: []};
tempPathObj = {
id: lastId + "." + nowPathObj.length,
label: nowPath, children: []
};
nowPathObj.push(tempPathObj);
}
lastId = tempPathObj.id;
nowPathObj = tempPathObj.children;
if (index == keyArr.length - 1) {
var tempPath = app.projectTreeIdIndex + ":" + interfaceTemp;
var tempPath = interfaceTemp;
tempPathObj.children = null;
tempPathObj.method = methods[j];
tempPathObj.interface = tempPath;
@@ -82,12 +74,19 @@ function createTreeViewByTree(json, keywords) {
});
}
}
app.projectTreeIdIndex++;
//var htmlStr = getTreeHtmlForTree(pathIndex, app.projectTreeIdIndex);
console.log(pathIndex);
// console.log(pathIndex);
return pathIndex;
}
function createTreeViewByTreeWithMerge(json, keywords) {
var pathIndex = createTreeViewByTree(json, keywords);
mergeNode(pathIndex);
return pathIndex;
}
/**
* 查找node节点
*/
function findNode(arr, service){
for (var i = 0; i < arr.length; i++) {
if(arr[i].label == service) {
@@ -98,30 +97,23 @@ function findNode(arr, service){
}
/**
* 将对象列表递归的方式转换成文档格式html字符串
* @param pathData 处理后的对象列表
* @returns 生成的html字符串
* 多层级合并
*/
function getTreeHtmlForTree(pathData, treeIdStr) {
var tempStr = "";
var indexNow = 1;
Object.keys(pathData).forEach(function (key) {
var tempNode = pathData[key];
var tempTreeId = treeIdStr + "_" + indexNow;
if (isNotEmpty(tempNode.interface)) {
tempNode.treeId = tempTreeId;
tempStr += '<li m-id="' + tempTreeId + '"><a href="#" class="show-doc" method="' + tempNode.method + '" path="' + tempNode.interface + '">' + key + '</a></li>';
} else {
tempStr += '<li>';
tempStr += '<a href="#">' + key + '</a>';
tempStr += '<ul>';
tempStr += getTreeHtmlForTree(tempNode, tempTreeId);
tempStr += '</ul>';
tempStr += '</li>';
function mergeNode(node) {
for (var i = 0; i < node.length; i++) {
var tempNode = node[i];
if (tempNode.children == null
|| tempNode.children[0].children == null
|| tempNode.children[0].children[0].children == null) {
continue;
}
indexNow++;
});
return tempStr;
if (tempNode.children.length == 1) {
tempNode.label = tempNode.label + "." + tempNode.children[0].label;
tempNode.children = tempNode.children[0].children;
i--;
}
mergeNode(tempNode.children);
}
}
function findInPathsValue(pathsValue, keywords) {

View File

@@ -4,37 +4,35 @@
* @since 2017年5月7日
*/
var Toast = {
notOpen: function () {
var data = {
message: "该功能暂未开放,敬请期待!",
icon: 'exclamation-sign', type: "warning",
};
this.show(data);
},
success: function (msg, time) {
var data = {
message: msg, time: time,
icon: 'check-circle-o', type: 'success',
};
this.show(data);
},
warn: function (msg, time) {
var data = {
message: msg, time: time,
icon: 'exclamation-sign', type: 'warning',
};
this.show(data);
},
error: function (msg, time) {
var data = {
message: msg, time: time,
icon: 'exclamation-sign', type: 'danger',
};
this.show(data);
},
show: function (data) {
data.time = isEmpty(data.time) ? 2000 : data.time;
data.placement = isEmpty(data.placement) ? 'top' : data.placement;
new $.zui.Messager(data.message, data).show();
}
}
notOpen: function () {
app.$message({
message: '该功能暂未开放,敬请期待!',
type: 'warning',
showClose: true
});
},
success: function (msg, time) {
app.$message({
message: msg,
duration: time || 3000,
type: 'success',
showClose: true
});
},
warn: function (msg, time) {
app.$message({
message: msg,
duration: time || 3000,
type: 'warning',
showClose: true
});
},
error: function (msg, time) {
app.$message({
message: msg,
duration: time || 3000,
type: 'error',
showClose: true
});
},
};