convert.blade.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. @extends('admin.layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h2 class="panel-title">格式转换
  7. <small>Shadowsocks 转 ShadowsocksR</small>
  8. </h2>
  9. </div>
  10. <div class="panel-body">
  11. <div class="row">
  12. <div class="col-md-4 form-group">
  13. <label for="method">加密方式</label>
  14. <select class="form-control" name="method" id="method">
  15. @foreach ($method_list as $method)
  16. <option value="{{$method->name}}"
  17. @if($method->is_default) selected @endif>{{$method->name}}</option>
  18. @endforeach
  19. </select>
  20. </div>
  21. <div class="col-md-4 form-group">
  22. <label for="transfer_enable">可用流量</label>
  23. <div class="input-group">
  24. <input type="number" class="form-control" name="transfer_enable" value="1000"
  25. id="transfer_enable" placeholder="" required>
  26. <span class="input-group-text">GB</span>
  27. </div>
  28. </div>
  29. <div class="col-md-4 form-group">
  30. <label for="protocol">协议</label>
  31. <select class="form-control" name="protocol" id="protocol">
  32. @foreach ($protocol_list as $protocol)
  33. <option value="{{$protocol->name}}"
  34. @if($protocol->is_default) selected @endif>{{$protocol->name}}</option>
  35. @endforeach
  36. </select>
  37. </div>
  38. <div class="col-md-4 form-group">
  39. <label for="protocol_param">协议参数</label>
  40. <input type="text" class="form-control" name="protocol_param" id="protocol_param"
  41. placeholder="">
  42. </div>
  43. <div class="col-md-4 form-group">
  44. <label for="obfs">混淆</label>
  45. <select class="form-control" name="obfs" id="obfs">
  46. @foreach ($obfs_list as $obfs)
  47. <option value="{{$obfs->name}}"
  48. @if($obfs->is_default) selected @endif>{{$obfs->name}}</option>
  49. @endforeach
  50. </select>
  51. </div>
  52. <div class="col-md-4 form-group">
  53. <label for="obfs_param">混淆参数</label>
  54. <input type="text" class="form-control" name="obfs_param" id="obfs_param" placeholder="">
  55. </div>
  56. <div class="col-md-6">
  57. <textarea class="form-control" rows="22" name="content" id="content" placeholder="请填入要转换的配置信息"
  58. autofocus></textarea>
  59. </div>
  60. <div class="col-md-6">
  61. <textarea class="form-control" rows="22" name="result" id="result"
  62. onclick="this.focus();this.select()" readonly="readonly"></textarea>
  63. </div>
  64. <div class="col-md-6">
  65. <button class="btn btn-block btn-primary" onclick="Convert()">转 换</button>
  66. </div>
  67. <div class="col-md-6">
  68. <a href="/admin/download?type=1" class="btn btn-block btn-danger">下 载</a>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. @endsection
  75. @section('script')
  76. <script type="text/javascript">
  77. // 转换
  78. function Convert() {
  79. const content = $('#content').val();
  80. if (content.trim() === '') {
  81. swal.fire({title: '请填入要转换的配置信息', type: 'warning', timer: 1000, showConfirmButton: false});
  82. return;
  83. }
  84. swal.fire({
  85. title: '确定继续转换吗?',
  86. type: 'question',
  87. allowEnterKey: false,
  88. showCancelButton: true,
  89. cancelButtonText: '{{trans('home.ticket_close')}}',
  90. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  91. }).then((result) => {
  92. if (result.value) {
  93. $.ajax({
  94. type: "POST",
  95. url: "/admin/convert",
  96. async: false,
  97. data: {
  98. _token: '{{csrf_token()}}',
  99. method: $('#method').val(),
  100. transfer_enable: $('#transfer_enable').val(),
  101. protocol: $('#protocol').val(),
  102. protocol_param: $('#protocol_param').val(),
  103. obfs: $('#obfs').val(),
  104. obfs_param: $('#obfs_param').val(),
  105. content: content
  106. },
  107. dataType: 'json',
  108. success: function (ret) {
  109. if (ret.status === 'success') {
  110. $("#result").val(ret.data);
  111. } else {
  112. $("#result").val(ret.message);
  113. }
  114. }
  115. })
  116. }
  117. });
  118. return false;
  119. }
  120. </script>
  121. @endsection