dubbo文档优化
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
import Qs from 'qs'
|
||||
import request from './request'
|
||||
|
||||
export default {
|
||||
queryTestDatasource: data => {
|
||||
return request({url: '/zyplayer-doc-db/datasource/test', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
queryTableDdl: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getTableDdl', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
getEditorData: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getEditorData', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
datasourceList: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getDataSourceList', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
databaseList: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getDatabaseList', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
tableList: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getTableList', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
tableColumnList: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getTableColumnList', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
tableStatus: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getTableStatus', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
tableAndColumnBySearch: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getTableAndColumnBySearch', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
updateTableDesc: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/updateTableDesc', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
updateTableColumnDesc: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/updateTableColumnDesc', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
manageDatasourceList: data => {
|
||||
return request({url: '/zyplayer-doc-db/datasource/list', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
manageUpdateDatasource: data => {
|
||||
return request({url: '/zyplayer-doc-db/datasource/update', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
queryExecuteSql: data => {
|
||||
return request({url: '/zyplayer-doc-db/executor/execute', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
executeSqlCancel: data => {
|
||||
return request({url: '/zyplayer-doc-db/executor/cancel', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
updateFavorite: data => {
|
||||
return request({url: '/zyplayer-doc-db/executor/favorite/add', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
favoriteList: data => {
|
||||
return request({url: '/zyplayer-doc-db/executor/favorite/list', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
historyList: data => {
|
||||
return request({url: '/zyplayer-doc-db/executor/history/list', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
transferStart: data => {
|
||||
return request({url: '/zyplayer-doc-db/transfer/start', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
transferCancel: data => {
|
||||
return request({url: '/zyplayer-doc-db/transfer/cancel', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
transferList: data => {
|
||||
return request({url: '/zyplayer-doc-db/transfer/list', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
transferDetail: data => {
|
||||
return request({url: '/zyplayer-doc-db/transfer/detail', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
transferUpdate: data => {
|
||||
return request({url: '/zyplayer-doc-db/transfer/update', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
transferSqlColumns: data => {
|
||||
return request({url: '/zyplayer-doc-db/transfer/sqlColumns', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
assignDbUserAuth: data => {
|
||||
return request({url: '/zyplayer-doc-db/auth/assign', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
dbUserAuthList: data => {
|
||||
return request({url: '/zyplayer-doc-db/auth/list', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
systemUpgradeInfo: data => {
|
||||
return request({url: '/system/info/upgrade', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
};
|
||||
23
zyplayer-doc-ui/dubbo-ui/src/common/api/dubbo.js
Normal file
23
zyplayer-doc-ui/dubbo-ui/src/common/api/dubbo.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import Qs from 'qs'
|
||||
import request from './request'
|
||||
|
||||
export default {
|
||||
findDocInfo: data => {
|
||||
return request({url: '/zyplayer-doc-dubbo/doc-dubbo/findDocInfo', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
reloadService: data => {
|
||||
return request({url: '/zyplayer-doc-dubbo/doc-dubbo/reloadService', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
getDocList: data => {
|
||||
return request({url: '/zyplayer-doc-dubbo/doc-dubbo/getDocList', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
saveDoc: data => {
|
||||
return request({url: '/zyplayer-doc-dubbo/doc-dubbo/saveDoc', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
request: data => {
|
||||
return request({url: '/zyplayer-doc-dubbo/doc-dubbo/request', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
systemUpgradeInfo: data => {
|
||||
return request({url: '/system/info/upgrade', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
};
|
||||
@@ -9,8 +9,7 @@ const service = axios.create({
|
||||
});
|
||||
// 增加不需要验证结果的标记
|
||||
const noValidate = {
|
||||
"/zyplayer-doc-db/executor/execute": true,
|
||||
"/zyplayer-doc-db/datasource/test": true,
|
||||
"/zyplayer-doc-dubbo/doc-dubbo/request": true,
|
||||
};
|
||||
|
||||
service.interceptors.request.use(
|
||||
@@ -32,17 +31,18 @@ service.interceptors.response.use(
|
||||
response => {
|
||||
if (!!response.message) {
|
||||
vue.$message.error('请求错误:' + response.message);
|
||||
}else {
|
||||
} else {
|
||||
if (!response.config.needValidateResult || response.data.errCode == 200) {
|
||||
return response.data;
|
||||
} else if (response.data.errCode == 400) {
|
||||
vue.$message.error('请先登录');
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
let href = encodeURIComponent(window.location.href);
|
||||
window.location = process.env.VUE_APP_BASE_API + "#/user/login?redirect=" + href;
|
||||
} else if (response.data.errCode == 402) {
|
||||
vue.$router.push("/common/noAuth");
|
||||
} else if (response.data.errCode !== 200) {
|
||||
vue.$message.error(response.data.errMsg || "未知错误");
|
||||
return Promise.reject(response.data.errMsg || "未知错误");
|
||||
}
|
||||
}
|
||||
return Promise.reject('请求错误');
|
||||
|
||||
154
zyplayer-doc-ui/dubbo-ui/src/common/js/doc-dubbo-tree.js
Normal file
154
zyplayer-doc-ui/dubbo-ui/src/common/js/doc-dubbo-tree.js
Normal file
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* 以树形方式生成并展示:
|
||||
* /api
|
||||
* /data
|
||||
* /getDateList
|
||||
* post
|
||||
* get
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年5月26日
|
||||
*/
|
||||
export default {
|
||||
/**
|
||||
* 把原始的json字符串转换成对象列表的方式,方便后续使用
|
||||
* @param json swagger的原始对象
|
||||
* @returns
|
||||
*/
|
||||
createTreeViewByTree(treePathDataMap, json, keywords) {
|
||||
let pathIndex = [];
|
||||
if (!json) return;
|
||||
//console.log(paths);
|
||||
let lastId = "";
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
let interfaceX = json[i].interface;
|
||||
//console.log(key, paths[key]);
|
||||
if (!this.findInPathsValue(json[i], keywords)) {
|
||||
continue;
|
||||
}
|
||||
if (json[i].nodeList.length <= 0) {
|
||||
continue;
|
||||
}
|
||||
let methods = json[i].nodeList[0].methods;
|
||||
let application = json[i].nodeList[0].application;
|
||||
for (let j = 0; j < methods.length; j++) {
|
||||
let interfaceTemp = interfaceX + "." + methods[j];
|
||||
let keyArr = interfaceTemp.split(".");
|
||||
let nowPathObj = null;
|
||||
keyArr.forEach((val, index) => {
|
||||
//console.log(val, index);
|
||||
if (!val && index == 0) {
|
||||
return;
|
||||
}
|
||||
let nowPath = val;
|
||||
if (nowPathObj == null) {
|
||||
nowPathObj = this.findNode(pathIndex, nowPath);
|
||||
if (nowPathObj == null) {
|
||||
nowPathObj = {
|
||||
id: pathIndex.length,
|
||||
label: nowPath, children: []
|
||||
};
|
||||
pathIndex.push(nowPathObj);
|
||||
}
|
||||
lastId = nowPathObj.id;
|
||||
nowPathObj = nowPathObj.children;
|
||||
} else {
|
||||
let tempPathObj = this.findNode(nowPathObj, nowPath);
|
||||
if (tempPathObj == null) {
|
||||
tempPathObj = {
|
||||
id: lastId + "." + nowPathObj.length,
|
||||
label: nowPath, children: []
|
||||
};
|
||||
nowPathObj.push(tempPathObj);
|
||||
}
|
||||
lastId = tempPathObj.id;
|
||||
nowPathObj = tempPathObj.children;
|
||||
if (index == keyArr.length - 1) {
|
||||
let tempPath = interfaceTemp;
|
||||
tempPathObj.children = null;
|
||||
tempPathObj.method = methods[j];
|
||||
tempPathObj.interface = tempPath;
|
||||
tempPathObj.application = application;
|
||||
treePathDataMap.set(tempPath, json[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// console.log(pathIndex);
|
||||
return pathIndex;
|
||||
},
|
||||
createTreeViewByTreeWithMerge(treePathDataMap, json, keywords) {
|
||||
let pathIndex = this.createTreeViewByTree(treePathDataMap, json, keywords);
|
||||
this.mergeNode(pathIndex);
|
||||
return pathIndex;
|
||||
},
|
||||
/**
|
||||
* 查找node节点
|
||||
*/
|
||||
findNode(arr, service) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i].label == service) {
|
||||
return arr[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
/**
|
||||
* 多层级合并
|
||||
*/
|
||||
mergeNode(node) {
|
||||
for (let i = 0; i < node.length; i++) {
|
||||
let tempNode = node[i];
|
||||
if (tempNode.children == null
|
||||
|| tempNode.children[0].children == null
|
||||
|| tempNode.children[0].children[0].children == null) {
|
||||
continue;
|
||||
}
|
||||
if (tempNode.children.length == 1) {
|
||||
tempNode.label = tempNode.label + "." + tempNode.children[0].label;
|
||||
tempNode.children = tempNode.children[0].children;
|
||||
i--;
|
||||
}
|
||||
this.mergeNode(tempNode.children);
|
||||
}
|
||||
},
|
||||
findInPathsValue(pathsValue, keywords) {
|
||||
if (!keywords) {
|
||||
return true;
|
||||
}
|
||||
keywords = keywords.toLowerCase();
|
||||
// 找路径和说明里面包含关键字的
|
||||
let interfaceX = pathsValue.interface;
|
||||
if (!!interfaceX && interfaceX.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (pathsValue.nodeList.length > 0) {
|
||||
for (let i = 0; i < pathsValue.nodeList.length; i++) {
|
||||
let node = pathsValue.nodeList[i];
|
||||
if (!!node.application && node.application.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (!!node.methods && node.methods.length > 0) {
|
||||
for (let j = 0; j < node.methods.length; j++) {
|
||||
let method = node.methods[j];
|
||||
if (method.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
let path = interfaceX + "." + method;
|
||||
let docInfo = app.dubboDocMap[path];
|
||||
if (!!docInfo) {
|
||||
if (!!docInfo.explain && docInfo.explain.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (!!docInfo.explain && docInfo.explain.toLowerCase().indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
125
zyplayer-doc-ui/dubbo-ui/src/common/js/format-json.js
Normal file
125
zyplayer-doc-ui/dubbo-ui/src/common/js/format-json.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* 将对象处理成json格式化和着色的html
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
let Formatjson = {
|
||||
// 需要在对象或列表后面添加注释的对象,例:{userList: "用户列表"}
|
||||
// 那么在名字为userList的对象或列表后面都会加上:“用户列表” 这个注释
|
||||
annotationObject: {},
|
||||
tabStr: " ",
|
||||
isArray: function (obj) {
|
||||
return obj && typeof obj === 'object' && typeof obj.length === 'number'
|
||||
&& !(obj.propertyIsEnumerable('length'));
|
||||
},
|
||||
processObjectToHtmlPre: function (obj, indent, addComma, isArray, isPropertyContent, showAnnotation) {
|
||||
var htmlStr = this.processObject(obj, "", indent, addComma, isArray, isPropertyContent, showAnnotation);
|
||||
htmlStr = '<pre class="json">' + htmlStr + '</pre>';
|
||||
return htmlStr;
|
||||
},
|
||||
processObject: function (obj, keyName, indent, addComma, isArray, isPropertyContent, showAnnotation) {
|
||||
var html = "";
|
||||
var comma = (addComma) ? "<span class='comma'>,</span> " : "";
|
||||
var type = typeof obj;
|
||||
if (this.isArray(obj)) {
|
||||
if (obj.length == 0) {
|
||||
html += this.getRow(indent, "<span class='array-brace'>[ ]</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
var clpsHtml = '<span><img class="option-img" src="webjars/doc-dubbo/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
var annotation = '';
|
||||
if (showAnnotation && !!keyName && !!this.annotationObject[keyName]) {
|
||||
annotation = '<span class="annotation">// ' + this.annotationObject[keyName] + '</span>';
|
||||
}
|
||||
html += this.getRow(indent, "<span class='array-brace'>[</span>" + clpsHtml + annotation, isPropertyContent);
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
html += this.processObject(obj[i], "", indent + 1, i < (obj.length - 1), true, false, showAnnotation);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='array-brace'>]</span>" + comma);
|
||||
}
|
||||
} else if (type == 'object' && obj == null) {
|
||||
html += this.formatLiteral("null", "", comma, indent, isArray, "null");
|
||||
} else if (type == 'object') {
|
||||
var numProps = 0;
|
||||
for (var prop in obj) {
|
||||
numProps++;
|
||||
}
|
||||
if (numProps == 0) {
|
||||
html += this.getRow(indent, "<span class='object-brace'>{ }</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
var clpsHtml = '<span><img class="option-img" src="webjars/doc-dubbo/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
var annotation = '';
|
||||
if (showAnnotation && !!keyName && !!this.annotationObject[keyName]) {
|
||||
annotation = '<span class="annotation">// ' + this.annotationObject[keyName] + '</span>';
|
||||
}
|
||||
html += this.getRow(indent, "<span class='object-brace'>{</span>" + clpsHtml + annotation, isPropertyContent);
|
||||
var j = 0;
|
||||
for (var prop in obj) {
|
||||
var processStr = '<span class="property-name">"' + prop + '"</span>: ' + this.processObject(obj[prop], prop, indent + 1, ++j < numProps, false, true, showAnnotation);
|
||||
html += this.getRow(indent + 1, processStr);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='object-brace'>}</span>" + comma);
|
||||
}
|
||||
} else if (type == 'number') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "number");
|
||||
} else if (type == 'boolean') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "boolean");
|
||||
} else if (type == 'function') {
|
||||
obj = this.formatFunction(indent, obj);
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "function");
|
||||
} else if (type == 'undefined') {
|
||||
html += this.formatLiteral("undefined", "", comma, indent, isArray, "null");
|
||||
} else {
|
||||
html += this.formatLiteral(obj, "\"", comma, indent, isArray, "string");
|
||||
}
|
||||
return html;
|
||||
},
|
||||
expImgClicked: function (img) {
|
||||
var container = img.parentNode.nextSibling;
|
||||
if (!container) return;
|
||||
var disp = "none";
|
||||
var src = "webjars/doc-dubbo/img/collapsed.png";
|
||||
if (container.style.display == "none") {
|
||||
disp = "inline";
|
||||
src = "webjars/doc-dubbo/img/expanded.png";
|
||||
}
|
||||
container.style.display = disp;
|
||||
img.src = src;
|
||||
},
|
||||
formatLiteral: function (literal, quote, comma, indent, isArray, style) {
|
||||
if (typeof literal == 'string') {
|
||||
literal = literal.split("<").join("<").split(">").join(">");
|
||||
}
|
||||
var str = "<span class='" + style + "'>" + quote + literal + quote + comma + "</span>";
|
||||
if (isArray) {
|
||||
str = this.getRow(indent, str);
|
||||
}
|
||||
return str;
|
||||
},
|
||||
formatFunction: function (indent, obj) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
var funcStrArray = obj.toString().split("\n");
|
||||
var str = "";
|
||||
for (var i = 0; i < funcStrArray.length; i++) {
|
||||
str += ((i == 0) ? "" : tabs) + funcStrArray[i] + "\n";
|
||||
}
|
||||
return str;
|
||||
},
|
||||
getRow: function (indent, data, isPropertyContent) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent && !isPropertyContent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
if (data != null && data.length > 0 && data.charAt(data.length - 1) != "\n") {
|
||||
data = data + "\n";
|
||||
}
|
||||
return tabs + data;
|
||||
}
|
||||
};
|
||||
window.Formatjson = Formatjson;
|
||||
export default Formatjson;
|
||||
|
||||
Reference in New Issue
Block a user