config.blade.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. @extends('admin.layouts')
  2. @section('css')
  3. <script src="//at.alicdn.com/t/font_682457_e6aq10jsbq0yhkt9.js" type="text/javascript"></script>
  4. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  5. @endsection
  6. @section('content')
  7. <div class="page-content container">
  8. <div class="panel">
  9. <div class="panel-heading">
  10. <h1 class="panel-title"><i class="icon wb-settings" aria-hidden="true"></i>通用配置</h1>
  11. </div>
  12. <div class="panel-body container-fluid">
  13. <div class="nav-tabs-vertical" data-plugin="tabs">
  14. <ul class="nav nav-tabs mr-25" role="tablist">
  15. <li class="nav-item" role="presentation">
  16. <a class="nav-link active" data-toggle="tab" href="#method" aria-controls="method"
  17. role="tab">加密</a>
  18. </li>
  19. <li class="nav-item" role="presentation">
  20. <a class="nav-link" data-toggle="tab" href="#protocol" aria-controls="protocol" role="tab">协议</a>
  21. </li>
  22. <li class="nav-item" role="presentation">
  23. <a class="nav-link" data-toggle="tab" href="#obfs" aria-controls="obfs" role="tab">混淆</a>
  24. </li>
  25. <li class="nav-item" role="presentation">
  26. <a class="nav-link" data-toggle="tab" href="#level" aria-controls="level" role="tab">等级</a>
  27. </li>
  28. <li class="nav-item" role="presentation">
  29. <a class="nav-link" data-toggle="tab" href="#country" aria-controls="country" role="tab">国家地区</a>
  30. </li>
  31. </ul>
  32. <div class="tab-content py-15">
  33. <div class="tab-pane active" id="method" role="tabpanel">
  34. <button class="btn btn-primary float-right mb-10" data-toggle="modal"
  35. data-target="#add_config_modal"> 新增
  36. <i class="icon wb-plus"></i></button>
  37. <table class="text-md-center" data-toggle="table" data-height="700"
  38. data-virtual-scroll="true" data-mobile-responsive="true">
  39. <thead class="thead-default">
  40. <tr>
  41. <th> 名称</th>
  42. <th> 操作</th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. @foreach($method_list as $method)
  47. <tr>
  48. <td> {{$method->name}}</td>
  49. <td>
  50. @if($method->is_default)
  51. <span class='badge badge-lg badge-default'>默认</span>
  52. @else
  53. <div class="btn-group">
  54. <button class="btn btn-primary"
  55. onclick="setDefault('{{$method->id}}')">默认
  56. </button>
  57. <button class="btn btn-danger"
  58. onclick="delConfig('{{$method->id}}','{{$method->name}}')">
  59. <i class="icon wb-trash"></i>
  60. </button>
  61. </div>
  62. @endif
  63. </td>
  64. </tr>
  65. @endforeach
  66. </tbody>
  67. </table>
  68. </div>
  69. <div class="tab-pane" id="protocol" role="tabpanel">
  70. <button class="btn btn-primary float-right mb-10" data-toggle="modal"
  71. data-target="#add_config_modal"> 新增
  72. <i class="icon wb-plus"></i></button>
  73. <table class="text-md-center" data-toggle="table" data-height="700"
  74. data-virtual-scroll="true" data-mobile-responsive="true">
  75. <thead class="thead-default">
  76. <tr>
  77. <th> 名称</th>
  78. <th> 操作</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. @foreach($protocol_list as $protocol)
  83. <tr>
  84. <td> {{$protocol->name}}</td>
  85. <td>
  86. @if($protocol->is_default)
  87. <span class="badge badge-lg badge-default">默认</span>
  88. @else
  89. <div class="btn-group">
  90. <button class="btn btn-primary"
  91. onclick="setDefault('{{$protocol->id}}')">默认
  92. </button>
  93. <button class="btn btn-danger"
  94. onclick="delConfig('{{$protocol->id}}','{{$protocol->name}}')">
  95. <i class="icon wb-trash"></i>
  96. </button>
  97. </div>
  98. @endif
  99. </td>
  100. </tr>
  101. @endforeach
  102. </tbody>
  103. </table>
  104. </div>
  105. <div class="tab-pane" id="obfs" role="tabpanel">
  106. <button class="btn btn-primary float-right mb-10" data-toggle="modal"
  107. data-target="#add_config_modal"> 新增
  108. <i class="icon wb-plus"></i></button>
  109. <table class="text-md-center" data-toggle="table" data-height="700"
  110. data-virtual-scroll="true" data-mobile-responsive="true">
  111. <thead class="thead-default">
  112. <tr>
  113. <th> 名称</th>
  114. <th> 操作</th>
  115. </tr>
  116. </thead>
  117. <tbody>
  118. @foreach($obfs_list as $obfs)
  119. <tr>
  120. <td> {{$obfs->name}}</td>
  121. <td>
  122. @if($obfs->is_default)
  123. <span class="badge badge-lg badge-default">默认</span>
  124. @else
  125. <button class="btn btn-primary" onclick="setDefault('{{$obfs->id}}')">
  126. 默认
  127. </button>
  128. <button class="btn btn-danger"
  129. onclick="delConfig('{{$obfs->id}}','{{$obfs->name}}')">
  130. <i class="icon wb-trash"></i>
  131. </button>
  132. @endif
  133. </td>
  134. </tr>
  135. @endforeach
  136. </tbody>
  137. </table>
  138. </div>
  139. <div class="tab-pane" id="level" role="tabpanel">
  140. <button class="btn btn-primary float-right mb-10" data-toggle="modal"
  141. data-target="#add_level_modal"> 新增
  142. <i class="icon wb-plus"></i></button>
  143. <table class="text-md-center" data-toggle="table" data-height="700"
  144. data-virtual-scroll="true" data-mobile-responsive="true">
  145. <thead class="thead-default">
  146. <tr>
  147. <th> 等级</th>
  148. <th> 名称</th>
  149. <th> 操作</th>
  150. </tr>
  151. </thead>
  152. <tbody>
  153. @foreach($level_list as $level)
  154. <tr>
  155. <td>
  156. <input type="text" class="form-control" name="level"
  157. id="level_{{$level->id}}" value="{{$level->level}}"/>
  158. </td>
  159. <td>
  160. <input type="text" class="form-control" name="level_name"
  161. id="level_name_{{$level->id}}" value="{{$level->level_name}}"/>
  162. </td>
  163. <td>
  164. <div class="btn-group">
  165. <button type="button" class="btn btn-primary"
  166. onclick="updateLevel('{{$level->id}}')">修改
  167. </button>
  168. <button type="button" class="btn btn-danger"
  169. onclick="delLevel('{{$level->id}}','{{$level->level_name}}')">
  170. <i class="icon wb-trash"></i>
  171. </button>
  172. </div>
  173. </td>
  174. </tr>
  175. @endforeach
  176. </tbody>
  177. </table>
  178. </div>
  179. <div class="tab-pane" id="country" role="tabpanel">
  180. <button class="btn btn-primary float-right mb-10" data-toggle="modal"
  181. data-target="#add_country_modal"> 新增
  182. <i class="icon wb-plus"></i></button>
  183. <table class="text-md-center" data-toggle="table" data-height="600"
  184. data-virtual-scroll="true" data-mobile-responsive="true">
  185. <thead class="thead-default">
  186. <tr>
  187. <th> 图标</th>
  188. <th> 国家/地区名称</th>
  189. <th> 代码</th>
  190. <th> 操作</th>
  191. </tr>
  192. </thead>
  193. <tbody>
  194. @foreach($country_list as $country)
  195. <tr>
  196. <td>
  197. <svg class="w-40 h-40 text-center" aria-hidden="true">
  198. <use
  199. xlink:href="@if($country->code)#icon-{{$country->code}}@endif"></use>
  200. </svg>
  201. </td>
  202. <td>
  203. <input type="text" class="form-control" name="country_name"
  204. id="country_name_{{$country->id}}" value="{{$country->name}}"/>
  205. </td>
  206. <td>
  207. <input type="text" class="form-control" name="country_code"
  208. id="country_code_{{$country->id}}" value="{{$country->code}}"/>
  209. </td>
  210. <td>
  211. <div class="btn-group">
  212. <button type="button" class="btn btn-primary"
  213. onclick="updateCountry('{{$country->id}}')">修改
  214. </button>
  215. <button type="button" class="btn btn-danger"
  216. onclick="delCountry('{{$country->id}}','{{$country->name}}')"><i
  217. class="icon wb-trash"></i></button>
  218. </div>
  219. </td>
  220. </tr>
  221. @endforeach
  222. </tbody>
  223. </table>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="modal fade" id="add_config_modal" aria-hidden="true" role="dialog" tabindex="-1">
  231. <div class="modal-dialog modal-simple modal-center">
  232. <div class="modal-content">
  233. <div class="modal-header">
  234. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  235. <span aria-hidden="true">×</span>
  236. </button>
  237. <h4 class="modal-title">新增配置</h4>
  238. </div>
  239. <form action="#" method="post" class="modal-body">
  240. <div class="alert alert-danger" style="display: none;" id="msg"></div>
  241. <div class="row">
  242. <div class="col-md-6 form-group">
  243. <select class="form-control" name="type" id="type" placeholder="类型">
  244. <option value="1" selected>加密方式</option>
  245. <option value="2">协议</option>
  246. <option value="3">混淆</option>
  247. </select>
  248. </div>
  249. <div class="col-md-6 form-group">
  250. <input type="text" class="form-control" name="name" id="name" placeholder="名称">
  251. </div>
  252. </div>
  253. </form>
  254. <div class="modal-footer">
  255. <button class="btn btn-danger" data-dismiss="modal">关 闭</button>
  256. <button class="btn btn-primary" onclick="addConfig()">提 交</button>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. <div class="modal fade" id="add_level_modal" aria-hidden="true" role="dialog" tabindex="-1">
  262. <div class="modal-dialog modal-simple modal-center">
  263. <div class="modal-content">
  264. <div class="modal-header">
  265. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  266. <span aria-hidden="true">×</span>
  267. </button>
  268. <h4 class="modal-title">新增配置</h4>
  269. </div>
  270. <form action="#" method="post" class="modal-body">
  271. <div class="alert alert-danger" style="display: none;" id="level_msg"></div>
  272. <div class="row">
  273. <div class="col-md-6 form-group">
  274. <input type="text" class="form-control" name="level" id="add_level" placeholder="等级">
  275. </div>
  276. <div class="col-md-6 form-group">
  277. <input type="text" class="form-control" name="level_name" id="add_level_name"
  278. placeholder="等级名称">
  279. </div>
  280. </div>
  281. </form>
  282. <div class="modal-footer">
  283. <button data-dismiss="modal" class="btn btn-danger">关 闭</button>
  284. <button class="btn btn-primary" onclick="addLevel('4')">提 交</button>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. <div class="modal fade" id="add_country_modal" aria-hidden="true" role="dialog" tabindex="-1">
  290. <div class="modal-dialog modal-simple modal-center">
  291. <div class="modal-content">
  292. <div class="modal-header">
  293. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  294. <span aria-hidden="true">×</span>
  295. </button>
  296. <h4 class="modal-title">新增国家/地区</h4>
  297. </div>
  298. <form action="#" method="post" class="modal-body">
  299. <div class="alert alert-danger" style="display: none;" id="country_msg"></div>
  300. <div class="row">
  301. <div class="col-md-6 form-group">
  302. <input type="text" class="form-control" name="country_name" id="add_country_name"
  303. placeholder=" 国家/地区名称">
  304. </div>
  305. <div class="col-md-6 form-group">
  306. <input type="text" class="form-control" name="country_code" id="add_country_code"
  307. placeholder="国家代码">
  308. </div>
  309. </div>
  310. </form>
  311. <div class="modal-footer">
  312. <button data-dismiss="modal" class="btn btn-danger">关 闭</button>
  313. <button class="btn btn-primary" onclick="addCountry('5')">提 交</button>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. @endsection
  319. @section('script')
  320. <script src="/assets/global/vendor/matchheight/jquery.matchHeight-min.js" type="text/javascript"></script>
  321. <script src="/assets/global/js/Plugin/tabs.js" type="text/javascript"></script>
  322. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  323. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"
  324. type="text/javascript"></script>
  325. <script type="text/javascript">
  326. // 添加等级
  327. function addLevel() {
  328. const level = $('#add_level').val();
  329. const level_name = $('#add_level_name').val();
  330. if (level.trim() === '') {
  331. $("#level_msg").show().html("等级不能为空");
  332. $("#level").focus();
  333. return false;
  334. }
  335. if (level_name.trim() === '') {
  336. $("#level_msg").show().html("等级名称不能为空");
  337. $("#level_name").focus();
  338. return false;
  339. }
  340. $.ajax({
  341. url: '/admin/addLevel',
  342. type: "POST",
  343. data: {_token: '{{csrf_token()}}', level: level, level_name: level_name},
  344. beforeSend: function () {
  345. $("#level_msg").show().html("正在添加");
  346. },
  347. success: function (ret) {
  348. if (ret.status === 'fail') {
  349. $("#level_msg").show().html(ret.message);
  350. return false;
  351. }
  352. $("#add_level_modal").modal("hide");
  353. window.location.href = '/admin/config';
  354. },
  355. error: function () {
  356. $("#level_msg").show().html("请求错误,请重试");
  357. },
  358. complete: function () {
  359. swal.fire({
  360. title: '添加成功',
  361. type: "success",
  362. timer: 1000,
  363. showConfirmButton: false
  364. }).then(() => window.location.reload())
  365. }
  366. });
  367. }
  368. // 更新等级
  369. function updateLevel(id) {
  370. $.ajax({
  371. type: "POST",
  372. url: "/admin/updateLevel",
  373. async: false,
  374. data: {
  375. _token: '{{csrf_token()}}',
  376. id: id,
  377. level: $('#level_' + id).val(),
  378. level_name: $('#level_name_' + id).val()
  379. },
  380. dataType: 'json',
  381. success: function (ret) {
  382. if (ret.status === 'success') {
  383. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  384. .then(() => window.location.href = '/admin/config')
  385. } else {
  386. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  387. }
  388. }
  389. });
  390. }
  391. // 删除等级
  392. function delLevel(id, name) {
  393. swal.fire({
  394. title: '确定删除等级 【' + name + '】 ?',
  395. type: 'question',
  396. allowEnterKey: false,
  397. showCancelButton: true,
  398. cancelButtonText: '{{trans('home.ticket_close')}}',
  399. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  400. }).then((result) => {
  401. if (result.value) {
  402. $.post("/admin/delLevel", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  403. if (ret.status === 'success') {
  404. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  405. .then(() => window.location.href = '/admin/config')
  406. } else {
  407. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  408. }
  409. });
  410. }
  411. })
  412. }
  413. // 添加国家/地区
  414. function addCountry() {
  415. const country_name = $('#add_country_name').val();
  416. const country_code = $('#add_country_code').val();
  417. if (country_name.trim() === '') {
  418. $("#country_msg").show().html("国家/地区名称不能为空");
  419. $("#add_country_name").focus();
  420. return false;
  421. }
  422. if (country_code.trim() === '') {
  423. $("#country_msg").show().html("国家/地区代码不能为空");
  424. $("#add_country_code").focus();
  425. return false;
  426. }
  427. $.ajax({
  428. url: '/admin/addCountry',
  429. type: "POST",
  430. data: {_token: '{{csrf_token()}}', country_name: country_name, country_code: country_code},
  431. beforeSend: function () {
  432. $("#country_msg").show().html("正在添加");
  433. },
  434. success: function (ret) {
  435. if (ret.status === 'fail') {
  436. $("#country_msg").show().html(ret.message);
  437. return false;
  438. }
  439. $("#add_country_modal").modal("hide");
  440. window.location.href = '/admin/config';
  441. },
  442. error: function () {
  443. $("#country_msg").show().html("请求错误,请重试");
  444. },
  445. complete: function () {
  446. swal.fire({
  447. title: '添加成功',
  448. type: "success",
  449. timer: 1000,
  450. showConfirmButton: false
  451. }).then(() => window.location.reload())
  452. }
  453. });
  454. }
  455. // 更新国家/地区
  456. function updateCountry(id) {
  457. const country_name = $('#country_name_' + id).val();
  458. const country_code = $('#country_code_' + id).val();
  459. $.ajax({
  460. type: "POST",
  461. url: "/admin/updateCountry",
  462. async: false,
  463. data: {_token: '{{csrf_token()}}', id: id, country_name: country_name, country_code: country_code},
  464. dataType: 'json',
  465. success: function (ret) {
  466. if (ret.status === 'success') {
  467. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  468. .then(() => window.location.href = '/admin/config')
  469. } else {
  470. swal.fire({title: ret.message, type: "error"});
  471. }
  472. }
  473. });
  474. }
  475. // 删除国家/地区
  476. function delCountry(id, name) {
  477. swal.fire({
  478. title: '确定删除 【' + name + '】 信息?',
  479. type: 'question',
  480. allowEnterKey: false,
  481. showCancelButton: true,
  482. cancelButtonText: '{{trans('home.ticket_close')}}',
  483. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  484. }).then((result) => {
  485. if (result.value) {
  486. $.post("/admin/delCountry", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  487. if (ret.status === 'success') {
  488. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  489. .then(() => window.location.href = '/admin/config')
  490. } else {
  491. swal.fire({title: ret.message, type: "error"});
  492. }
  493. });
  494. }
  495. })
  496. }
  497. // 添加配置
  498. function addConfig() {
  499. const name = $("#name").val();
  500. const type = $("#type").val();
  501. if (name.trim() === '') {
  502. $("#msg").show().html("名称不能为空");
  503. $("#name").focus();
  504. return false;
  505. }
  506. $.ajax({
  507. url: '/admin/config',
  508. type: "POST",
  509. data: {_token: '{{csrf_token()}}', name: name, type: type},
  510. beforeSend: function () {
  511. $("#msg").show().html("正在添加");
  512. },
  513. success: function (ret) {
  514. if (ret.status === 'fail') {
  515. $("#msg").show().html(ret.message);
  516. return false;
  517. }
  518. $("#add_config_modal").modal("hide");
  519. },
  520. error: function () {
  521. $("#msg").show().html("请求错误,请重试");
  522. },
  523. complete: function () {
  524. swal.fire({
  525. title: '添加成功',
  526. type: "success",
  527. timer: 1000,
  528. showConfirmButton: false
  529. }).then(() => window.location.reload())
  530. }
  531. });
  532. }
  533. // 删除配置
  534. function delConfig(id, name) {
  535. swal.fire({
  536. title: '确定删除配置 【' + name + '】 ?',
  537. type: 'question',
  538. allowEnterKey: false,
  539. showCancelButton: true,
  540. cancelButtonText: '{{trans('home.ticket_close')}}',
  541. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  542. }).then((result) => {
  543. if (result.value) {
  544. $.post("/admin/delConfig", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  545. if (ret.status === 'success') {
  546. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  547. .then(() => window.location.href = '/admin/config')
  548. } else {
  549. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  550. }
  551. });
  552. }
  553. })
  554. }
  555. // 置为默认
  556. function setDefault(id) {
  557. $.ajax({
  558. type: "POST",
  559. url: "/admin/setDefaultConfig",
  560. async: false,
  561. data: {_token: '{{csrf_token()}}', id: id},
  562. dataType: 'json',
  563. success: function (ret) {
  564. if (ret.status === 'success') {
  565. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  566. .then(() => window.location.href = '/admin/config')
  567. } else {
  568. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  569. }
  570. }
  571. });
  572. }
  573. </script>
  574. @endsection