Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
var sybool = false;
function changeStyle(sel){
css=document.getElementById("cssfile");
css.href='/css/'+sel.value+'.css';
localStorage.setItem('styleName',sel.value);
}
//点击左边菜单栏展示相对应内容
function leftMenu(){
setTimeout(()=>{
let uls = $('.secondary')
for(let i = 0; i < uls.length;i++){
uls[i].onclick=function(){
indexFlag =this.getAttribute("data")
let flag = true
let tabBox = $('#tabBox>li')
for(let m = 0; m < tabBox.length;m++){
tabBox[m].className=''
if(indexFlag == tabBox[m].getAttribute("data")){
flag = false
tabBox[m].className='activeTab'
}
}
if(flag){
const urlname = this.getAttribute("urlname")
let lis = `
${urlname}
`
$('#tabBox').append(lis);
topMenu()
delMenu()
}
for(let j = 0; j < uls.length;j++){
uls[j].className = 'secondary'
//$(uls[j]).find("img").attr("src","img/f.gif")
}
this.className = 'secondary active'
//$(this).find("img").attr("src","img/fw.gif")
let ids = '#method_'+indexFlag
let divs = $(ids)[0].getElementsByTagName('div')[0]
$('#tabBox').css("left",oldLeft + 'px')
}
}
},0)
}
//点击顶部菜单栏展示内容
function topMenu(){
let addTabBox = $('#tabBox>li')
for(let i = 0; i < addTabBox.length;i++){
addTabBox[i].onclick=function(){
indexFlag = this.getAttribute("data")
/*if(indexFlag == 0) return*/
switchMenu(addTabBox)
}
}
}
//顶部菜单栏点击删除事件
function delMenu(){
let uls = $('.delImg')
let tabBoxs = $('#tabBox>li')
for(let i = 0; i < uls.length;i++){
uls[i].onclick = function(event){
let removeId = this.getAttribute("data")
let tag = tabBoxs[i]
//if(uls.length==1) return //如果只有一项,不允许删除
//如果当前删除的选项和页面显示的选项一致
if(removeId==indexFlag){
if(i==tabBoxs.length-1){//当前删除项是最后一项
try{
indexFlag = tabBoxs[i-1].getAttribute("data")
}catch{
indexFlag = null;
$(".welcome").show();
}
}else{
indexFlag = tabBoxs[i+1].getAttribute("data")
}
switchMenu(tabBoxs)
}
tag.parentNode.removeChild(tag);
delMenu()
event.stopPropagation();//阻止点击事件冒泡
return false;
}
}
}
//切换菜单事件
function switchMenu(tabs){
let uls = $('.secondary')
let ids = '#method_'+indexFlag
for(let j = 0; j < uls.length;j++){
if(indexFlag==uls[j].getAttribute("data")){
uls[j].className = 'secondary active'
let divs = $(ids)[0].getElementsByTagName('div')[0]
divs.style.left = oldLeft + 'px'
}else{
uls[j].className = 'secondary'
}
}
for(let n = 0; n < tabs.length;n++){
if(indexFlag==tabs[n].getAttribute("data")){
tabs[n].className = 'activeTab'
}else{
tabs[n].className = ''
}
}
$(".method-table").hide();
$(ids).show()
}
//复制属性
function copyVal(btn){
var a = btn.parentNode.firstChild;
var textArea = document.createElement('textarea');
var text = a.nodeValue;
if(text.lastIndexOf('.') != -1){
text = text.substring(text.lastIndexOf('.')+1);
}
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy"); // 执行浏览器复制命令
document.body.removeChild(textArea);
btn.value = "复制成功";
}
function copyUrl(pt){
var textArea = document.createElement('textarea');
textArea.value = pt.previousSibling.innerHTML;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy"); // 执行浏览器复制命令
document.body.removeChild(textArea);
pt.value = "复制成功";
}
let indexFlag = null
let oldWidth = 248
let oldLeft = 258
function bindResize(el) {
//初始化参数
let menuBody = document.getElementById('menu')
var els = el.style,
//鼠标的 X 和 Y 轴坐标
x = y = 0;
//邪恶的食指
$(el).mousedown(function (e) {
//按下元素后,计算当前鼠标与对象计算后的坐标
x = e.clientX - el.offsetWidth, y = e.clientY - el.offsetHeight;
//在支持 setCapture 做些东东
el.setCapture ? (
//捕捉焦点
el.setCapture(),
//设置事件
el.onmousemove = function (ev) {
mouseMove(ev || event)
},
el.onmouseup = mouseUp
) : (
//绑定事件
$(document).bind("mousemove", mouseMove).bind("mouseup", mouseUp)
)
//防止默认事件发生
e.preventDefault()
});
//移动事件
let oldFeft_s = 0
let oldWidth_s =0
let minWidth = 248
let maxWidth = 755
function mouseMove(e) {
oldFeft_s = oldLeft+ e.clientX - x
oldFeft_s= oldFeft_s< (minWidth+15) ? (minWidth+15) : (oldFeft_s > (maxWidth+15) ? (maxWidth+15) : oldFeft_s)
if(indexFlag != null){
let ids = '#method_'+indexFlag
let divs = $(ids)[0].getElementsByTagName('div')[0]
divs.style.left = oldFeft_s + 'px'
$('#tabBox')[0].style.left = oldFeft_s + 'px'
}
oldWidth_s = oldWidth+ e.clientX - x
oldWidth_s=oldWidth_smaxWidth?maxWidth:oldWidth_s)
menuBody.style.width = oldWidth_s+ 'px' //改变宽度
}
//停止事件
function mouseUp() {
//在支持 releaseCapture 做些东东
el.releaseCapture ? (
//释放焦点
el.releaseCapture(),
//移除事件
el.onmousemove = el.onmouseup = null
) : (
//卸载事件
$(document).unbind("mousemove", mouseMove).unbind("mouseup", mouseUp)
)
oldLeft = oldFeft_s
oldWidth = oldWidth_s
}
}
$(function(){
//右键菜单
$.contextMenu({
selector: '.activeTab',
callback: function(key, options) {
let tabBoxs = $('#tabBox>li')
if(key == 'now'){ //关闭当前页
var num = $(".activeTab").attr("data");
var num2 = tabBoxs[tabBoxs.length-1].getAttribute("data");
if(tabBoxs.length == 1){
indexFlag = null;
$(".welcome").show();
}else if(num == num2){
indexFlag = tabBoxs[tabBoxs.length-2].getAttribute("data");
}else{
indexFlag = tabBoxs[tabBoxs.length-1].getAttribute("data");
}
$(".activeTab").remove();
switchMenu(tabBoxs)
delMenu()
event.stopPropagation();//阻止点击事件冒泡
}
if(key == 'other'){ //关闭其它页
var num = $(".activeTab").attr("data");
for(var i = 0;i 0 ?1:2;
let methodurl = $(this).parents(".hovertable").parent().parent().find(".method-URL").html();
let content = methodurl+"."+type+"."+value;
var tr = this;
if(key == 'add'){ //添加高亮样式
var tit = $(this).attr("add");
if(tit == 1){
$.ajax({
url:"lkad/delParamInfo",
type:"post",
dataType:"text",
data:{"value":value,"type":type,"url":methodurl,'random':Math.random(),'serverName':getServerName()},
success:function(data){
$(tr).css("color","#8b99b1").css("text-shadow","none");
$(tr).removeAttr("add");
$(tr).attr("title",'右键可修改参数状态');
},
error:function(){
alert("连接服务器异常");
}
})
}else{
let modaltype = 1;
let modalcontent = '高亮状态';
$.ajax({
url:"lkad/addParamInfo",
type:"post",
dataType:"text",
data:{"value":value,"type":type,"url":methodurl,"modaltype":modaltype,"content":modalcontent,'random':Math.random(),'serverName':getServerName()},
success:function(data){
getParamInfo();
},
error:function(){
alert("连接服务器异常");
}
})
}
}
if(key == 'del'){ //添加删除标签
var tit = $(this).attr("del");
if(tit == 3){
$.ajax({
url:"lkad/delParamInfo",
type:"post",
dataType:"text",
data:{"value":value,"type":type,"url":methodurl,'random':Math.random(),'serverName':getServerName()},
success:function(data){
$(tr).css("text-decoration","none");
$(tr).removeAttr("del");
$(tr).attr("title",'右键可修改参数状态');
},
error:function(){
alert("连接服务器异常");
}
})
}else{
let modaltype = 3;
let modalcontent = '删除状态,参数不会传输到服务器';
$.ajax({
url:"lkad/addParamInfo",
type:"post",
dataType:"text",
data:{"value":value,"type":type,"url":methodurl,"modaltype":modaltype,"content":modalcontent,'random':Math.random(),'serverName':getServerName()},
success:function(data){
getParamInfo();
},
error:function(){
alert("连接服务器异常");
}
})
}
}
if(key == 'diy'){ //修改作用
var tit = $(this).attr("diy");
var oldName = $(this).attr("oldName");
if(value.lastIndexOf('.') != -1){
value = value.substring(value.lastIndexOf('.')+1);
}
if(value.lastIndexOf('[]') != -1){
value = value.substring(0,value.lastIndexOf('[]'));
}
if(tit == 5){
$.ajax({
url:"lkad/delParamInfo",
type:"post",
dataType:"text",
data:{"value":value,"type":type,"url":methodurl,'random':Math.random(),'serverName':getServerName()},
success:function(data){
getParamInfo();
$(tr).next().html(oldName);
$(tr).removeAttr("diy");
$(tr).removeAttr("oldName");
},
error:function(){
alert("连接服务器异常");
}
})
}else{
let modaltype = 5;
let modalcontent = prompt("请输入作用","");
if(modalcontent==""){
return;
}
$.ajax({
url:"lkad/addParamInfo",
type:"post",
dataType:"text",
data:{"value":value,"type":type,"url":methodurl,"modaltype":modaltype,"content":modalcontent,'random':Math.random(),'serverName':getServerName()},
success:function(data){
getParamInfo();
},
error:function(){
alert("连接服务器异常");
}
})
}
}
},
items: {
"add": {name:$(trigger).attr("add")==1?"去掉高亮":"添加高亮", icon:""},
"del": {name:$(trigger).attr("del")==3?"去掉删除线":"添加删除线", icon:""},
"diy": {name:$(trigger).attr("diy")==5?"还原作用":"修改作用", icon:""},
"sep1": "---------",
"quit": {name: "退出操作", icon: function(){
return 'context-menu-icon context-menu-icon-quit';
}}
}
};
}
});
//加载风格
css=document.getElementById("cssfile");
var styleName = localStorage.getItem('styleName');
styleName = null;
if(styleName == null){
css.href='css/green.css';
$("#changeStyle").find("option").eq(0).prop("selected",true)
}else{
css.href='css/'+styleName+'.css';
if(styleName == 'black'){
$("#changeStyle").find("option").eq(1).prop("selected",true)
}
if(styleName == 'red'){
$("#changeStyle").find("option").eq(2).prop("selected",true)
}
if(styleName == 'blue'){
$("#changeStyle").find("option").eq(3).prop("selected",true)
}
if(styleName == 'default'){
$("#changeStyle").find("option").eq(4).prop("selected",true)
}
}
setTimeout(()=>{
bindResize(document.getElementById('line'));
})
function reloadDoc(serverName,type){
let password = "";
if(type == 1){
$.ajax({
url:"lkad/isPwd",
type:"get",
dataType:"json",
async:false,
data:{"serverName":serverName,"pwd":password,"type":type},
success:function(data){
if(data == 1){
//需要密码
$("#syServerName").val(serverName);
$("#syType").val(type);
syalert.syopen('alert4')
}else{
//不需要密码
loadData(serverName,password,type)
}
}
})
}else{
//不需要密码
loadData(serverName,password,type)
}
$(".isRequired").each(function(){
if($(this).html() == '是'){
$(this).css("color","#A12F2F");
}
})
$(".paramType").each(function(){
if($(this).html() == 'header'){
$(this).css("color","#A12F2F");
}
if($(this).html() == 'path'){
$(this).css("color","#068043");
}
})
$(".method-URL").each(function(){
if($(this).html() == '该API未设置请求路径'){
$(this).css("color","#red");
}
})
}
function getServerName(){
var serverName = $("#changeProject").val();
if(serverName == null || serverName == 'now'){
serverName = '';
}else{
if(!serverName.toLowerCase().startsWith("http://") && !serverName.toLowerCase().startsWith("https://")){
serverName = "http://"+serverName;
}
}
return serverName;
}
//搜索接口名称
$("#search-button").click(function(){
reloadDoc(getServerName(),0);
indexFlag=null
$("#tabBox>li").hide();
$(".method-table").hide();
$(".welcome").show();
});
//切换项目
$("#changeProjectButton").click(function(){
reloadDoc(getServerName(),1);
indexFlag=null
$("#tabBox>li").hide();
$(".method-table").hide();
$(".welcome").show();
});
reloadDoc('',1);
//导出PDF,MD文档
$("#exportMarkDown").click(function(){
if($("#changeProject").val() != 'now' && $("#changeProject").val()!=null){
alert("暂不支持远程服务器生成文档!");
}else{
var xhr = new XMLHttpRequest();
xhr.open("post","lkad/exportMarkDown",true);
// 设置请求头
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.responseType = "blob";
xhr.onreadystatechange = function () {
// 请求完成
if (this.status === 200) {
var blob = this.response;
var reader = new FileReader();
// 转换为base64,可以直接放入a表情href
reader.readAsDataURL(blob);
reader.onload = function (e) {
// 转换完成,创建一个a标签用于下载
var a = document.createElement('a');
a.download = $("#projectName").html()+".md";
a.href = e.target.result;
// 修复firefox中无法触发click
$("body").append(a);
a.click();
$(a).remove();
}
}
if(this.readyState == 4){
if(this.status == 200){
alert("生成成功!")
}else{
alert("生成失败!");
}
}
};
//发送ajax请求
xhr.send("serverName="+getServerName())
}
})
//生成复制按钮 复制属性名
$(".right-box").on("mouseenter",".addinfo",function(){
$(this).append('');
})
$(".right-box").on("mouseleave",".addinfo",function(){
$(this).find(".copyText").remove();
})
//生成复制按钮 复制属性名
$(".right-box").on("mouseenter",".method-requestParamInfo",function(){
$(this).find(".method-URL").after('');
})
$(".right-box").on("mouseleave",".method-requestParamInfo",function(){
$(this).find(".copyText").remove();
})
//设置高亮参数判断
function getParamInfo(){
$.getJSON("lkad/getParamInfo",{'random':Math.random(),'serverName':getServerName()},function(data){
if(data != null && data != 'null'){
$(".addinfo").each(function(){
try{
let value = this.firstChild.nodeValue;
let type = $(this).parents(".hovertable").find(".reqcls").length > 0 ?1:2;
let methodurl = $(this).parents(".hovertable").parent().parent().find(".method-URL").html();
let content = methodurl+"."+type+"."+value;
let str = data[content];
if(str != null && str.length>0){
var arrs = str.split("-");
//匹配上,设置样式
$(this).attr("title",arrs[1]);
if(arrs[0] == 1){
$(this).css("color","#fff");
$(this).css("text-shadow","1px 1px 1px #fff");
$(this).attr("add","1");
}else if(arrs[0] == 3){
$(this).css("text-decoration","line-through");
$(this).attr("del","3");
}else if(arrs[0] == 5){
$(this).attr("diy","5");
$(this).attr("oldName",$(this).next().text());
$(this).next().html(arrs[1]);
}else{
/*$(this).css("color","#000").css("text-decoration","none");
$(this).css("text-shadow","none");
$(this).attr("title",'右键可修改参数状态');
$(this).removeAttr("add");
$(this).removeAttr("update");
$(this).removeAttr("del");
$(this).removeAttr("diy");*/
}
}else{
/*$(this).css("color","#000").css("text-decoration","none");
$(this).css("text-shadow","none");
$(this).attr("title",'右键可修改参数状态');
$(this).removeAttr("add");
$(this).removeAttr("update");
$(this).removeAttr("del");
$(this).removeAttr("diy");*/
}
}catch(e){
return false;
}
})
}
});
}
getParamInfo();
// 加载令牌
$(".headerKey").val($.cookie('tokenKey'));
$(".headerValue").val($.cookie('tokenValue'));
$(".navBox").on("click","h3",function(){
$(this).next().toggle()
if($(this).find("div").attr('class')=='d4'){
$(this).find("div").removeClass("d4");
$(this).find("div").addClass("d3");
}else{
$(this).find("div").removeClass("d3");
$(this).find("div").addClass("d4");
}
let uls = $('.secondary')
for(let i = 0; i < uls.length;i++){
if(i != indexFlag - 1){
uls[i].className = 'secondary'
}
}
})
$(".navBox").on("click","li",function(){
var index = $(this).attr("data");
$(".method-table").hide();
$(".welcome").hide();
$("#method_"+index).toggle();
var rightH = $(".right-box").height();
$("#menu").height(rightH+20);
$("#menu #open").height(rightH+10);
})
$(".right-box").on("click",".add",function(){
$(this).prev().before("");
})
$(".right-box").on("click",".subtract",function(){
if($(this).prev().attr('class')=='prevData'){
$(this).prev().remove();
}
})
$(".right-box").on("click",".addFile",function(){
var value = $(this).parent().find(".fileValue").val()
$(this).prev().before("");
})
$(".right-box").on("click",".subFile",function(){
if($(this).prev().attr('class')=='prevFileData'){
$(this).prev().remove();
}
})
$(".right-box").on("click",".close-resposeData a",function(){
if($(this).html() == '隐藏调试窗口'){
//$(this).parent().parent().hide();
$(this).html('打开调试窗口');
$(this).parents("table").find(".resposeData").hide();
}else{
$(this).html('隐藏调试窗口');
$(this).parents("table").find(".resposeData").show();
}
})
$(".right-box").on("change",".ImplementWay",function(){
if($(this).val() == 'async'){
$(this).parent().find('.timeNumber').attr("disabled",true).attr("type","text");
$(this).parent().find('.timeNumber').css("backgroundColor","#333")
$(this).parent().find('.timeNumber').val(1);
}else{
$(this).parent().find('.timeNumber').attr("disabled",false).attr("type","number");
$(this).parent().find('.timeNumber').css("backgroundColor","#8b99b1")
}
})
//执行入参单击事件
$(".checkData").click(function() {
if ($(this).is(":checked")== true) {
//选中触发事件
if($(this).parent().parent().hasClass("parentParam")){
var ptxt = $(this).parent().parent().find(".paramValue").html();
var paramValues = $(this).parents("table").find(".paramValue");
for(var i = 0;i 0){
var formData = new FormData(fileInput[0]);
Object.keys(queryData).forEach((key) => {
formData.append(key, queryData[key]);
});
queryData = formData;
processData=false; // jQuery不要去处理发送的数据
contentTypeBool=false; // jQuery不要去设置Content-Type请求头
path = path+"?random="+Math.random();
delete headerJson['Content-Type'];
}
var requestLength=$(this).parents("table").find(".request-length");
var requestFail=$(this).parents("table").find(".request-fail");
var requestSuccess=$(this).parents("table").find(".request-success");
var requestStatus = $(this).parents("table").find(".request-status");
var requestTime = $(this).parents("table").find(".request-time");
var conutNumber = $(this).parents("table").find(".conutNumber");//执行次数
var timeNumber = $(this).parents("table").find(".timeNumber");//执行间隔
var iw = $(this).parents("table").find(".ImplementWay");//执行方式
if(conutNumber.val() == null || conutNumber.val() == ''){
conutNumber.val(1);
}
if(timeNumber.val() == null || timeNumber.val() == ''){
timeNumber.val(1);
}
requestLength.html(0);
requestFail.html(0);
requestSuccess.html(0);
var totalStartTime = new Date().getTime();
var countNum = 1;
for(var i=0;iconut:"+(countNum++)+" status:"+this.status+" "
+"msg:"+(this.status==200?"success":"fail")+" time:"+countTime+"ms "+""+json+"