214 lines
6.8 KiB
HTML
214 lines
6.8 KiB
HTML
<!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">
|
||
<div class="alert alert-primary">
|
||
<div class="content">Tips:开放文档地址 可以不需要登录即可访问</div>
|
||
</div>
|
||
<table class="table table-bordered setting-table">
|
||
<thead>
|
||
<tr>
|
||
<td style="width: 50px;">序号</td>
|
||
<td>地址</td>
|
||
<td>开放文档地址</td>
|
||
<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>
|
||
<td><a :href="'../../open-doc.html?doc='+item.uuid" target="_blank">{{item.uuid}}</a></td>
|
||
<td>{{item.rewriteDomainUrl}}</td>
|
||
<td>
|
||
<button class="btn btn-danger" type="button" v-on:click="deleteDocUrl($event)">删除</button>
|
||
<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>
|
||
<td colspan="5" align="center">
|
||
<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">
|
||
地址:
|
||
<input v-model="addNewDocumentInput" type="text" class="form-control" placeholder="例:http://127.0.0.1/swagger-resources 或 http://127.0.0.1/v2/api-docs">
|
||
</div>
|
||
<div class="input-line">
|
||
重写域名地址:
|
||
<input v-model="rewriteDomainUrl" type="text" name="rewriteDomainUrl" class="form-control" placeholder="文档展示配置页 勾选“重写域名”重写的地址">
|
||
</div>
|
||
<div class="input-line">
|
||
<div class="switch switch-inline">
|
||
<input type="checkbox" v-model="openVisit">
|
||
<label>是否开启开放文档</label>
|
||
</div>
|
||
</div>
|
||
</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: '',
|
||
rewriteDomainUrl: '',
|
||
openVisit: '',
|
||
oldLocation: ''
|
||
},
|
||
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;
|
||
app.openVisit = (item.openVisit == 1);
|
||
$('#addNewDocumentModal').modal({moveable: true});
|
||
},
|
||
addNewDocument: function(){
|
||
app.openVisit = false;
|
||
app.oldLocation = '';
|
||
app.addNewDocumentInput = '';
|
||
$('#addNewDocumentModal').modal({moveable:true});
|
||
},
|
||
addNewDocumentBtn: function(){
|
||
var addNewDocumentInput = app.addNewDocumentInput;
|
||
if(isEmpty(addNewDocumentInput)) {
|
||
Toast.error("地址不可以为空");return;
|
||
}
|
||
var param = {
|
||
openVisit: app.openVisit ? 1 : 0,
|
||
resourcesUrl: addNewDocumentInput,
|
||
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("保存成功,刷新后生效!");
|
||
}
|
||
});
|
||
},
|
||
deleteDocUrl: function (event) {
|
||
if (!confirm("确定要删除吗?")) {
|
||
return;
|
||
}
|
||
var tr = $(event.currentTarget).parents("tr");
|
||
var index = tr.data("index");
|
||
var newDocList = [];
|
||
for (var i = 0; i < app.swaggerLocationList.length; i++) {
|
||
if (i !== index) {
|
||
newDocList.push(app.swaggerLocationList[i]);
|
||
}
|
||
}
|
||
setStorage(cacheKeys.swaggerLocationList, newDocList, function () {
|
||
app.swaggerLocationList = newDocList;
|
||
});
|
||
},
|
||
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();
|
||
},
|
||
watch: {
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<style>
|
||
#app{padding-top: 10px;}
|
||
.input-line{margin-bottom: 15px;}
|
||
</style>
|
||
</html>
|
||
|
||
|
||
|