fix: 修复特定情况下报错的问题

This commit is contained in:
JoeanAmier
2024-12-29 10:34:08 +08:00
parent 102e7adbd4
commit 1d2731b93a
5 changed files with 16 additions and 16 deletions

View File

@@ -30,7 +30,7 @@ class About(Screen):
description=_("检查更新")), description=_("检查更新")),
Binding( Binding(
key="B", key="B",
action="index", action="back",
description=_("返回首页")), description=_("返回首页")),
] ]
@@ -73,8 +73,8 @@ class About(Screen):
async def action_quit(self) -> None: async def action_quit(self) -> None:
await self.app.action_quit() await self.app.action_quit()
async def action_index(self): async def action_back(self) -> None:
await self.app.push_screen("index") await self.app.action_back()
async def action_check_update(self): async def action_check_update(self):
await self.app.run_action("update_and_return") await self.app.run_action("update_and_return")

View File

@@ -74,7 +74,7 @@ class XHSDownloader(App):
await self.push_screen("setting", save_settings) await self.push_screen("setting", save_settings)
async def refresh_screen(self): async def refresh_screen(self):
await self.pop_screen() await self.action_back()
await self.close_database() await self.close_database()
await self.APP.close() await self.APP.close()
self.__initialization() self.__initialization()
@@ -100,12 +100,12 @@ class XHSDownloader(App):
log.write(tip) log.write(tip)
log.write(">" * 50) log.write(">" * 50)
async def action_check_update(self): async def action_update(self):
await self.push_screen(Update(self.APP, ), callback=self.update_result) await self.push_screen(Update(self.APP, ), callback=self.update_result)
async def action_update_and_return(self): async def action_update_and_return(self):
await self.push_screen("index") await self.action_back()
await self.action_check_update() await self.action_update()
async def close_database(self): async def close_database(self):
await self.APP.id_recorder.cursor.close() await self.APP.id_recorder.cursor.close()

View File

@@ -130,13 +130,13 @@ class Index(Screen):
Text(">" * 50, style=GENERAL), Text(">" * 50, style=GENERAL),
animate=True, animate=True,
) )
await self.app.pop_screen() await self.app.action_back()
async def action_quit(self) -> None: async def action_quit(self) -> None:
await self.app.action_quit() await self.app.action_quit()
async def action_update(self) -> None: async def action_update(self) -> None:
await self.app.run_action("check_update") await self.app.run_action("update")
async def action_settings(self): async def action_settings(self):
await self.app.run_action("settings") await self.app.run_action("settings")

View File

@@ -39,13 +39,13 @@ class Monitor(Screen):
yield Footer() yield Footer()
@on(Button.Pressed, "#close") @on(Button.Pressed, "#close")
def close_button(self): async def close_button(self):
self.action_close() await self.action_close()
@work(exclusive=True) @work(exclusive=True)
async def run_monitor(self): async def run_monitor(self):
await self.xhs.monitor(download=True, log=self.query_one(RichLog), data=False, ) await self.xhs.monitor(download=True, log=self.query_one(RichLog), data=False, )
self.action_close() await self.action_close()
def on_mount(self) -> None: def on_mount(self) -> None:
self.title = PROJECT self.title = PROJECT
@@ -55,10 +55,10 @@ class Monitor(Screen):
style=MASTER)) style=MASTER))
self.run_monitor() self.run_monitor()
def action_close(self): async def action_close(self):
self.xhs.stop_monitor() self.xhs.stop_monitor()
self.app.pop_screen() await self.app.action_back()
async def action_quit(self) -> None: async def action_quit(self) -> None:
self.action_close() await self.action_close()
await self.app.action_quit() await self.app.action_quit()

View File

@@ -126,4 +126,4 @@ class Setting(Screen):
await self.app.action_quit() await self.app.action_quit()
async def action_index(self): async def action_index(self):
await self.app.push_screen("index") await self.app.action_back()