增加 web_base_url 配置, 用于配置 web 后台可置于代理子路径下

This commit is contained in:
涵曦
2019-05-10 16:29:55 +00:00
parent 4b7b2f4c27
commit 383dbd1b7b
21 changed files with 124 additions and 73 deletions

View File

@@ -134,7 +134,7 @@
$("#add").on("click", function () {
$.ajax({
type: "POST",
url: "/client/add",
url: "{{.web_base_url}}/client/add",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)

View File

@@ -145,7 +145,7 @@
$("#add").on("click", function () {
$.ajax({
type: "POST",
url: "/client/edit",
url: "{{.web_base_url}}/client/edit",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)

View File

@@ -20,7 +20,7 @@
<div class="table-responsive">
<div id="toolbar">
<a href="/client/add" class="btn btn-primary dim" type="button" langtag="info-new">新增</a>
<a href="{{.web_base_url}}/client/add" class="btn btn-primary dim" type="button" langtag="info-new">新增</a>
</div>
<table id="taskList_table" class="table-striped table-hover"
data-mobile-responsive="true"></table>
@@ -42,7 +42,7 @@
if (confirm("Are you sure you want to delete it")) {
$.ajax({
type: "POST",
url: "/client/del",
url: "{{.web_base_url}}/client/del",
data: {"id": id},
success: function (res) {
alert(res.msg)
@@ -58,7 +58,7 @@
if (confirm("Are you sure you want to start it")) {
$.ajax({
type: "POST",
url: "/client/changestatus",
url: "{{.web_base_url}}/client/changestatus",
data: {"id": id, "status": 1},
success: function (res) {
alert(res.msg)
@@ -74,7 +74,7 @@
if (confirm("Are you sure you want to stop it")) {
$.ajax({
type: "POST",
url: "/client/changestatus",
url: "{{.web_base_url}}/client/changestatus",
data: {
"id": id, "status": 0
},
@@ -90,26 +90,26 @@
}
function edit(id) {
window.location.href = "/client/edit?id=" + id
window.location.href = "{{.web_base_url}}/client/edit?id=" + id
}
function add() {
window.location.href = "/client/add"
window.location.href = "{{.web_base_url}}/client/add"
}
function tunnel(id) {
window.location.href = "/index/all?client_id=" + id
window.location.href = "{{.web_base_url}}/index/all?client_id=" + id
}
function host(id) {
window.location.href = "/index/hostlist?client_id=" + id
window.location.href = "{{.web_base_url}}/index/hostlist?client_id=" + id
}
/*bootstrap table*/
$('#table').bootstrapTable({
toolbar: "#toolbar",
method: 'post', // 服务器数据的请求方式 get or post
url: "/client/list", // 服务器数据的加载地址
url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
contentType: "application/x-www-form-urlencoded",
striped: true, // 设置为true会有隔行变色效果
search: true,

View File

@@ -162,7 +162,7 @@
$("#add").on("click", function () {
$.ajax({
type: "POST",
url: "/index/add",
url: "{{.web_base_url}}/index/add",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)

View File

@@ -160,7 +160,7 @@
$("#add").on("click", function () {
$.ajax({
type: "POST",
url: "/index/edit",
url: "{{.web_base_url}}/index/edit",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)

View File

@@ -112,7 +112,7 @@
$("#add").on("click", function () {
$.ajax({
type: "POST",
url: "/index/addhost",
url: "{{.web_base_url}}/index/addhost",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)

View File

@@ -116,7 +116,7 @@
$("#add").on("click", function () {
$.ajax({
type: "POST",
url: "/index/edithost",
url: "{{.web_base_url}}/index/edithost",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)

View File

@@ -18,7 +18,7 @@
<div class="content">
<div class="table-responsive">
<div id="toolbar">
<a href="/index/addhost?vkey={{.task_id}}&client_id={{.client_id}}"
<a href="{{.web_base_url}}/index/addhost?vkey={{.task_id}}&client_id={{.client_id}}"
class="btn btn-primary dim"
type="button" langtag="info-new">新增</a>
</div>
@@ -158,7 +158,7 @@
if (confirm("Are you sure you want to delete it")) {
$.ajax({
type: "POST",
url: "/index/delhost",
url: "{{.web_base_url}}/index/delhost",
data: {"id": id},
success: function (res) {
alert(res.msg)
@@ -171,7 +171,7 @@
}
function edit(id) {
window.location.href = "/index/edithost?id=" + id
window.location.href = "{{.web_base_url}}/index/edithost?id=" + id
}

View File

@@ -18,7 +18,7 @@
<div class="content">
<div class="table-responsive">
<div id="toolbar">
<a href="/index/add?type={{.type}}&client_id={{.client_id}}" class="btn btn-primary dim"
<a href="{{.web_base_url}}/index/add?type={{.type}}&client_id={{.client_id}}" class="btn btn-primary dim"
type="button" langtag="info-new">新增</a>
</div>
<table id="taskList_table" class="table-striped table-hover"
@@ -40,7 +40,7 @@
$('#table').bootstrapTable({
toolbar: "#toolbar",
method: 'post', // 服务器数据的请求方式 get or post
url: "/index/gettunnel", // 服务器数据的加载地址
url: "{{.web_base_url}}/index/gettunnel", // 服务器数据的加载地址
queryParams: function (params) {
return {
"offset": params.offset,
@@ -191,7 +191,7 @@
if (confirm("Are you sure you want to delete it")) {
$.ajax({
type: "POST",
url: "/index/del",
url: "{{.web_base_url}}/index/del",
data: {"id": id},
success: function (res) {
alert(res.msg)
@@ -207,7 +207,7 @@
if (confirm("Are you sure you want to start it")) {
$.ajax({
type: "POST",
url: "/index/start",
url: "{{.web_base_url}}/index/start",
data: {"id": id},
success: function (res) {
alert(res.msg)
@@ -223,7 +223,7 @@
if (confirm("Are you sure you want to stop it")) {
$.ajax({
type: "POST",
url: "/index/stop",
url: "{{.web_base_url}}/index/stop",
data: {"id": id},
success: function (res) {
alert(res.msg)
@@ -236,7 +236,7 @@
}
function edit(id) {
window.location.href = "/index/edit?id=" + id
window.location.href = "{{.web_base_url}}/index/edit?id=" + id
}
</script>

View File

@@ -8,10 +8,10 @@
<title>nps admin login</title>
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/css/bootstrap.min.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="/static/css/style.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/css/style.css" rel="stylesheet">
</head>
@@ -49,7 +49,7 @@
</div>
<button onclick="login()" class="btn btn-primary block full-width m-b">login</button>
{{if eq true .register_allow}}
<a class="btn btn-sm btn-white btn-block" href="/login/register">register</a>
<a class="btn btn-sm btn-white btn-block" href="{{.web_base_url}}/login/register">register</a>
{{end}}
</form>
</div>
@@ -59,7 +59,7 @@
</div>
</body>
<script src="/static/js/jquery-2.1.1.js"></script>
<script src="{{.web_base_url}}/static/js/jquery-2.1.1.js"></script>
</html>
@@ -68,11 +68,11 @@
function login() {
$.ajax({
type: "POST",
url: "/login/verify",
url: "{{.web_base_url}}/login/verify",
data: $("form").serializeArray(),
success: function (res) {
if (res.status) {
window.location.href = "/index/index"
window.location.href = "{{.web_base_url}}/index/index"
} else {
alert(res.msg)
}

View File

@@ -8,10 +8,10 @@
<title>nps register</title>
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/css/bootstrap.min.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="/static/css/style.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/css/style.css" rel="stylesheet">
</head>
@@ -34,22 +34,22 @@
</div>
<button onclick="register()" type="submit" class="btn btn-primary block full-width m-b">register</button>
<a class="btn btn-sm btn-white btn-block" href="/login/index">login</a>
<a class="btn btn-sm btn-white btn-block" href="{{.web_base_url}}/login/index">login</a>
</form>
</div>
</div>
<script src="/static/js/jquery-2.1.1.js"></script>
<script src="{{.web_base_url}}/static/js/jquery-2.1.1.js"></script>
<script>
function register() {
$.ajax({
type: "POST",
url: "/login/register",
url: "{{.web_base_url}}/login/register",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)
if (res.status) {
window.location.href = "/login/index"
window.location.href = "{{.web_base_url}}/login/index"
}
}
})

View File

@@ -9,22 +9,22 @@
<title>nps admin</title>
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="/static/css/style.css" rel="stylesheet">
<script src="/static/js/main.js"></script>
<link href="{{.web_base_url}}/static/css/bootstrap.min.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="{{.web_base_url}}/static/css/style.css" rel="stylesheet">
<script src="{{.web_base_url}}/static/js/main.js"></script>
<!-- Mainly scripts -->
<script src="/static/js/jquery-2.1.1.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/echarts.min.js"></script>
<script src="{{.web_base_url}}/static/js/jquery-2.1.1.js"></script>
<script src="{{.web_base_url}}/static/js/bootstrap.min.js"></script>
<script src="{{.web_base_url}}/static/js/echarts.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="/static/css/bootstrap-table.min.css">
<link rel="stylesheet" href="{{.web_base_url}}/static/css/bootstrap-table.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="/static/js/bootstrap-table.min.js"></script>
<script src="/static/js/inspinia.js"></script>
<script src="{{.web_base_url}}/static/js/bootstrap-table.min.js"></script>
<script src="{{.web_base_url}}/static/js/inspinia.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="/static/js/langchange.js" type="text/javascript"></script>
<script src="{{.web_base_url}}/static/js/langchange.js" type="text/javascript"></script>
</head>
@@ -35,7 +35,7 @@
<ul class="nav metismenu" id="side-menu">
<li class="nav-header">
<div class="dropdown profile-element"> <span>
{{/*<img alt="image" class="img-circle" src="/static/img/profile_small.jpg"/>*/}}
{{/*<img alt="image" class="img-circle" src="{{.web_base_url}}/static/img/profile_small.jpg"/>*/}}
</span>
<a href="#">
<span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">
@@ -53,42 +53,42 @@
</div>
</li>
<li class="{{if eq "index" .menu}}active{{end}}">
<a href="/"><i class="fa fa-dashboard"></i> <span langtag="menu-dashboard"
<a href="{{.web_base_url}}/"><i class="fa fa-dashboard"></i> <span langtag="menu-dashboard"
class="nav-label">仪表盘</span></a>
</li>
<li class="{{if eq "client" .menu}}active{{end}}">
<a href="/client/list"><i class="fa fa-clipboard"></i> <span langtag="menu-client"
<a href="{{.web_base_url}}/client/list"><i class="fa fa-clipboard"></i> <span langtag="menu-client"
class="nav-label">客户端</span></a>
</li>
<li class="{{if eq "host" .menu}}active{{end}}">
<a href="/index/hostlist"><i class="fa fa-paperclip"></i> <span langtag="menu-host"
<a href="{{.web_base_url}}/index/hostlist"><i class="fa fa-paperclip"></i> <span langtag="menu-host"
class="nav-label">域名解析</span></a>
</li>
<li class="{{if eq "tcp" .menu}}active{{end}}">
<a href="/index/tcp"><i class="fa fa-line-chart"></i> <span langtag="menu-tcp"
<a href="{{.web_base_url}}/index/tcp"><i class="fa fa-line-chart"></i> <span langtag="menu-tcp"
class="nav-label">tcp隧道</span></a>
</li>
<li class="{{if eq "udp" .menu}}active{{end}}">
<a href="/index/udp"><i class="fa fa-server"></i> <span langtag="menu-udp"
<a href="{{.web_base_url}}/index/udp"><i class="fa fa-server"></i> <span langtag="menu-udp"
class="nav-label">udp隧道</span></a>
</li>
<li class="{{if eq "http" .menu}}active{{end}}">
<a href="/index/http"><i class="fa fa-html5"></i> <span langtag="menu-http"
<a href="{{.web_base_url}}/index/http"><i class="fa fa-html5"></i> <span langtag="menu-http"
class="nav-label">http代理</span></a>
</li>
<li class="{{if eq "socks5" .menu}}active{{end}}">
<a href="/index/socks5"><i class="fa fa-table"></i> <span langtag="menu-socks5" class="nav-label">socks5代理</span></a>
<a href="{{.web_base_url}}/index/socks5"><i class="fa fa-table"></i> <span langtag="menu-socks5" class="nav-label">socks5代理</span></a>
</li>
<li class="{{if eq "secret" .menu}}active{{end}}">
<a href="/index/secret"><i class="fa fa-backward"></i> <span langtag="menu-secret"
<a href="{{.web_base_url}}/index/secret"><i class="fa fa-backward"></i> <span langtag="menu-secret"
class="nav-label">私密代理</span></a>
</li>
<li class="{{if eq "p2p" .menu}}active{{end}}">
<a href="/index/p2p"><i class="fa fa-dashcube"></i> <span langtag="menu-p2p"
<a href="{{.web_base_url}}/index/p2p"><i class="fa fa-dashcube"></i> <span langtag="menu-p2p"
class="nav-label">p2p代理</span></a>
</li>
<li class="{{if eq "file" .menu}}active{{end}}">
<a href="/index/file"><i class="fa fa-laptop"></i> <span langtag="menu-file"
<a href="{{.web_base_url}}/index/file"><i class="fa fa-laptop"></i> <span langtag="menu-file"
class="nav-label">文件代理</span></a>
</li>
</ul>
@@ -115,7 +115,7 @@
</li>
<li>
<a href="/login/out">
<a href="{{.web_base_url}}/login/out">
<i class="fa fa-sign-out"></i> logout
</a>
</li>
@@ -142,6 +142,9 @@
</html>
<script>
window.nps = {
"web_base_url": {{.web_base_url}},
}
// googleTranslateElementInit()
//
// function googleTranslateElementInit() {