This commit is contained in:
lisida 2019-02-14 18:15:22 +08:00
parent d5d06d3b84
commit 5a670b51d3
2 changed files with 69 additions and 83 deletions

View File

@ -1,13 +1,13 @@
<html> <html>
<head> <head>
<title>Json Rpc Debug Tool</title> <title>Json Rpc Doc</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/highlight.js/9.13.1/styles/ocean.min.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/highlight.js/9.13.1/styles/ocean.min.css" rel="stylesheet">
</head> </head>
<body> <body>
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0"> <nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Json Rpc Debug Tool</a> <a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Json Rpc Doc</a>
{{--<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">--}} {{--<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">--}}
{{--<ul class="navbar-nav px-3">--}} {{--<ul class="navbar-nav px-3">--}}
{{--<li class="nav-item text-nowrap">--}} {{--<li class="nav-item text-nowrap">--}}
@ -23,17 +23,19 @@
<div class="sidebar-sticky"> <div class="sidebar-sticky">
<ul class="nav flex-column"> <ul class="nav flex-column">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" href="/rpc/doc.html"> <a class="nav-link active" href="#">
<span data-feather="home"></span> <span data-feather="home"></span>
文档 <span class="sr-only">(current)</span> Method <span class="sr-only">(current)</span>
</a> </a>
</li> </li>
{{--<li class="nav-item">--}} @foreach( $methods as $method )
{{--<a class="nav-link" href="#">--}} <li class="nav-item">
{{--<span data-feather="file"></span>--}} <a class="nav-link" href="#{{$method['method']}}">
{{--abc--}} <span data-feather="file"></span>
{{--</a>--}} {{$method['method']}}
{{--</li>--}} </a>
</li>
@endforeach
</ul> </ul>
</div> </div>
</nav> </nav>
@ -43,8 +45,8 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="endpoint">Endpoint</label> <label for="endpoint">Endpoint</label>
<input type="text" class="form-control" id="endpoint" placeholder="Endpoint" {{--<input type="text" class="form-control" id="endpoint" placeholder="Endpoint"--}}
value="{{$endpoint}}" readonly> {{-- value="{{$endpoint}}" readonly>--}}
</div> </div>
{{--<div class="form-group col-md-2">--}} {{--<div class="form-group col-md-2">--}}
{{--<label for="method">Request Method</label>--}} {{--<label for="method">Request Method</label>--}}
@ -55,60 +57,39 @@
{{--</div>--}} {{--</div>--}}
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="inputAddress">Method</label> <label for="inputAddress">Method</label>
<select class="form-control" id="method" name="method"> <select class="form-control" id="method" name="method">
@foreach($methods as $k => $v) {{--@foreach($methods as $k => $v)--}}
<option @if($method == $k) selected @endif>{{$k}}</option> {{--<option>{{$k}}</option>--}}
@endforeach {{--@endforeach--}}
</select> </select>
</div> </div>
<div class="table-item col-md-12">
<p class="table-title">
<span class="btn btn-xs btn-info">请求参数</span>
</p>
<table id="methodRequird" class="table">
<tr>
<td>参数</td>
<td>类型</td>
<td>描述</td>
<td>默认值</td>
<td>是否必须</td>
</tr>
</table>
</div>
</div>
<div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="inputAddress">Paramsjson 数组)</label> <label for="inputAddress">Params</label>
<div id="editor" style="height: 300px">{{$params}}</div> {{--<input type="text" class="form-control" name="params" id="params" placeholder="逗号分隔"--}}
<input type="hidden" name="params" id="params" value="{{$params}}"> {{--value="{{$params}}">--}}
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">Request</button> <button type="submit" class="btn btn-primary">Request</button>
</form> </form>
<div class="row col-md-12"> <div class="row col-md-12">
@if( !empty($error) ) {{--@if( !empty($error) )--}}
<div id='alert' class="alert alert-danger" role="alert" style="width: 100%"> {{--<div id='alert' class="alert alert-danger" role="alert">--}}
code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: {{$error['code']}} <br> {{--RpcServerException: {{$error['message']}} with code {{$error['code']}}--}}
message : {{$error['message']}} {{--</div>--}}
</div> {{--@endif--}}
@if($error['resp']) {{--@if( !empty($result) )--}}
<h5>返回内容:</h5> {{--<h5>Result:</h5>--}}
<iframe style="width: 100%;height: 500px;border: none;"
srcdoc='{{$error['resp']->getBody()}}'></iframe>
<hr>
@endif
@endif
@if( !empty($result) )
<h5>Result:</h5>
<div class="col-md-12"> {{--<div class="col-md-12">--}}
<pre><code class="json">{{$result}}</code></pre> {{--<pre><code class="json">{{$result}}</code></pre>--}}
</div> {{--</div>--}}
@endif {{--@endif--}}
</div> </div>
</main> </main>
@ -120,34 +101,6 @@
<script src="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script> <script src="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script> <script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/languages/json.min.js"></script> <script src="https://cdn.bootcss.com/highlight.js/9.13.1/languages/json.min.js"></script>
<script src="https://cdn.bootcss.com/ace/1.4.2/ace.js"></script>
<script type="text/javascript">
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/json");
editor.on('change', function (e) {
$('#params').val(editor.getValue())
})
$('#method').bind('change', function() {
var valKey = $("#method").find("option:selected").text();
var data = <?php echo $data; ?>;
var methodArray = data[valKey];
$("#methodRequird").empty();
var html = "<tr><td>参数</td><td>类型</td><td>描述</td><td>默认值</td><td>是否必须</td></tr>";
$(html).appendTo("#methodRequird");
console.log(methodArray, valKey)
methodArray.map(function (val, index) {
var $trTemp = $("<tr></tr>");
//往行里面追加 td单元格
$trTemp.append("<td>"+ data[i].param_name +"</td>");
$trTemp.append("<td>"+ data[i].param_type +"</td>");
$trTemp.append("<td>"+ data[i].param_title +"</td>");
$trTemp.append("<td>"+ data[i].param_default +"</td>");
$trTemp.append("<td>"+ data[i].param_require +"</td>");
$trTemp.appendTo("#methodRequird");
})
})
</script>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
</body> </body>
</html> </html>

View File

@ -55,7 +55,6 @@
{{--</div>--}} {{--</div>--}}
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="inputAddress">Method</label> <label for="inputAddress">Method</label>
<select class="form-control" id="method" name="method"> <select class="form-control" id="method" name="method">
@ -64,9 +63,24 @@
@endforeach @endforeach
</select> </select>
</div> </div>
<div class="table-item col-md-12">
<p class="table-title">
<span class="btn btn-xs btn-info">请求参数</span>
</p>
<table id="methodRequird" class="table">
<tr>
<td>参数</td>
<td>类型</td>
<td>描述</td>
<td>默认值</td>
<td>是否必须</td>
</tr>
</table>
</div>
</div>
<div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="inputAddress">Paramsjson 数组)</label> <label for="inputAddress">Paramsjson 数组)</label>
<div id="editor" style="height: 300px">{{$params}}</div> <div id="editor" style="height: 300px">{{$params}}</div>
@ -107,13 +121,32 @@
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script> <script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/languages/json.min.js"></script> <script src="https://cdn.bootcss.com/highlight.js/9.13.1/languages/json.min.js"></script>
<script src="https://cdn.bootcss.com/ace/1.4.2/ace.js"></script> <script src="https://cdn.bootcss.com/ace/1.4.2/ace.js"></script>
<script> <script type="text/javascript">
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai"); editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/json"); editor.session.setMode("ace/mode/json");
editor.on('change', function (e) { editor.on('change', function (e) {
$('#params').val(editor.getValue()) $('#params').val(editor.getValue())
}) })
$('#method').bind('change', function() {
var valKey = $("#method").find("option:selected").text();
var data = <?php echo $data; ?>;
var methodArray = data[valKey];
$("#methodRequird").empty();
var html = "<tr><td>参数</td><td>类型</td><td>描述</td><td>默认值</td><td>是否必须</td></tr>";
$(html).appendTo("#methodRequird");
console.log(methodArray, valKey)
methodArray.map(function (val, index) {
var $trTemp = $("<tr></tr>");
//往行里面追加 td单元格
$trTemp.append("<td>"+ data[i].param_name +"</td>");
$trTemp.append("<td>"+ data[i].param_type +"</td>");
$trTemp.append("<td>"+ data[i].param_title +"</td>");
$trTemp.append("<td>"+ data[i].param_default +"</td>");
$trTemp.append("<td>"+ data[i].param_require +"</td>");
$trTemp.appendTo("#methodRequird");
})
})
</script> </script>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
</body> </body>