79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
Tea.context(function () {
|
|
this.selectedAppId = ""
|
|
this.selectedApp = {}
|
|
this.currentStep = 1
|
|
this.signSecretVisible = false
|
|
this.aesSecretVisible = false
|
|
|
|
if (typeof this.apps == "undefined") {
|
|
this.apps = []
|
|
}
|
|
|
|
this.onAppChange = function () {
|
|
if (this.selectedAppId.length == 0) {
|
|
this.selectedApp = {}
|
|
return
|
|
}
|
|
|
|
for (var i = 0; i < this.apps.length; i++) {
|
|
if (this.apps[i].appId == this.selectedAppId) {
|
|
this.selectedApp = this.apps[i]
|
|
break
|
|
}
|
|
}
|
|
if (!this.selectedApp.gatewayDomain || this.selectedApp.gatewayDomain.length == 0) {
|
|
this.selectedApp.gatewayDomain = "gw.httpdns.example.com"
|
|
}
|
|
if (!this.selectedApp.gatewayDomainDisplay || this.selectedApp.gatewayDomainDisplay.length == 0) {
|
|
this.selectedApp.gatewayDomainDisplay = this.selectedApp.gatewayDomain
|
|
}
|
|
|
|
this.signSecretVisible = false
|
|
this.aesSecretVisible = false
|
|
this.currentStep = 1
|
|
}
|
|
|
|
this.copyText = function (text, name) {
|
|
if (typeof text != "string" || text.length == 0) {
|
|
teaweb.warn("没有可复制的内容")
|
|
return
|
|
}
|
|
|
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
navigator.clipboard.writeText(text).then(function () {
|
|
teaweb.success(name + "已复制")
|
|
}).catch(function () {
|
|
this.copyByTextarea(text, name)
|
|
}.bind(this))
|
|
return
|
|
}
|
|
|
|
this.copyByTextarea(text, name)
|
|
}
|
|
|
|
this.copyByTextarea = function (text, name) {
|
|
var input = document.createElement("textarea")
|
|
input.value = text
|
|
input.setAttribute("readonly", "readonly")
|
|
input.style.position = "fixed"
|
|
input.style.left = "-10000px"
|
|
input.style.top = "-10000px"
|
|
document.body.appendChild(input)
|
|
input.select()
|
|
|
|
var ok = false
|
|
try {
|
|
ok = document.execCommand("copy")
|
|
} catch (e) {
|
|
ok = false
|
|
}
|
|
document.body.removeChild(input)
|
|
|
|
if (ok) {
|
|
teaweb.success(name + "已复制")
|
|
} else {
|
|
teaweb.warn("复制失败,请手动复制")
|
|
}
|
|
}
|
|
})
|