2019-01-27 22:28:35 +08:00
|
|
|
|
<!doctype html>
|
|
|
|
|
|
<html xmlns:v-on="http://www.w3.org/1999/xhtml">
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
|
<title>详细地址管理</title>
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="../zui/css/zui.min.css">
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<div id="app">
|
2019-01-30 22:21:52 +08:00
|
|
|
|
<div class="alert alert-primary">
|
2019-02-02 21:17:44 +08:00
|
|
|
|
<div class="content">Tips:开放文档地址 可以不需要登录即可访问,重写域名地址 填写后需开启:文档展示配置->强制重写域名 后才生效</div>
|
2019-01-30 22:21:52 +08:00
|
|
|
|
</div>
|
2019-01-27 22:28:35 +08:00
|
|
|
|
<table class="table table-bordered setting-table">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td style="width: 50px;">序号</td>
|
|
|
|
|
|
<td>地址</td>
|
2019-01-30 22:21:52 +08:00
|
|
|
|
<td>开放文档地址</td>
|
2019-01-27 22:28:35 +08:00
|
|
|
|
<td>重写域名地址</td>
|
|
|
|
|
|
<td>操作</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<tr v-for="(item,index) in swaggerLocationList" :key="item.id" :data-id="item.id" :data-index="index" >
|
|
|
|
|
|
<td>{{index+1}}</td>
|
|
|
|
|
|
<td>{{item.location}}</td>
|
2019-02-02 21:17:44 +08:00
|
|
|
|
<td>
|
|
|
|
|
|
<!--未开放时即使访问这个地址也看不了-->
|
|
|
|
|
|
<a v-if="item.openVisit == 1" :href="'../../open-doc.html?doc='+item.uuid" target="_blank">{{item.uuid}}</a>
|
|
|
|
|
|
<span v-else>暂未开放</span>
|
|
|
|
|
|
</td>
|
2019-01-27 22:28:35 +08:00
|
|
|
|
<td>{{item.rewriteDomainUrl}}</td>
|
|
|
|
|
|
<td>
|
2019-02-02 21:17:44 +08:00
|
|
|
|
<button class="btn btn-danger" type="button" @click="deleteDocUrl(item.location)">删除</button>
|
2019-01-27 22:28:35 +08:00
|
|
|
|
<button class="btn btn-info" type="button" v-on:click="editDocUrl($event)">编辑</button>
|
|
|
|
|
|
<!--<button class="btn btn-danger" type="button" v-on:click="syncDocData($event)">持久化</button>-->
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
2019-01-28 22:26:34 +08:00
|
|
|
|
<td colspan="5" align="center">
|
2019-01-27 22:28:35 +08:00
|
|
|
|
<button class="btn" type="button" v-on:click="btnRefreshList"> 刷新 </button>
|
|
|
|
|
|
<button class="btn btn-primary" type="button" v-on:click="addNewDocument">增加文档</button>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
<!-- 增加文档弹出框 -->
|
|
|
|
|
|
<div class="modal fade" id="addNewDocumentModal">
|
|
|
|
|
|
<div class="modal-dialog">
|
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
|
<button type="button" class="close" data-dismiss="modal">
|
|
|
|
|
|
<span aria-hidden="true">×</span><span class="sr-only">关闭</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<h4 class="modal-title">输入文档地址</h4>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
|
<div class="input-line">
|
2019-08-12 20:44:17 +08:00
|
|
|
|
文档地址:
|
|
|
|
|
|
<input v-model="addNewDocumentInput" type="text" class="form-control" :readonly="addNewDocumentInput.indexOf('proxy-api-docs') > 0" placeholder="例:http://127.0.0.1/swagger-resources 或 http://127.0.0.1/v2/api-docs">
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="input-line">
|
|
|
|
|
|
swagger文档内容:
|
2019-08-13 22:52:24 +08:00
|
|
|
|
<textarea v-model="addNewSwaggerJson" type="text" rows="5" class="form-control" placeholder="swagger的json文档内容,和文档地址选填其一,如果填了则不再请求上面的地址获取内容,而是直接返回这里输入的"></textarea>
|
2019-01-27 22:28:35 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="input-line">
|
|
|
|
|
|
重写域名地址:
|
|
|
|
|
|
<input v-model="rewriteDomainUrl" type="text" name="rewriteDomainUrl" class="form-control" placeholder="文档展示配置页 勾选“重写域名”重写的地址">
|
|
|
|
|
|
</div>
|
2019-01-30 23:10:28 +08:00
|
|
|
|
<div class="input-line">
|
|
|
|
|
|
<div class="switch switch-inline">
|
|
|
|
|
|
<input type="checkbox" v-model="openVisit">
|
|
|
|
|
|
<label>是否开启开放文档</label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2019-01-27 22:28:35 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
|
<button type="button" class="btn btn-primary" v-on:click="addNewDocumentBtn">保存</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
<script src="../mg-ui/js/jquery-3.1.0.min.js"></script>
|
|
|
|
|
|
<script src="../zui/js/zui.min.js"></script>
|
|
|
|
|
|
<script src="../mg-ui/js/common.js"></script>
|
|
|
|
|
|
<script src="../mg-ui/js/mg-ui-cache-keys.js"></script>
|
|
|
|
|
|
<script src="../vue/vue.js"></script>
|
|
|
|
|
|
<script src="../mg-ui/js/toast.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
var urlBase = "../../";
|
|
|
|
|
|
var app = new Vue({
|
|
|
|
|
|
el: '#app',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
swaggerLocationList: [],
|
|
|
|
|
|
addNewDocumentInput: '',
|
2019-08-12 20:44:17 +08:00
|
|
|
|
addNewSwaggerJson: '',
|
2019-01-27 22:28:35 +08:00
|
|
|
|
rewriteDomainUrl: '',
|
2019-01-30 23:10:28 +08:00
|
|
|
|
openVisit: '',
|
2019-01-27 22:28:35 +08:00
|
|
|
|
oldLocation: ''
|
|
|
|
|
|
},
|
2019-08-13 22:52:24 +08:00
|
|
|
|
watch: {
|
|
|
|
|
|
},
|
2019-01-27 22:28:35 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
btnRefreshList: function(){
|
|
|
|
|
|
this.refreshList();
|
|
|
|
|
|
Toast.success("刷新成功!");
|
|
|
|
|
|
},
|
|
|
|
|
|
refreshList: function () {
|
|
|
|
|
|
getStorage(cacheKeys.swaggerLocationList, function (data) {
|
|
|
|
|
|
//console.log(data);
|
|
|
|
|
|
var swaggerLocationList = data;
|
|
|
|
|
|
for (var i = 0; i < swaggerLocationList.length; i++) {
|
|
|
|
|
|
swaggerLocationList[i].location = decodeURI(swaggerLocationList[i].location);
|
|
|
|
|
|
}
|
|
|
|
|
|
app.swaggerLocationList = swaggerLocationList;
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
editDocUrl: function (event) {
|
|
|
|
|
|
var tr = $(event.currentTarget).parents("tr");
|
|
|
|
|
|
var index = tr.data("index");
|
|
|
|
|
|
var item = app.swaggerLocationList[index];
|
|
|
|
|
|
app.oldLocation = item.location;
|
|
|
|
|
|
app.addNewDocumentInput = item.location;
|
|
|
|
|
|
app.rewriteDomainUrl = item.rewriteDomainUrl;
|
2019-08-17 21:16:32 +08:00
|
|
|
|
app.addNewSwaggerJson = "";
|
2019-01-30 23:10:28 +08:00
|
|
|
|
app.openVisit = (item.openVisit == 1);
|
2019-08-17 21:16:32 +08:00
|
|
|
|
if (item.location.indexOf('proxy-api-docs') > 0) {
|
|
|
|
|
|
var docId = item.location.substring(item.location.indexOf("?id=") + 4);
|
|
|
|
|
|
// 获取文档内容
|
|
|
|
|
|
ajaxTemp(urlBase + "swagger-mg-ui/document/proxy-api-docs", "get", "text", {id: docId}, function (json) {
|
|
|
|
|
|
app.addNewSwaggerJson = json;
|
|
|
|
|
|
$('#addNewDocumentModal').modal({moveable: true});
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$('#addNewDocumentModal').modal({moveable: true});
|
|
|
|
|
|
}
|
2019-01-27 22:28:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
addNewDocument: function(){
|
2019-01-30 23:10:28 +08:00
|
|
|
|
app.openVisit = false;
|
2019-01-27 22:28:35 +08:00
|
|
|
|
app.oldLocation = '';
|
|
|
|
|
|
app.addNewDocumentInput = '';
|
2019-08-17 21:49:59 +08:00
|
|
|
|
app.addNewSwaggerJson = "";
|
2019-01-27 22:28:35 +08:00
|
|
|
|
$('#addNewDocumentModal').modal({moveable:true});
|
|
|
|
|
|
},
|
|
|
|
|
|
addNewDocumentBtn: function(){
|
|
|
|
|
|
var addNewDocumentInput = app.addNewDocumentInput;
|
2019-08-12 20:44:17 +08:00
|
|
|
|
if(isEmpty(addNewDocumentInput) && isEmpty(app.addNewSwaggerJson)) {
|
2019-01-27 22:28:35 +08:00
|
|
|
|
Toast.error("地址不可以为空");return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var param = {
|
2019-01-30 23:10:28 +08:00
|
|
|
|
openVisit: app.openVisit ? 1 : 0,
|
2019-01-27 22:28:35 +08:00
|
|
|
|
resourcesUrl: addNewDocumentInput,
|
2019-08-12 20:44:17 +08:00
|
|
|
|
swaggerJson: app.addNewSwaggerJson,
|
2019-01-27 22:28:35 +08:00
|
|
|
|
rewriteDomainUrl: app.rewriteDomainUrl,
|
|
|
|
|
|
oldUrl: app.oldLocation
|
|
|
|
|
|
};
|
|
|
|
|
|
ajaxTemp(urlBase + "swagger-mg-ui/document/addSwaggerResources", "post", "json", param, function(json){
|
|
|
|
|
|
if(validateResult(json)) {
|
|
|
|
|
|
//window.parent.document.location.reload();
|
|
|
|
|
|
//app.swaggerLocationList.push(addNewDocumentInput);
|
|
|
|
|
|
app.refreshList();
|
|
|
|
|
|
$('#addNewDocumentModal').modal('hide');
|
|
|
|
|
|
Toast.success("保存成功,刷新后生效!");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2019-02-02 21:17:44 +08:00
|
|
|
|
deleteDocUrl: function (location) {
|
2019-01-27 22:28:35 +08:00
|
|
|
|
if (!confirm("确定要删除吗?")) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-02-02 21:17:44 +08:00
|
|
|
|
ajaxTemp(urlBase + "swagger-mg-ui/document/deleteSwaggerDoc", "post", "json", {location: location}, function (json) {
|
|
|
|
|
|
if (validateResult(json)) {
|
|
|
|
|
|
app.refreshList();
|
2019-01-27 22:28:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
syncDocData: function (event) {
|
|
|
|
|
|
var tr = $(event.currentTarget).parents("tr");
|
|
|
|
|
|
var index = tr.data("index");
|
|
|
|
|
|
var newDocUrl = app.swaggerLocationList[index].location;
|
|
|
|
|
|
ajaxTemp(urlBase + "swagger-mg-ui/document/syncDocData", "post", "json", {resourcesUrl: newDocUrl}, function (json) {
|
|
|
|
|
|
if (validateResult(json)) {
|
|
|
|
|
|
app.refreshList();
|
|
|
|
|
|
Toast.success("持久化成功!");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
encodeUrlParam: function(resourcesUrl) {
|
|
|
|
|
|
var indexOf = resourcesUrl.indexOf("?");
|
|
|
|
|
|
if (indexOf < 0) {
|
|
|
|
|
|
return resourcesUrl;
|
|
|
|
|
|
}
|
|
|
|
|
|
var baseUrl = resourcesUrl.substring(0, indexOf + 1);
|
|
|
|
|
|
var paramArr = resourcesUrl.substring(indexOf + 1).split("&");
|
|
|
|
|
|
for (var i = 0; i < paramArr.length; i++) {
|
|
|
|
|
|
var param = paramArr[i];
|
|
|
|
|
|
var split = param.split("=");
|
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
|
baseUrl.append("&");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (split.length === 2) {
|
|
|
|
|
|
baseUrl += split[0] + "=" + encodeURI(split[1]);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
baseUrl += param;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return baseUrl.toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted: function(){
|
|
|
|
|
|
this.refreshList();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
#app{padding-top: 10px;}
|
|
|
|
|
|
.input-line{margin-bottom: 15px;}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|