mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2026-03-22 06:57:16 +08:00
refactor: 重构项目翻译模块
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
from typing import Callable
|
||||
|
||||
from pyperclip import paste
|
||||
from rich.text import Text
|
||||
from textual import on
|
||||
@@ -28,6 +26,7 @@ from ..module import (
|
||||
REPOSITORY,
|
||||
GENERAL,
|
||||
)
|
||||
from ..translation import _
|
||||
|
||||
__all__ = ["Index"]
|
||||
|
||||
@@ -42,10 +41,9 @@ class Index(Screen):
|
||||
Binding(key="A", action="about", description="关于项目/About"),
|
||||
]
|
||||
|
||||
def __init__(self, app: XHS, message: Callable[[str], str]):
|
||||
def __init__(self, app: XHS, ):
|
||||
super().__init__()
|
||||
self.xhs = app
|
||||
self.message = message
|
||||
self.url = None
|
||||
self.tip = None
|
||||
|
||||
@@ -54,24 +52,24 @@ class Index(Screen):
|
||||
yield ScrollableContainer(
|
||||
Label(
|
||||
Text(
|
||||
f"{self.message("开源协议")}: {LICENCE}",
|
||||
f"{_("开源协议")}: {LICENCE}",
|
||||
style=MASTER)
|
||||
),
|
||||
Label(
|
||||
Text(
|
||||
f"{self.message("项目地址")}{REPOSITORY}",
|
||||
f"{_("项目地址")}{REPOSITORY}",
|
||||
style=MASTER)
|
||||
),
|
||||
Label(
|
||||
Text(
|
||||
self.message("请输入小红书图文/视频作品链接"),
|
||||
_("请输入小红书图文/视频作品链接"),
|
||||
style=PROMPT), classes="prompt",
|
||||
),
|
||||
Input(placeholder=self.message("多个链接之间使用空格分隔")),
|
||||
Input(placeholder=_("多个链接之间使用空格分隔")),
|
||||
HorizontalScroll(
|
||||
Button(self.message("下载无水印作品文件"), id="deal"),
|
||||
Button(self.message("读取剪贴板"), id="paste"),
|
||||
Button(self.message("清空输入框"), id="reset"),
|
||||
Button(_("下载无水印作品文件"), id="deal"),
|
||||
Button(_("读取剪贴板"), id="paste"),
|
||||
Button(_("清空输入框"), id="reset"),
|
||||
),
|
||||
)
|
||||
yield RichLog(markup=True, )
|
||||
@@ -83,7 +81,7 @@ class Index(Screen):
|
||||
self.tip = self.query_one(RichLog)
|
||||
self.tip.write(
|
||||
Text(
|
||||
self.message("免责声明\n") +
|
||||
_("免责声明\n") +
|
||||
f"\n{
|
||||
">" *
|
||||
50}",
|
||||
@@ -96,7 +94,7 @@ class Index(Screen):
|
||||
if self.url.value:
|
||||
self.deal()
|
||||
else:
|
||||
self.tip.write(Text(self.message("未输入任何小红书作品链接"), style=WARNING))
|
||||
self.tip.write(Text(_("未输入任何小红书作品链接"), style=WARNING))
|
||||
self.tip.write(Text(">" * 50, style=GENERAL))
|
||||
|
||||
@on(Button.Pressed, "#reset")
|
||||
@@ -113,7 +111,7 @@ class Index(Screen):
|
||||
if any(await self.xhs.extract(self.url.value, True, log=self.tip, data=False, )):
|
||||
self.url.value = ""
|
||||
else:
|
||||
self.tip.write(Text(self.message("下载小红书作品文件失败"), style=ERROR))
|
||||
self.tip.write(Text(_("下载小红书作品文件失败"), style=ERROR))
|
||||
self.tip.write(Text(">" * 50, style=GENERAL))
|
||||
self.app.pop_screen()
|
||||
|
||||
@@ -127,7 +125,7 @@ class Index(Screen):
|
||||
await self.app.run_action("settings")
|
||||
|
||||
async def action_monitor(self):
|
||||
await self.app.push_screen(Monitor(self.xhs, self.message))
|
||||
await self.app.push_screen(Monitor(self.xhs, ))
|
||||
|
||||
async def action_about(self):
|
||||
await self.app.push_screen("about")
|
||||
|
||||
Reference in New Issue
Block a user