Skip to content
This repository was archived by the owner on Jun 8, 2025. It is now read-only.

Commit fd56976

Browse files
committed
fix: 热重载失败后正确fallback到登录流程
1 parent dc4f684 commit fd56976

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "VChat"
3-
version = "1.0.1"
3+
dynamic = ["version"]
44
authors = [
55
{ name="z2z63", email="[email protected]" },
66
]
@@ -26,5 +26,8 @@ Homepage = "https://github.com/z2z63/VChat"
2626
Issues = "https://github.com/z2z63/VChat/issues"
2727

2828
[build-system]
29-
requires = ["setuptools>=61.0"]
30-
build-backend = "setuptools.build_meta"
29+
requires = ["setuptools>=64", "setuptools_scm>=8"]
30+
build-backend = "setuptools.build_meta"
31+
32+
[tool.setuptools_scm]
33+
version_file = "vchat/_version.py"

vchat/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_version.py

vchat/core/hotreload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ async def _load_login_status(self, file_path, login_callback=None):
5454
rmsgs, contacts = await self._net_helper.get_msg()
5555
except VOperationFailedError:
5656
await self.logout()
57-
await self._load_last_login_status(jar["cookies"])
5857
logger.debug("server refused, loading login status failed.")
5958
raise VNetworkError("server refused, loading login status failed.")
6059

vchat/net/interface.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
def catch_exception(
27-
fn: Callable[P, Coroutine[Any, Any, T]]
27+
fn: Callable[P, Coroutine[Any, Any, T]]
2828
) -> Callable[P, Coroutine[Any, Any, T]]:
2929
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
3030
try:
@@ -33,11 +33,7 @@ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
3333
msg = f"{fn.__name__}出现网络错误: {str(e)}"
3434
logger.warning(msg)
3535
raise VNetworkError(msg)
36-
except KeyError as e:
37-
msg = f"服务器返回的数据错误: {str(e)}"
38-
logger.warning(msg)
39-
raise VOperationFailedError(msg)
40-
except AttributeError as e:
36+
except (KeyError, AttributeError, ValueError) as e:
4137
msg = f"服务器返回的数据错误: {str(e)}"
4238
logger.warning(msg)
4339
raise VOperationFailedError(msg)
@@ -97,7 +93,7 @@ async def show_mobile_login(self):
9793

9894
@abstractmethod
9995
async def update_batch_contact(
100-
self, batch: int, callback: Callable
96+
self, batch: int, callback: Callable
10197
) -> tuple[Literal[0, 1], Iterable[Contact]]:
10298
pass
10399

@@ -108,7 +104,7 @@ async def update_chatroom(self, usernames: list[str]) -> list[dict]:
108104

109105
@abstractmethod
110106
async def get_detailed_member_info(
111-
self, encry_chatroom_id: str, members: Collection[User]
107+
self, encry_chatroom_id: str, members: Collection[User]
112108
) -> AsyncGenerator[User, None]:
113109
async for member in self.get_detailed_member_info(encry_chatroom_id, members):
114110
yield member
@@ -140,7 +136,7 @@ async def get_chatroom_head_img(self, chatroom_name: str, fd: BinaryIO) -> None:
140136

141137
@abstractmethod
142138
async def get_chatroom_member_head_img(
143-
self, username: str, chatroom_id: str, fd: BinaryIO
139+
self, username: str, chatroom_id: str, fd: BinaryIO
144140
) -> None:
145141
pass
146142

@@ -154,7 +150,7 @@ async def set_chatroom_name(self, chatroom_username, name):
154150

155151
@abstractmethod
156152
async def delete_member_from_chatroom(
157-
self, chatroom_username: str, members: list[User]
153+
self, chatroom_username: str, members: list[User]
158154
):
159155
pass
160156

@@ -196,7 +192,7 @@ def get_dumpable_cookies(self):
196192

197193
@abstractmethod
198194
def _get_download_fn(
199-
self, url: str, params: dict, headers: dict | None = None
195+
self, url: str, params: dict, headers: dict | None = None
200196
) -> Callable[..., Awaitable]:
201197
pass
202198

@@ -218,7 +214,7 @@ def get_attach_download_fn(self, rmsg: "RawMessage|dict[str, str]"):
218214

219215
@abstractmethod
220216
async def send_document(
221-
self, file_name: str, media_id: str, file_size: int, to_username: str
217+
self, file_name: str, media_id: str, file_size: int, to_username: str
222218
) -> None:
223219
pass
224220

0 commit comments

Comments
 (0)