Skip to content

Commit

Permalink
perfect(AlistClient): 使用属性方法装饰用户名和密码属性,避免被意外修改
Browse files Browse the repository at this point in the history
  • Loading branch information
Akimio521 committed Oct 31, 2024
1 parent 0c4b00f commit f280690
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/api/alist/v3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def __init__(self, url: str, username: str, password: str) -> None:
url = "https://" + url
self.url = url.rstrip("/")

self.username = str(username)
self.__password = str(password)
self.__username = str(username)
self.___password = str(password)
self.__dir = "/"
self.__token = {
"token": "", # 令牌 token str
Expand All @@ -56,6 +56,22 @@ async def __aenter__(self):
async def __aexit__(self, *_):
await self.__session.close()

@property
def username(self) -> str:
"""
获取用户名
"""

return self.__username

@property
def __password(self) -> str:
"""
获取密码
"""

return self.___password

@property
def __get_token(self) -> str:
"""
Expand Down

0 comments on commit f280690

Please sign in to comment.