fix: 稳定性修复

This commit is contained in:
2026-05-04 13:13:05 +08:00
parent 40f4d6c6e3
commit e2b9fb94f3
13 changed files with 11612 additions and 27 deletions

View File

@@ -13,3 +13,13 @@ NavigatorScreen {
border: thick $background 80%;
background: $surface;
}
.favorite-item {
height: auto;
}
.favorite-item-btn {
dock: right;
width: 8;
padding: 0;
}

View File

@@ -1,4 +1,8 @@
#puzzle_container > * {
height: auto;
width: auto;
}
.hori {
height: auto;
}

View File

@@ -60,12 +60,12 @@ API 版本代号: `{version.codename.capitalize()}`
一个基于启发式算法与认知科学理论的辅助记忆调度器, 旨在帮助用户更高效地进行记忆工作与学习规划.
一个开放, 优雅, 易于扩展的间隔重复调度器实验平台, 旨在帮助研究者更高效地进行前沿记忆算法的研究.
以 AGPL-3.0 开放源代码, 这直接意味着任何个体直接基于此代码对外或内部提供的应用和服务, 无论本地或网络, 必须向所有用户公开完整修改后的源代码, 且继续沿用 AGPL-3.0 协议.
您正使用的 TUI 用户界面是 python 版本程序库自带的基本用户界面, 以作为第一个全功能前端实现与程序库测试套件, 位于程序库根目录中的 interface 文件夹.
您正使用的 TUI 用户界面是 python 版本程序库自带的基本用户界面, 以作为第一个全功能前端实现与程序库测试套件, 位于程序库下 interface 目录.
您可在项目主页 https://ams.pluv27.top 获取用户指南, 开发文档与软件更新.
以 GNU Affero 通用公共许可证 (第3版) 开放源代码.
如果您觉得这个软件有用, 可以考虑参与贡献, 或在它的源代码仓库给它添加一个星标 :)
您的慷慨支持, 我们必当涌泉相报.
@@ -90,7 +90,7 @@ Textual 框架版本: {textual_version}
操作系统版本: {os_version}
存储余量: {disk_usage}
内存大小: {memory_info}
报告问题时, 请复制这些信息到问题描述, 并上传软件日志 `heurams.log` 作为附件, 以协助开发者定位错误
"""
yield Markdown(about_text, classes="about-markdown")

View File

@@ -7,7 +7,7 @@ from typing import List, Optional
from textual import events, on
from textual.app import ComposeResult
from textual.containers import ScrollableContainer
from textual.containers import ScrollableContainer, Horizontal
from textual.screen import Screen
from textual.widgets import (
Button,
@@ -104,23 +104,20 @@ class FavoriteManagerScreen(Screen):
# 尝试获取仓库信息
repo_info = self._get_repo_info(fav.repo_path, fav)
title = repo_info.get("title", fav.repo_path) if repo_info else fav.repo_path
content_preview = repo_info.get("content_preview", "") if repo_info else ""
added_time = self._format_time(fav.added)
# 构建显示文本
display_text = f"[b]{title}[/b] ({fav.ident})\n"
if content_preview:
display_text += f"{content_preview}\n"
display_text += f"添加于: {added_time}"
display_text = f"{fav.ident}\n"
display_text += f" [d]添加于: {added_time}\n 来自 {title}[/d]"
if fav.tags:
display_text += f" 标签: {', '.join(fav.tags)}"
display_text += f"{', '.join(fav.tags)}"
# 创建安全的按钮 ID
button_key = self._encode_favorite_key(fav.repo_path, fav.ident)
# 创建列表项,包含移除按钮
container = ScrollableContainer(
Markdown(display_text, classes="favorite-content"),
Button("移除", id=f"remove-{button_key}", variant="error"),
container = Horizontal(
Label(display_text, classes="favorite-content"),
Button("移除", id=f"remove-{button_key}", variant="error", flat=True, classes="favorite-item-btn"),
classes="favorite-item",
)
return ListItem(container)

View File

@@ -24,12 +24,13 @@ logger = get_logger(__name__)
class MemScreen(Screen):
BINDINGS = [
("q", "go_back", "返回"),
("q", "go_back_notif", "返回"),
("p", "prev", "查看上一个"),
("d", "toggle_dark", ""),
("v", "play_voice", "朗读"),
("*", "toggle_favorite", "收藏"),
("r", "resume_mark"),
("Q", "go_back"),
("n", "block_prompt"),
("s", "block_prompt"),
("z", "block_prompt"),
@@ -220,6 +221,8 @@ class MemScreen(Screen):
self.update_state() # 刷新状态
self.expander = self.procession.get_expander()
def action_go_back_notif(self):
self.notify("确定吗? 按下大写 Q 以返回")
def action_go_back(self):
self.app.pop_screen()

View File

@@ -2,7 +2,7 @@ import copy
import random
from typing import TypedDict
from textual.containers import ScrollableContainer
from textual.containers import ScrollableContainer, Horizontal
from textual.widget import Widget
from textual.widgets import Button, Label, Markdown
from textual.events import Key
@@ -71,6 +71,7 @@ class ClozePuzzle(BasePuzzleWidget):
# 渲染当前问题的选项
with ScrollableContainer(id="btn-container") as s:
c = 0
btns = []
for i in self.ans:
h = str(hash(i))
if hash(i) in self.hashmap.keys():
@@ -80,7 +81,12 @@ class ClozePuzzle(BasePuzzleWidget):
btnid = f"sel000-{h}"
logger.debug(f"建立按钮 {btnid}")
self.btn_shortcuts[f"{c}"] = btnid
yield Button(f"[{c}] {i}", id=f"{btnid}")
btns.append(Button(f"{i}", id=f"{btnid}", classes='cloze-option-btn'))
for i in range((len(btns)+1)//2):
if 2 * i + 1 + 1 <= len(btns):
yield Horizontal(btns[i], btns[len(btns) - 1 - i], classes='hori')
else:
yield btns[i]
s.focus()
yield Button("退格", id="delete")
@@ -130,7 +136,7 @@ class ClozePuzzle(BasePuzzleWidget):
self.atom.minimize(rating)
def on_key(self, event: Key) -> None:
self.notify(event.key)
#self.notify(event.key)
if event.key in self.btn_shortcuts:
btn_id = self.btn_shortcuts.get(event.key)
btn_id = "#" + btn_id