更新components.js

This commit is contained in:
GoEdgeLab
2023-04-02 10:17:47 +08:00
parent f43d935a5c
commit f4471ec2cd
2 changed files with 248 additions and 105 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1139,7 +1139,7 @@ Vue.component("message-row", {
<!-- 证书即将过期 --> <!-- 证书即将过期 -->
<div v-if="message.type == 'SSLCertExpiring'" style="margin-top: 0.8em"> <div v-if="message.type == 'SSLCertExpiring'" style="margin-top: 0.8em">
<a href="" @click.prevent="viewCert(params.certId)" target="_top">查看证书</a> &nbsp;|&nbsp; <a :href="'/servers/certs/acme'" v-if="params != null && params.acmeTaskId > 0" target="_top">查看任务&raquo;</a> <a href="" @click.prevent="viewCert(params.certId)" target="_top">查看证书</a><span v-if="params != null && params.acmeTaskId > 0"> &nbsp;|&nbsp; <a :href="'/servers/certs/acme'" target="_top">查看任务&raquo;</a></span>
</div> </div>
<!-- 证书续期成功 --> <!-- 证书续期成功 -->
@@ -3616,7 +3616,11 @@ Vue.component("http-request-conds-box", {
}) })
Vue.component("ssl-config-box", { Vue.component("ssl-config-box", {
props: ["v-ssl-policy", "v-protocol", "v-server-id"], props: [
"v-ssl-policy",
"v-protocol",
"v-server-id"
],
created: function () { created: function () {
let that = this let that = this
setTimeout(function () { setTimeout(function () {
@@ -3724,12 +3728,23 @@ Vue.component("ssl-config-box", {
selectedCertIds.push(cert.id.toString()) selectedCertIds.push(cert.id.toString())
}) })
} }
teaweb.popup("/servers/certs/selectPopup?selectedCertIds=" + selectedCertIds, { let serverId = this.vServerId
if (serverId == null) {
serverId = 0
}
teaweb.popup("/servers/certs/selectPopup?selectedCertIds=" + selectedCertIds + "&serverId=" + serverId, {
width: "50em", width: "50em",
height: "30em", height: "30em",
callback: function (resp) { callback: function (resp) {
that.policy.certRefs.push(resp.data.certRef) if (resp.data.cert != null && resp.data.certRef != null) {
that.policy.certs.push(resp.data.cert) that.policy.certRefs.push(resp.data.certRef)
that.policy.certs.push(resp.data.cert)
}
if (resp.data.certs != null && resp.data.certRefs != null) {
that.policy.certRefs.$pushAll(resp.data.certRefs)
that.policy.certs.$pushAll(resp.data.certs)
}
that.$forceUpdate()
} }
}) })
}, },
@@ -3737,8 +3752,12 @@ Vue.component("ssl-config-box", {
// 上传证书 // 上传证书
uploadCert: function () { uploadCert: function () {
let that = this let that = this
teaweb.popup("/servers/certs/uploadPopup", { let serverId = this.vServerId
height: "28em", if (typeof serverId != "number" && typeof serverId != "string") {
serverId = 0
}
teaweb.popup("/servers/certs/uploadPopup?serverId=" + serverId, {
height: "30em",
callback: function (resp) { callback: function (resp) {
teaweb.success("上传成功", function () { teaweb.success("上传成功", function () {
that.policy.certRefs.push(resp.data.certRef) that.policy.certRefs.push(resp.data.certRef)
@@ -3748,6 +3767,28 @@ Vue.component("ssl-config-box", {
}) })
}, },
// 批量上传
uploadBatch: function () {
let that = this
let serverId = this.vServerId
if (typeof serverId != "number" && typeof serverId != "string") {
serverId = 0
}
teaweb.popup("/servers/certs/uploadBatchPopup?serverId=" + serverId, {
callback: function (resp) {
if (resp.data.cert != null) {
that.policy.certRefs.push(resp.data.certRef)
that.policy.certs.push(resp.data.cert)
}
if (resp.data.certs != null) {
that.policy.certRefs.$pushAll(resp.data.certRefs)
that.policy.certs.$pushAll(resp.data.certs)
}
that.$forceUpdate()
}
})
},
// 申请证书 // 申请证书
requestCert: function () { requestCert: function () {
// 已经在证书中的域名 // 已经在证书中的域名
@@ -3929,8 +3970,15 @@ Vue.component("ssl-config-box", {
width: "50em", width: "50em",
height: "30em", height: "30em",
callback: function (resp) { callback: function (resp) {
that.policy.clientCARefs.push(resp.data.certRef) if (resp.data.cert != null && resp.data.certRef != null) {
that.policy.clientCACerts.push(resp.data.cert) that.policy.clientCARefs.push(resp.data.certRef)
that.policy.clientCACerts.push(resp.data.cert)
}
if (resp.data.certs != null && resp.data.certRefs != null) {
that.policy.clientCARefs.$pushAll(resp.data.certRefs)
that.policy.clientCACerts.$pushAll(resp.data.certs)
}
that.$forceUpdate()
} }
}) })
}, },
@@ -3986,7 +4034,10 @@ Vue.component("ssl-config-box", {
<div class="ui divider"></div> <div class="ui divider"></div>
</div> </div>
<button class="ui button tiny" type="button" @click.prevent="selectCert()">选择已有证书</button> &nbsp; <button class="ui button tiny" type="button" @click.prevent="selectCert()">选择已有证书</button> &nbsp;
<span class="disabled">|</span> &nbsp;
<button class="ui button tiny" type="button" @click.prevent="uploadCert()">上传新证书</button> &nbsp; <button class="ui button tiny" type="button" @click.prevent="uploadCert()">上传新证书</button> &nbsp;
<button class="ui button tiny" type="button" @click.prevent="uploadBatch()">批量上传证书</button> &nbsp;
<span class="disabled">|</span> &nbsp;
<button class="ui button tiny" type="button" @click.prevent="requestCert()" v-if="vServerId != null && vServerId > 0">申请免费证书</button> <button class="ui button tiny" type="button" @click.prevent="requestCert()" v-if="vServerId != null && vServerId > 0">申请免费证书</button>
</td> </td>
</tr> </tr>
@@ -4142,7 +4193,7 @@ Vue.component("ssl-config-box", {
<td>客户端认证CA证书</td> <td>客户端认证CA证书</td>
<td> <td>
<div v-if="policy.clientCACerts != null && policy.clientCACerts.length > 0"> <div v-if="policy.clientCACerts != null && policy.clientCACerts.length > 0">
<div class="ui label small" v-for="(cert, index) in policy.clientCACerts"> <div class="ui label small basic" v-for="(cert, index) in policy.clientCACerts">
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} &nbsp; <a href="" title="删除" @click.prevent="removeClientCACert()"><i class="icon remove"></i></a> {{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} &nbsp; <a href="" title="删除" @click.prevent="removeClientCACert()"><i class="icon remove"></i></a>
</div> </div>
<div class="ui divider"></div> <div class="ui divider"></div>
@@ -4352,7 +4403,9 @@ Vue.component("ssl-certs-box", {
"v-protocol", // 协议https|tls "v-protocol", // 协议https|tls
"v-view-size", // 弹窗尺寸normal, mini "v-view-size", // 弹窗尺寸normal, mini
"v-single-mode", // 单证书模式 "v-single-mode", // 单证书模式
"v-description" // 描述文字 "v-description", // 描述文字
"v-domains", // 搜索的域名列表或者函数
"v-user-id" // 用户ID
], ],
data: function () { data: function () {
let certs = this.vCerts let certs = this.vCerts
@@ -4390,8 +4443,8 @@ Vue.component("ssl-certs-box", {
// 选择证书 // 选择证书
selectCert: function () { selectCert: function () {
let that = this let that = this
let width = "50em" let width = "54em"
let height = "30em" let height = "32em"
let viewSize = this.vViewSize let viewSize = this.vViewSize
if (viewSize == null) { if (viewSize == null) {
viewSize = "normal" viewSize = "normal"
@@ -4400,11 +4453,41 @@ Vue.component("ssl-certs-box", {
width = "35em" width = "35em"
height = "20em" height = "20em"
} }
teaweb.popup("/servers/certs/selectPopup?viewSize=" + viewSize, {
let searchingDomains = []
if (this.vDomains != null) {
if (typeof this.vDomains == "function") {
let resultDomains = this.vDomains()
if (resultDomains != null && typeof resultDomains == "object" && (resultDomains instanceof Array)) {
searchingDomains = resultDomains
}
} else if (typeof this.vDomains == "object" && (this.vDomains instanceof Array)) {
searchingDomains = this.vDomains
}
if (searchingDomains.length > 10000) {
searchingDomains = searchingDomains.slice(0, 10000)
}
}
let selectedCertIds = this.certs.map(function (cert) {
return cert.id
})
let userId = this.vUserId
if (userId == null) {
userId = 0
}
teaweb.popup("/servers/certs/selectPopup?viewSize=" + viewSize + "&searchingDomains=" + window.encodeURIComponent(searchingDomains.join(",")) + "&selectedCertIds=" + selectedCertIds.join(",") + "&userId=" + userId, {
width: width, width: width,
height: height, height: height,
callback: function (resp) { callback: function (resp) {
that.certs.push(resp.data.cert) if (resp.data.cert != null) {
that.certs.push(resp.data.cert)
}
if (resp.data.certs != null) {
that.certs.$pushAll(resp.data.certs)
}
that.$forceUpdate()
} }
}) })
}, },
@@ -4412,16 +4495,46 @@ Vue.component("ssl-certs-box", {
// 上传证书 // 上传证书
uploadCert: function () { uploadCert: function () {
let that = this let that = this
teaweb.popup("/servers/certs/uploadPopup", { let userId = this.vUserId
if (typeof userId != "number" && typeof userId != "string") {
userId = 0
}
teaweb.popup("/servers/certs/uploadPopup?userId=" + userId, {
height: "28em", height: "28em",
callback: function (resp) { callback: function (resp) {
teaweb.success("上传成功", function () { teaweb.success("上传成功", function () {
that.certs.push(resp.data.cert) if (resp.data.cert != null) {
that.certs.push(resp.data.cert)
}
if (resp.data.certs != null) {
that.certs.$pushAll(resp.data.certs)
}
that.$forceUpdate()
}) })
} }
}) })
}, },
// 批量上传
uploadBatch: function () {
let that = this
let userId = this.vUserId
if (typeof userId != "number" && typeof userId != "string") {
userId = 0
}
teaweb.popup("/servers/certs/uploadBatchPopup?userId=" + userId, {
callback: function (resp) {
if (resp.data.cert != null) {
that.certs.push(resp.data.cert)
}
if (resp.data.certs != null) {
that.certs.$pushAll(resp.data.certs)
}
that.$forceUpdate()
}
})
},
// 格式化时间 // 格式化时间
formatTime: function (timestamp) { formatTime: function (timestamp) {
return new Date(timestamp * 1000).format("Y-m-d") return new Date(timestamp * 1000).format("Y-m-d")
@@ -4447,7 +4560,9 @@ Vue.component("ssl-certs-box", {
</div> </div>
<div v-if="buttonsVisible()"> <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="selectCert()">选择已有证书</button> &nbsp;
<span class="disabled">|</span> &nbsp;
<button class="ui button tiny" type="button" @click.prevent="uploadCert()">上传新证书</button> &nbsp; <button class="ui button tiny" type="button" @click.prevent="uploadCert()">上传新证书</button> &nbsp;
<button class="ui button tiny" type="button" @click.prevent="uploadBatch()">批量上传证书</button> &nbsp;
</div> </div>
</div>` </div>`
}) })
@@ -7026,80 +7141,102 @@ Vue.component("http-rewrite-labels-label", {
}) })
Vue.component("server-name-box", { Vue.component("server-name-box", {
props: ["v-server-names"], props: ["v-server-names"],
data: function () { data: function () {
let serverNames = this.vServerNames; let serverNames = this.vServerNames;
if (serverNames == null) { if (serverNames == null) {
serverNames = [] serverNames = []
} }
return { return {
serverNames: serverNames, serverNames: serverNames,
isSearching: false, isSearching: false,
keyword: "" keyword: ""
} }
}, },
methods: { methods: {
addServerName: function () { addServerName: function () {
window.UPDATING_SERVER_NAME = null window.UPDATING_SERVER_NAME = null
let that = this let that = this
teaweb.popup("/servers/addServerNamePopup", { teaweb.popup("/servers/addServerNamePopup", {
callback: function (resp) { callback: function (resp) {
var serverName = resp.data.serverName var serverName = resp.data.serverName
that.serverNames.push(serverName) that.serverNames.push(serverName)
} }
}); });
}, },
removeServerName: function (index) { removeServerName: function (index) {
this.serverNames.$remove(index) this.serverNames.$remove(index)
}, },
updateServerName: function (index, serverName) { updateServerName: function (index, serverName) {
window.UPDATING_SERVER_NAME = teaweb.clone(serverName) window.UPDATING_SERVER_NAME = teaweb.clone(serverName)
let that = this let that = this
teaweb.popup("/servers/addServerNamePopup", { teaweb.popup("/servers/addServerNamePopup", {
callback: function (resp) { callback: function (resp) {
var serverName = resp.data.serverName var serverName = resp.data.serverName
Vue.set(that.serverNames, index, serverName) Vue.set(that.serverNames, index, serverName)
} }
}); });
}, },
showSearchBox: function () { showSearchBox: function () {
this.isSearching = !this.isSearching this.isSearching = !this.isSearching
if (this.isSearching) { if (this.isSearching) {
let that = this let that = this
setTimeout(function () { setTimeout(function () {
that.$refs.keywordRef.focus() that.$refs.keywordRef.focus()
}, 200) }, 200)
} else { } else {
this.keyword = "" this.keyword = ""
} }
}, },
}, allServerNames: function () {
watch: { if (this.serverNames == null) {
keyword: function (v) { return []
this.serverNames.forEach(function (serverName) { }
if (v.length == 0) { let result = []
serverName.isShowing = true this.serverNames.forEach(function (serverName) {
return if (serverName.subNames != null && serverName.subNames.length > 0) {
} serverName.subNames.forEach(function (subName) {
if (serverName.subNames == null || serverName.subNames.length == 0) { if (subName != null && subName.length > 0) {
if (!teaweb.match(serverName.name, v)) { if (!result.$contains(subName)) {
serverName.isShowing = false result.push(subName)
} }
} else { }
let found = false })
serverName.subNames.forEach(function (subName) { } else if (serverName.name != null && serverName.name.length > 0) {
if (teaweb.match(subName, v)) { if (!result.$contains(serverName.name)) {
found = true result.push(serverName.name)
} }
}) }
serverName.isShowing = found })
} return result
}) }
} },
}, watch: {
template: `<div> keyword: function (v) {
this.serverNames.forEach(function (serverName) {
if (v.length == 0) {
serverName.isShowing = true
return
}
if (serverName.subNames == null || serverName.subNames.length == 0) {
if (!teaweb.match(serverName.name, v)) {
serverName.isShowing = false
}
} else {
let found = false
serverName.subNames.forEach(function (subName) {
if (teaweb.match(subName, v)) {
found = true
}
})
serverName.isShowing = found
}
})
}
},
template: `<div>
<input type="hidden" name="serverNames" :value="JSON.stringify(serverNames)"/> <input type="hidden" name="serverNames" :value="JSON.stringify(serverNames)"/>
<div v-if="serverNames.length > 0"> <div v-if="serverNames.length > 0">
<div v-for="(serverName, index) in serverNames" class="ui label small basic" :class="{hidden: serverName.isShowing === false}"> <div v-for="(serverName, index) in serverNames" class="ui label small basic" :class="{hidden: serverName.isShowing === false}">
@@ -9621,8 +9758,6 @@ Vue.component("http-compression-config-box", {
Vue.component("http-cc-config-box", { Vue.component("http-cc-config-box", {
props: ["v-cc-config", "v-is-location", "v-is-group"], props: ["v-cc-config", "v-is-location", "v-is-group"],
data: function () { data: function () {
let config = this.vCcConfig let config = this.vCcConfig
if (config == null) { if (config == null) {
config = { config = {
@@ -9667,7 +9802,7 @@ Vue.component("http-cc-config-box", {
<td class="title">启用CC无感防护</td> <td class="title">启用CC无感防护</td>
<td> <td>
<checkbox v-model="config.isOn"></checkbox> <checkbox v-model="config.isOn"></checkbox>
<p class="comment"><plus-label></plus-label>启用后自动检测并拦截CC攻击此功能不需要开启WAF功能。</p> <p class="comment"><plus-label></plus-label>启用后自动检测并拦截CC攻击。</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -15685,6 +15820,9 @@ Vue.component("file-textarea", {
}, },
setValue: function (value) { setValue: function (value) {
this.realValue = value this.realValue = value
},
focus: function () {
this.$refs.textarea.focus()
} }
}, },
template: `<textarea @drop.prevent="drop" @dragover.prevent="dragover" ref="textarea" v-model="realValue"></textarea>` template: `<textarea @drop.prevent="drop" @dragover.prevent="dragover" ref="textarea" v-model="realValue"></textarea>`
@@ -16417,9 +16555,9 @@ Vue.component("combo-box", {
<!-- 当前选中 --> <!-- 当前选中 -->
<div v-if="selectedItem != null"> <div v-if="selectedItem != null">
<input type="hidden" :name="name" :value="selectedItem.value"/> <input type="hidden" :name="name" :value="selectedItem.value"/>
<a href="" class="ui label basic" style="line-height: 1.4; font-weight: normal; font-size: 1em" ref="selectedLabel" @click.prevent="submitForm"><span><span v-if="title != null && title.length > 0">{{title}}</span>{{selectedItem.name}}</span> <span class="ui label basic" style="line-height: 1.4; font-weight: normal; font-size: 1em" ref="selectedLabel"><span><span v-if="title != null && title.length > 0">{{title}}</span>{{selectedItem.name}}</span>
<span title="清除" @click.prevent="reset"><i class="icon remove small"></i></span> <a href="" title="清除" @click.prevent="reset"><i class="icon remove small"></i></a>
</a> </span>
</div> </div>
<!-- 菜单 --> <!-- 菜单 -->