适配 TETR.IO record 模板

This commit is contained in:
2024-06-14 07:45:47 +08:00
parent b08685086a
commit 1dd3d310c9
2 changed files with 94 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ from ..templates import templates_dir
from .schemas.bind import Bind
from .schemas.tetrio_info import Info as TETRIOInfo
from .schemas.tetrio_info_v2 import Info as TETRIOInfoV2
from .schemas.tetrio_record_sprint import Record as TETRIORecordSprint
from .schemas.top_info import Info as TOPInfo
from .schemas.tos_info import Info as TOSInfo
@@ -27,6 +28,10 @@ async def render(render_type: Literal['v1/tetrio/info'], data: TETRIOInfo) -> st
async def render(render_type: Literal['v2/tetrio/info'], data: TETRIOInfoV2) -> str: ...
@overload
async def render(render_type: Literal['v2/tetrio/record/40l'], data: TETRIORecordSprint) -> str: ...
@overload
async def render(render_type: Literal['v1/top/info'], data: TOPInfo) -> str: ...
@@ -36,8 +41,15 @@ async def render(render_type: Literal['v1/tos/info'], data: TOSInfo) -> str: ...
async def render(
render_type: Literal['v1/binding', 'v1/tetrio/info', 'v2/tetrio/info', 'v1/top/info', 'v1/tos/info'],
data: Bind | TETRIOInfo | TETRIOInfoV2 | TOPInfo | TOSInfo,
render_type: Literal[
'v1/binding',
'v1/tetrio/info',
'v2/tetrio/info',
'v1/top/info',
'v1/tos/info',
'v2/tetrio/record/40l',
],
data: Bind | TETRIOInfo | TETRIOInfoV2 | TETRIORecordSprint | TOPInfo | TOSInfo,
) -> str:
if PYDANTIC_V2:
return await env.get_template('index.html').render_async(