diff --git a/class/core/config_api.py b/class/core/config_api.py index b36e33488..7c71b828b 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -22,6 +22,37 @@ class config_api: ##### ----- start ----- ### + # 取面板列表 + def getPanelListApi(self): + data = public.M('panel').field( + 'id,title,url,username,password,click,addtime').order('click desc').select() + return public.getJson(data) + + def addPanelInfoApi(self): + title = request.form.get('title', '') + url = request.form.get('url', '') + username = request.form.get('username', '') + password = request.form.get('password', '') + # 校验是还是重复 + isAdd = public.M('panel').where( + 'title=? OR url=?', (title, url)).count() + if isAdd: + return public.returnJson(False, '备注或面板地址重复!') + isRe = public.M('panel').add('title,url,username,password,click,addtime', + (title, url, username, password, 0, int(time.time()))) + if isRe: + return public.returnJson(True, '添加成功!') + return public.returnJson(False, '添加失败!') + + # 删除面板资料 + def delPanelInfoApi(self): + mid = request.form.get('id', '') + isExists = public.M('panel').where('id=?', (mid,)).count() + if not isExists: + return public.returnJson(False, '指定面板资料不存在!') + public.M('panel').where('id=?', (mid,)).delete() + return public.returnJson(True, '删除成功!') + def syncDateApi(self): if public.isAppleSystem(): return public.returnJson(True, '开发系统不必同步时间!') diff --git a/route/static/app/public.js b/route/static/app/public.js index 9d36b0fbd..bd3f56ee5 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -837,24 +837,78 @@ function listOrder(skey,type,obj){ } } + +//获取关联列表 +function getBtpanelList(){ + var con =''; + $.post("/config/get_panel_list",function(rdata){ + for(var i=0; i\ + '+rdata[i].title+'\ + \ + '; + } + + $("#newbtpc").html(con); + $(".mypcipnew").hover(function(){ + $(this).css("opacity","1"); + },function(){ + $(this).css("opacity",".6"); + }).click(function(){ + $("#btpanelform").remove(); + var murl = $(this).attr("data-url"); + var user = $(this).attr("data-user"); + var pw = $(this).attr("data-pw"); + layer.open({ + type: 2, + title: false, + closeBtn: 0, //不显示关闭按钮 + shade: [0], + area: ['340px', '215px'], + offset: 'rb', //右下角弹出 + time: 5, //2秒后自动关闭 + anim: 2, + content: [murl+'/login', 'no'] + }); + var loginForm =''; + $("body").append(loginForm); + layer.msg('正在打开面板...',{icon:16,shade: [0.3, '#000'],time:1000}); + setTimeout(function(){ + $("#toBtpanel").submit(); + },500); + setTimeout(function(){ + window.open(murl); + },1000); + }); + $(".btedit").click(function(e){ + e.stopPropagation(); + }); + },'json'); +} +getBtpanelList(); + //添加面板快捷登录 function bindPanel(a,type,ip,btid,url,user,pw){ var titleName = '关联面板'; if(type == "b"){ - btn = ""; + btn = ""; } else { titleName = '修改关联' + ip; - btn = ""; + btn = ""; } if(url == undefined) url="http://"; if(user == undefined) user=""; if(pw == undefined) pw=""; if(ip == undefined) ip=""; if(a == 1) { - var gurl = "/config?action=AddPanelInfo"; + var gurl = "/config/add_panel_info"; var btaddress = $("#btaddress").val(); if(!btaddress.match(/^(http|https)+:\/\/([\w-]+\.)+[\w-]+:\d+/)){ - layer.msg(lan.bt.panel_err_format+'

http://192.168.0.1:8888

',{icon:5,time:5000}); + layer.msg('面板地址格式不正确,示例:

http://192.168.0.1:8888

',{icon:5,time:5000}); return; } var btuser = encodeURIComponent($("#btuser").val()); @@ -873,7 +927,7 @@ function bindPanel(a,type,ip,btid,url,user,pw){ if(b.status) { layer.closeAll(); layer.msg(b.msg, {icon: 1}); - GetBtpanelList(); + getBtpanelList(); } else { layer.msg(b.msg, {icon: 2}) } @@ -888,20 +942,23 @@ function bindPanel(a,type,ip,btid,url,user,pw){ shift: 5, shadeClose: false, content: "
\ -
"+lan.bt.panel_address+"\ -
\ +
面板地址\ +
\
\ -
"+lan.bt.panel_user+"\ -
\ +
用户名\ +
\
\ -
"+lan.bt.panel_pass+"\ -
\ +
密码\ +
\
\ -
"+lan.bt.panel_ps+"\ -
\ +
备注\ +
\
\ -
  • "+lan.bt.panel_ps_1+"
  • "+lan.bt.panel_ps_2+"
  • "+lan.bt.panel_ps_3+"
\ -
"+btn+"
\ +
    \ +
  • 收藏其它服务器面板资料,实现一键登录面板功能
  • 面板备注不可重复
  • \ +
  • 注意,开启广告拦截会导致无法快捷登录。
\ +
\ +
"+btn+"
\
" }); $("#btaddress").on("input",function(){ @@ -918,11 +975,11 @@ function bindPanel(a,type,ip,btid,url,user,pw){ } //删除快捷登录 function bindPaneldel(id){ - $.post("/config?action=DelPanelInfo","id="+id,function(rdata){ + $.post("/config/del_panel_info","id="+id,function(rdata){ layer.closeAll(); layer.msg(rdata.msg,{icon:rdata.status?1:2}); - GetBtpanelList(); - }) + getBtpanelList(); + },'json'); } function getSpeed(sele){