refactor: IP归属地改为apihz.cn id+key配置,后端测试修复验证条件
This commit is contained in:
@@ -158,21 +158,18 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="IP 归属地查询">
|
||||
<div style="display: flex; gap: 8px; align-items: center; width: 100%;">
|
||||
<el-input
|
||||
v-model="configs.ip_geo_api_url"
|
||||
placeholder="https://cn.apihz.cn/api/ip/chaapi.php?id=xxx&key=***&ip={ip}&td=0"
|
||||
style="max-width: 360px"
|
||||
/>
|
||||
<el-button type="primary" :loading="ipGeoTesting" @click="handleTestIpGeo" size="default" style="width: 100px;">
|
||||
<div style="display:flex; flex-direction:column; gap:8px; width:100%;">
|
||||
<el-select v-model="configs.ip_geo_provider" placeholder="选择接口" style="max-width:260px">
|
||||
<el-option label="接口盒子 (apihz.cn)" value="apihz" />
|
||||
</el-select>
|
||||
<template v-if="configs.ip_geo_provider === 'apihz'">
|
||||
<el-input v-model="configs.ip_geo_api_id" placeholder="API ID(如:10014356)" style="max-width:360px" />
|
||||
<el-input v-model="configs.ip_geo_api_key" placeholder="API Key" type="password" show-password style="max-width:360px" />
|
||||
</template>
|
||||
<el-button type="primary" :loading="ipGeoTesting" @click="handleTestIpGeo" size="small" style="width:100px">
|
||||
{{ ipGeoTesting ? "测试中..." : "验证接口" }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="form-tip" style="margin-top: 4px;">
|
||||
IP 归属地查询 API 地址,<code>{ip}</code> 会被替换为实际 IP。
|
||||
</div>
|
||||
<div style="color: var(--el-color-warning); font-size: 13px; margin-top: 2px; width: 100%;">
|
||||
⚠ 当前仅支持 接口盒子(apihz.cn) 格式
|
||||
<div class="form-tip">用于查询用户 IP 归属地(搜索/转存记录中显示)。留空则不做 IP 归属地查询。</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-divider content-position="left">Redis 缓存</el-divider>
|
||||
@@ -1447,12 +1444,12 @@ async function handleTestProxy() {
|
||||
async function handleTestIpGeo() {
|
||||
ipGeoTesting.value = true
|
||||
try {
|
||||
const url = String(configs.ip_geo_api_url || "")
|
||||
if (!url) {
|
||||
ElMessage.warning("请先输入 IP 归属地查询 API 地址")
|
||||
const apiId = String(configs.ip_geo_api_id || "")
|
||||
if (!apiId) {
|
||||
ElMessage.warning("请先输入 API ID")
|
||||
return
|
||||
}
|
||||
const result = await testExternalService({ type: "ip_geo", url })
|
||||
const result = await testExternalService({ type: "ip_geo", url: apiId })
|
||||
if (result.ok) {
|
||||
ElMessage.success("✅ IP 归属地接口可用 — " + result.info)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user