1 Commits

Author SHA1 Message Date
暮光:城中城
fc41ebdac1 本分支用于同步代码 2019-01-28 22:49:33 +08:00
3 changed files with 29 additions and 73 deletions

View File

@@ -175,7 +175,7 @@ function getObjectFirstAttributeIfOnly(data) {
/**
* ajax处理事件模板
*
*
* @url 后台处理的url即action
* @dataSentType 数据发送的方式有postget方式
* @dataReceiveType 数据接收格式有html json text等
@@ -255,6 +255,13 @@ function getCookie(name) {
return null;
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
/**
* 字符串格式化
*/
@@ -280,7 +287,7 @@ String.prototype.format = function(args) {
} else {
return this;
}
}
};
String.prototype.endWith = function(str) {
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
@@ -395,4 +402,4 @@ function deleteStorage(key, success, fail) {
*/
function getExport(){
return window.parent.window.exports;
}
}

View File

@@ -116,7 +116,7 @@ $(document).ready(function(){
var afterSendTime = new Date().getTime();
//console.log(result);
var requestObj = result.data;
setStorage(cacheKeys.pRequestObjStart + docUrl, storeRequestParam);
// open-doc去掉存储
$("#httpRequestStatus").text(requestObj.status);
$("#httpRequestTime").text((afterSendTime - beforeSendTime) + "ms");
try {
@@ -224,23 +224,13 @@ $(document).ready(function(){
* 提交模拟返回值
*/
$("#simulationResultSubmit").click(function(){
var value = $("#simulationResultText").val();
value = getNotEmptyStr(value, "");
var docUrl = $("#simulationResultUrl").text();
setStorage(cacheKeys.pSimulationResponse + docUrl, value, function() {
Toast.warn("提交成功!");
}, function(msg) {
Toast.error("提交失败!" + msg);
});
// open-doc去掉存储
});
/**
* 获取模拟返回值
*/
$("#simulationResultGet").click(function(){
var docUrl = $("#simulationResultUrl").text();
getStorage(cacheKeys.pSimulationResponse + docUrl, function(data){
$("#simulationResultText").val(data);
});
// open-doc去掉获取存储
});
});
@@ -272,10 +262,8 @@ function createOnlineDebugParamTable() {
* @returns
*/
function createOnlineDebugRequestParam(requestParamObj, url) {
// 查询之前的调试参数信息
getStorage(cacheKeys.pRequestObjStart + url, function(data) {
createOnlineDebugRequestParamFun(data, requestParamObj, url);
});
// open-doc去掉获取存储
createOnlineDebugRequestParamFun({}, requestParamObj, url);
}
/**

View File

@@ -63,12 +63,7 @@ $(document).ready(function(){
}
}
);
// 定义配置的标签页
var tabsArr = [
{id: 'docShowConfig', url: 'webjars/zpages/docShowConfig.html', type: 'iframe', icon: 'icon-cog', forbidClose: true}
];
$('#rightZpages').tabs({tabs: tabsArr});
rightContentTabs = $('#rightZpages').data('zui.tabs');
// open-doc去掉定义配置的标签页
});
/**
@@ -76,34 +71,10 @@ $(document).ready(function(){
* @returns
*/
function getDocumentListByService() {
$("#choiseDocListUl").empty();
// open-doc整个方法不同
showGlobalLoadingMessage('获取文档列表中,请稍候...', true);
// ajaxTemp("swagger-mg-ui/document/resourcesList", "post", "json", {}, function(json){
// if(validateResult(json) && json.data.length > 1) {
// showGlobalLoadingMessage('等待选择需展示的文档,请选择...', true);
// for (var i = 0; i < json.data.length; i++) {
// var item = json.data[i];
// $("#choiseDocListUl").append('<li value="'+item.url+'">'+item.url+'</li>');
// }
// $('#choiseDocModal').modal({moveable:true, backdrop:'static', keyboard: false});
// } else {
// addDocumentByService();
// }
// });
ajaxTemp("swagger-mg-ui/document/getLocationList", "post", "json", {}, function (json) {
if (validateResult(json) && json.data.length >= 1) {
for (var i = 0; i < json.data.length; i++) {
var item = json.data[i];
$("#choiceLocationList .dropdown-menu").append('<li><a href="javascript:void(0);" data-location="' + item.location + '">' + item.name + '</a></li>');
}
$("#choiceLocationList .choice-text").text(json.data[0].name);
addDocumentByLocationService(json.data[0].location);
} else {
initDashboard();
documentLoadFinish();
$("#choiceLocationList .choice-text").text("请先至 文档地址管理 处增加文档");
}
});
var doc = getQueryString("doc");
addDocumentByLocationService(doc);
}
/**
@@ -149,7 +120,8 @@ function addDocumentByLocationService(choiceDocList) {
// 获取原始的swagger的json对象
globalLoadingMessager.show();
showGlobalLoadingMessage('通过服务器端获取文档中,请稍候...', true);
ajaxTemp("swagger-mg-ui/document/docs", "post", "json", {choiceLocationList: choiceDocList}, function(json){
// open-doc请求地址不同
ajaxTemp("swagger-mg-ui/open-doc/docs", "post", "json", {choiceLocationList: choiceDocList}, function(json){
//console.log(json);
showGlobalLoadingMessage('文档获取成功,解析中,请稍候...', true);
if(isEmptyObject(json) || json.errCode !== 200) {
@@ -412,11 +384,7 @@ $("#apiPathTree").on("click", ".show-doc", function(){
$("#simulationResultUrlTest").text(data.domain + docUrl + "?zyplayerApiTest=1");
$("#simulationResultUrlTest").attr("href", data.domain + docUrl + "?zyplayerApiTest=1");
$("#simulationResultText").val("");
getStorage('p-simulation-response-' + docUrl, function(data){
var resultText = getNotEmptyStr(data);
resultText = (typeof resultText == 'string') ? resultText : JSON.stringify(resultText, null, 4);
$("#simulationResultText").val(resultText);
});
// open-doc去掉了模拟返回
// 处理在线文档
$("#docUrl").text(docUrl);
$("#docRequestMethod").text(getNotEmptyStr(data.method));
@@ -1004,7 +972,7 @@ function documentLoadFinish() {
* 存储用户设置
*/
function storeUserSettings() {
setStorage(cacheKeys.userSettings, userSettings);
// open-doc去掉存储设置
}
/**
@@ -1020,19 +988,12 @@ function updateUserSettings(newSetting) {
* @returns
*/
function initUserSettings() {
getStorage(cacheKeys.userSettings, function(data) {
userSettings = data;
if(isEmpty(userSettings) || isEmptyObject(userSettings)) {
userSettings = defaultUserSettings;
}
changeContentWidth(userSettings.prevWNow);
updateTreeShowType();
// 增加文档
getDocumentListByService();
});
getStorage(cacheKeys.globalParamList, function(data) {
debugGlobalParam = data;
});
// open-doc去掉了获取配置和全局参数
userSettings = defaultUserSettings;
changeContentWidth(userSettings.prevWNow);
updateTreeShowType();
// 增加文档
getDocumentListByService();
}
function showGlobalLoadingMessage(text, loading) {