From 794cce63ce4af409ed7d0d07a5d2761d2719f941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E4=BA=9A=E6=98=95?= <1549469775@qq.com> Date: Thu, 25 Sep 2025 17:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=8E=B7=E5=8F=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7IP=E5=9C=B0=E5=9D=80=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E7=AE=80=E5=8C=96CommonController=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/Index/controller/index.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/modules/Index/controller/index.js b/src/modules/Index/controller/index.js index d5c80e4..764df8f 100644 --- a/src/modules/Index/controller/index.js +++ b/src/modules/Index/controller/index.js @@ -24,15 +24,7 @@ export default class CommonController extends BaseController { // 可以在这里添加一些需要用户信息的逻辑 // 例如获取用户相关的统计数据等 const user = ctx.state.user || null - - // 获取请求的IP地址 - const ip = ctx.request.ip || ctx.ip || (ctx.req && ctx.req.connection && ctx.req.connection.remoteAddress) || null - - const res = await fetch("https://restapi.amap.com/v3/ip?key=5bd92438c102ddf15083a46cf705decf&ip=" + ip) - const data = await res.json() - console.log(ip) - console.log(data) - + // 示例数据,实际项目中可以从数据库获取 const stats = { articles: 1234,