增加debug参数管理,代码优化

This commit is contained in:
暮光:城中城
2018-12-11 22:36:02 +08:00
parent 452062e967
commit a9c86940e2
16 changed files with 3118 additions and 3038 deletions

View File

@@ -5,7 +5,7 @@
* @since 2017年5月7日 * @since 2017年5月7日
*/ */
(function($){ (function($){
$.fn.mgResizebleHeight = function(options) { $.fn.mgResizableHeight = function(options) {
var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999}; var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disY = 0, prevH = 0, nextH = 0, isStart = false; var disY = 0, prevH = 0, nextH = 0, isStart = false;
@@ -52,7 +52,7 @@
/** /**
* 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作 * 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作
*/ */
$.fn.mgResizebleWidth = function(options) { $.fn.mgResizableWidth = function(options) {
var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999}; var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disX = 0, prevW = 0, nextW = 0, isStart = false; var disX = 0, prevW = 0, nextW = 0, isStart = false;

View File

@@ -5,7 +5,7 @@
* @since 2017年5月7日 * @since 2017年5月7日
*/ */
(function($){ (function($){
$.fn.mgResizebleHeight = function(options) { $.fn.mgResizableHeight = function(options) {
var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999}; var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disY = 0, prevH = 0, nextH = 0, isStart = false; var disY = 0, prevH = 0, nextH = 0, isStart = false;
@@ -52,7 +52,7 @@
/** /**
* 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作 * 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作
*/ */
$.fn.mgResizebleWidth = function(options) { $.fn.mgResizableWidth = function(options) {
var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999}; var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disX = 0, prevW = 0, nextW = 0, isStart = false; var disX = 0, prevW = 0, nextW = 0, isStart = false;

View File

@@ -46,7 +46,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
String loginPage = "/statics/manage/login.html"; String loginPage = "/statics/manage/login.html";
http.authorizeRequests().antMatchers("/login/**", "/document.html").permitAll()//为了测试其他功能,设置“ /** ”允许所有请求 http.authorizeRequests().antMatchers("/login/**").permitAll()//为了测试其他功能,设置“ /** ”允许所有请求
.antMatchers("/document.html").hasAuthority("DOC_ALL") .antMatchers("/document.html").hasAuthority("DOC_ALL")
// 其他地址的访问均需登录 // 其他地址的访问均需登录
.anyRequest().authenticated().and() .anyRequest().authenticated().and()

View File

@@ -5,7 +5,7 @@
* @since 2017年5月7日 * @since 2017年5月7日
*/ */
(function($){ (function($){
$.fn.mgResizebleHeight = function(options) { $.fn.mgResizableHeight = function(options) {
var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999}; var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disY = 0, prevH = 0, nextH = 0, isStart = false; var disY = 0, prevH = 0, nextH = 0, isStart = false;
@@ -52,7 +52,7 @@
/** /**
* 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作 * 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作
*/ */
$.fn.mgResizebleWidth = function(options) { $.fn.mgResizableWidth = function(options) {
var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999}; var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disX = 0, prevW = 0, nextW = 0, isStart = false; var disX = 0, prevW = 0, nextW = 0, isStart = false;

View File

@@ -59,7 +59,7 @@ public class MgStorageController {
} }
@PostMapping(value = "/like") @PostMapping(value = "/like")
public DocResponseJson<Object> like(String key, String value) { public DocResponseJson<List<MgStorage>> like(String key, String value) {
List<MgStorage> likeList = storageService.like(key, value); List<MgStorage> likeList = storageService.like(key, value);
return DocResponseJson.ok(likeList); return DocResponseJson.ok(likeList);
} }

View File

@@ -44,7 +44,7 @@
</div> </div>
</div> </div>
</div> </div>
<div id="resizebleLeftRight" class="ui-resizable-handle mgresizebleW"></div> <div id="resizableLeftRight" class="ui-resizable-handle mgresizableW"></div>
<div class="right-container" id="rightContent"> <div class="right-container" id="rightContent">
<div class="right-container" id="rightContentMask"></div> <div class="right-container" id="rightContentMask"></div>
<div class="tab-page tab-home-page"> <div class="tab-page tab-home-page">
@@ -74,25 +74,6 @@
<div class="tab-page tab-zpages hide"> <div class="tab-page tab-zpages hide">
<div class="tabs" id="rightZpages"></div> <div class="tabs" id="rightZpages"></div>
</div> </div>
<!-- 在线调试配置 -->
<div class="tab-page tab-online-debug-page hide">
<div class="title-info">
<div class="text">
每次点击在线调试的发送请求后都会默认保存一次请求的form、header、body数据到网页的本地存储中以备下次使用在此页面可以管理这些数据。
一般浏览都有5M左右存储空间如果存储过多有可能会导致部分功能异常请随时清理一下不再使用的。
</div>
<button class="btn btn-primary refresh" type="button"><i class="icon icon-refresh"></i> 刷新</button>
<button class="btn btn-primary expand-all" type="button"><i class="icon icon-expand-full"></i> 全部展开</button>
<button class="btn btn-primary collapse-all" type="button"><i class="icon icon-collapse-full"></i> 全部收起</button>
<button class="btn btn-danger del-all-param" type="button"><i class="icon icon-remove-sign"></i> 全部删除</button>
</div>
<table class="table table-bordered" id="onlineDebugParamTable">
<thead>
<tr><th>接口地址</th><th>参数配置</th><th>操作</th></tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="tab-page tab-document hide"> <div class="tab-page tab-document hide">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a data-tab href="#tabDocInfo">接口说明</a></li> <li class="active"><a data-tab href="#tabDocInfo">接口说明</a></li>

View File

@@ -31,9 +31,9 @@ label{font-weight: normal;}
.setting-table tr .info{text-align: right; max-width: 150px;} .setting-table tr .info{text-align: right; max-width: 150px;}
.show-doc span{color: #aaa;} .show-doc span{color: #aaa;}
.mgresizebleW{z-index: 90;height: 100%; width: 10px; cursor: e-resize;} .mgresizableW{z-index: 90;height: 100%; width: 10px; cursor: e-resize;}
.ui-resizable-handle {display: block;font-size: 0.1px;position: absolute;} .ui-resizable-handle {display: block;font-size: 0.1px;position: absolute;}
#resizebleLeftRight{left: 360px;} #resizableLeftRight{left: 360px;}
.unselect{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;} .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{overflow-y: auto;bottom: 0;top: 0;right: 0;left: 0;position: absolute;overflow-x: hidden;padding: 10px;}

View File

@@ -33,7 +33,7 @@
</div> </div>
</div> </div>
</div> </div>
<div id="resizebleLeftRight" class="ui-resizable-handle mgresizebleW"></div> <div id="resizableLeftRight" class="ui-resizable-handle mgresizableW"></div>
<div class="right-container" id="rightContent"> <div class="right-container" id="rightContent">
<div class="tab-page tab-home-page"> <div class="tab-page tab-home-page">
<div id="homePageDashboard" class="dashboard dashboard-draggable" data-height="290"> <div id="homePageDashboard" class="dashboard dashboard-draggable" data-height="290">
@@ -195,7 +195,7 @@
<script type="text/javascript" src="js/formatjson.js"></script> <script type="text/javascript" src="js/formatjson.js"></script>
<script type="text/javascript" src="js/toast.js"></script> <script type="text/javascript" src="js/toast.js"></script>
<script type="text/javascript" src="js/common.js"></script> <script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/mgResizeble.js"></script> <script type="text/javascript" src="js/mgResizable.js"></script>
<script type="text/javascript" src="js/mg-ui-tree.js"></script> <script type="text/javascript" src="js/mg-ui-tree.js"></script>
<script type="text/javascript" src="js/mg-ui-tag.js"></script> <script type="text/javascript" src="js/mg-ui-tag.js"></script>
<script type="text/javascript" src="js/mg-ui-debug.js"></script> <script type="text/javascript" src="js/mg-ui-debug.js"></script>

View File

@@ -71,7 +71,7 @@ $(document).ready(function(){
/** /**
* 自由拖动改变左右框架的宽度 * 自由拖动改变左右框架的宽度
*/ */
$("#resizebleLeftRight").mgResizebleWidth({ $("#resizableLeftRight").mgResizableWidth({
prev:"#leftContent", prev:"#leftContent",
prevWtMin: 120, prevWtMax: 999999, prevWtMin: 120, prevWtMax: 999999,
nextWtMin: 360, nextWtMax: 999999, nextWtMin: 360, nextWtMax: 999999,
@@ -585,7 +585,7 @@ function createDefinitionsMapByJson(json) {
*/ */
function changeContentWidth(width) { function changeContentWidth(width) {
$("#leftContent").css("width", width + 'px'); $("#leftContent").css("width", width + 'px');
$("#resizebleLeftRight").css("left", width + 'px'); $("#resizableLeftRight").css("left", width + 'px');
$("#rightContent").css("left", width + 'px'); $("#rightContent").css("left", width + 'px');
var logoText = "swagger-mg-ui"; var logoText = "swagger-mg-ui";
if(width < 270 && width > 140){ if(width < 270 && width > 140){

View File

@@ -5,7 +5,7 @@
* @since 2017年5月7日 * @since 2017年5月7日
*/ */
(function($){ (function($){
$.fn.mgResizebleHeight = function(options) { $.fn.mgResizableHeight = function(options) {
var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999}; var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disY = 0, prevH = 0, nextH = 0, isStart = false; var disY = 0, prevH = 0, nextH = 0, isStart = false;
@@ -52,7 +52,7 @@
/** /**
* 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作 * 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作
*/ */
$.fn.mgResizebleWidth = function(options) { $.fn.mgResizableWidth = function(options) {
var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999}; var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disX = 0, prevW = 0, nextW = 0, isStart = false; var disX = 0, prevW = 0, nextW = 0, isStart = false;

View File

@@ -13,10 +13,6 @@ ul{list-style: none;list-style-type: none;}
.table td, .table th {vertical-align: middle;} .table td, .table th {vertical-align: middle;}
#tabDocInfo{position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;} #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;} #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;} .local-storage{display: none;}
@@ -31,9 +27,9 @@ label{font-weight: normal;}
.setting-table tr .info{text-align: right; max-width: 150px;} .setting-table tr .info{text-align: right; max-width: 150px;}
.show-doc span{color: #aaa;} .show-doc span{color: #aaa;}
.mgresizebleW{z-index: 90;height: 100%; width: 10px; cursor: e-resize;} .mgresizableW{z-index: 90;height: 100%; width: 10px; cursor: e-resize;}
.ui-resizable-handle {display: block;font-size: 0.1px;position: absolute;} .ui-resizable-handle {display: block;font-size: 0.1px;position: absolute;}
#resizebleLeftRight{left: 360px;} #resizableLeftRight{left: 360px;}
.unselect{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;} .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{overflow-y: auto;bottom: 0;top: 0;right: 0;left: 0;position: absolute;overflow-x: hidden;padding: 10px;}

View File

@@ -13,7 +13,7 @@ function serialize(value) {
function deserialize(value) { function deserialize(value) {
if (typeof value !== 'string' || isEmpty(value)) { if (typeof value !== 'string' || isEmpty(value)) {
return undefined; return value;
} }
try { try {
return JSON.parse(value); return JSON.parse(value);
@@ -266,6 +266,29 @@ String.prototype.startWith = function(str) {
return (this.substr(0, str.length) == str); return (this.substr(0, str.length) == str);
}; };
/**
* 获取数据,异步的操作
*/
function getStorageLike(key, success, fail) {
var start = (typeof urlBase === 'string') ? urlBase : '';
ajaxTemp(start + "swagger-mg-ui/storage/like", "post", "json", {key: key}, function(json){
if(json.errCode == 200) {
if(typeof success == "function") {
var result = deserialize(json.data);
success(result);
}
} else {
if(typeof fail == "function") {
fail();
}
}
}, function(msg){
if(typeof fail == "function") {
fail();
}
});
}
/** /**
* 获取数据,异步的操作 * 获取数据,异步的操作
*/ */
@@ -313,6 +336,29 @@ function setStorage(key, value, success, fail) {
}); });
} }
/**
* 删除数据
*/
function deleteStorage(key, success, fail) {
var start = (typeof urlBase === 'string') ? urlBase : '';
ajaxTemp(start + "swagger-mg-ui/storage/delete", "post", "json", {key: key}, function(json){
if(json.errCode == 200) {
if(typeof success == "function") {
success();
}
} else {
if(typeof fail == "function") {
fail(getNotEmptyStr(json.errMsg));
}
}
}, function(msg){
if(typeof fail == "function") {
fail("");
}
console.log("存储数据到服务器失败,请检查");
});
}
/** /**
* 获取父窗口的exports * 获取父窗口的exports
* @returns * @returns

View File

@@ -2,4 +2,5 @@ var cacheKeys = {
userSettings: 'userSettings', userSettings: 'userSettings',
swaggerResourcesList: 'swagger-resources-list', swaggerResourcesList: 'swagger-resources-list',
globalParamList: 'zyplayer-doc-global-param-list', globalParamList: 'zyplayer-doc-global-param-list',
pRequestObjStart: 'p-request-obj-',
} }

View File

@@ -133,7 +133,7 @@ function addDocumentByService(choiseDocList) {
/** /**
* 自由拖动改变左右框架的宽度 * 自由拖动改变左右框架的宽度
*/ */
$("#resizebleLeftRight").mgResizebleWidth({ $("#resizableLeftRight").mgResizableWidth({
prev:"#leftContent", prev:"#leftContent",
prevWtMin: 120, prevWtMax: 999999, prevWtMin: 120, prevWtMax: 999999,
nextWtMin: 360, nextWtMax: 999999, nextWtMin: 360, nextWtMax: 999999,
@@ -851,7 +851,7 @@ function getRequestParamObj(responsesObj, prevRef) {
*/ */
function changeContentWidth(width) { function changeContentWidth(width) {
$("#leftContent").css("width", width + 'px'); $("#leftContent").css("width", width + 'px');
$("#resizebleLeftRight").css("left", width + 'px'); $("#resizableLeftRight").css("left", width + 'px');
$("#rightContent").css("left", width + 'px'); $("#rightContent").css("left", width + 'px');
var logoText = "zyplayer-doc-swagger"; var logoText = "zyplayer-doc-swagger";
if(width < 370 && width > 290){ if(width < 370 && width > 290){
@@ -995,7 +995,6 @@ function updateUserSettingsUi() {
$("input[name='showParamType'][value='"+userSettings.showParamType+"']").prop("checked",true); $("input[name='showParamType'][value='"+userSettings.showParamType+"']").prop("checked",true);
$("input[name='onlyUseLastParam'][value='"+userSettings.onlyUseLastParam+"']").prop("checked",true); $("input[name='onlyUseLastParam'][value='"+userSettings.onlyUseLastParam+"']").prop("checked",true);
$("input[name='autoFillParam'][value='"+userSettings.autoFillParam+"']").prop("checked",true); $("input[name='autoFillParam'][value='"+userSettings.autoFillParam+"']").prop("checked",true);
//$(".local-storage").show();// 服务器存储了就不用管理了
} }
/** /**

View File

@@ -5,7 +5,7 @@
* @since 2017年5月7日 * @since 2017年5月7日
*/ */
(function($){ (function($){
$.fn.mgResizebleHeight = function(options) { $.fn.mgResizableHeight = function(options) {
var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999}; var defaults = {prev:this,next:this, prevHtMin:0, prevHtMax:999, nextHtMin:0, nextHtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disY = 0, prevH = 0, nextH = 0, isStart = false; var disY = 0, prevH = 0, nextH = 0, isStart = false;
@@ -52,7 +52,7 @@
/** /**
* 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作 * 改变宽度的功能,只是实现各种消息的通知,实际改变大小需要在回调里面自己操作
*/ */
$.fn.mgResizebleWidth = function(options) { $.fn.mgResizableWidth = function(options) {
var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999}; var defaults = {prev:this,next:this, prevWtMin:0, prevWtMax:999, nextWtMin:0, nextWtMax:999};
var opts = $.extend(defaults, options); var opts = $.extend(defaults, options);
var disX = 0, prevW = 0, nextW = 0, isStart = false; var disX = 0, prevW = 0, nextW = 0, isStart = false;

View File

@@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html> <html xmlns:v-on="http://www.w3.org/1999/xhtml">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@@ -9,27 +9,84 @@
<body> <body>
<div id="app"> <div id="app">
调试数据管理 <div class="title-info">
<div class="alert alert-primary">
<div class="content">Tips每次点击在线调试的发送请求后都会默认保存一次请求的form、header、body数据以备下次使用在此页面可以管理这些数据</div>
</div>
</div>
<table class="table table-bordered" id="onlineDebugParamTable">
<thead>
<tr><th>接口地址</th><th>参数配置</th><th>操作</th></tr>
</thead>
<tbody>
<tr v-for="(item,index) in debugDataList" :key="item.id" :data-id="item.id" :data-index="index" >
<td>{{item.key}}</td>
<td>{{item.value}}</td>
<td>
<button class="btn btn-danger" type="button" v-on:click="deleteDebugData($event)">删除</button>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<button class="btn" type="button" v-on:click="btnRefreshList"> 刷新 </button>
</td>
</tr>
</tbody>
</table>
</div> </div>
</body> </body>
<script src="../zui/js/zui.min.js"></script>
<script src="../mg-ui/js/jquery-3.1.0.min.js"></script> <script src="../mg-ui/js/jquery-3.1.0.min.js"></script>
<script src="../zui/js/zui.min.js"></script>
<script src="../mg-ui/js/common.js"></script>
<script src="../mg-ui/js/mg-ui-cache-keys.js"></script>
<script src="../vue/vue.js"></script> <script src="../vue/vue.js"></script>
<script src="../mg-ui/js/toast.js"></script>
<script> <script>
var urlBase = "../../";
var app = new Vue({ var app = new Vue({
el: '#app', el: '#app',
data: { data: {
userId: "", debugDataList: [],
},
mounted: function(){
this.refreshList();
}, },
methods: { methods: {
btnRefreshList: function(){
this.refreshList();
Toast.success("刷新成功!");
},
deleteDebugData: function(event){
if(!confirm("确定要删除吗?")) {
return;
}
var tr = $(event.currentTarget).parents("tr");
var index = tr.data("index");
var delKey = app.debugDataList[index].key;
var newDebugList = [];
for(var i=0;i<app.debugDataList.length;i++){
if(i != index) {
newDebugList.push(app.debugDataList[i]);
}
}
deleteStorage(delKey, function(data){
app.debugDataList = newDebugList;
Toast.success("删除成功!");
});
},
refreshList: function () {
getStorageLike(cacheKeys.pRequestObjStart, function(data){
// console.log(data);
app.debugDataList = data;
});
}
} }
}); });
</script> </script>
<style> <style>
#app{padding-top: 10px;}
</style> </style>
</html> </html>