mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 23:30:26 +08:00
优化代码
This commit is contained in:
12
internal/utils/email.go
Normal file
12
internal/utils/email.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "regexp"
|
||||||
|
|
||||||
|
var emailReg = regexp.MustCompile(`(?i)^[a-z\d]+([._+-]*[a-z\d]+)*@([a-z\d]+[a-z\d-]*[a-z\d]+\.)+[a-z\d]+$`)
|
||||||
|
|
||||||
|
// ValidateEmail 校验电子邮箱格式
|
||||||
|
func ValidateEmail(email string) bool {
|
||||||
|
return emailReg.MatchString(email)
|
||||||
|
}
|
||||||
22
internal/utils/email_test.go
Normal file
22
internal/utils/email_test.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
|
||||||
|
package utils_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||||
|
"github.com/iwind/TeaGo/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValidateEmail(t *testing.T) {
|
||||||
|
var a = assert.NewAssertion(t)
|
||||||
|
a.IsTrue(utils.ValidateEmail("aaaa@gmail.com"))
|
||||||
|
a.IsTrue(utils.ValidateEmail("a.b@gmail.com"))
|
||||||
|
a.IsTrue(utils.ValidateEmail("a.b.c.d@gmail.com"))
|
||||||
|
a.IsTrue(utils.ValidateEmail("aaaa@gmail.com.cn"))
|
||||||
|
a.IsTrue(utils.ValidateEmail("hello.world.123@gmail.123.com"))
|
||||||
|
a.IsTrue(utils.ValidateEmail("10000@qq.com"))
|
||||||
|
a.IsFalse(utils.ValidateEmail("aaaa.@gmail.com"))
|
||||||
|
a.IsFalse(utils.ValidateEmail("aaaa@gmail"))
|
||||||
|
a.IsFalse(utils.ValidateEmail("aaaa@123"))
|
||||||
|
}
|
||||||
@@ -2,8 +2,25 @@ Vue.component("ns-access-log-box", {
|
|||||||
props: ["v-access-log", "v-keyword"],
|
props: ["v-access-log", "v-keyword"],
|
||||||
data: function () {
|
data: function () {
|
||||||
let accessLog = this.vAccessLog
|
let accessLog = this.vAccessLog
|
||||||
|
let isFailure = false
|
||||||
|
|
||||||
|
if (accessLog.isRecursive) {
|
||||||
|
if (accessLog.recordValue == null || accessLog.recordValue.length == 0) {
|
||||||
|
isFailure = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (accessLog.recordType == "SOA" || accessLog.recordType == "NS") {
|
||||||
|
if (accessLog.recordValue == null || accessLog.recordValue.length == 0) {
|
||||||
|
isFailure = true
|
||||||
|
}
|
||||||
|
} else if (accessLog.nsRecordId == null || accessLog.nsRecordId == 0) {
|
||||||
|
isFailure = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accessLog: accessLog
|
accessLog: accessLog,
|
||||||
|
isFailure: isFailure
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -32,7 +49,7 @@ Vue.component("ns-access-log-box", {
|
|||||||
this.$refs.box.parentNode.style.cssText = ""
|
this.$refs.box.parentNode.style.cssText = ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div class="access-log-row" :style="{'color': (!accessLog.isRecursive && (accessLog.nsRecordId == null || accessLog.nsRecordId == 0) || (accessLog.isRecursive && accessLog.recordValue != null && accessLog.recordValue.length == 0)) ? '#dc143c' : ''}" ref="box">
|
template: `<div class="access-log-row" :style="{'color': isFailure ? '#dc143c' : ''}" ref="box">
|
||||||
<span v-if="accessLog.region != null && accessLog.region.length > 0" class="grey">[{{accessLog.region}}]</span> <keyword :v-word="vKeyword">{{accessLog.remoteAddr}}</keyword> [{{accessLog.timeLocal}}] [{{accessLog.networking}}] <em>{{accessLog.questionType}} <keyword :v-word="vKeyword">{{accessLog.questionName}}</keyword></em> ->
|
<span v-if="accessLog.region != null && accessLog.region.length > 0" class="grey">[{{accessLog.region}}]</span> <keyword :v-word="vKeyword">{{accessLog.remoteAddr}}</keyword> [{{accessLog.timeLocal}}] [{{accessLog.networking}}] <em>{{accessLog.questionType}} <keyword :v-word="vKeyword">{{accessLog.questionName}}</keyword></em> ->
|
||||||
|
|
||||||
<span v-if="accessLog.recordType != null && accessLog.recordType.length > 0"><em>{{accessLog.recordType}} <keyword :v-word="vKeyword">{{accessLog.recordValue}}</keyword></em></span>
|
<span v-if="accessLog.recordType != null && accessLog.recordType.length > 0"><em>{{accessLog.recordType}} <keyword :v-word="vKeyword">{{accessLog.recordValue}}</keyword></em></span>
|
||||||
|
|||||||
Reference in New Issue
Block a user