list.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <div class="row">
  2. <div class="col-md-12">
  3. <div class="tile">
  4. <div class="tile-body">
  5. <table class="table table-hover table-bordered" id="sampleTable">
  6. <thead>
  7. <tr>
  8. {{/*<th>模式</th>*/}}
  9. <th>监听端口</th>
  10. <th>内网目标</th>
  11. <th>多客户端模式客户端执行命令</th>
  12. <th>压缩方式</th>
  13. <th>加密传输</th>
  14. <th>用户名</th>
  15. <th>密码</th>
  16. <th>客户端状态</th>
  17. <th>状态</th>
  18. <th>操作</th>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. </tbody>
  23. </table>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </main>
  29. <script type="text/javascript">
  30. function del(vKey) {
  31. if (confirm("确定要删除数据吗?")) {
  32. $.ajax({
  33. type: "POST",
  34. url: "/index/del",
  35. data: {"vKey": vKey},
  36. success: function (res) {
  37. alert(res.msg)
  38. if (res.status) {
  39. document.location.reload();
  40. }
  41. }
  42. })
  43. }
  44. }
  45. function start(vKey) {
  46. if (confirm("确定要开始任务吗?")) {
  47. $.ajax({
  48. type: "POST",
  49. url: "/index/start",
  50. data: {"vKey": vKey},
  51. success: function (res) {
  52. alert(res.msg)
  53. if (res.status) {
  54. document.location.reload();
  55. }
  56. }
  57. })
  58. }
  59. }
  60. function stop(vKey) {
  61. if (confirm("确定要暂停吗?")) {
  62. $.ajax({
  63. type: "POST",
  64. url: "/index/stop",
  65. data: {"vKey": vKey},
  66. success: function (res) {
  67. alert(res.msg)
  68. if (res.status) {
  69. document.location.reload();
  70. }
  71. }
  72. })
  73. }
  74. }
  75. function edit(vKey) {
  76. window.location.href = "/index/edit?vKey=" + vKey
  77. }
  78. function add() {
  79. window.location.href = "/index/add?type=" +{{.type}}
  80. }
  81. function hostList(vkey) {
  82. window.location.href = "/index/hostlist?vkey=" + vkey
  83. }
  84. $(document).ready(function () {
  85. var table = $('#sampleTable').DataTable({
  86. dom: 'Bfrtip',
  87. processing: true,
  88. serverSide: true,
  89. autoWidth: false,
  90. ordering: false,
  91. ajax: {
  92. url: '/index/gettasklist?type={{.type}}',
  93. type: 'POST'
  94. },
  95. dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
  96. columns: [ //这个是显示到界面上的个数据 格式为 {data:'显示的字段名'}
  97. // {data: 'Mode'},
  98. {data: 'TcpPort'},
  99. {data: 'Target'},
  100. {data: 'VerifyKey'},
  101. {data: 'Compress'},
  102. {data: 'Crypt'},
  103. {data: 'U'},
  104. {data: 'P'},
  105. {data: 'ClientStatus'},
  106. {data: 'IsRun'},
  107. {data: "Id"}
  108. ],
  109. bFilter: false,
  110. columnDefs: [{
  111. targets: -1,
  112. render: function (data, type, row, meta) {
  113. if (row.IsRun == 1) {
  114. btn = "<button onclick=\"stop('" + row.VerifyKey + "')\" class=\"btn btn-secondary btn-sm\" type=\"button\">关闭</button>"
  115. } else {
  116. btn = "<button onclick=\"start('" + row.VerifyKey + "')\" class=\"btn btn-success btn-sm\" type=\"button\">打开</button>"
  117. }
  118. btn_edit = '<button onclick="edit(\'' + row.VerifyKey + '\')" type="button" class="btn btn-primary btn-sm">查看编辑</button> '
  119. if ({{.type}} == "hostServer"
  120. )
  121. {
  122. btn_host = '<button onclick="hostList(\'' + row.VerifyKey + '\')" type="button" class="btn btn-info btn-sm">域名管理</button> '
  123. }
  124. else
  125. {
  126. btn_host = ""
  127. }
  128. return '<div class="btn-group" role="group" aria-label="..."> ' +
  129. '<button onclick="del(\'' + row.VerifyKey + '\')" type="button" class="btn btn-danger btn-sm">删除</button>' +
  130. btn_edit + btn + btn_host + ' </div>'
  131. }
  132. },
  133. {
  134. targets: -2,
  135. render: function (data, type, row, meta) {
  136. if (data == 0) {
  137. return "<span class=\"badge badge-pill badge-secondary\">暂停</span>"
  138. } else {
  139. return "<span class=\"badge badge-pill badge-success\">正常</span>"
  140. }
  141. }
  142. },
  143. {
  144. targets: -6,
  145. render: function (data, type, row, meta) {
  146. if (data == "0") {
  147. return "不加密"
  148. } else {
  149. return "加密"
  150. }
  151. }
  152. },
  153. {
  154. targets: 2,
  155. render: function (data, type, row, meta) {
  156. return "./easyProxy -server={{.ip}}:{{.p}} -vkey=" + data
  157. // return data
  158. }
  159. },
  160. {
  161. targets: -3,
  162. render: function (data, type, row, meta) {
  163. if (data == 0) {
  164. return "<span class=\"badge badge-pill badge-secondary\">离线</span>"
  165. } else {
  166. return "<span class=\"badge badge-pill badge-success\">在线</span>"
  167. }
  168. }
  169. }
  170. ],
  171. buttons: []
  172. });
  173. $("#sampleTable_length").html('<button class="btn btn-primary" onclick="add()" type="button">新增</button>')
  174. })
  175. ;
  176. </script>