convert.blade.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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="请填入要转换的配置信息" autofocus></textarea>
  58. </div>
  59. <div class="col-md-6">
  60. <textarea class="form-control" rows="22" name="result" id="result" onclick="this.focus();this.select()" readonly="readonly"></textarea>
  61. </div>
  62. <div class="col-md-6">
  63. <button class="btn btn-block btn-primary" onclick="Convert()">转 换</button>
  64. </div>
  65. <div class="col-md-6">
  66. <a href="/tools/download?type=1" class="btn btn-block btn-danger">下 载</a>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. @endsection
  73. @section('script')
  74. <script type="text/javascript">
  75. // 转换
  76. function Convert() {
  77. const content = $('#content').val();
  78. if (content.trim() === '') {
  79. swal.fire({title: '请填入要转换的配置信息', type: 'warning', timer: 1000, showConfirmButton: false});
  80. return;
  81. }
  82. swal.fire({
  83. title: '确定继续转换吗?',
  84. type: 'question',
  85. allowEnterKey: false,
  86. showCancelButton: true,
  87. cancelButtonText: '{{trans('home.ticket_close')}}',
  88. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  89. }).then((result) => {
  90. if (result.value) {
  91. $.ajax({
  92. type: "POST",
  93. url: "/tools/convert",
  94. async: false,
  95. data: {
  96. _token: '{{csrf_token()}}',
  97. method: $('#method').val(),
  98. transfer_enable: $('#transfer_enable').val(),
  99. protocol: $('#protocol').val(),
  100. protocol_param: $('#protocol_param').val(),
  101. obfs: $('#obfs').val(),
  102. obfs_param: $('#obfs_param').val(),
  103. content: content
  104. },
  105. dataType: 'json',
  106. success: function (ret) {
  107. if (ret.status === 'success') {
  108. $("#result").val(ret.data);
  109. } else {
  110. $("#result").val(ret.message);
  111. }
  112. }
  113. })
  114. }
  115. });
  116. return false;
  117. }
  118. </script>
  119. @endsection