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:
@@ -5,6 +5,7 @@ from textual.screen import Screen
|
||||
from textual.widgets import Footer
|
||||
from textual.widgets import Header
|
||||
from textual.widgets import Label
|
||||
from textual.widgets import Link
|
||||
|
||||
from ..module import (
|
||||
PROJECT,
|
||||
@@ -22,15 +23,15 @@ class About(Screen):
|
||||
Binding(
|
||||
key="Q",
|
||||
action="quit",
|
||||
description="退出程序/Quit"),
|
||||
description=_("退出程序")),
|
||||
Binding(
|
||||
key="U",
|
||||
action="check_update",
|
||||
description="检查更新/Update"),
|
||||
description=_("检查更新")),
|
||||
Binding(
|
||||
key="B",
|
||||
action="index",
|
||||
description="返回首页/Back"),
|
||||
description=_("返回首页")),
|
||||
]
|
||||
|
||||
def __init__(self, ):
|
||||
@@ -40,13 +41,25 @@ class About(Screen):
|
||||
yield Header()
|
||||
yield Label(Text(_("如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star,感谢您的支持!"), style=INFO),
|
||||
classes="prompt", )
|
||||
yield Label(Text("Discord 社区", style=PROMPT), classes="prompt", )
|
||||
yield Label(f"{_("邀请链接:")}https://discord.com/invite/ZYtmgKud9Y")
|
||||
yield Label(Text(_("Discord 社区"), style=PROMPT), classes="prompt", )
|
||||
yield Link(
|
||||
f"{_("邀请链接:")}https://discord.com/invite/ZYtmgKud9Y",
|
||||
url="https://discord.com/invite/ZYtmgKud9Y",
|
||||
tooltip=_("点击访问"),
|
||||
)
|
||||
yield Label(Text(_("作者的其他开源项目"), style=PROMPT), classes="prompt", )
|
||||
yield Label(Text("TikTokDownloader (抖音 / TikTok)", style=MASTER), classes="prompt", )
|
||||
yield Label("https://github.com/JoeanAmier/TikTokDownloader")
|
||||
yield Link(
|
||||
"https://github.com/JoeanAmier/TikTokDownloader",
|
||||
url="https://github.com/JoeanAmier/TikTokDownloader",
|
||||
tooltip=_("点击访问"),
|
||||
)
|
||||
yield Label(Text("KS-Downloader (快手)", style=MASTER), classes="prompt", )
|
||||
yield Label("https://github.com/JoeanAmier/KS-Downloader")
|
||||
yield Link(
|
||||
"https://github.com/JoeanAmier/KS-Downloader",
|
||||
url="https://github.com/JoeanAmier/KS-Downloader",
|
||||
tooltip=_("点击访问"),
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
|
||||
@@ -44,6 +44,7 @@ class XHSDownloader(App):
|
||||
)
|
||||
|
||||
async def on_mount(self) -> None:
|
||||
self.theme = "nord"
|
||||
self.install_screen(
|
||||
Setting(
|
||||
self.parameter,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -23,8 +23,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=_("退出程序")),
|
||||
Binding(key="C", action="close", description=_("关闭监听")),
|
||||
]
|
||||
|
||||
def __init__(self, app: XHS, ):
|
||||
@@ -42,7 +42,7 @@ class Monitor(Screen):
|
||||
def close_button(self):
|
||||
self.action_close()
|
||||
|
||||
@work()
|
||||
@work(exclusive=True)
|
||||
async def run_monitor(self):
|
||||
await self.xhs.monitor(download=True, log=self.query_one(RichLog), data=False, )
|
||||
self.action_close()
|
||||
|
||||
@@ -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=_("退出程序")),
|
||||
Binding(key="B", action="index", description=_("返回首页")),
|
||||
]
|
||||
|
||||
def __init__(self, data: dict, ):
|
||||
|
||||
@@ -30,7 +30,7 @@ class Update(ModalScreen):
|
||||
classes="loading",
|
||||
)
|
||||
|
||||
@work()
|
||||
@work(exclusive=True)
|
||||
async def check_update(self) -> None:
|
||||
try:
|
||||
url = await self.xhs.html.request_url(RELEASES, False, None, timeout=5, )
|
||||
|
||||
@@ -22,7 +22,7 @@ def retry(function):
|
||||
def logging(log, text, style=INFO):
|
||||
string = Text(text, style=style)
|
||||
if log:
|
||||
log.write(string)
|
||||
log.write(string, animate=True, )
|
||||
else:
|
||||
print(string)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user