fix: 改进

This commit is contained in:
2025-12-13 13:13:55 +08:00
parent 7ab6881905
commit a0b327cdbb
2 changed files with 10 additions and 13 deletions

View File

@@ -26,7 +26,7 @@ class MemScreen(Screen):
if config_var.get()["quick_pass"]:
BINDINGS.append(("k", "quick_pass", "跳过"))
rating = reactive(-1)
def __init__(self, atoms: list, name: str | None = None, id: str | None = None, classes: str | None = None) -> None:
super().__init__(name, id, classes)
self.atoms = atoms
@@ -34,8 +34,8 @@ class MemScreen(Screen):
#print(self.phaser.state)
self.procession: Procession = self.phaser.current_procession() # type: ignore
#print(self.phaser.state)
self.procession.forward(1)
self.rating = reactive(0)
#self.procession.forward(1)
def on_mount(self):
self.load_puzzle()
@@ -60,7 +60,7 @@ class MemScreen(Screen):
yield Static(f"当前进度: {self.procession.process()}/{self.procession.total_length()}")
#self.mount(self.current_widget()) # type: ignore
yield Container(id="puzzle-container")
yield Button("重新学习此单元", id="re-recognize", variant="warning")
#yield Button("重新学习此单元", id="re-recognize", variant="warning")
yield Footer()
def load_puzzle(self):
@@ -72,8 +72,11 @@ class MemScreen(Screen):
def on_button_pressed(self, event):
event.stop()
def watch_rating(self, old_value, new_value) -> None:
forwards = 1 if new_value >= 4 else 0
def watch_rating(self, old_rating, new_rating) -> None:
if new_rating == -1:
return
forwards = 1 if new_rating >= 4 else 0
self.rating = -1
if forwards:
self.procession.forward(1)
self.load_puzzle()

View File

@@ -28,12 +28,6 @@ class Recognition(BasePuzzleWidget):
alia = "Recognition"
self.alia = alia
class RatingChanged(Message):
"""评分改变消息"""
def __init__(self, rating: int) -> None:
self.rating = rating
super().__init__()
def compose(self):
cfg: RecognitionConfig = self.atom.registry["orbital"]["puzzles"][self.alia]
delim = self.atom.registry['nucleon'].metadata["formation"]["delimiter"]
@@ -85,4 +79,4 @@ class Recognition(BasePuzzleWidget):
def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "ok":
self.post_message(self.RatingChanged(5))
self.screen.rating = 5 # type: ignore