You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
5.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>显示代码</title>
<script src="./js/clipboard.min.js"></script>
<!--加载代码高亮js与样式-->
<link href="./highlight/styles/ocean.css" rel="stylesheet">
<script src="./highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="./lib/JqueryExtend.js"></script>
<script src="./js/layuiExtend.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="./static/css/font.css">
<link rel="stylesheet" href="./static/css/weadmin.css">
<link rel="stylesheet" href="./layui/css/layui.css">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
select {
width: 180px;
height: 38px;
line-height: 38px;
border: 1px solid #ccc;
border-radius: 3px;
font-size: 15px;
padding-left: 6px;
color: #666;
}
.inline {
display: inline-block;
vertical-align: top;
}
ul.log li {
color: #666666;
list-style: none;
padding-left: 10px;
}
</style>
</head>
<body>
<div>文件路径:<span id="path"></span></div>
<div>
<button id="button1" class="layui-btn" data-clipboard-action="copy" data-clipboard-target="#path">复制路径
</button>
<button id="button2" class="layui-btn layui-btn-normal" data-clipboard-action="copy"
data-clipboard-target="#copyCode">复制代码
</button>
</div>
<pre class='language-golang'>
<code id="copyCode"></code>
</pre>
</body>
<script src="./layui/layui.js"></script>
<script src="./lib/template.js"></script>
<script src="./lib/base64.js"></script>
<script src="./lib/JqueryExtend.js"></script>
<script>
layui.use(['jquery', 'layer'], function () {
var $ = layui.jquery,
layer = layui.layer;
//调用接口
var interfaceId = GetQueryString("interfaceId");
var interfaceName = GetQueryString("interfaceName");
//生成哪一层的代码
var type = GetQueryString("type")
//作者
var author_id = GetQueryString("author_id")
//WEB接口名称
var ControllerName=GetQueryString("ControllerName")
//走哪一个后台的controller
var url = "/proto/proto/Code#type#?interfaceId=" + interfaceId + "&interfaceName=" + interfaceName + "&author_id=" + author_id+"&controllerName="+ControllerName
url = url.replace(/#type#/g, type)
$.ajax({
type: "GET",
dataType: "json",
async: false,
url: url,
success: function (data) {
if (data.code == 500) {
layer.alert(data.msg, {
title: "配置错误",
skin: 'layui-layer-lan'
, closeBtn: 0
, anim: 4 //动画类型
}, function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
}
$("#copyCode").html(data.data);
$('pre code').each(function (i, block) {
hljs.highlightBlock(block);
});
$("#path").html(data.code_path)
}
});
//复制功能
var clipboard0 = new ClipboardJS('#button1');
clipboard0.on('success', function (e) {
layer.msg("复制成功", {icon: 1, time: 2000, shade: [0.5, '#000', true]}, function () {
var index = layer.getFrameIndex(window.name);
layer.close(index);
});
});
clipboard0.on('error', function (e) {
console.log(e);
});
var clipboard1 = new ClipboardJS('#button2');
clipboard1.on('success', function (e) {
layer.msg("复制成功", {icon: 1, time: 2000, shade: [0.5, '#000', true]}, function () {
var index = layer.getFrameIndex(window.name);
layer.close(index);
});
});
clipboard1.on('error', function (e) {
console.log(e);
});
}
);
</script>
</html>