改进文字提示

This commit is contained in:
GoEdgeLab
2022-11-27 22:00:35 +08:00
parent 92a36f99f1
commit 5c20606430
4 changed files with 35 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ Tea.context(function () {
this.sshPort = ""
this.grantId = 0
this.step = "info"
this.name = ""
this.success = function (resp) {
this.node = resp.data.node
@@ -170,4 +171,32 @@ Tea.context(function () {
this.createNext = function () {
teaweb.reload()
}
this.defaultIP = ""
this.changeName = function () {
if (this.validateIP(this.name)) {
this.defaultIP = this.name
} else {
this.defaultIP = ""
}
}
this.validateIP = function (v) {
// 目前只支持ipv4
let pieces = v.split(".")
if (pieces.length != 4) {
return false
}
for (let i = 0; i < pieces.length; i++) {
if (!/^\d{1,3}$/.test(pieces[i])) {
return false
}
let p = parseInt(pieces[i], 10)
if (p > 255) {
return false
}
}
return true
}
})