mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-08 04:55:47 +08:00
🐛 使用Union以支持低版本python
This commit is contained in:
parent
333541a361
commit
776e936119
@ -1,6 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TypedDict
|
from typing import TypedDict, Union
|
||||||
|
|
||||||
|
|
||||||
class MihomoData(TypedDict):
|
class MihomoData(TypedDict):
|
||||||
@ -15,8 +15,8 @@ class Behavior(TypedDict):
|
|||||||
class Equipment(TypedDict):
|
class Equipment(TypedDict):
|
||||||
level: int
|
level: int
|
||||||
tid: int
|
tid: int
|
||||||
promotion: int | None
|
promotion: Union[int, None]
|
||||||
rank: int | None
|
rank: Union[int, None]
|
||||||
|
|
||||||
|
|
||||||
class Relic(TypedDict):
|
class Relic(TypedDict):
|
||||||
@ -34,19 +34,19 @@ class SubAffix(TypedDict):
|
|||||||
|
|
||||||
class Avatar(TypedDict):
|
class Avatar(TypedDict):
|
||||||
skillTreeList: list[Behavior]
|
skillTreeList: list[Behavior]
|
||||||
rank: int | None
|
rank: Union[int, None]
|
||||||
pos: int | None
|
pos: Union[int, None]
|
||||||
avatarId: int
|
avatarId: int
|
||||||
level: int
|
level: int
|
||||||
equipment: Equipment | None
|
equipment: Union[Equipment, None]
|
||||||
relicList: list[Relic]
|
relicList: list[Relic]
|
||||||
promotion: int
|
promotion: int
|
||||||
|
|
||||||
|
|
||||||
class Challenge(TypedDict):
|
class Challenge(TypedDict):
|
||||||
scheduleMaxLevel: int
|
scheduleMaxLevel: int
|
||||||
MazeGroupIndex: int | None
|
MazeGroupIndex: Union[int, None]
|
||||||
PreMazeGroupIndex: int | None
|
PreMazeGroupIndex: Union[int, None]
|
||||||
|
|
||||||
|
|
||||||
class PlayerSpaceInfo(TypedDict):
|
class PlayerSpaceInfo(TypedDict):
|
||||||
@ -61,13 +61,13 @@ class PlayerDetailInfo(TypedDict):
|
|||||||
assistAvatarDetail: Avatar
|
assistAvatarDetail: Avatar
|
||||||
platform: str
|
platform: str
|
||||||
isDisplayAvatar: bool
|
isDisplayAvatar: bool
|
||||||
avatarDetailList: list[Avatar] | None
|
avatarDetailList: Union[list[Avatar], None]
|
||||||
uid: int
|
uid: int
|
||||||
friendCount: int
|
friendCount: int
|
||||||
worldLevel: int
|
worldLevel: int
|
||||||
nickname: str
|
nickname: str
|
||||||
Birthday: int | None
|
Birthday: Union[int, None]
|
||||||
level: int
|
level: int
|
||||||
recordInfo: PlayerSpaceInfo | None
|
recordInfo: Union[PlayerSpaceInfo, None]
|
||||||
headIcon: int
|
headIcon: int
|
||||||
signature: str | None
|
signature: Union[str, None]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, List, Optional, TypedDict
|
from typing import Any, Dict, List, TypedDict, Union
|
||||||
|
|
||||||
################
|
################
|
||||||
# 抽卡记录相关 #
|
# 抽卡记录相关 #
|
||||||
@ -91,8 +91,8 @@ class RogueRecordInfo(TypedDict):
|
|||||||
miracles: List[RogueMiracles]
|
miracles: List[RogueMiracles]
|
||||||
difficulty: int
|
difficulty: int
|
||||||
progress: int
|
progress: int
|
||||||
detail_h: Optional[int]
|
detail_h: Union[int, None]
|
||||||
start_h: Optional[int]
|
start_h: Union[int, None]
|
||||||
|
|
||||||
|
|
||||||
class RogueBasic(TypedDict):
|
class RogueBasic(TypedDict):
|
||||||
@ -373,7 +373,7 @@ class AvatarListItemDetail(TypedDict):
|
|||||||
rarity: int
|
rarity: int
|
||||||
rank: int
|
rank: int
|
||||||
image: str
|
image: str
|
||||||
equip: Optional[Equip]
|
equip: Union[Equip, None]
|
||||||
relics: List[RelicsItem]
|
relics: List[RelicsItem]
|
||||||
ornaments: List
|
ornaments: List
|
||||||
ranks: List[RanksItem]
|
ranks: List[RanksItem]
|
||||||
|
@ -29,7 +29,7 @@ async def convert_img(img: Path, is_base64: bool = False) -> str:
|
|||||||
|
|
||||||
async def convert_img(
|
async def convert_img(
|
||||||
img: Union[Image.Image, str, Path, bytes], is_base64: bool = False
|
img: Union[Image.Image, str, Path, bytes], is_base64: bool = False
|
||||||
) -> str | bytes:
|
) -> Union[str, bytes]:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
将PIL.Image对象转换为bytes或者base64格式。
|
将PIL.Image对象转换为bytes或者base64格式。
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Tuple
|
from typing import Dict, List, Tuple, Union
|
||||||
|
|
||||||
from aiohttp.client import ClientSession
|
from aiohttp.client import ClientSession
|
||||||
from msgspec import json as msgjson
|
from msgspec import json as msgjson
|
||||||
@ -15,7 +15,7 @@ with Path.open(
|
|||||||
) as f:
|
) as f:
|
||||||
resource_map = msgjson.decode(
|
resource_map = msgjson.decode(
|
||||||
f.read(),
|
f.read(),
|
||||||
type=Dict[str, Dict[str, Dict[str, Dict[str, str | int]]]],
|
type=Dict[str, Dict[str, Dict[str, Dict[str, Union[str, int]]]]],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user