mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
修复获取ip api失败时,无法登陆
修复禁用或者运行定时任务出现重复
This commit is contained in:
+8
-4
@@ -165,9 +165,13 @@ export async function getNetIp(req: any) {
|
||||
.json();
|
||||
return { address: data[0].location, ip };
|
||||
} catch (error) {
|
||||
const { country, regionName, city } = await got
|
||||
.get(`http://ip-api.com/json/${ip}?lang=zh-CN`)
|
||||
.json();
|
||||
return { address: `${country} ${regionName} ${city}`, ip };
|
||||
try {
|
||||
const { country, regionName, city } = await got
|
||||
.get(`http://ip-api.com/json/${ip}?lang=zh-CN`)
|
||||
.json();
|
||||
return { address: `${country} ${regionName} ${city}`, ip };
|
||||
} catch (err) {
|
||||
return { address: `获取失败`, ip };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user