更新项目依赖库版本

This commit is contained in:
JoeanAmier
2024-06-29 10:12:04 +08:00
parent e7c4d6daee
commit b87132e364
22 changed files with 257 additions and 89 deletions

View File

@@ -21,15 +21,15 @@ __all__ = ["About"]
class About(Screen):
BINDINGS = [
Binding(
key="q",
key="Q",
action="quit",
description="退出程序/Quit"),
Binding(
key="u",
action="check_update_about",
key="U",
action="check_update",
description="检查更新/Update"),
Binding(
key="b",
key="B",
action="index",
description="返回首页/Back"),
]
@@ -53,3 +53,12 @@ class About(Screen):
def on_mount(self) -> None:
self.title = PROJECT
async def action_quit(self) -> None:
await self.app.action_quit()
async def action_index(self):
await self.app.push_screen("index")
async def action_check_update(self):
await self.app.run_action("update_and_return")

View File

@@ -14,7 +14,6 @@ from source.module import logging
from .about import About
from .index import Index
from .loading import Loading
from .monitor import Monitor
from .record import Record
from .setting import Setting
from .update import Update
@@ -78,15 +77,6 @@ class XHSDownloader(App):
await self.push_screen("setting", save_settings)
async def action_about(self):
await self.push_screen("about")
async def action_index(self):
await self.push_screen("index")
async def action_record(self):
await self.push_screen("record")
async def refresh_screen(self):
self.pop_screen()
await self.close_database()
@@ -117,13 +107,10 @@ class XHSDownloader(App):
async def action_check_update(self):
await self.push_screen(Update(self.APP, self.message), callback=self.update_result)
async def action_check_update_about(self):
async def action_update_and_return(self):
await self.push_screen("index")
await self.action_check_update()
async def action_monitor(self):
await self.push_screen(Monitor(self.APP, self.message))
async def close_database(self):
await self.APP.id_recorder.cursor.close()
await self.APP.id_recorder.database.close()

View File

@@ -27,18 +27,19 @@ from source.module import (
REPOSITORY,
GENERAL,
)
from .monitor import Monitor
__all__ = ["Index"]
class Index(Screen):
BINDINGS = [
Binding(key="q", action="quit", description="退出程序/Quit"),
Binding(key="u", action="check_update", description="检查更新/Update"),
Binding(key="s", action="settings", description="程序设置/Settings"),
Binding(key="r", action="record", description="下载记录/Record"),
Binding(key="m", action="monitor", description="开启监听/Monitor"),
Binding(key="a", action="about", description="关于项目/About"),
Binding(key="Q", action="quit", description="退出程序/Quit"),
Binding(key="U", action="update", description="检查更新/Update"),
Binding(key="S", action="settings", description="程序设置/Settings"),
Binding(key="R", action="record", description="下载记录/Record"),
Binding(key="M", action="monitor", description="开启监听/Monitor"),
Binding(key="A", action="about", description="关于项目/About"),
]
def __init__(self, app: XHS, message: Callable[[str], str]):
@@ -73,7 +74,7 @@ class Index(Screen):
Button(self.message("清空输入框"), id="reset"),
),
)
yield RichLog(markup=True, wrap=True)
yield RichLog(markup=True, )
yield Footer()
def on_mount(self) -> None:
@@ -86,7 +87,8 @@ class Index(Screen):
f"\n{
">" *
50}",
style=MASTER), scroll_end=False)
style=MASTER), scroll_end=False,
)
self.xhs.manager.print_proxy_tip(log=self.tip, )
@on(Button.Pressed, "#deal")
@@ -114,3 +116,21 @@ class Index(Screen):
self.tip.write(Text(self.message("下载小红书作品文件失败"), style=ERROR))
self.tip.write(Text(">" * 50, style=GENERAL))
self.app.pop_screen()
async def action_quit(self) -> None:
await self.app.action_quit()
async def action_update(self) -> None:
await self.app.run_action("check_update")
async def action_settings(self):
await self.app.run_action("settings")
async def action_monitor(self):
await self.app.push_screen(Monitor(self.xhs, self.message))
async def action_about(self):
await self.app.push_screen("about")
async def action_record(self):
await self.app.push_screen("record")

View File

@@ -24,8 +24,8 @@ __all__ = ["Monitor"]
class Monitor(Screen):
BINDINGS = [
Binding(key="q", action="quit", description="退出程序/Quit"),
Binding(key="c", action="close", description="关闭监听/Close"),
Binding(key="Q", action="quit", description="退出程序/Quit"),
Binding(key="C", action="close", description="关闭监听/Close"),
]
def __init__(self, app: XHS, message: Callable[[str], str]):
@@ -60,3 +60,7 @@ class Monitor(Screen):
def action_close(self):
self.xhs.stop_monitor()
self.app.pop_screen()
async def action_quit(self) -> None:
self.action_close()
await self.app.action_quit()

View File

@@ -15,7 +15,6 @@ __all__ = ["Record"]
class Record(ModalScreen):
def __init__(self, app: XHS, message: Callable[[str], str]):
super().__init__()
self.xhs = app

View File

@@ -19,8 +19,8 @@ __all__ = ["Setting"]
class Setting(Screen):
BINDINGS = [
Binding(key="q", action="quit", description="退出程序/Quit"),
Binding(key="b", action="index", description="返回首页/Back"),
Binding(key="Q", action="quit", description="退出程序/Quit"),
Binding(key="B", action="index", description="返回首页/Back"),
]
def __init__(self, data: dict, message: Callable[[str], str]):
@@ -39,8 +39,15 @@ class Setting(Screen):
Label(self.message("作品文件名称格式"), classes="params", ),
Input(self.data["name_format"], placeholder=self.message("发布时间 作者昵称 作品标题"), valid_empty=True,
id="name_format", ),
Label(self.message("Sec-Ch-Ua"), classes="params", ),
Input(self.data["sec_ch_ua"], placeholder=self.message("内置 Chrome Sec-Ch-Ua"), valid_empty=True,
id="sec_ch_ua", ),
Label(self.message("Sec-Ch-Ua-Platform"), classes="params", ),
Input(self.data["sec_ch_ua_platform"], placeholder=self.message("内置 Chrome Sec-Ch-Ua-Platform"),
valid_empty=True,
id="sec_ch_ua_platform", ),
Label(self.message("User-Agent"), classes="params", ),
Input(self.data["user_agent"], placeholder=self.message("内置 Chrome User-Agent"), valid_empty=True,
Input(self.data["user_agent"], placeholder=self.message("内置 Chrome User Agent"), valid_empty=True,
id="user_agent", ),
Label(self.message("小红书网页版 Cookie"), classes="params", ),
Input(placeholder=self.__check_cookie(), valid_empty=True, id="cookie", ),
@@ -101,6 +108,8 @@ class Setting(Screen):
"work_path": self.query_one("#work_path").value,
"folder_name": self.query_one("#folder_name").value,
"name_format": self.query_one("#name_format").value,
"sec_ch_ua": self.query_one("#sec_ch_ua").value,
"sec_ch_ua_platform": self.query_one("#sec_ch_ua_platform").value,
"user_agent": self.query_one("#user_agent").value,
"cookie": self.query_one("#cookie").value or self.data["cookie"],
"proxy": self.query_one("#proxy").value or None,
@@ -120,3 +129,9 @@ class Setting(Screen):
@on(Button.Pressed, "#abandon")
def reset(self):
self.dismiss(self.data)
async def action_quit(self) -> None:
await self.app.action_quit()
async def action_index(self):
await self.app.push_screen("index")