From 1ed02f5f7db5e5396058f7114971742e9d9afa82 Mon Sep 17 00:00:00 2001 From: XIE7654 <765462425@qq.com> Date: Thu, 2 Oct 2025 16:02:43 +0800 Subject: [PATCH] fix: location_info --- backend/system/tasks.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/system/tasks.py b/backend/system/tasks.py index 261372d..535fb62 100644 --- a/backend/system/tasks.py +++ b/backend/system/tasks.py @@ -20,8 +20,8 @@ def update_user_login_info(user_id, client_ip, user_agent): user.save(update_fields=['login_ip', 'last_login']) # 获取地理位置信息 - # location_info = get_location_from_ip(client_ip) - location_info = None + location_info = get_location_from_ip(client_ip) + # location_info = None # 记录登录日录 LoginLog.objects.create( @@ -46,9 +46,11 @@ def get_location_from_ip(ip): location_parts = [data["city"], data["regionName"], data["country"]] return ', '.join(location_parts) if location_parts else "未知位置" else: - return f"IP {ip} 查询失败:{data['message']}" + return "位置获取失败" + # return f"IP {ip} 查询失败:{data['message']}" except Exception as e: - return f"IP {ip} 连接错误:{str(e)}" + return "位置获取失败" + # return f"IP {ip} 连接错误:{str(e)}" except Exception as e: import logging logger = logging.getLogger(__name__)