From 3411765be7ee335bde397448ec84b2b72427415e Mon Sep 17 00:00:00 2001 From: david-ajax Date: Fri, 25 Jul 2025 22:04:46 +0800 Subject: [PATCH] =?UTF-8?q?v0.2.4=20=E5=9F=BA=E6=9C=AC=E5=8F=AF=E7=94=A8?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __pycache__/auxiliary.cpython-313.pyc | Bin 337 -> 2423 bytes __pycache__/particles.cpython-313.pyc | Bin 9159 -> 9739 bytes __pycache__/reactor.cpython-313.pyc | Bin 5066 -> 5866 bytes auxiliary.py | 17 ++++++++---- config.toml | 8 ++++-- main.py | 24 ++++++++++------- particles.py | 27 ++++++++++++++----- generate_audio_cache.py => precaching.py | 0 reactor.py | 32 ++++++++++++++++++----- 9 files changed, 77 insertions(+), 31 deletions(-) rename generate_audio_cache.py => precaching.py (100%) diff --git a/__pycache__/auxiliary.cpython-313.pyc b/__pycache__/auxiliary.cpython-313.pyc index bcd17a10c9f84aca0d7f49987da9d76d8852bfc8..8fbc6f52a2db0240eb59365773f925b5b93a52ed 100644 GIT binary patch literal 2423 zcmbVO&2JM|5P$pO?=M132?>F92x%Q?tQJrSDzwl9DU>9|ODa^;t~T~MEVb9^+cm^g zsOhD`km96Ol&C%6D~C#)dWZf4L5@na_<+=2xKYvyiAy`P>vbFyE*&eg^WMyx_h#ld z?`1s{@)Mx`-@d){3rENwIB2mrgsrrA($g|%h({VC3)+qu@G&Z%(u}*Gxq>V2`%(g__+ye>=KgW+irbvt&ByTkqW*|pdRv>$c0KX}6 zoZCyXOq?5|m@<>0P!-R#Y+TBzlP3QO2quq1)2+;?x}lpcqfku4WJXOJz-2==`NFiK znY>ZR=S)6VkTZ8Vlh>78mLfV$CaYr^1wk+qiA#mNl8`UUGl`)>x|mlqLr;t<`62a+ zLKB)YV!G&!-lh0Ld|6x# z#j5A(9lP)Ne)3ggKL>9N&5gX^NVw-wDE50O_EHbRZubXw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~eBe5+CN>P1g2hXk^g6pWMXE zBClGS+>jRsxN;_3ORIBk+5|wHK-ql)fG1As%^0fN^duFmRAcJMO^ga&e7u4`mavHs zeE#q2hXiTKj4)vk~$hGWnA1FbG+Cuqec2-7=zRI+NCP;W<@_ zX(*M{ZD}M$xMDG|LX@)4qQ z3XP&WjEw}_8&43?nmiCw6%v}Iz8Qg7;--S;z(xZ8D7fh>`(#i29FkadT(^>%6If#?dY5Kg$X@Z`)S2T6{oqY{-#_<-!aFOFMOk`LU*OqY7aV8D`?A&4nlNSSc%586lz`$u?623CvEfs^jkav z@OMR}_<6e*mrD|sc>&5e;3_dCe5u$MV|6Z#5=qVIGtzR=gNo5@A!ww|(CJ;y*+p~O z&79OSOf;DmLPo)L!7=3w%m|gUf;}(zbAmrF1abn=$QO>f?Qm@;F*9%_2$j%CR-_zE zWKu}CMB{M-3sg13IDj8Y%2xXl+y?Lzm!)~2@GU`V%!mOgjf@QZ3^?h? z^pLA~@Pwzbp^`{?;TAF>iP#R(7^sz6(^o^=D50PtdP~%Y?|If7q9a?b-m*dNwi>749*NZEzW9Oqkbik$mljf*Q8Q3(O}vcge}iF+Xk#z=;t8*7!vGQK8)ViH^1uQiyapWC afcF}3K4Kx<2Im2#kN5!yJqv(R!~0* int: + config = ConfigFile("config.toml") + + time_override = config.get("time_override", -1) + + if time_override is not None and time_override != -1: + print(f"TIME OVERRIDEED TO {time_override}") + return int(time_override) + + return int(time.time() // (24 * 3600)) diff --git a/config.toml b/config.toml index 4062be5..538c6d0 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,8 @@ -# 将更改保存到文件 +# [调试] 将更改保存到文件 save = 1 +# [调试] 覆写时间 +time_override = 10 # 对于每个项目的新记忆核子数量 -tasked_number = 8 \ No newline at end of file +tasked_number = 12 +# 竖屏适配 +mobile_mode = 1 \ No newline at end of file diff --git a/main.py b/main.py index f4904a7..5a832e1 100644 --- a/main.py +++ b/main.py @@ -2,17 +2,19 @@ from textual.app import App, ComposeResult from textual.widgets import Header, Footer, ListView, ListItem, Label, Static, Button from textual.containers import Container, Horizontal from textual.screen import Screen -import particles as pt -from reactor import Reactor import pathlib import threading import edge_tts as tts from playsound import playsound from textual.logging import TextualHandler -ver = '0.2.1' +import particles as pt +from reactor import Reactor +import auxiliary as aux -debug = TextualHandler(stderr=True) +ver = '0.2.4' + +config = aux.ConfigFile("config.toml") class MemScreen(Screen): BINDINGS = [ @@ -37,7 +39,7 @@ class MemScreen(Screen): self, nucleon_file: pt.AtomicFile, electron_file: pt.AtomicFile, - tasked_num: int + tasked_num ): super().__init__(name=None, id=None, classes=None) self.reactor = Reactor(nucleon_file, electron_file, tasked_num) @@ -104,13 +106,16 @@ class MemScreen(Screen): ret = self.reactor.forward(1) if ret == -1: if self.reactor.round_set == 0: - if self.stage == 3: + if self.stage == 4: # NOTE # - #self.reactor.save() + if config.get("save"): + self.reactor.save() self._show_finished_screen("今日目标已完成") else: - self.stage += 1 self.reactor.set_round_templated(self.stage) + self.reactor.forward(1) + self._update_ui() + self.stage += 1 return #feedback_label.update("") # 清除反馈消息 self._update_ui() @@ -168,7 +173,7 @@ class PreparationScreen(Screen): pass if event.button.id == "start_memorizing_button": #init_file(Path(self.atom_file).name) - newscr = MemScreen(self.nucleon_file, self.electron_file, 8) + newscr = MemScreen(self.nucleon_file, self.electron_file, config.get("tasked_number", 8)) self.app.push_screen( newscr ) @@ -236,6 +241,5 @@ class AppLauncher(App): self.push_screen("file_selection_screen") if __name__ == "__main__": - css_path = pathlib.Path("styles_dashboard.tcss") app = AppLauncher() app.run() diff --git a/particles.py b/particles.py index 6b74aae..d54e2d4 100644 --- a/particles.py +++ b/particles.py @@ -36,6 +36,17 @@ class Electron(): setattr(self, var, value) self.last_modify = time.time() + def export_data(self): + return { + 'efactor': self.efactor, + 'real_rept': self.real_rept, + 'rept': self.rept, + 'interval': self.interval, + 'last_date': self.last_date, + 'next_date': self.next_date, + 'is_activated': self.is_activated + } + def revisor(self, quality): """SM-2 算法迭代决策机制实现 根据 quality(0 ~ 5) 进行参数迭代最佳间隔 @@ -66,7 +77,7 @@ class Electron(): self.interval = round(self.interval * self.efactor) self.last_date = aux.get_daystamp() - self.next_date = self.last_date + self.interval + self.next_date = aux.get_daystamp() + self.interval def __str__(self): return (f"记忆单元预览 \n" @@ -98,9 +109,9 @@ class Electron(): lst.append(Electron(i, all[i])) return (name, lst) @staticmethod - def save_to_file(electron_list, path: pathlib.Path): + def save_to_file(electron_dictized, path: pathlib.Path): with open(path, 'w') as f: - toml.dump(electron_list, f) + toml.dump(electron_dictized, f) class Nucleon(): """核子: 材料元数据""" @@ -119,9 +130,9 @@ class Nucleon(): return (name, lst) @staticmethod - def save_to_file(nucleon_list, path: pathlib.Path): + def save_to_file(nucleon_dictized, path: pathlib.Path): with open(path, 'w') as f: - toml.dump(nucleon_list, f) + toml.dump(nucleon_dictized, f) @staticmethod def placeholder(): @@ -136,10 +147,12 @@ class AtomicFile(): if type_ == "electron": self.name, self.datalist = Electron.import_from_file(pathlib.Path(path)) def save(self): + dictobj = {i.content: i.export_data() for i in self.datalist} + print(dictobj) if self.type_ == "nucleon": - Nucleon.save_to_file(self.datalist, self.path) + Nucleon.save_to_file(dictobj, self.path) if self.type_ == "electron": - Electron.save_to_file(self.datalist, self.path) + Electron.save_to_file(dictobj, self.path) def get_full_content(self): if self.type_ == "nucleon": text = "" diff --git a/generate_audio_cache.py b/precaching.py similarity index 100% rename from generate_audio_cache.py rename to precaching.py diff --git a/reactor.py b/reactor.py index 59db57c..038045a 100644 --- a/reactor.py +++ b/reactor.py @@ -3,10 +3,10 @@ import particles as pt import pathlib import auxiliary as aux class Parser(): - """轻量级版本文件解析器, 用于解析记忆状态""" + """轻量级版本文件解析器, 用于文件管理器的记忆状态解析""" class Reactor(): - """反应堆对象, 用于处理 & 分配一次文件记忆流程的资源/策略""" + """反应堆对象, 用于全面解析文件, 并处理和分配一次文件记忆流程的资源与策略""" def __init__(self, nucleon_file: pt.AtomicFile, electron_file: pt.AtomicFile, tasked_num): # 导入原子对象 self.reported = set() @@ -15,14 +15,28 @@ class Reactor(): self.tasked_num = tasked_num self.atoms_new = list() self.atoms_review = list() + counter = self.tasked_num - electron_dict = {elect.content: elect for elect in electron_file.datalist} + self.electron_dict = {elect.content: elect for elect in electron_file.datalist} + + def electron_dict_get_fallback(key) -> pt.Electron: + value = self.electron_dict.get(key) + + # 如果值不存在,则设置默认值 + if value is None: + value = pt.Electron(key, {}) # 获取默认值 + self.electron_dict[key] = value # 将默认值存入字典 + value = self.electron_dict[key] + + return value # 返回获取的值(可能是默认值) for nucleon in nucleon_file.datalist: - atom = (electron_dict.get(nucleon_file, pt.Electron.placeholder()), nucleon) + atom = (electron_dict_get_fallback(nucleon.content), nucleon) if atom[0].is_activated == 0: - atom[0].is_activated = 1 - self.atoms_new.append(atom) + if counter > 0: + atom[0].is_activated = 1 + self.atoms_new.append(atom) + counter -= 1 else: if atom[0].next_date <= aux.get_daystamp(): atom[0].last_date = aux.get_daystamp() @@ -81,7 +95,11 @@ class Reactor(): def save(self): print("Progress saved") - self.nucleon_file.save() + # self.nucleon_file.save() + temp = list() + for i in self.electron_dict.keys(): + temp.append(self.electron_dict[i]) + self.electron_file.datalist = temp self.electron_file.save() def report(self, atom, quality):