From 954e0e5357895c4a86c1ae50077b1a5ee4a5014c Mon Sep 17 00:00:00 2001 From: KimigaiiWuyi <444835641@qq.com> Date: Sun, 21 Apr 2024 07:12:26 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=88=A9=E7=94=A8`gs=5Fcache()`?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C`ba=E6=9F=A5=E8=AF=A2`=E5=92=8C`ba=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E6=8E=92=E5=90=8D`=E7=BB=93=E6=9E=9C=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlueArchiveUID/bauid_guide/get_char.py | 4 ++++ BlueArchiveUID/bauid_info/draw_user_info_pic.py | 2 ++ BlueArchiveUID/bauid_ranklist/draw_rank_pic.py | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/BlueArchiveUID/bauid_guide/get_char.py b/BlueArchiveUID/bauid_guide/get_char.py index 764f88a..019066f 100644 --- a/BlueArchiveUID/bauid_guide/get_char.py +++ b/BlueArchiveUID/bauid_guide/get_char.py @@ -13,6 +13,10 @@ async def get_hehedi_char_img(name: str) -> Optional[str]: name = alias_to_char_name(name) + return await _get_hehedi_char_img(name) + + +async def _get_hehedi_char_img(name: str) -> Optional[str]: path = HEHEDI_CHAR_GUIDE_PATH / f'{name}.jpg' if path.exists(): return await convert_img(path) diff --git a/BlueArchiveUID/bauid_info/draw_user_info_pic.py b/BlueArchiveUID/bauid_info/draw_user_info_pic.py index 9778d07..8e69301 100644 --- a/BlueArchiveUID/bauid_info/draw_user_info_pic.py +++ b/BlueArchiveUID/bauid_info/draw_user_info_pic.py @@ -3,6 +3,7 @@ from PIL import Image, ImageDraw from gsuid_core.models import Event +from gsuid_core.utils.cache import gs_cache from gsuid_core.utils.image.convert import convert_img from gsuid_core.utils.fonts.fonts import core_font as cf from gsuid_core.utils.image.image_tools import ( @@ -158,6 +159,7 @@ def get_bg(w: int, h: int): return img +@gs_cache() async def draw_user_info_img( _fcode: str, ev: Event, user_id: str ) -> Union[str, bytes]: diff --git a/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py b/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py index 4d4f8cc..71e5ebb 100644 --- a/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py +++ b/BlueArchiveUID/bauid_ranklist/draw_rank_pic.py @@ -2,6 +2,7 @@ from typing import Union from PIL import Image, ImageDraw +from gsuid_core.utils.cache import gs_cache from gsuid_core.utils.image.convert import convert_img from gsuid_core.utils.fonts.fonts import core_font as cf @@ -27,6 +28,11 @@ def get_color(rank_key: int): async def draw_rank_pic(student: str) -> Union[bytes, str]: student_id = student_name_to_id(student) + return await _draw_rank_pic(student_id) + + +@gs_cache() +async def _draw_rank_pic(student_id: str) -> Union[bytes, str]: if student_id == '9999': return '要查询的角色不存在或别名未收录, 请尝试使用完整名字。'