fix: 变更哈希注册表以修复重复键造成的崩溃

This commit is contained in:
2026-04-19 12:08:58 +08:00
parent 0572848803
commit a8cd774123
9 changed files with 25 additions and 20 deletions

View File

@@ -17,6 +17,7 @@ import heurams.services.version as version
from heurams.context import *
from heurams.kernel.particles import *
from heurams.kernel.repolib import *
from heurams.kernel.algorithms import algorithms
from heurams.services.logger import get_logger
from .about import AboutScreen
@@ -58,14 +59,14 @@ class DashboardScreen(Screen):
f"当前 UNIX 日时间戳: {timer.get_daystamp()}"
),
Label(f"应用时区修正: UTC+{config_var.get()['timezone_offset'] / 3600}"),
Label(f"全局算法设置: {config_var.get()['algorithm']['default']}"),
Label(f"全局算法设置: {config_var.get()['algorithm']['default']}: {algorithms[config_var.get()['algorithm']['default']].desc}"),
classes="column infview",
),
Vertical(
Label(f"已加载 {len(self.repostat)} 个单元集", classes='dataview'),
Label(f"共计 {reduce(lambda x, y: x + y, map(lambda x: x.get('unit_sum'), self.repostat.values()))} 个单元", classes='dataview'),
Label(f"已激活 {reduce(lambda x, y: x + y, map(lambda x: x.get('activated_sum'), self.repostat.values()))} 个单元", classes='dataview'),
Label(f"终端尺寸: {os.get_terminal_size()[0]}x{os.get_terminal_size()[1]}"),
Label(f""),
classes="column dataview",
),
id="dashboardtop"
@@ -191,4 +192,4 @@ class DashboardScreen(Screen):
if str(event.button.id).startswith("launch_"): # type: ignore
from .preparation import launch
launch(repo=self.dirname2repo[event.button.id[7:]], app=self.app, scheduled_num=-1) # type: ignore
# TODO: 这样启动的记忆实例的状态机无法绑定到 PreparationScreen 中
# TODO: 这样启动的记忆实例的状态机无法绑定到 PreparationScreen 中

View File

@@ -70,8 +70,9 @@ class ClozePuzzle(BasePuzzleWidget):
# 渲染当前问题的选项
with Container(id="btn-container"):
for i in self.ans:
self.hashmap[str(hash(i))] = i
btnid = f"sel000-{hash(i)}"
h = str(hash(i))
self.hashmap[h] = i
btnid = f"sel000-{h}"
logger.debug(f"建立按钮 {btnid}")
yield Button(i, id=f"{btnid}")