diff --git a/src/heurams/interface/__init__.py b/src/heurams/interface/__init__.py index cf37948..2bb3171 100644 --- a/src/heurams/interface/__init__.py +++ b/src/heurams/interface/__init__.py @@ -1,15 +1,21 @@ -from time import sleep +from time import sleep, perf_counter print("欢迎使用基本用户界面!") -print("加载配置... ", end="", flush=True) +print("加载配置与上下文... ", end="", flush=True) +_start1 = perf_counter() +_start = perf_counter() from heurams.context import * -print("已完成!") +_end = perf_counter() +print(f"已完成! (耗时: {round(1000 * (_end - _start))}ms)") print("加载用户界面框架... ", end="", flush=True) +_start = perf_counter() from textual.app import App from textual.widgets import Button -print("已完成!") +_end = perf_counter() +print(f"已完成! (耗时: {round(1000 * (_end - _start))}ms)") print("加载用户界面布局... ", end="", flush=True) +_start = perf_counter() from .screens.about import AboutScreen from .screens.dashboard import DashboardScreen from .screens.llmchat import LLMChatScreen @@ -19,9 +25,13 @@ from .screens.radio import RadioScreen from .screens.repocreator import RepoCreatorScreen from .screens.repoeditor import RepoEditorScreen from .screens.synctool import SyncScreen -print("已完成!") +_end = perf_counter() +print(f"已完成! (耗时: {round(1000 * (_end - _start))}ms)") + print(f"组件目录: {rootdir}") print(f"工作目录: {workdir}") +_end1 = perf_counter() +print(f"前置工作共计耗时: {round(1000 * (_end1 - _start1))}ms") class HeurAMSApp(App): TITLE = "潜进" CSS_PATH = "css/main.tcss" diff --git a/src/heurams/interface/css/main.tcss b/src/heurams/interface/css/main.tcss index 8314c2d..347966d 100644 --- a/src/heurams/interface/css/main.tcss +++ b/src/heurams/interface/css/main.tcss @@ -4,6 +4,12 @@ NavigatorScreen { align: center middle; } +.infview { + width: 5fr +} +.dataview { + width: 3fr +} .repo_listitem { layout: grid; diff --git a/src/heurams/interface/screens/dashboard.py b/src/heurams/interface/screens/dashboard.py index 9964a26..cf8b9ce 100644 --- a/src/heurams/interface/screens/dashboard.py +++ b/src/heurams/interface/screens/dashboard.py @@ -3,6 +3,7 @@ from functools import reduce import pathlib from pathlib import Path +import os from textual.app import ComposeResult from textual.containers import ScrollableContainer, Container, Horizontal, Vertical @@ -53,26 +54,26 @@ class DashboardScreen(Screen): with ScrollableContainer(): yield Horizontal( Vertical( - Label('欢迎使用 "潜进" 启发式辅助记忆调度器'), + Label(f'欢迎使用 "潜进" 版本 {version.ver}'), Label( - f"当前 UNIX 日时间戳: {timer.get_daystamp()} (UTC+{config_var.get()['timezone_offset'] / 3600})" + f"当前 UNIX 日时间戳: {timer.get_daystamp()}" ), + Label(f"应用时区修正: UTC+{config_var.get()['timezone_offset'] / 3600}"), Label(f"全局算法设置: {config_var.get()['algorithm']['default']}"), - Label("选择待学习或待修改的项目:"), - classes="column", + 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(""), - classes="column", + Label(f"终端尺寸: {os.get_terminal_size()[0]}x{os.get_terminal_size()[1]}"), + classes="column dataview", ), id="dashboardtop" ) yield ListView(id="repo-list", classes="repo-list-view") - yield Label(f'"潜进" 启发式辅助记忆调度器 版本 {version.ver} ') + yield Label(f'"潜进" 启发式辅助记忆调度器 版本 {version.ver} {version.stage.capitalize()}') yield Footer() def _load_data(self): diff --git a/src/heurams/interface/screens/precache.py b/src/heurams/interface/screens/precache.py index 300690b..422f738 100644 --- a/src/heurams/interface/screens/precache.py +++ b/src/heurams/interface/screens/precache.py @@ -98,11 +98,6 @@ class PrecachingScreen(Screen): yield Header(show_clock=True) with ScrollableContainer(id="precache_container"): yield Label("[b]音频预缓存[/b]", classes="title-label") - with Container(classes="cache-info"): - yield Static(f"缓存路径: {cache_dir}", classes="cache-path") - yield Static(f"文件数: {self.cache_stats['file_count']}", classes="cache-count") - yield Static(f"总大小: {self.cache_stats['human_size']}", classes="cache-size") - yield Button("刷新", id="refresh_cache_stats", variant="default") with Container(): yield Static( f"缓存率: {self.cache_stats.get('cache_rate', 0):.1f}% (已缓存 {self.cache_stats.get('cached_units', 0)} / {self.cache_stats.get('total_units', 0)} 个单元)", @@ -117,17 +112,20 @@ class PrecachingScreen(Screen): yield Static(id="status", classes="status-info") yield Static(id="current_item", classes="current-item") yield ProgressBar(total=100, show_eta=False, id="progress_bar") - - with Horizontal(classes="button-group"): - if not self.is_precaching: - yield Button("开始预缓存", id="start_precache", variant="primary") - else: - yield Button("取消预缓存", id="cancel_precache", variant="error") - yield Button("清空缓存", id="clear_cache", variant="warning") - yield Button("返回", id="go_back", variant="default") - - yield Static("若您离开此界面, 未完成的缓存进程会自动停止.") - yield Static('缓存程序支持 "断点续传".') + with Horizontal(classes="button-group"): + if not self.is_precaching: + yield Button("开始预缓存", id="start_precache", variant="primary") + else: + yield Button("取消预缓存", id="cancel_precache", variant="error") + yield Button("清空缓存", id="clear_cache", variant="warning") + yield Button("返回", id="go_back", variant="default") + with Container(classes="cache-info"): + yield Static(f"缓存路径: {cache_dir}", classes="cache-path") + yield Static(f"文件数: {self.cache_stats['file_count']}", classes="cache-count") + yield Static(f"总大小: {self.cache_stats['human_size']}", classes="cache-size") + yield Button("刷新", id="refresh_cache_stats", variant="default", flat=True) + yield Static("若您离开此界面, 未完成的缓存进程会自动停止.") + yield Static('缓存程序支持 "断点续传".') yield Footer()