页面调整

master
fengfei 7 years ago
parent 7db0805b23
commit b4b81f0921
  1. 11
      proxy-server/src/main/java/org/fengfei/lanproxy/server/config/web/routes/RouteConfig.java
  2. 169
      proxy-server/webpages/lanproxy-config/index.html

@ -56,6 +56,14 @@ public class RouteConfig {
} }
} }
String auth = request.headers().get(HttpHeaders.Names.AUTHORIZATION);
if (!authenticated && auth != null) {
String[] authArr = auth.split(" ");
if (authArr.length == 2 && authArr[0].equals(ProxyConfig.getInstance().getConfigAdminUsername()) && authArr[1].equals(ProxyConfig.getInstance().getConfigAdminPassword())) {
authenticated = true;
}
}
if (!request.getUri().equals("/login") && !authenticated) { if (!request.getUri().equals("/login") && !authenticated) {
throw new ContextException(ResponseInfo.CODE_UNAUTHORIZED); throw new ContextException(ResponseInfo.CODE_UNAUTHORIZED);
} }
@ -118,8 +126,7 @@ public class RouteConfig {
return ResponseInfo.build(ResponseInfo.CODE_INVILID_PARAMS, "Error username or password"); return ResponseInfo.build(ResponseInfo.CODE_INVILID_PARAMS, "Error username or password");
} }
if (username.equals(ProxyConfig.getInstance().getConfigAdminUsername()) if (username.equals(ProxyConfig.getInstance().getConfigAdminUsername()) && password.equals(ProxyConfig.getInstance().getConfigAdminPassword())) {
&& password.equals(ProxyConfig.getInstance().getConfigAdminPassword())) {
token = UUID.randomUUID().toString().replace("-", ""); token = UUID.randomUUID().toString().replace("-", "");
return ResponseInfo.build(token); return ResponseInfo.build(token);
} }

@ -17,14 +17,13 @@
<div class="layui-header"> <div class="layui-header">
<div class="layui-logo">LanProxy内网穿透</div> <div class="layui-logo">LanProxy内网穿透</div>
<ul class="layui-nav layui-layout-right"> <ul class="layui-nav layui-layout-right">
<li class="layui-nav-item"><a href="javascript:;" class="logout">退出</a></li> <li class="layui-nav-item"><a href="javascript:;"
class="logout">退出</a></li>
</ul> </ul>
</div> </div>
<div class="layui-side layui-bg-black"> <div class="layui-side layui-bg-black">
<div class="layui-side-scroll"> <div class="layui-side-scroll"></div>
</div>
</div> </div>
<div class="layui-body"></div> <div class="layui-body"></div>
@ -38,96 +37,96 @@
<script src="/jquery/jquery-3.1.1.min.js"></script> <script src="/jquery/jquery-3.1.1.min.js"></script>
<script src="/template/template.js"></script> <script src="/template/template.js"></script>
<script> <script>
layui.use('layer', function() { window.clientList = [];
window.layer = layui.layer; layui.use('layer', function() {
update_menu(); window.layer = layui.layer;
}); update_menu();
load_page("html/client/list.html");
});
function api_invoke(uri, params, callback) {
var index = layer.load(1, {
shade : [ 0.1, '#fff' ]
});
$.ajax({
url : uri,
data : JSON.stringify(params),
type : 'POST',
cache : false,
dataType : 'json',
contentType : "application/json; charset=utf-8",
success : function(data) {
layer.close(index);
callback(data);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
layer.close(index);
if ("undefined" == typeof (XMLHttpRequest.responseJSON)) {
layer.alert("System error, please try again later.");
return;
}
function api_invoke(uri, params, callback) { if (40100 == XMLHttpRequest.responseJSON.code) {
var index = layer.load(1, { location.href = "/";
shade: [0.1,'#fff'] //0.1透明度的白色背景 } else {
}); layer.alert(XMLHttpRequest.responseJSON.message);
$.ajax({ api_invoke("/config/detail", {}, function(data) {
url : uri, clientList = data.data;
data : JSON.stringify(params), });
type : 'POST', }
cache : false, }
dataType : 'json', });
contentType : "application/json; charset=utf-8", }
success : function(data) {
layer.close(index);
callback(data);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
layer.close(index);
if ("undefined" == typeof (XMLHttpRequest.responseJSON)) {
alert("System error, please try again later.");
return;
}
if(40100 == XMLHttpRequest.responseJSON.code){ function load_page(pageUrl) {
location.href="/"; $(".layui-body").load(pageUrl);
}else{ }
layer.alert(XMLHttpRequest.responseJSON.message);
api_invoke("/config/detail", {}, function(data) {
clientList = data.data;
});
}
}
});
}
function load_page(pageUrl) { function check_lan(ip) {
$(".layui-body").load(pageUrl); var re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]):([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/
} return re.test(ip);
}
function check_lan(ip)
{
var re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]):([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/
return re.test(ip);
}
function check_port(port) function check_port(port) {
{ if (port > 65535) {
if (port>65535) { return false;
return false; }
} var re = /^[1-9]+[0-9]*]*$/
var re = /^[1-9]+[0-9]*]*$/ return re.test(port);
return re.test(port); }
}
$(function() { $(function() {
if (window.history && window.history.pushState) { if (window.history && window.history.pushState) {
$(window).on('popstate', function() { $(window).on('popstate', function() {
window.history.pushState('forward', null, '#'); window.history.pushState('forward', null, '#');
window.history.forward(1); window.history.forward(1);
}); });
} }
if ('pushState' in history) { if ('pushState' in history) {
window.history.pushState('forward', null, '#'); window.history.pushState('forward', null, '#');
window.history.forward(1); window.history.forward(1);
} else { } else {
History.pushState('forward', null, '?state=2'); History.pushState('forward', null, '?state=2');
window.history.forward(1); window.history.forward(1);
} }
window.onhashchange = function() { window.onhashchange = function() {
History.pushState('forward', null, '?state=1'); History.pushState('forward', null, '?state=1');
} }
load_page("html/client/list.html"); $(".logout").click(function() {
$(".logout").click(function(){ api_invoke("/logout", {}, function(data) {
api_invoke("/logout", {}, function(data){ location.href = "/";
location.href = "/"; })
}) });
});
window.clientList = []; });
}); function update_menu() {
function update_menu(){
api_invoke("/config/detail", {}, function(data) { api_invoke("/config/detail", {}, function(data) {
if (data.code == 20000) { if (data.code == 20000) {
clientList = data.data; clientList = data.data;
var html = template($("#menu-tpl").html(), {list: clientList}); var html = template($("#menu-tpl").html(), {
list : clientList
});
$(".layui-side-scroll").html(html); $(".layui-side-scroll").html(html);
layui.use('element', function() { layui.use('element', function() {
var element = layui.element; var element = layui.element;
@ -141,7 +140,7 @@
} }
}); });
} }
</script> </script>
<script id="menu-tpl" type="text/html"> <script id="menu-tpl" type="text/html">
<ul class="layui-nav layui-nav-tree"> <ul class="layui-nav layui-nav-tree">
<li class="layui-nav-item layui-nav-itemed"><a class="" <li class="layui-nav-item layui-nav-itemed"><a class=""

Loading…
Cancel
Save