mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2026-03-22 06:57:16 +08:00
perf: 更新程序交互界面
1. 更新英语翻译 2. 更新界面文本 3. 更新界面主题
This commit is contained in:
@@ -12,6 +12,7 @@ from textual.widgets import Footer
|
||||
from textual.widgets import Header
|
||||
from textual.widgets import Input
|
||||
from textual.widgets import Label
|
||||
from textual.widgets import Link
|
||||
from textual.widgets import RichLog
|
||||
|
||||
from .monitor import Monitor
|
||||
@@ -33,12 +34,12 @@ __all__ = ["Index"]
|
||||
|
||||
class Index(Screen):
|
||||
BINDINGS = [
|
||||
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"),
|
||||
Binding(key="Q", action="quit", description=_("退出程序")),
|
||||
Binding(key="U", action="update", description=_("检查更新")),
|
||||
Binding(key="S", action="settings", description=_("程序设置")),
|
||||
Binding(key="R", action="record", description=_("下载记录")),
|
||||
Binding(key="M", action="monitor", description=_("开启监听")),
|
||||
Binding(key="A", action="about", description=_("关于项目")),
|
||||
]
|
||||
|
||||
def __init__(self, app: XHS, ):
|
||||
@@ -55,10 +56,13 @@ class Index(Screen):
|
||||
f"{_("开源协议")}: {LICENCE}",
|
||||
style=MASTER)
|
||||
),
|
||||
Label(
|
||||
Link(
|
||||
Text(
|
||||
f"{_("项目地址")}{REPOSITORY}",
|
||||
style=MASTER)
|
||||
style=MASTER,
|
||||
),
|
||||
url=REPOSITORY,
|
||||
tooltip=_("点击访问"),
|
||||
),
|
||||
Label(
|
||||
Text(
|
||||
@@ -72,7 +76,7 @@ class Index(Screen):
|
||||
Button(_("清空输入框"), id="reset"),
|
||||
),
|
||||
)
|
||||
yield RichLog(markup=True, )
|
||||
yield RichLog(markup=True, wrap=True, )
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
@@ -85,7 +89,8 @@ class Index(Screen):
|
||||
f"\n{
|
||||
">" *
|
||||
50}",
|
||||
style=MASTER), scroll_end=False,
|
||||
style=MASTER),
|
||||
animate=True,
|
||||
)
|
||||
self.xhs.manager.print_proxy_tip(log=self.tip, )
|
||||
|
||||
@@ -94,8 +99,14 @@ class Index(Screen):
|
||||
if self.url.value:
|
||||
self.deal()
|
||||
else:
|
||||
self.tip.write(Text(_("未输入任何小红书作品链接"), style=WARNING))
|
||||
self.tip.write(Text(">" * 50, style=GENERAL))
|
||||
self.tip.write(
|
||||
Text(_("未输入任何小红书作品链接"), style=WARNING),
|
||||
animate=True,
|
||||
)
|
||||
self.tip.write(
|
||||
Text(">" * 50, style=GENERAL),
|
||||
animate=True,
|
||||
)
|
||||
|
||||
@on(Button.Pressed, "#reset")
|
||||
def reset_button(self):
|
||||
@@ -105,14 +116,20 @@ class Index(Screen):
|
||||
def paste_button(self):
|
||||
self.query_one(Input).value = paste()
|
||||
|
||||
@work()
|
||||
@work(exclusive=True)
|
||||
async def deal(self):
|
||||
await self.app.push_screen("loading")
|
||||
if any(await self.xhs.extract(self.url.value, True, log=self.tip, data=False, )):
|
||||
self.url.value = ""
|
||||
else:
|
||||
self.tip.write(Text(_("下载小红书作品文件失败"), style=ERROR))
|
||||
self.tip.write(Text(">" * 50, style=GENERAL))
|
||||
self.tip.write(
|
||||
Text(_("下载小红书作品文件失败"), style=ERROR),
|
||||
animate=True,
|
||||
)
|
||||
self.tip.write(
|
||||
Text(">" * 50, style=GENERAL),
|
||||
animate=True,
|
||||
)
|
||||
self.app.pop_screen()
|
||||
|
||||
async def action_quit(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user