config.blade.php 23 KB

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