提供管理界面的HTTP/HTTPS修改功能

This commit is contained in:
GoEdgeLab
2020-10-15 16:41:32 +08:00
parent 9c9fbcd45d
commit c5b48bd3f8
34 changed files with 596 additions and 73 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -1,5 +1,5 @@
Vue.component("ssl-certs-box", {
props: ["v-certs", "v-protocol"],
props: ["v-certs", "v-protocol", "v-view-size", "v-single-mode"],
data: function () {
let certs = this.vCerts
if (certs == null) {
@@ -26,9 +26,19 @@ Vue.component("ssl-certs-box", {
// 选择证书
selectCert: function () {
let that = this
teaweb.popup("/servers/components/ssl/selectPopup", {
width: "50em",
height: "30em",
let width = "50em"
let height = "30em"
let viewSize = this.vViewSize
if (viewSize == null) {
viewSize = "normal"
}
if (viewSize == "mini") {
width = "35em"
height = "20em"
}
teaweb.popup("/servers/components/ssl/selectPopup?viewSize=" + viewSize, {
width: width,
height: height,
callback: function (resp) {
that.certs.push(resp.data.cert)
}
@@ -51,6 +61,11 @@ Vue.component("ssl-certs-box", {
// 格式化时间
formatTime: function (timestamp) {
return new Date(timestamp * 1000).format("Y-m-d")
},
// 判断是否显示选择|上传按钮
buttonsVisible: function () {
return this.vSingleMode == null || !this.vSingleMode || this.certs == null || this.certs.length == 0
}
},
template: `<div>
@@ -59,13 +74,15 @@ Vue.component("ssl-certs-box", {
<div class="ui label small" v-for="(cert, index) in certs">
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} &nbsp; <a href="" title="删除" @click.prevent="removeCert()"><i class="icon remove"></i></a>
</div>
<div class="ui divider"></div>
<div class="ui divider" v-if="buttonsVisible()"></div>
</div>
<div v-else>
<span class="red">选择或上传证书后<span v-if="vProtocol == 'https'">HTTPS</span><span v-if="vProtocol == 'tls'">TLS</span>服务才能生效。</span>
<div class="ui divider"></div>
<div class="ui divider" v-if="buttonsVisible()"></div>
</div>
<div v-if="buttonsVisible()">
<button class="ui button tiny" type="button" @click.prevent="selectCert()">选择已有证书</button> &nbsp;
<button class="ui button tiny" type="button" @click.prevent="uploadCert()">上传新证书</button>
</div>
<button class="ui button tiny" type="button" @click.prevent="selectCert()">选择已有证书</button> &nbsp;
<button class="ui button tiny" type="button" @click.prevent="uploadCert()">上传新证书</button>
</div>`
})

View File

@@ -57,7 +57,7 @@
.right-box {
position: fixed;
top: 7.5em;
bottom: 0;
bottom: 1.3em;
right: 0;
left: 18em;
padding-right: 2em;

File diff suppressed because one or more lines are too long

View File

@@ -83,6 +83,17 @@
<!-- 功能区 -->
{$TEA.VIEW}
</div>
<!-- 底部 -->
<div id="footer" class="ui menu inverted light-blue borderless small">
<a href="/settings/upgrade" class="item" title="点击进入检查版本更新页面">{{teaName}} v{{teaVersion}}</a>
<a href="https://github.com/TeaOSLab/EdgeAdmin" target="_blank" class="item">GitHub</a>
<!--<a href="http://teaos.cn" target="_blank" class="item">官网</a>
<a href="http://teaos.cn/doc" target="_blank" class="item">文档</a>-->
<a href="https://github.com/TeaOSLab/EdgeAdmin/issues" target="_blank" class="item">提Bug</a>
<a class="item" @click.prevent="showQQGroupQrcode()">QQ讨论群659832182 &nbsp;<i class="icon qrcode"></i> </a>
<a class="item right" href="http://teaos.cn/doc/donate/Index.md" target="_blank">捐赠作者</a>
</div>
</div>
{$echo "footer"}

View File

@@ -1,6 +1,7 @@
Tea.context(function () {
this.moreOptionsVisible = false;
this.globalChangedClusters = [];
this.moreOptionsVisible = false
this.globalChangedClusters = []
this.teaDemoEnabled = false
if (typeof this.leftMenuItemIsDisabled == "undefined") {
this.leftMenuItemIsDisabled = false
@@ -8,29 +9,29 @@ Tea.context(function () {
this.$delay(function () {
if (this.$refs.focus != null) {
this.$refs.focus.focus();
this.$refs.focus.focus()
}
// 检查变更
this.checkClusterChanges()
});
})
/**
* 左侧子菜单
*/
this.showSubMenu = function (menu) {
if (menu.alwaysActive) {
return;
return
}
if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) {
this.teaSubMenus.menus.$each(function (k, v) {
if (menu.id == v.id) {
return;
return
}
v.isActive = false;
});
v.isActive = false
})
}
menu.isActive = !menu.isActive;
menu.isActive = !menu.isActive
};
/**
@@ -70,6 +71,16 @@ Tea.context(function () {
})
})
};
/**
* 底部伸展框
*/
this.showQQGroupQrcode = function () {
teaweb.popup("/about/qq", {
width: "21em",
height: "24em"
})
}
});
window.NotifySuccess = function (message, url, params) {

View File

@@ -15,6 +15,7 @@
<script type="text/javascript" src="/ui/components.js"></script>
<script type="text/javascript" src="/js/utils.js"></script>
<script type="text/javascript" src="/js/sweetalert2/dist/sweetalert2.all.min.js"></script>
<script type="text/javascript" src="/js/date.tea.js"></script>
<style type="text/css">
.main {
left: 0;
@@ -22,7 +23,7 @@
bottom: 0;
right: 0;
overflow-y: auto;
padding-bottom: 0em;
padding-bottom: 0;
}
.main::-webkit-scrollbar {

View File

@@ -36,6 +36,7 @@
border-bottom: 1px #666 dashed;
}
}
.item.off {
span {
var {
@@ -78,7 +79,7 @@
.right-box {
position: fixed;
top: 7.5em;
bottom: 0;
bottom: 1.3em;
right: 0;
left: 18em;
padding-right: 2em;

View File

@@ -0,0 +1,4 @@
table img {
width: 20em;
}
/*# sourceMappingURL=qq.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":["qq.less"],"names":[],"mappings":"AAAA,KAAM;EACL,WAAA","file":"qq.css"}

View File

@@ -0,0 +1,8 @@
{$layout "layout_popup"}
<h3>QQ群 <span>659832182</span></h3>
<table class="ui table">
<tr>
<td><img src="/images/qq-group-qrcode.png"/></td>
</tr>
</table>

View File

@@ -0,0 +1,3 @@
table img {
width: 20em;
}

View File

@@ -6,10 +6,10 @@
<thead>
<tr>
<th>证书说明</th>
<th>顶级发行组织</th>
<th v-if="viewSize == 'normal'">顶级发行组织</th>
<th>域名</th>
<th>过期日期</th>
<th>引用服务</th>
<th v-if="viewSize == 'normal'">引用服务</th>
<th>状态</th>
<th class="one op">操作</th>
</tr>
@@ -20,7 +20,7 @@
<span class="ui label olive tiny">CA</span>
</div>
</td>
<td>
<td v-if="viewSize == 'normal'">
<span v-if="cert.commonNames != null && cert.commonNames.length > 0">{{cert.commonNames[cert.commonNames.length-1]}}</span>
</td>
<td>
@@ -29,7 +29,7 @@
</div>
</td>
<td>{{certInfos[index].endDay}}</td>
<td>{{certInfos[index].countServers}}</td>
<td v-if="viewSize == 'normal'">{{certInfos[index].countServers}}</td>
<td nowrap="">
<span class="ui label red tiny basic" v-if="certInfos[index].isExpired">已过期</span>
<span class="ui label green tiny basic" v-else>有效中</span>

View File

@@ -0,0 +1,54 @@
{$layout}
<div class="ui message warning" v-if="serverIsChanged">服务配置已修改,请在命令行下重启后生效。</div>
<h3>HTTP <a href="/settings/server/http" v-if="!teaDemoEnabled" @click.prevent="updateHTTP()">修改</a><a v-if="teaDemoEnabled">[演示版无法修改]</a></h3>
<table class="ui table definition selectable">
<tr>
<td>状态</td>
<td>
<label-on :v-is-on="serverConfig.http.on"></label-on>
</td>
</tr>
<tr>
<td class="title">绑定地址</td>
<td>
<span v-for="listen in serverConfig.http.listen" class="ui label tiny">{{listen}}</span>
<p class="ui comment">如果地址中的IP是0.0.0.0表示服务器的所有IP都可以用来使用访问此服务。</p>
</td>
</tr>
</table>
<div class="ui divider"></div>
<h3>HTTPS <a href="" v-if="!teaDemoEnabled" @click.prevent="updateHTTPS()">修改</a><a v-if="teaDemoEnabled">[演示版无法修改]</a></h3>
<table class="ui table definition selectable">
<tr>
<td>状态</td>
<td>
<label-on :v-is-on="serverConfig.https.on"></label-on>
</td>
</tr>
<tr>
<td class="title">绑定地址</td>
<td>
<span v-for="listen in serverConfig.https.listen" class="ui label tiny">{{listen}}</span>
<p class="ui comment">如果地址中的IP是0.0.0.0表示服务器的所有IP都可以用来使用访问此服务。</p>
</td>
</tr>
<tr>
<td>证书文件<span class="small">Cert</span></td>
<td>
<span v-if="serverConfig.https.cert.length > 0">{{serverConfig.https.cert}}</span>
<span class="disabled" v-else>还没有设置证书</span>
</td>
</tr>
<tr>
<td>私钥文件<span class="small">Key</span></td>
<td>
<span v-if="serverConfig.https.key.length > 0">{{serverConfig.https.key}}</span>
<span class="disabled" v-else>还没有设置私钥</span>
</td>
</tr>
</table>

View File

@@ -0,0 +1,19 @@
Tea.context(function () {
this.updateHTTP = function () {
teaweb.popup("/settings/ui/updateHTTPPopup", {
callback: function () {
teaweb.success("保存成功", teaweb.reload)
}
})
}
this.updateHTTPS = function () {
teaweb.popup("/settings/ui/updateHTTPSPopup", {
height: "26em",
width:"50em",
callback: function () {
teaweb.success("保存成功", teaweb.reload)
}
})
}
})

View File

@@ -0,0 +1,27 @@
{$layout "layout_popup"}
<h3>修改HTTP设置</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<table class="ui table definition selectable">
<tr>
<td>是否启用</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="serverConfig.http.on"/>
<label></label>
</div>
</td>
</tr>
<tr>
<td class="title">绑定地址</td>
<td>
<values-box name="listens" :values="addresses"></values-box>
<p class="comment" style="margin-bottom:0">地址格式为:"IP:端口",比如:"127.0.0.1:7777"。</p>
<p class="comment">如果地址中的IP是0.0.0.0表示服务器的所有IP都可以用来使用访问此服务。</p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,8 @@
Tea.context(function () {
this.success = NotifyPopup
this.addresses = [];
if (this.serverConfig != null && this.serverConfig.http != null && this.serverConfig.http.listen != null) {
this.addresses = this.serverConfig.http.listen
}
})

View File

@@ -0,0 +1,33 @@
{$layout "layout_popup"}
<h3>修改HTTPS配置</h3>
<form data-tea-action="$" data-tea-success="success" class="ui form">
<table class="ui table definition selectable">
<tr>
<td>是否启用</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="serverConfig.https.on"/>
<label></label>
</div>
</td>
</tr>
<tr>
<td class="title">绑定地址</td>
<td>
<values-box name="listens" :values="addresses"></values-box>
<p class="comment" style="margin-bottom:0">每行一个地址,地址格式为:"IP:端口",比如:"127.0.0.1:7778"。</p>
<p class="comment">如果地址中的IP是0.0.0.0表示服务器的所有IP都可以用来使用访问此服务。</p>
</td>
</tr>
<tr v-show="serverConfig.https.on">
<td>选择证书文件</td>
<td>
<ssl-certs-box :v-certs="certConfigs" :v-protocol="'http'" :v-view-size="'mini'" :v-single-mode="true"></ssl-certs-box>
</td>
</tr>
</table>
<button class="ui button primary">保存</button>
</form>

View File

@@ -0,0 +1,8 @@
Tea.context(function () {
this.success = NotifyPopup
this.addresses = [];
if (this.serverConfig != null && this.serverConfig.https != null && this.serverConfig.https.listen != null) {
this.addresses = this.serverConfig.https.listen
}
})