项目导入初始化
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
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;}
|
||||
#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;}
|
||||
.tab-online-debug-page{overflow-y: auto;position: absolute; bottom: 0;top: 10px; right: 0; left: 10px;}
|
||||
.tab-online-debug-page .title-info{padding-bottom: 10px;}
|
||||
.tab-online-debug-page .title-info .btn{margin-right: 20px;}
|
||||
.tab-online-debug-page .title-info .text{padding-bottom: 10px;}
|
||||
|
||||
.local-storage{display: none;}
|
||||
|
||||
/**lable的覆盖样式*/
|
||||
.label{font-size: 100%;}
|
||||
.label-warning {background-color: #f9f5ee; color: #f1a325;}
|
||||
label{font-weight: normal;}
|
||||
|
||||
.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;}
|
||||
|
||||
.mgresizebleW{z-index: 90;height: 100%; width: 10px; cursor: e-resize;}
|
||||
.ui-resizable-handle {display: block;font-size: 0.1px;position: absolute;}
|
||||
#resizebleLeftRight{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;}
|
||||
|
||||
#homePageLi{margin-top: 5px;}
|
||||
|
||||
.left-body{
|
||||
width: 360px; height:100%; position: fixed; top: 0; bottom: 0; left: 0;
|
||||
}
|
||||
.left-header{
|
||||
background: #3280fc;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;}
|
||||
|
||||
/* 在线调试框样式 */
|
||||
#tabParamBody .tab-content{padding-top: 10px;}
|
||||
|
||||
.post-url-box{padding: 10px 0;}
|
||||
.post-url-box .input-group-btn:nth-child(2) button{border-right: 0;border-radius: 0;}
|
||||
.post-url-box .send-request .hide{display: none;}
|
||||
|
||||
.param-box{}
|
||||
.param-box .panel-collapse{padding: 10px;}
|
||||
.param-box .nav{background-color: #f1f1f1;}
|
||||
/* .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: 10px 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 td:first-child{width: 250px;}
|
||||
.param-box .param-table tbody td:nth-child(2){border-right: 0;}
|
||||
.param-box .param-table tbody td:nth-child(3){border-left: 0;padding: 0 10px 0 0;width: 10px;}
|
||||
.param-box .param-table tbody td:nth-child(3) i{cursor: pointer;color: #ccc;}
|
||||
.param-box .param-table tbody td:nth-child(3) i:hover{color: #888;}
|
||||
.param-box .param-table tbody tr.base td:last-child{display: none;}
|
||||
#bulkEditHeaderCheck{margin-left: 10px;}
|
||||
#bulkEditHeader,#bulkEditForm{display: none;}
|
||||
|
||||
.response-box{margin-top: 20px;}
|
||||
.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: 10px 0;}
|
||||
/* 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展示的样式 */
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 340 B |
Binary file not shown.
|
After Width: | Height: | Size: 331 B |
@@ -0,0 +1,269 @@
|
||||
/**
|
||||
* 一些公用方法
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function deserialize(value) {
|
||||
if (typeof value !== 'string' || isEmpty(value)) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
try {
|
||||
return eval('(' + value + ')');// 处理变态的单双引号共存字符串
|
||||
} catch (e) {
|
||||
return value || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateResult(result) {
|
||||
if(result.errCode == 200) {
|
||||
return true;
|
||||
} else {
|
||||
Toast.error(result.errMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getNowDate() {
|
||||
var date = new Date();
|
||||
var month = date.getMonth() + 1;
|
||||
var strDate = date.getDate();
|
||||
if (month >= 1 && month <= 9) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (strDate >= 0 && strDate <= 9) {
|
||||
strDate = "0" + strDate;
|
||||
}
|
||||
var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
function getNowTime() {
|
||||
var date = new Date();
|
||||
var hours = date.getHours();
|
||||
var minutes = date.getMinutes();
|
||||
var seconds = date.getSeconds();
|
||||
if (hours >= 1 && hours <= 9) {
|
||||
hours = "0" + hours;
|
||||
}
|
||||
if (minutes >= 0 && minutes <= 9) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
if (seconds >= 0 && seconds <= 9) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
var currentdate = hours + ":" + minutes + ":" + seconds;
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
function getNowDateTime() {
|
||||
var currentdate = getNowDate() + " " + getNowTime();
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回不为空的字符串,为空返回def
|
||||
*/
|
||||
function getNotEmptyStr(str, def) {
|
||||
if (isEmpty(str)) {
|
||||
return isEmpty(def) ? "" : def;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空对象
|
||||
* @param obj
|
||||
* @returns
|
||||
*/
|
||||
function isEmptyObject(obj){
|
||||
return $.isEmptyObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isEmpty(str){
|
||||
return (str == "" || str == null || str == undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否不是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isNotEmpty(str){
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转字符串,使用空格分隔
|
||||
* @param array
|
||||
* @returns
|
||||
*/
|
||||
function arrToString(array){
|
||||
var temStr = "";
|
||||
if(isEmpty(array)){
|
||||
return temStr;
|
||||
}
|
||||
array.forEach(function(e){
|
||||
if(isNotEmpty(temStr)) {
|
||||
temStr += " ";
|
||||
}
|
||||
temStr += e;
|
||||
});
|
||||
return temStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组array中是否包含str字符串
|
||||
* @param array
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function haveString(array, str){
|
||||
if(isEmpty(array)) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if(array[i] == str) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回对象的第一个属性
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttribute(data) {
|
||||
for ( var key in data) {
|
||||
return data[key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果对象只有一个属性则返回第一个属性,否则返回null
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttributeIfOnly(data) {
|
||||
var len = 0, value = "";
|
||||
for ( var key in data) {
|
||||
if (++len > 1) {
|
||||
return null;
|
||||
}
|
||||
value = data[key];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax处理事件模板
|
||||
*
|
||||
* @url 后台处理的url,即action
|
||||
* @dataSentType 数据发送的方式,有post,get方式
|
||||
* @dataReceiveType 数据接收格式,有html json text等
|
||||
* @paramsStr 传入后台的参数
|
||||
* @successFunction ajax成功后执行的函数名 ajaxTemp("", "GET", "html", {}, function(){},
|
||||
* function(){}, "");
|
||||
*/
|
||||
function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||
$.ajax({
|
||||
url : url, // 后台处理程序
|
||||
sync : false,
|
||||
type : dataSentType, // 数据发送方式
|
||||
dataType : dataReceiveType, // 接受数据格式
|
||||
data : eval(paramsStr),
|
||||
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
success : function(msg) {
|
||||
if(typeof successFunction == "function") {
|
||||
successFunction(msg,id);
|
||||
}
|
||||
},
|
||||
beforeSend : function() {
|
||||
|
||||
},
|
||||
complete : function(msg) {
|
||||
if(typeof completeFunction == "function") {
|
||||
completeFunction(msg,id);
|
||||
}
|
||||
},
|
||||
error : function(msg) {
|
||||
if(typeof errorFunction == "function") {
|
||||
errorFunction(msg,id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cookie
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
function getCookie(name) {
|
||||
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||
if(arr=document.cookie.match(reg)){
|
||||
return unescape(arr[2]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串格式化
|
||||
*/
|
||||
String.prototype.format = function(args) {
|
||||
if (arguments.length > 0) {
|
||||
var result = this;
|
||||
if (arguments.length == 1 && typeof (args) == "object") {
|
||||
for ( var key in args) {
|
||||
var reg = new RegExp("({" + key + "})", "g");
|
||||
result = result.replace(reg, args[key]);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] == undefined) {
|
||||
return "";
|
||||
} else {
|
||||
var reg = new RegExp("({[" + i + "]})", "g");
|
||||
result = result.replace(reg, arguments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
String.prototype.endWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substring(this.length - str.length) == str);
|
||||
};
|
||||
|
||||
String.prototype.startWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substr(0, str.length) == str);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
|
||||
/**
|
||||
* 将对象处理成json格式化和着色的html
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var 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/mg-ui/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
var annotation = '';
|
||||
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(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/mg-ui/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
var annotation = '';
|
||||
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(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/mg-ui/img/collapsed.png";
|
||||
if(container.style.display == "none"){
|
||||
disp = "inline";
|
||||
src = "webjars/mg-ui/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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
4
zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/jquery-3.1.0.min.js
vendored
Normal file
4
zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/jquery-3.1.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,646 @@
|
||||
/**
|
||||
* 在线调试页面js
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年7月20日
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#debugRequstType .dropdown-menu li").click(function(){
|
||||
var text = $(this).find("a").text();
|
||||
$("#debugRequstType .options").text(text);
|
||||
});
|
||||
/**
|
||||
* 保存参数模板
|
||||
* @returns
|
||||
*/
|
||||
$(".save-request-template").click(function(){
|
||||
Toast.notOpen();
|
||||
});
|
||||
/**
|
||||
* 发送请求
|
||||
* @returns
|
||||
*/
|
||||
$(".send-request").click(function(){
|
||||
// 多行编辑状态下转成表单,下面读取表单内容
|
||||
if($("#bulkEditFormCheck").prop('checked')) {
|
||||
var bulkEdit = $("#bulkEditForm").val();
|
||||
bulkEditToTable("#tabParamTypeForm", bulkEdit);
|
||||
}
|
||||
if($("#bulkEditHeaderCheck").prop('checked')) {
|
||||
var bulkEdit = $("#bulkEditHeader").val();
|
||||
bulkEditToTable("#tabParamHeader", bulkEdit);
|
||||
}
|
||||
$("#tabResponseHeader table tbody").empty();
|
||||
$("#tabResponseCookie table tbody").empty();
|
||||
$("#responseBodyTextArea").val("");
|
||||
$("#responseBodyJsonDiv").html("暂无数据");
|
||||
|
||||
var storeRequestParam = {};
|
||||
var docUrl = $("#docUrl").text();
|
||||
var options = $("#debugRequstType .btn .options").text();
|
||||
var postUrl = $("#postUrlInput").val();
|
||||
var requestHeaderForm = $("#requestHeaderForm").serializeArray();
|
||||
var requestParamForm = $("#requestParamForm").serializeArray();
|
||||
var paramBodySend = $("[name=paramBody]").val();
|
||||
var formToUrl = $("[name=formToUrl]").prop('checked') ? 1 : 0;
|
||||
var paramSendToServer = {};
|
||||
requestHeaderForm = serializeArrayToObj(requestHeaderForm);
|
||||
requestParamForm = serializeArrayToObj(requestParamForm);
|
||||
storeRequestParam.formToUrl = formToUrl;
|
||||
paramSendToServer.formToUrl = formToUrl;
|
||||
if(isNotEmpty(paramBodySend)) {
|
||||
try {
|
||||
paramBodySend = JSON.stringify(JSON.parse(paramBodySend));
|
||||
} catch (e) {
|
||||
// e
|
||||
}
|
||||
storeRequestParam.body = paramBodySend;
|
||||
paramSendToServer.body = paramBodySend;
|
||||
// 替换path参数
|
||||
Object.keys(requestParamForm).forEach(function(key){
|
||||
postUrl = postUrl.replace("{"+key+"}", requestParamForm[key]);
|
||||
});
|
||||
} else {
|
||||
var reqParamStr = "";
|
||||
paramBodySend = {};
|
||||
Object.keys(requestParamForm).forEach(function(key){
|
||||
var value = requestParamForm[key];
|
||||
if(isNotEmpty(key) && isNotEmpty(value)) {
|
||||
if(isNotEmpty(reqParamStr)) {
|
||||
reqParamStr += "&";
|
||||
}
|
||||
reqParamStr += key + "=" + value;
|
||||
paramBodySend[key] = value;
|
||||
// 替换path参数
|
||||
postUrl = postUrl.replace("{"+key+"}", value);
|
||||
}
|
||||
});
|
||||
storeRequestParam.form = paramBodySend;
|
||||
if(formToUrl == 1) {
|
||||
postUrl += "?" + reqParamStr;
|
||||
paramBodySend = "";
|
||||
} else {
|
||||
paramSendToServer.form = JSON.stringify(paramBodySend);
|
||||
}
|
||||
}
|
||||
$(".send-request .icon").removeClass("hide");
|
||||
// 获取header
|
||||
var requestHeaderStore = {};
|
||||
Object.keys(requestHeaderForm).forEach(function(key){
|
||||
var value = requestHeaderForm[key];
|
||||
if(isNotEmpty(key) && isNotEmpty(value)) {
|
||||
requestHeaderStore[key] = value;
|
||||
}
|
||||
});
|
||||
storeRequestParam.header = requestHeaderStore;
|
||||
paramSendToServer.header = JSON.stringify(requestHeaderStore);
|
||||
//console.log(paramBodySend);
|
||||
var beforSendTime = new Date().getTime();
|
||||
if(serverStorage) {
|
||||
paramSendToServer.url = postUrl;
|
||||
paramSendToServer.method = options;
|
||||
ajaxTemp("swagger-mg-ui/http/request", "post", "json", paramSendToServer, function(result){
|
||||
//console.log(result);
|
||||
setStorage('p-request-obj-' + docUrl, storeRequestParam);
|
||||
var afterSendTime = new Date().getTime();
|
||||
$("#httpRequestStatus").text(result.status);
|
||||
$("#httpRequestTime").text((afterSendTime - beforSendTime) + "ms");
|
||||
try {
|
||||
var htmlStr = Formatjson.processObjectToHtmlPre(JSON.parse(result.data), 0, false, false, false, false);
|
||||
$("#responseBodyJsonDiv").html(htmlStr);
|
||||
} catch (e) {
|
||||
$("#responseBodyJsonDiv").html("<iframe id='responseBodyJsonIframe'></iframe>");
|
||||
setTimeout(function(){
|
||||
$("#responseBodyJsonIframe").contents().find("body").html(result.data);
|
||||
}, 300);
|
||||
}
|
||||
$("#tabResponseHeader table tbody").empty();
|
||||
$("#tabResponseCookie table tbody").empty();
|
||||
var headers = result.header||[];
|
||||
for (var i = 0; i < headers.length; i++) {
|
||||
var name = getNotEmptyStr(headers[i].name);
|
||||
var value = getNotEmptyStr(headers[i].value);
|
||||
$("#tabResponseHeader table tbody").append(
|
||||
'<tr>'+'<td>'+name+'</td>' + '<td>'+value+'</td>'+'</tr>'
|
||||
);
|
||||
}
|
||||
var cookies = result.cookie||[];
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var name = getNotEmptyStr(cookies[i].name);
|
||||
var value = getNotEmptyStr(cookies[i].value);
|
||||
$("#tabResponseCookie table tbody").append(
|
||||
'<tr>'+'<td>'+name+'</td>' + '<td>'+value+'</td>'+'</tr>'
|
||||
);
|
||||
}
|
||||
}, function(){
|
||||
Toast.error("请求失败!");
|
||||
}, function(){
|
||||
$(".send-request .icon").addClass("hide");
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url : postUrl,
|
||||
sync : false,
|
||||
type : options, // 数据发送方式
|
||||
dataType : "JSON", // 接受数据格式
|
||||
data : paramBodySend,//requestParamForm,
|
||||
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
beforeSend : function(request) {
|
||||
Object.keys(requestHeaderStore).forEach(function(key){
|
||||
request.setRequestHeader(key, requestHeaderStore[key]);
|
||||
});
|
||||
},
|
||||
success : function(data, status, xhr) {
|
||||
},
|
||||
complete : function(xhr) {
|
||||
//console.log(xhr);
|
||||
setStorage('p-request-obj-' + docUrl, storeRequestParam);
|
||||
$(".send-request .icon").addClass("hide");
|
||||
var afterSendTime = new Date().getTime();
|
||||
$("#httpRequestStatus").text(xhr.status + "-" + xhr.statusText);
|
||||
$("#httpRequestTime").text((afterSendTime - beforSendTime) + "ms");
|
||||
try {
|
||||
var htmlStr = Formatjson.processObjectToHtmlPre(JSON.parse(xhr.responseText), 0, false, false, false, false);
|
||||
$("#responseBodyJsonDiv").html(htmlStr);
|
||||
} catch (e) {
|
||||
$("#responseBodyJsonDiv").html("<iframe id='responseBodyJsonIframe'></iframe>");
|
||||
setTimeout(function(){
|
||||
$("#responseBodyJsonIframe").contents().find("body").html(xhr.responseText);
|
||||
}, 300);
|
||||
}
|
||||
var allHeaders = xhr.getAllResponseHeaders();
|
||||
var headers = allHeaders.split("\r\n");
|
||||
$("#tabResponseHeader table tbody").empty();
|
||||
$("#tabResponseCookie table tbody").empty();
|
||||
for (var i = 0; i < headers.length; i++) {
|
||||
if(isEmpty(headers[i])){
|
||||
continue;
|
||||
}
|
||||
var headerArr = headers[i].split(":");
|
||||
$("#tabResponseHeader table tbody").append(
|
||||
'<tr>'+'<td>'+headerArr[0]+'</td>' + '<td>'+headerArr[1]+'</td>'+'</tr>'
|
||||
);
|
||||
}
|
||||
},
|
||||
error : function(data) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 输入框输入之后,如果是最后一行则在增加一行
|
||||
* @returns
|
||||
*/
|
||||
$(".param-table").on("keyup", "input[name=paramName]", function(){
|
||||
var nextTr = $(this).parents("tr").next();
|
||||
if(nextTr.length <= 0) {
|
||||
$(this).parents(".param-table").append(getParamTableTr());
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 参数删除一行
|
||||
* @returns
|
||||
*/
|
||||
$(".param-table").on("click", ".icon-times", function(){
|
||||
$(this).parents("tr").remove();
|
||||
});
|
||||
/**
|
||||
* 在线调试管理
|
||||
*/
|
||||
$("#onlineDebugLi").click(function(){
|
||||
$(".tab-page").hide();
|
||||
$(".tab-online-debug-page").show();
|
||||
createOnlineDebugParamTable();
|
||||
});
|
||||
/**
|
||||
* 在线调试管理-刷新
|
||||
*/
|
||||
$(".tab-online-debug-page .refresh").click(function(){
|
||||
createOnlineDebugParamTable();
|
||||
});
|
||||
/**
|
||||
* 在线调试管理-展开所有
|
||||
*/
|
||||
$(".tab-online-debug-page .expand-all").click(function(){
|
||||
$("#onlineDebugParamTable .option-img").attr("src", "webjars/mg-ui/img/expanded.png")
|
||||
$("#onlineDebugParamTable .option-img").parent().next().show();
|
||||
});
|
||||
/**
|
||||
* 在线调试管理-收起所有
|
||||
*/
|
||||
$(".tab-online-debug-page .collapse-all").click(function(){
|
||||
$("#onlineDebugParamTable .option-img").attr("src", "webjars/mg-ui/img/collapsed.png")
|
||||
$("#onlineDebugParamTable .option-img").parent().next().hide();
|
||||
});
|
||||
/**
|
||||
* 在线调试-删除所有参数
|
||||
*/
|
||||
$(".tab-online-debug-page").on("click", ".del-all-param", function(){
|
||||
$.zui.store.forEach(function(key, value) {// 遍历所有本地存储的条目
|
||||
if(!key.startWith('p-request-obj-')) {
|
||||
return;
|
||||
}
|
||||
$.zui.store.remove(key);
|
||||
});
|
||||
createOnlineDebugParamTable();
|
||||
});
|
||||
/**
|
||||
* 在线调试-删除参数
|
||||
*/
|
||||
$(".tab-online-debug-page").on("click", ".del-param", function(){
|
||||
var key = $(this).attr("key");
|
||||
if(isNotEmpty(key)) {
|
||||
$.zui.store.remove(key);
|
||||
$(this).parents("tr").remove();
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 提交模拟返回值
|
||||
*/
|
||||
$("#simulationResultSubmit").click(function(){
|
||||
if(!serverStorage) {
|
||||
Toast.error("没有开启服务器端存储模拟返回是无效的");
|
||||
return;
|
||||
}
|
||||
var value = $("#simulationResultText").val();
|
||||
value = getNotEmptyStr(value, "");
|
||||
var docUrl = $("#simulationResultUrl").text();
|
||||
setStorage('p-simulation-response-' + docUrl, value, function() {
|
||||
Toast.warn("提交成功!");
|
||||
}, function(msg) {
|
||||
Toast.error("提交失败!" + msg);
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 获取模拟返回值
|
||||
*/
|
||||
$("#simulationResultGet").click(function(){
|
||||
if(!serverStorage) {
|
||||
Toast.error("没有开启服务器端存储模拟返回是无效的");
|
||||
return;
|
||||
}
|
||||
var docUrl = $("#simulationResultUrl").text();
|
||||
getStorage('p-simulation-response-' + docUrl, function(data){
|
||||
$("#simulationResultText").val(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 生成在线调试管理页面
|
||||
* @returns
|
||||
*/
|
||||
function createOnlineDebugParamTable() {
|
||||
$("#onlineDebugParamTable tbody").empty();
|
||||
$.zui.store.forEach(function(key, value) {// 遍历所有本地存储的条目
|
||||
if(!key.startWith('p-request-obj-')) {
|
||||
return;
|
||||
}
|
||||
var newKey = key.substring(14, key.length);
|
||||
var htmlStr = Formatjson.processObjectToHtmlPre(value, 0, false, false, false, false);
|
||||
$("#onlineDebugParamTable tbody").append(
|
||||
'<tr>'
|
||||
+'<td>'+newKey+'</td>'
|
||||
+'<td>'+htmlStr+'</td>'
|
||||
+'<td><button class="btn btn-danger del-param" type="button" key="'+key+'">删除</button></td>'
|
||||
+'</tr>'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成在线调试相关数据
|
||||
* @param requestParamObj
|
||||
* @returns
|
||||
*/
|
||||
function createOnlineDebugRequestParam(requestParamObj, url) {
|
||||
getStorage('p-request-obj-' + url, function(data) {
|
||||
createOnlineDebugRequestParamFun(data, requestParamObj, url);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成在线调试相关数据
|
||||
* @param requestParamObj
|
||||
* @returns
|
||||
*/
|
||||
function createOnlineDebugRequestParamFun(pRequestObj, requestParamObj, url) {
|
||||
if(isEmptyObject(pRequestObj)) {
|
||||
pRequestObj = {};
|
||||
}
|
||||
// 清空参数列表
|
||||
$("#tabParamHeader table tbody .new").remove();
|
||||
$("#tabParamTypeForm table tbody .new").remove();
|
||||
$("#tabResponseHeader table tbody").empty();
|
||||
$("#tabResponseCookie table tbody").empty();
|
||||
$("#tabParamHeader .form-control").val("");
|
||||
$("#tabParamTypeForm .form-control").val("");
|
||||
$("#responseBodyTextArea").val("");
|
||||
$("#responseBodyJsonDiv").html("暂无数据");
|
||||
$("#bulkEditHeaderCheck").prop("checked", false);
|
||||
$("#bulkEditFormCheck").prop("checked", false);
|
||||
$("#bulkEditHeader,#bulkEditForm").hide();
|
||||
$("#tabParamTypeForm table").show();
|
||||
$("#requestHeaderForm table").show();
|
||||
|
||||
var options = $("#debugRequstType .btn .options").text();
|
||||
var formToUrl = pRequestObj.formToUrl || 0;
|
||||
var formToUrlChecked = (options != "GET" && formToUrl == 1);
|
||||
$("input[name='formToUrl']").prop("checked", formToUrlChecked);
|
||||
|
||||
var onlyUseLastParam = (userSettings.onlyUseLastParam == 1);
|
||||
var onlyUseLastHeader = onlyUseLastParam && !isEmptyObject(pRequestObj.header);
|
||||
var onlyUseLastForm = onlyUseLastParam && !isEmptyObject(pRequestObj.form);
|
||||
var onlyUseLastBody = onlyUseLastParam && !isEmptyObject(pRequestObj.body);
|
||||
var headerValueCount = 0, formValueCount = 0;
|
||||
Object.keys(requestParamObj).forEach(function(key){
|
||||
var tempParam = requestParamObj[key];
|
||||
if (key == "p-body-obj") {
|
||||
//console.log(tempParam);
|
||||
var paramObj = onlyUseLastBody ? {} : getParamBodyTransObj(tempParam);
|
||||
var bodyObj = pRequestObj.body;
|
||||
try {
|
||||
bodyObj = JSON.parse(bodyObj);
|
||||
if(!isEmptyObject(bodyObj)) {
|
||||
paramObj = $.extend(true, paramObj, bodyObj);
|
||||
}
|
||||
$("#tabParamTypeBody textarea").val(JSON.stringify(paramObj, null, 4));
|
||||
} catch (e) {
|
||||
var tempText = isEmpty(bodyObj) ? JSON.stringify(paramObj, null, 4) : bodyObj;
|
||||
$("#tabParamTypeBody textarea").val(tempText);
|
||||
}
|
||||
$("#tabParamBody .nav li").eq(1).find("a").click();
|
||||
} else {
|
||||
if (tempParam.paramIn == "header" && !onlyUseLastHeader) {
|
||||
//console.log(tempParam);
|
||||
var headerVal = getNotEmptyStr(tempParam.value);
|
||||
var headerObj = pRequestObj.header;
|
||||
if(!isEmptyObject(headerObj) && isNotEmpty(headerObj[key])) {
|
||||
headerVal = headerObj[key];
|
||||
headerObj[key] = "";// 赋值为空,后面不再使用
|
||||
}
|
||||
if(isEmpty(headerVal)) {
|
||||
headerVal = getAutoFillValue(tempParam.paramType, key);
|
||||
}
|
||||
if(headerValueCount > 0) {
|
||||
$("#tabParamHeader table tbody").append(getParamTableTr(key, headerVal, "", tempParam.paramDesc));
|
||||
} else {
|
||||
$("#tabParamHeader table tbody .base input[name=paramName]").val(key);
|
||||
$("#tabParamHeader table tbody .base input[name=paramValue]").val(headerVal);
|
||||
$("#tabParamHeader table tbody .base input[name=paramValue]").attr("placeholder", getNotEmptyStr(tempParam.paramDesc));
|
||||
}
|
||||
headerValueCount++;
|
||||
} else {
|
||||
// 只有这几种类型,列出来后面看单独处理不
|
||||
var paramInForm = (tempParam.paramIn == "query")
|
||||
|| (tempParam.paramIn == "path")
|
||||
|| (tempParam.paramIn == "body")
|
||||
|| (tempParam.paramIn == "form")
|
||||
|| isNotEmpty(tempParam.paramIn);
|
||||
if (paramInForm && !onlyUseLastForm) {
|
||||
//console.log(tempParam);
|
||||
var formVal = getNotEmptyStr(tempParam.value);
|
||||
var formObj = pRequestObj.form;
|
||||
if(!isEmptyObject(formObj) && isNotEmpty(formObj[key])) {
|
||||
formVal = formObj[key];
|
||||
formObj[key] = "";// 赋值为空,后面不再使用
|
||||
}
|
||||
if(isEmpty(formVal)) {
|
||||
formVal = getAutoFillValue(tempParam.paramType, key);
|
||||
}
|
||||
if(formValueCount > 0) {
|
||||
$("#tabParamTypeForm table tbody").append(getParamTableTr(key, formVal, "", tempParam.paramDesc));
|
||||
} else {
|
||||
$("#tabParamTypeForm table tbody .base input[name=paramName]").val(key);
|
||||
$("#tabParamTypeForm table tbody .base input[name=paramValue]").val(formVal);
|
||||
$("#tabParamTypeForm table tbody .base input[name=paramValue]").attr("placeholder", getNotEmptyStr(tempParam.paramDesc));
|
||||
}
|
||||
$("#tabParamBody .nav li").eq(0).find("a").click();
|
||||
formValueCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 处理参数外的header
|
||||
var headerObj = pRequestObj.header;
|
||||
if(!isEmptyObject(headerObj)) {
|
||||
Object.keys(headerObj).forEach(function(key){
|
||||
if(isNotEmpty(headerObj[key])) {
|
||||
if(headerValueCount > 0) {
|
||||
$("#tabParamHeader table tbody").append(getParamTableTr(key, headerObj[key], "", ""));
|
||||
} else {
|
||||
$("#tabParamHeader table tbody .base input[name=paramName]").val(key);
|
||||
$("#tabParamHeader table tbody .base input[name=paramValue]").val(headerObj[key]);
|
||||
}
|
||||
headerValueCount++;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 处理参数外的form
|
||||
var formObj = pRequestObj.form;
|
||||
if(!isEmptyObject(formObj)) {
|
||||
Object.keys(formObj).forEach(function(key){
|
||||
if(isNotEmpty(formObj[key])) {
|
||||
if(formValueCount > 0) {
|
||||
$("#tabParamTypeForm table tbody").append(getParamTableTr(key, formObj[key], "", ""));
|
||||
} else {
|
||||
$("#tabParamTypeForm table tbody .base input[name=paramName]").val(key);
|
||||
$("#tabParamTypeForm table tbody .base input[name=paramValue]").val(formObj[key]);
|
||||
}
|
||||
formValueCount++;
|
||||
}
|
||||
});
|
||||
}
|
||||
if(headerValueCount > 0) {
|
||||
$("#tabParamHeader table tbody").append(getParamTableTr("", "", "", ""));
|
||||
}
|
||||
if(formValueCount > 0) {
|
||||
$("#tabParamTypeForm table tbody").append(getParamTableTr("", "", "", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取测试的对象
|
||||
*/
|
||||
function getParamBodyTransObj(paramObj) {
|
||||
var newObject = $.extend(true, {}, paramObj);
|
||||
Object.keys(newObject).forEach(function(key){
|
||||
var subObj = newObject[key];
|
||||
if(typeof subObj == 'object') {
|
||||
if (subObj.hasOwnProperty("isParamObj")) {
|
||||
var value = getNotEmptyStr(subObj.value);
|
||||
if(isEmpty(value) && isNotEmpty(subObj.paramType)) {
|
||||
value = getAutoFillValue(subObj.paramType, key);
|
||||
}
|
||||
newObject[key] = value;
|
||||
} else if(subObj instanceof Array) {
|
||||
subObj[0] = getParamBodyTransObj(subObj[0]);
|
||||
} else {
|
||||
newObject[key] = getParamBodyTransObj(subObj);
|
||||
}
|
||||
}
|
||||
});
|
||||
return newObject;
|
||||
}
|
||||
|
||||
function serializeArrayToBulkEdit(formArr) {
|
||||
var formObj = serializeArrayToObj(formArr);
|
||||
var formStr = "";
|
||||
Object.keys(formObj).forEach(function(key){
|
||||
formStr += key + ":" + formObj[key] + "\n";
|
||||
});
|
||||
return formStr;
|
||||
}
|
||||
|
||||
function serializeArrayToObj(formArr) {
|
||||
var paramObj = {};
|
||||
for (var i = 0; i < formArr.length; i++) {
|
||||
if (formArr[i].name == "paramName" && i < formArr.length) {
|
||||
var key = formArr[i].value;
|
||||
var value = formArr[i+1].value;
|
||||
if(isNotEmpty(key)) {
|
||||
paramObj[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return paramObj;
|
||||
}
|
||||
|
||||
function bulkEditToTable(tableId, bulkEdit) {
|
||||
$(tableId + " table tbody .new").remove();
|
||||
var valueCount = 0;
|
||||
var headerArr = bulkEdit.split("\n");
|
||||
for (var i = 0; i < headerArr.length; i++) {
|
||||
var index = headerArr[i].indexOf(":");
|
||||
if(index < 0) {
|
||||
continue;
|
||||
}
|
||||
var key = headerArr[i].substring(0, index);
|
||||
var value = headerArr[i].substring(index+1, headerArr[i].length);
|
||||
if(valueCount > 0) {
|
||||
$(tableId + " table tbody").append(getParamTableTr(key, value, "", ""));
|
||||
} else {
|
||||
$(tableId + " table tbody .base input[name=paramName]").val(key);
|
||||
$(tableId + " table tbody .base input[name=paramValue]").val(value);
|
||||
}
|
||||
valueCount++;
|
||||
}
|
||||
if(valueCount > 0) {
|
||||
$(tableId + " table tbody").append(getParamTableTr("", "", "", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数的tr
|
||||
* @param name
|
||||
* @param value
|
||||
* @param namePl
|
||||
* @param valuePl
|
||||
* @returns
|
||||
*/
|
||||
function getParamTableTr(name, value, namePl, valuePl) {
|
||||
name = getNotEmptyStr(name);
|
||||
namePl = getNotEmptyStr(namePl);
|
||||
value = getNotEmptyStr(value);
|
||||
valuePl = getNotEmptyStr(valuePl);
|
||||
|
||||
var regExp = new RegExp("\"", "gm");
|
||||
name = (typeof name === 'string') ? name.replace(regExp, """) : name;
|
||||
namePl = (typeof namePl === 'string') ? namePl.replace(regExp, """) : namePl;
|
||||
value = (typeof value === 'string') ? value.replace(regExp, """) : value;
|
||||
valuePl = (typeof valuePl === 'string') ? valuePl.replace(regExp, """) : valuePl;
|
||||
var resultStr =
|
||||
'<tr class="new">'
|
||||
+'<td><input type="text" class="form-control" name="paramName" value="'+name+'" placeholder="'+namePl+'"></td>'
|
||||
+'<td><input type="text" class="form-control" name="paramValue" value="'+value+'" placeholder="'+valuePl+'"></td>'
|
||||
+'<td><i class="icon-times"></i></td>'
|
||||
+'</tr>';
|
||||
return resultStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自动填充的值
|
||||
* @param paramType
|
||||
* @returns
|
||||
*/
|
||||
function getAutoFillValue(paramType, paramName) {
|
||||
if(userSettings.autoFillParam == 0 || isEmpty(paramType)) {
|
||||
return "";
|
||||
}
|
||||
paramName = getNotEmptyStr(paramName).toLowerCase();
|
||||
var isTimeColumn = (paramType.indexOf("date-time") >= 0
|
||||
|| paramName.endWith("date") || paramName.endWith("time"));
|
||||
var isTypeColumn = (paramName.endWith("type") || paramName.endWith("status")
|
||||
|| paramName.endWith("level") || paramName.endWith("num"));
|
||||
var isPriceColumn = (paramName.endWith("money") || paramName.endWith("price")
|
||||
|| paramName.endWith("cash") || paramName.endWith("coin"));
|
||||
var isBooleanColumn = (paramName.startWith("is"));
|
||||
var resultValue = "";
|
||||
if(paramType.indexOf("int") >= 0){
|
||||
if(isTypeColumn) {
|
||||
resultValue = Math.ceil(Math.random() * 5);
|
||||
} else if(paramName.endWith("age")) {
|
||||
resultValue = Math.ceil(Math.random() * 100);
|
||||
} else {
|
||||
resultValue = Math.ceil(Math.random() * 100);
|
||||
}
|
||||
} else if(paramType.indexOf("double") >= 0){
|
||||
resultValue = Math.ceil(Math.random() * 1000);
|
||||
} else if(paramType.indexOf("float") >= 0){
|
||||
resultValue = parseFloat(Math.random() * 1000).toFixed(2);
|
||||
} else if(paramType.indexOf("byte") >= 0){
|
||||
if(isTypeColumn) {
|
||||
resultValue = Math.ceil(Math.random() * 5);
|
||||
} else {
|
||||
resultValue = Math.ceil(Math.random() * 127);
|
||||
}
|
||||
} else if(paramType.indexOf("boolean") >= 0){
|
||||
resultValue = Math.random() > 0.5;
|
||||
} else if(isTimeColumn){
|
||||
resultValue = getNowDateTime();
|
||||
} else {
|
||||
if(paramName.endWith("id")) {
|
||||
resultValue = Math.ceil(Math.random() * 1000);
|
||||
} else if(paramName.endWith("age")) {
|
||||
resultValue = Math.ceil(Math.random() * 100);
|
||||
} else if(isPriceColumn){
|
||||
resultValue = parseFloat(Math.random() * 1000).toFixed(2);
|
||||
} else if(isTypeColumn){
|
||||
resultValue = Math.ceil(Math.random() * 5);
|
||||
} else if(isBooleanColumn){
|
||||
resultValue = (Math.random() > 0.5) ? 0 : 1;
|
||||
} else if(paramName.endWith("phone") || paramName.endWith("mobile")){
|
||||
var arr = ["15226645814", "15226645815", "15226645816", "15226645817", "15226645818"];
|
||||
resultValue = arr[Math.ceil(Math.random() * 5) - 1];
|
||||
} else if(paramName.endWith("ids")){
|
||||
var counts = Math.ceil(Math.random() * 5);
|
||||
for (var i = 0; i < counts; i++) {
|
||||
if(isNotEmpty(resultValue)){resultValue += ",";}
|
||||
resultValue += Math.ceil(Math.random() * 1000);
|
||||
}
|
||||
} else if(paramName.endWith("types")){
|
||||
var counts = Math.ceil(Math.random() * 3);
|
||||
for (var i = 0; i < counts; i++) {
|
||||
if(isNotEmpty(resultValue)){resultValue += ",";}
|
||||
resultValue += Math.ceil(Math.random() * 5);
|
||||
}
|
||||
} else if(paramName.endWith("md5")){
|
||||
resultValue = "5082079d92a8ef985f59e001d445ff20";
|
||||
} else if(paramName.endWith("photo")){
|
||||
resultValue = "http://www.zyplayer.com/freeplay/img/headIcon/myhead.jpg";
|
||||
} else if(paramName.endWith("url") || paramName.endWith("uri")){
|
||||
var arr = ["http://www.zyplayer.com", "http://www.kongjianzhou.com"];
|
||||
resultValue = arr[Math.ceil(Math.random() * 2) - 1];
|
||||
} else if(paramName.endWith("username")){
|
||||
var arr = ["张三", "李四", "王二", "暮光:城中城", "海贼王"];
|
||||
resultValue = arr[Math.ceil(Math.random() * 5) - 1];
|
||||
} else if(userSettings.autoFillParam == 2){
|
||||
//var arr = ["您好!","请!","对不起。","谢谢!","再见!","您早!","晚安!","请问您贵姓?","请原谅!","不用谢!","没关系!","欢迎您光临!","请坐!","请喝茶!","请多关照!","请多指教!","谢谢您的合作!","对不起,让您久等了。","没关系,我刚到。","给您添麻烦了。","我能为您做什么?","您好,请问您需要帮助吗?","您走好。","请慢走!"];
|
||||
//resultValue = arr[Math.ceil(Math.random() * 24) - 1];
|
||||
resultValue = "我是默认字符串";
|
||||
}
|
||||
//console.log(paramType);
|
||||
}
|
||||
return resultValue;
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* 以每个Tag方式生成并展示:
|
||||
* 核心信息控制器
|
||||
* /api/data/getDataList
|
||||
* /api/data/getDataDetail
|
||||
* 跟进控制器
|
||||
* /api/track/getTrackList
|
||||
* /api/track/getTrackDetail
|
||||
*
|
||||
* 先把树形的写完了再写这个,,
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年5月26日
|
||||
*/
|
||||
|
||||
function createTreeViewByTag(json, keywords) {
|
||||
var pathIndex = {};
|
||||
var paths = json.paths;
|
||||
var domain = json.domainUrl;// 服务器代理会返回此属性
|
||||
if(isEmpty(domain)) {
|
||||
domain = "http://" + json.host + json.basePath;
|
||||
}
|
||||
if(domain.endWith("/")) {
|
||||
domain = domain.substring(0, domain.length - 1);
|
||||
}
|
||||
if (isEmptyObject(paths)) {
|
||||
return;
|
||||
}
|
||||
//console.log(paths);
|
||||
Object.keys(paths).forEach(function(key){
|
||||
//console.log(key, paths[key]);
|
||||
if(!findInPathsValue(key, paths[key], keywords)) {
|
||||
return;
|
||||
}
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "get");
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "head");
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "post");
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "put");
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "patch");
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "delete");
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "options");
|
||||
setRequestMethodForTag(domain, paths[key], pathIndex, key, "trace");
|
||||
});
|
||||
//console.log(pathIndex);
|
||||
var htmlStr = '<li>';
|
||||
htmlStr += '<a href="#">'+json.info.title+'</a>';
|
||||
htmlStr += '<ul>';
|
||||
htmlStr += getTreeHtmlForTag(pathIndex, projectTreeIdIndex);
|
||||
htmlStr += '</ul>';
|
||||
htmlStr += '</li>';
|
||||
$('#apiPathTree .projects').append(htmlStr);
|
||||
projectTreeIdIndex++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置对象的各种请求方式,存在则复制
|
||||
* @param source 资源,原始json的paths的指定对象
|
||||
* @param pathObj 当前的待赋值对象
|
||||
* @param url url绝对路径
|
||||
* @param method 请求方式,post、get...
|
||||
* @returns
|
||||
*/
|
||||
function setRequestMethodForTag(domain, source, pathObj, url, method) {
|
||||
if (isEmpty(source[method])) {
|
||||
return;
|
||||
}
|
||||
source[method].tags.forEach(function(val, index) {
|
||||
var tempObj = pathObj[val];
|
||||
if(isEmpty(tempObj)) {
|
||||
tempObj = pathObj[val] = {};
|
||||
}
|
||||
var tempUrlObj = tempObj[url];
|
||||
if(isEmpty(tempUrlObj)) {
|
||||
tempUrlObj = tempObj[url] = {};
|
||||
}
|
||||
var tempPath = projectTreeIdIndex + url + "." + method;
|
||||
tempUrlObj[method] = source[method];
|
||||
tempUrlObj[method].path = tempPath;
|
||||
tempUrlObj[method].url = url;
|
||||
tempUrlObj[method].method = method;
|
||||
tempUrlObj[method].domain = domain;
|
||||
treePathDataMap.set(tempPath, source[method]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象列表递归的方式转换成文档格式html字符串
|
||||
* @param pathData 处理后的对象列表
|
||||
* @returns 生成的html字符串
|
||||
*/
|
||||
function getTreeHtmlForTag(pathData, treeIdStr) {
|
||||
var tempStr = "";
|
||||
var indexNow = 1;
|
||||
// get, head, post, put, patch, delete, options, trace
|
||||
var actionArrays = ["get", "head", "post", "put", "patch", "delete", "options", "trace"];
|
||||
Object.keys(pathData).forEach(function(key){
|
||||
var tempNode = pathData[key];
|
||||
var tempTreeId = treeIdStr + "_" + indexNow;
|
||||
// 只有一个子元素,而且有method元素,说明是只有一个节点
|
||||
var nodeSub = getObjectFirstAttributeIfOnly(tempNode);
|
||||
if(nodeSub != null && isNotEmpty(nodeSub.method)) {
|
||||
var summary = isEmpty(nodeSub.summary) ? "" : "(" + nodeSub.summary + ")";
|
||||
if(summary.length > 10){
|
||||
summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字
|
||||
}
|
||||
nodeSub.treeId = tempTreeId;
|
||||
tempStr += '<li m-id="'+tempTreeId+'"><a href="#" class="show-doc" path="'+nodeSub.path+'">'+key+'<span>'+summary+'</span></a></li>';
|
||||
} else if(haveString(actionArrays, key)) {
|
||||
//console.log(tempTreeId);
|
||||
tempNode.treeId = tempTreeId;
|
||||
var summary = isEmpty(tempNode.summary) ? "" : "("+tempNode.summary+")";
|
||||
if(summary.length > 10){
|
||||
summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字
|
||||
}
|
||||
tempStr += '<li m-id="'+tempTreeId+'"><a href="#" class="show-doc" path="'+tempNode.path+'">'+key+'<span>'+summary+'</span></a></li>';
|
||||
} else {
|
||||
tempStr += '<li>';
|
||||
tempStr += '<a href="#">'+key+'</a>';
|
||||
tempStr += '<ul>';
|
||||
tempStr += getTreeHtmlForTag(tempNode, tempTreeId);
|
||||
tempStr += '</ul>';
|
||||
tempStr += '</li>';
|
||||
}
|
||||
indexNow++;
|
||||
});
|
||||
return tempStr;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* 以树形方式生成并展示:
|
||||
* /api
|
||||
* /data
|
||||
* /getDateList
|
||||
* post
|
||||
* get
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年5月26日
|
||||
*/
|
||||
|
||||
/**
|
||||
* 把原始的json字符串转换成对象列表的方式,方便后续使用
|
||||
* @param json swagger的原始对象
|
||||
* @returns
|
||||
*/
|
||||
function createTreeViewByTree(json, keywords) {
|
||||
var pathIndex = {};
|
||||
var paths = json.paths;
|
||||
var domain = json.domainUrl;// 服务器代理会返回此属性
|
||||
if(isEmpty(domain)) {
|
||||
domain = "http://" + json.host + json.basePath;
|
||||
}
|
||||
if(domain.endWith("/")) {
|
||||
domain = domain.substring(0, domain.length - 1);
|
||||
}
|
||||
if (isEmptyObject(paths)) {
|
||||
return;
|
||||
}
|
||||
//console.log(paths);
|
||||
Object.keys(paths).forEach(function(key){
|
||||
//console.log(key, paths[key]);
|
||||
if(!findInPathsValue(key, paths[key], keywords)) {
|
||||
return;
|
||||
}
|
||||
var keyArr = key.split("/");
|
||||
var nowPathObj = null;
|
||||
keyArr.forEach(function(val, index) {
|
||||
//console.log(val, index);
|
||||
if(isEmpty(val) && index == 0) {
|
||||
return;
|
||||
}
|
||||
var nowPath = "/" + val;
|
||||
if(nowPathObj == null) {
|
||||
nowPathObj = {};
|
||||
nowPathObj[nowPath] = pathIndex[nowPath];
|
||||
if(nowPathObj[nowPath] == null) {
|
||||
nowPathObj[nowPath] = {};
|
||||
pathIndex[nowPath] = nowPathObj[nowPath];
|
||||
}
|
||||
}
|
||||
var tempPathObj = nowPathObj[nowPath];
|
||||
if(isEmpty(tempPathObj)) {
|
||||
tempPathObj = nowPathObj[nowPath] = {};
|
||||
}
|
||||
nowPathObj = tempPathObj;
|
||||
if(index == keyArr.length - 1) {
|
||||
//get, head, post, put, patch, delete, options, trace
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "get");
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "head");
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "post");
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "put");
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "patch");
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "delete");
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "options");
|
||||
setRequestMethodForTree(domain, paths[key], tempPathObj, key, "trace");
|
||||
}
|
||||
});
|
||||
});
|
||||
var htmlStr = '<li>';
|
||||
htmlStr += '<a href="#">'+json.info.title+'</a>';
|
||||
htmlStr += '<ul>';
|
||||
htmlStr += getTreeHtmlForTree(pathIndex, projectTreeIdIndex);
|
||||
htmlStr += '</ul>';
|
||||
htmlStr += '</li>';
|
||||
$('#apiPathTree .projects').append(htmlStr);
|
||||
projectTreeIdIndex++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置对象的各种请求方式,存在则复制
|
||||
* @param source 资源,原始json的paths的指定对象
|
||||
* @param pathObj 当前的待赋值对象
|
||||
* @param url url绝对路径
|
||||
* @param method 请求方式,post、get...
|
||||
* @returns
|
||||
*/
|
||||
function setRequestMethodForTree(domain, source, pathObj, url, method) {
|
||||
if (isEmpty(source[method])) {
|
||||
return;
|
||||
}
|
||||
var tempPath = projectTreeIdIndex + url + "." + method;
|
||||
pathObj[method] = source[method];
|
||||
pathObj[method].path = tempPath;
|
||||
pathObj[method].url = url;
|
||||
pathObj[method].method = method;
|
||||
pathObj[method].domain = domain;
|
||||
treePathDataMap.set(tempPath, source[method]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象列表递归的方式转换成文档格式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;
|
||||
var nodeSub = getObjectFirstAttributeIfOnly(tempNode);
|
||||
if(nodeSub != null && isNotEmpty(nodeSub.method)) {
|
||||
//console.log(nodeSub);
|
||||
nodeSub.treeId = tempTreeId;
|
||||
var summary = isEmpty(nodeSub.summary) ? "" : "("+nodeSub.summary+")";
|
||||
if(summary.length > 10){
|
||||
summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字
|
||||
}
|
||||
tempStr += '<li m-id="'+tempTreeId+'"><a href="#" class="show-doc" path="'+nodeSub.path+'">'+key+'<span>'+summary+'</span></a></li>';
|
||||
} else if(key.indexOf("/") < 0) {
|
||||
//console.log(tempTreeId);
|
||||
tempNode.treeId = tempTreeId;
|
||||
var summary = isEmpty(tempNode.summary) ? "" : "("+tempNode.summary+")";
|
||||
if(summary.length > 10){
|
||||
summary = summary.substring(0, 10)+"...)";// 防止被撑得太长,只显示10个字
|
||||
}
|
||||
tempStr += '<li m-id="'+tempTreeId+'"><a href="#" class="show-doc" path="'+tempNode.path+'">'+key+'<span>'+summary+'</span></a></li>';
|
||||
} else {
|
||||
tempStr += '<li>';
|
||||
tempStr += '<a href="#">'+key+'</a>';
|
||||
tempStr += '<ul>';
|
||||
tempStr += getTreeHtmlForTree(tempNode, tempTreeId);
|
||||
tempStr += '</ul>';
|
||||
tempStr += '</li>';
|
||||
}
|
||||
indexNow++;
|
||||
});
|
||||
return tempStr;
|
||||
}
|
||||
|
||||
1309
zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/mg-ui.js
Normal file
1309
zyplayer-doc-swagger/src/main/resources/webjars/mg-ui/js/mg-ui.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,106 @@
|
||||
|
||||
/**
|
||||
* 两个元素上下、左右拖动动态改变大小
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
(function($){
|
||||
$.fn.mgResizebleHeight = function(options) {
|
||||
var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999};
|
||||
var opts = $.extend(defaults, options);
|
||||
var disY = 0, prevH = 0, nextH = 0, isStart = false;
|
||||
var prev, next, thisObj = this;
|
||||
$(document).mousemove(function(ev){
|
||||
if(!isStart){return;}
|
||||
var ev = ev || window.event;
|
||||
var H = ev.clientY - disY;
|
||||
var prevHNow = prevH+H, nextHNow = nextH-H;
|
||||
if(opts.prevHtMin >= prevHNow) {
|
||||
prevHNow = opts.prevHtMin;
|
||||
nextHNow = next.outerHeight();
|
||||
}
|
||||
if(opts.nextHtMin >= nextHNow) {
|
||||
nextHNow = opts.nextHtMin;
|
||||
prevHNow = prev.outerHeight();
|
||||
}
|
||||
if(opts.prevHtMax <= prevHNow) {
|
||||
prevHNow = opts.prevHtMax;
|
||||
nextHNow = next.outerHeight();
|
||||
}
|
||||
if(opts.nextHtMax <= nextHNow) {
|
||||
nextHNow = opts.nextHtMax;
|
||||
prevHNow = prev.outerHeight();
|
||||
}
|
||||
//prev.css("height", prevHNow + 'px');
|
||||
//next.css("height", nextHNow + 'px');
|
||||
if(typeof opts.onresize == 'function') {
|
||||
opts.onresize(prevHNow, nextHNow);
|
||||
}
|
||||
}).mouseup(function(ev){
|
||||
isStart = false;
|
||||
});
|
||||
$(this).mousedown(function(ev){
|
||||
var ev = ev || window.event;
|
||||
disY = ev.clientY;
|
||||
prev = (opts.prev == thisObj)?$(opts.prev).prev():$(opts.prev);
|
||||
next = (opts.next == thisObj)?$(opts.next).next():$(opts.next);
|
||||
prevH = prev.outerHeight();
|
||||
nextH = next.outerHeight();
|
||||
isStart = true;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作
|
||||
*/
|
||||
$.fn.mgResizebleWidth = function(options) {
|
||||
var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999};
|
||||
var opts = $.extend(defaults, options);
|
||||
var disX = 0, prevW = 0, nextW = 0, isStart = false;
|
||||
var prev, next, thisObj = this;
|
||||
$(document).mousemove(function(ev){
|
||||
if(!isStart){return;}
|
||||
var ev = ev || window.event;
|
||||
var W = ev.clientX - disX;
|
||||
var prevWNow = prevW+W, nextWNow = nextW-W;
|
||||
if(opts.prevWtMin >= prevWNow) {
|
||||
prevWNow = opts.prevWtMin;
|
||||
nextWNow = next.outerWidth();
|
||||
}
|
||||
if(opts.nextWtMin >= nextWNow) {
|
||||
nextWNow = opts.nextWtMin;
|
||||
prevWNow = prev.outerWidth();
|
||||
}
|
||||
if(opts.prevWtMax <= prevWNow) {
|
||||
prevWNow = opts.prevWtMax;
|
||||
nextWNow = next.outerWidth();
|
||||
}
|
||||
if(opts.nextWtMax <= nextWNow) {
|
||||
nextWNow = opts.nextWtMax;
|
||||
prevWNow = prev.outerWidth();
|
||||
}
|
||||
//prev.css("width", prevWNow + 'px');
|
||||
//next.css("width", nextWNow + 'px');
|
||||
if(typeof opts.onresize == 'function') {
|
||||
opts.onresize(prevWNow, nextWNow);
|
||||
}
|
||||
}).mouseup(function(ev){
|
||||
if(!isStart){return;}
|
||||
isStart = false;
|
||||
if(typeof opts.onfinish == 'function') {
|
||||
opts.onfinish();
|
||||
}
|
||||
});
|
||||
$(this).mousedown(function(ev){
|
||||
var ev = ev || window.event;
|
||||
disX = ev.clientX;
|
||||
prev = (opts.prev == thisObj)?$(opts.prev).prev():$(opts.prev);
|
||||
next = (opts.next == thisObj)?$(opts.next).next():$(opts.next);
|
||||
prevW = prev.outerWidth();
|
||||
nextW = next.outerWidth();
|
||||
isStart = true;
|
||||
if(typeof opts.onstart == 'function') {
|
||||
opts.onstart();
|
||||
}
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 提示工具类
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var Toast = {
|
||||
notOpen:function(){
|
||||
var data = {
|
||||
message:"该功能暂未开放,敬请期待!",
|
||||
icon: 'exclamation-sign',type:"warning",
|
||||
};
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user