Files
waf-platform/EdgeAdmin/web/views/@default/settings/ip-library/library/test.js
2026-02-04 20:27:13 +08:00

72 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Tea.context(function () {
this.ip = ""
this.result = {
isDone: false
}
// 如果数据还没有从后端传入window.TEA.ACTION.data则设置默认值
if (typeof this.maxMindCityExists === "undefined") {
this.maxMindCityExists = false
}
if (typeof this.maxMindASNExists === "undefined") {
this.maxMindASNExists = false
}
if (typeof this.usingMaxMind === "undefined") {
this.usingMaxMind = false
}
if (typeof this.usingEmbeddedMaxMind === "undefined") {
this.usingEmbeddedMaxMind = false
}
this.$delay(function () {
if (this.$refs.focus) {
this.$refs.focus.focus()
}
// 确保表单使用AJAX提交
var form = this.$el.querySelector('form')
if (form) {
form.addEventListener('submit', function (e) {
e.preventDefault()
e.stopPropagation()
// 使用TeaGo的AJAX提交
Tea.runActionOn(form)
})
}
})
// 如果数据还没有从后端传入,则通过 AJAX 获取(作为后备方案)
if (this.maxMindCityExists === false && this.maxMindASNExists === false && this.usingMaxMind === false) {
this.$get("/settings/ip-library/library/test")
.success(function (resp) {
this.maxMindCityExists = resp.data.maxMindCityExists || false
this.maxMindASNExists = resp.data.maxMindASNExists || false
this.usingMaxMind = resp.data.usingMaxMind || false
this.usingEmbeddedMaxMind = resp.data.usingEmbeddedMaxMind || false
})
}
this.success = function (resp) {
if (!resp || !resp.data) {
return
}
this.result = resp.data.result || {
isDone: true,
isOk: false
}
this.maxMindCityExists = resp.data.maxMindCityExists || false
this.maxMindASNExists = resp.data.maxMindASNExists || false
this.usingMaxMind = resp.data.usingMaxMind || false
this.usingEmbeddedMaxMind = resp.data.usingEmbeddedMaxMind || false
// 滚动到结果区域
this.$nextTick(function () {
if (this.$refs.resultBox) {
this.$refs.resultBox.scrollIntoView({ behavior: 'smooth', block: 'start' })
}
})
}
})