From ee926cfa42191cd6a1d1163a9811401de28aa8d4 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 23 Feb 2023 15:04:07 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20agent=20=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/utils/django.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/common/utils/django.py b/apps/common/utils/django.py index 2c4808d16..ad8a218d8 100644 --- a/apps/common/utils/django.py +++ b/apps/common/utils/django.py @@ -85,13 +85,12 @@ def bulk_create_with_signal(cls: models.Model, items, **kwargs): def get_request_os(request): """获取请求的操作系统""" agent = request.META.get('HTTP_USER_AGENT', '').lower() - - if agent is None: - return 'unknown' - if 'windows' in agent.lower(): + + if 'windows' in agent: return 'windows' - if 'mac' in agent.lower(): + elif 'mac' in agent: return 'mac' - if 'linux' in agent.lower(): + elif 'linux' in agent: return 'linux' - return 'unknown' + else: + return 'unknown'