From 8515b0ce718030ffc315a24999c1bc3cd9d0d7bb Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Sun, 1 Sep 2024 16:41:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9IPlocationAPI=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/src/APIs/BlogComment.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Server/src/APIs/BlogComment.ts b/Server/src/APIs/BlogComment.ts index 074e9c0..aed0838 100644 --- a/Server/src/APIs/BlogComment.ts +++ b/Server/src/APIs/BlogComment.ts @@ -26,9 +26,10 @@ class BlogComment extends API { // 获取IPAddress let ip_address = '未知' try { - let ipAddressRes = await axios.get(`http://ip-api.com/json/${_ip}?lang=zh-CN`); - if (ipAddressRes.data && ipAddressRes.data.status == 'success') { - ip_address = ipAddressRes.data.country == '中国' ? ipAddressRes.data.city : ipAddressRes.data.country; + let ipAddressRes = await axios.get(`https://mesh.if.iqiyi.com/aid/ip/info?version=1.1.1&ip=`+_ip); + if (ipAddressRes.data && ipAddressRes.data.msg == 'success') { + + ip_address = ipAddressRes.data.data.countryCN == '中国' ? ipAddressRes.data.data.provinceCN : ipAddressRes.data.data.countryCN; } } catch (error) { this.logger.warn('获取IP属地失败', error);