fix: 修复部分问题
This commit is contained in:
24
src/heurams/interface/css/screens/preparation.tcss
Normal file
24
src/heurams/interface/css/screens/preparation.tcss
Normal file
@@ -0,0 +1,24 @@
|
||||
#operations {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin: 0 1 0 0;
|
||||
padding: 0 1 0 1;
|
||||
}
|
||||
|
||||
#main_container {
|
||||
|
||||
}
|
||||
|
||||
#previewer_container {
|
||||
|
||||
}
|
||||
|
||||
.unit-statline {
|
||||
|
||||
}
|
||||
|
||||
#title {
|
||||
padding: 0;
|
||||
}
|
||||
@@ -45,27 +45,23 @@ API 版本代号: `{version.codename.capitalize()}`
|
||||
|
||||
以 AGPL-3.0 开放源代码, 这直接意味着任何个体直接基于此代码对外或内部提供的应用和服务, 无论本地或网络, 必须向所有用户公开完整修改后的源代码, 且继续沿用 AGPL-3.0 协议.
|
||||
|
||||
您正使用的 TUI 用户界面是 python 版本程序库自带的基本用户界面, 作为基本的全功能前端实现与程序库测试, 如果您想去除它, 请移除程序库根目录中的 interface 文件夹.
|
||||
您正使用的 TUI 用户界面是 python 版本程序库自带的基本用户界面, 以作为基本的全功能前端实现与程序库测试, 位于程序库根目录中的 interface 文件夹.
|
||||
|
||||
您可在项目主页 https://ams.pluv27.top 获取用户指南, 开发文档与软件更新.
|
||||
|
||||
如果您觉得这个软件有用, 可以在它的源代码仓库给它添加一个星标 :)
|
||||
如果您觉得这个软件有用, 可以考虑参与贡献, 或在它的源代码仓库给它添加一个星标 :)
|
||||
|
||||
> 潜进(HeurAMS), 以及它作为一个"程序库"是自由且免费的, 但是开发工作必须投入大量精力.
|
||||
> 您可以加入各种语言的翻译团队来翻译软件的界面, 您还可以制作图像、主题、音效, 或者改进软件配套的文档……
|
||||
> 不管您来自何方, 我们都欢迎您加入社区并做出贡献.
|
||||
> 我们的共同目标是为人人带来高品质的辅助记忆 & 学习软件.
|
||||
> 您的慷慨支持, 我们必当涌泉相报.
|
||||
您的慷慨支持, 我们必当涌泉相报.
|
||||
|
||||
开发人员列表:
|
||||
|
||||
- Wang Zhiyu([@pluvium27](https://github.com/pluvium27)): 发起项目与主要维护者
|
||||
|
||||
特别感谢以下人士, 他们的算法与理论构成了此软件算法的基石:
|
||||
特别感谢以下人士, 他们的算法与理论构成了此软件现有算法的基石:
|
||||
|
||||
- [Piotr A. Woźniak](https://supermemo.guru/wiki/Piotr_Wozniak): SM-2 算法与 SM-15 算法理论
|
||||
- [Kazuaki Tanida](https://github.com/slaypni): SM-15 算法的 CoffeeScript 实现
|
||||
- [Thoughts Memo](https://www.zhihu.com/people/L.M.Sherlock): 文献参考
|
||||
- [Thoughts Memo](https://www.zhihu.com/people/L.M.Sherlock): 中文文献参考
|
||||
|
||||
|
||||
# 运行环境信息
|
||||
@@ -86,6 +82,7 @@ Textual 框架版本: {textual_version}
|
||||
"返回主界面",
|
||||
id="back_button",
|
||||
variant="primary",
|
||||
flat=True,
|
||||
classes="back-button",
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
@@ -93,7 +93,6 @@ class DashboardScreen(Screen):
|
||||
# need_review: 需要/不需要学习
|
||||
# nearest_review_time: 最近下次学习时间
|
||||
# progress: 进度
|
||||
# algotype: 算法类型
|
||||
## initial_time: 起始时间
|
||||
# package: 包名
|
||||
# prompt: 最终呈现信息
|
||||
|
||||
@@ -19,15 +19,8 @@ from heurams.services.logger import get_logger
|
||||
|
||||
from .. import shim
|
||||
|
||||
|
||||
class AtomState(Enum):
|
||||
FAILED = auto()
|
||||
NORMAL = auto()
|
||||
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class MemScreen(Screen):
|
||||
BINDINGS = [
|
||||
("q", "go_back", "返回"),
|
||||
@@ -35,18 +28,17 @@ class MemScreen(Screen):
|
||||
("d", "toggle_dark", ""),
|
||||
("v", "play_voice", "朗读"),
|
||||
("*", "toggle_favorite", "收藏"),
|
||||
("0,1,2,3", "app.push_screen('about')", ""),
|
||||
]
|
||||
|
||||
if config_var.get()["interface"]["global"]["quick_pass"]:
|
||||
BINDINGS.append(("k", "quick_pass", "正确应答"))
|
||||
BINDINGS.append(("f", "quick_fail", "错误应答"))
|
||||
|
||||
rating = reactive(-1)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
phaser: Phaser,
|
||||
save_func: Callable,
|
||||
repo=None,
|
||||
name=None,
|
||||
id=None,
|
||||
@@ -54,7 +46,6 @@ class MemScreen(Screen):
|
||||
) -> None:
|
||||
super().__init__(name, id, classes)
|
||||
self.phaser = phaser
|
||||
self.save_func = save_func
|
||||
self.repo = repo
|
||||
self.update_state()
|
||||
self.fission: Fission
|
||||
@@ -62,8 +53,8 @@ class MemScreen(Screen):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
with ScrollableContainer():
|
||||
yield Label(self._get_progress_text(), id="progress")
|
||||
yield ScrollableContainer(id="puzzle-container")
|
||||
yield Label(self._get_progress_text(), id="head_stat")
|
||||
yield ScrollableContainer(id="puzzle_container")
|
||||
yield Footer()
|
||||
|
||||
def update_state(self):
|
||||
@@ -92,33 +83,12 @@ class MemScreen(Screen):
|
||||
if self.repo is not None:
|
||||
fav_status = "已收藏" if self._is_current_atom_favorited() else "未收藏"
|
||||
s += f"收藏: {fav_status}\n"
|
||||
"""if config_var.get().get("debug_topline", 0):
|
||||
try:
|
||||
alia = self.fission.get_current_puzzle_inf()["alia"] # type: ignore
|
||||
s += f"谜题: {alia}\n"
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
stat = self.phaser.__repr__("simple", "")
|
||||
s += f"{stat}\n"
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
stat = self.procession.__repr__("simple", "")
|
||||
s += f"{stat}\n"
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
stat = self.fission.__repr__("simple", "")
|
||||
s += f"{stat}\n"
|
||||
except Exception as e:
|
||||
s = str(e)"""
|
||||
s += f"进度: {self.procession.process() + 1}/{self.procession.total_length()}"
|
||||
return s
|
||||
|
||||
def update_display(self):
|
||||
"""更新进度显示"""
|
||||
progress_widget = self.query_one("#progress")
|
||||
progress_widget = self.query_one("#head_stat")
|
||||
progress_widget.update(self._get_progress_text()) # type: ignore
|
||||
|
||||
def mount_puzzle(self):
|
||||
@@ -126,14 +96,14 @@ class MemScreen(Screen):
|
||||
if self.procession.phase == PhaserState.FINISHED:
|
||||
self.mount_finished_widget()
|
||||
return
|
||||
container = self.query_one("#puzzle-container")
|
||||
container = self.query_one("#puzzle_container")
|
||||
for i in container.children:
|
||||
i.remove()
|
||||
container.mount(self.puzzle_widget())
|
||||
|
||||
def mount_finished_widget(self):
|
||||
"""挂载已完成组件"""
|
||||
container = self.query_one("#puzzle-container")
|
||||
container = self.query_one("#puzzle_container")
|
||||
for i in container.children:
|
||||
i.remove()
|
||||
from heurams.interface.widgets.finished import Finished
|
||||
|
||||
@@ -17,7 +17,7 @@ paths = config_var.get()["global"]["paths"]
|
||||
cache_dir = pathlib.Path(paths.get("cache", paths["data"] + "/cache")) / "voice"
|
||||
|
||||
|
||||
def format_size(bytes_num: int) -> str:
|
||||
def human_size(bytes_num: int) -> str:
|
||||
"""将字节数格式化为人类可读的字符串"""
|
||||
for unit in ["B", "KB", "MB", "GB", "TB"]:
|
||||
if bytes_num < 1024.0:
|
||||
@@ -97,7 +97,7 @@ class PrecachingScreen(Screen):
|
||||
|
||||
self.cache_stats["total_size"] = total_size
|
||||
self.cache_stats["file_count"] = file_count
|
||||
self.cache_stats["human_size"] = format_size(total_size)
|
||||
self.cache_stats["human_size"] = human_size(total_size)
|
||||
self.cache_stats["cached_units"] = cached_units
|
||||
self.cache_stats["total_units"] = total_units
|
||||
self.cache_stats["cache_rate"] = cache_rate
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""记忆准备界面"""
|
||||
|
||||
from textual.app import ComposeResult
|
||||
from textual.containers import ScrollableContainer, Container
|
||||
from textual.containers import ScrollableContainer, Container, Horizontal
|
||||
from textual.reactive import reactive
|
||||
from textual.screen import Screen
|
||||
from textual.widget import Widget
|
||||
@@ -22,6 +22,7 @@ import heurams.services.hasher as hasher
|
||||
from heurams.context import *
|
||||
from heurams.context import config_var
|
||||
from heurams.kernel.repolib import *
|
||||
from heurams.kernel.algorithms import algorithms
|
||||
from heurams.services.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -38,7 +39,7 @@ class PreparationScreen(Screen):
|
||||
("0,1,2,3", "app.push_screen('about')", ""),
|
||||
]
|
||||
|
||||
scheduled_num = reactive(config_var.get()["interface"]["global"]["scheduled_num"])
|
||||
CSS_PATH = rootdir / "interface" / "css" / "screens" / "preparation.tcss"
|
||||
|
||||
def __init__(self, repo: Repo) -> None:
|
||||
super().__init__(name=None, id=None, classes=None)
|
||||
@@ -47,32 +48,44 @@ class PreparationScreen(Screen):
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
with Reveal(ScrollableContainer(id="vice_container")):
|
||||
yield Label(f"准备就绪: [b]{self.repo.manifest['title']}[/b]\n")
|
||||
yield Label(f"[b]仓库路径: {self.repo.source}[/b]")
|
||||
yield Label(f"\n单元数量: {len(self.repo)}\n")
|
||||
yield Label(f"最小记忆分组: {self.scheduled_num}\n", id="schnum_label")
|
||||
|
||||
yield Button(
|
||||
"开始记忆",
|
||||
id="start_memorizing_button",
|
||||
variant="primary",
|
||||
classes="start-button",
|
||||
with ScrollableContainer(id="main_container"):
|
||||
yield Markdown(
|
||||
f"**准备就绪**: `{self.repo.manifest['title']}`\n", id="title"
|
||||
)
|
||||
yield Button(
|
||||
"预缓存音频",
|
||||
id="precache_button",
|
||||
variant="success",
|
||||
classes="precache-button",
|
||||
yield Label(f"单元集路径: {self.repo.source}")
|
||||
yield Label(
|
||||
f"学习完成度: {self.repo.progress['touched']}/{len(self.repo)} [d]\\[{round(self.repo.progress['touched']/self.repo.progress['total']*100, 1)}%][/d]"
|
||||
)
|
||||
yield Label(
|
||||
f"调度算法: {self.repo.config["algorithm"]} {algorithms[self.repo.config["algorithm"]].desc}"
|
||||
)
|
||||
yield Label(
|
||||
f"学习数量: {self.repo.preview['review'] + self.scheduled_num} = {self.repo.preview['review']} [d][复习][/d] + {self.scheduled_num} [d][新识记][/d]\n",
|
||||
id="schnum_label",
|
||||
)
|
||||
|
||||
yield Horizontal(
|
||||
Button(
|
||||
"开始记忆",
|
||||
id="start_memorizing_button",
|
||||
variant="primary",
|
||||
classes="btn",
|
||||
),
|
||||
Button(
|
||||
"预缓存音频",
|
||||
id="precache_button",
|
||||
variant="success",
|
||||
classes="btn",
|
||||
),
|
||||
id="operations",
|
||||
)
|
||||
|
||||
yield Static()
|
||||
yield Sparkline(self.spark_line_arr, summary_function=max)
|
||||
yield Rule()
|
||||
# yield Static(str(self.spark_line_arr))
|
||||
yield Static(f"单元状态预览:\n")
|
||||
for i in self.content.splitlines():
|
||||
yield Static(i, classes="full")
|
||||
with Reveal(ScrollableContainer(id="previewer_container")):
|
||||
for i in self.content.splitlines():
|
||||
yield Static(i, classes="unit-statline")
|
||||
yield Footer()
|
||||
|
||||
# def watch_scheduled_num(self, old_scheduled_num, new_scheduled_num):
|
||||
@@ -84,6 +97,7 @@ class PreparationScreen(Screen):
|
||||
# pass
|
||||
|
||||
def load_data(self):
|
||||
self.scheduled_num = self.repo.config["scheduled_num"]
|
||||
content = ""
|
||||
spark_line_arr = []
|
||||
for i in self.repo.ident_index:
|
||||
@@ -168,6 +182,5 @@ def launch(repo, app, scheduled_num):
|
||||
from .memoqueue import MemScreen
|
||||
|
||||
pheser = rt.Phaser(atoms_to_provide)
|
||||
save_func = repo.persist_to_repodir
|
||||
memscreen = MemScreen(pheser, save_func, repo=repo)
|
||||
memscreen = MemScreen(pheser, repo=repo)
|
||||
app.push_screen(memscreen)
|
||||
|
||||
Reference in New Issue
Block a user