feat(interface): 改进界面
This commit is contained in:
@@ -1,15 +1,21 @@
|
|||||||
from time import sleep
|
from time import sleep, perf_counter
|
||||||
print("欢迎使用基本用户界面!")
|
print("欢迎使用基本用户界面!")
|
||||||
print("加载配置... ", end="", flush=True)
|
print("加载配置与上下文... ", end="", flush=True)
|
||||||
|
_start1 = perf_counter()
|
||||||
|
_start = perf_counter()
|
||||||
from heurams.context import *
|
from heurams.context import *
|
||||||
print("已完成!")
|
_end = perf_counter()
|
||||||
|
print(f"已完成! (耗时: {round(1000 * (_end - _start))}ms)")
|
||||||
|
|
||||||
print("加载用户界面框架... ", end="", flush=True)
|
print("加载用户界面框架... ", end="", flush=True)
|
||||||
|
_start = perf_counter()
|
||||||
from textual.app import App
|
from textual.app import App
|
||||||
from textual.widgets import Button
|
from textual.widgets import Button
|
||||||
print("已完成!")
|
_end = perf_counter()
|
||||||
|
print(f"已完成! (耗时: {round(1000 * (_end - _start))}ms)")
|
||||||
|
|
||||||
print("加载用户界面布局... ", end="", flush=True)
|
print("加载用户界面布局... ", end="", flush=True)
|
||||||
|
_start = perf_counter()
|
||||||
from .screens.about import AboutScreen
|
from .screens.about import AboutScreen
|
||||||
from .screens.dashboard import DashboardScreen
|
from .screens.dashboard import DashboardScreen
|
||||||
from .screens.llmchat import LLMChatScreen
|
from .screens.llmchat import LLMChatScreen
|
||||||
@@ -19,9 +25,13 @@ from .screens.radio import RadioScreen
|
|||||||
from .screens.repocreator import RepoCreatorScreen
|
from .screens.repocreator import RepoCreatorScreen
|
||||||
from .screens.repoeditor import RepoEditorScreen
|
from .screens.repoeditor import RepoEditorScreen
|
||||||
from .screens.synctool import SyncScreen
|
from .screens.synctool import SyncScreen
|
||||||
print("已完成!")
|
_end = perf_counter()
|
||||||
|
print(f"已完成! (耗时: {round(1000 * (_end - _start))}ms)")
|
||||||
|
|
||||||
print(f"组件目录: {rootdir}")
|
print(f"组件目录: {rootdir}")
|
||||||
print(f"工作目录: {workdir}")
|
print(f"工作目录: {workdir}")
|
||||||
|
_end1 = perf_counter()
|
||||||
|
print(f"前置工作共计耗时: {round(1000 * (_end1 - _start1))}ms")
|
||||||
class HeurAMSApp(App):
|
class HeurAMSApp(App):
|
||||||
TITLE = "潜进"
|
TITLE = "潜进"
|
||||||
CSS_PATH = "css/main.tcss"
|
CSS_PATH = "css/main.tcss"
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ NavigatorScreen {
|
|||||||
align: center middle;
|
align: center middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.infview {
|
||||||
|
width: 5fr
|
||||||
|
}
|
||||||
|
.dataview {
|
||||||
|
width: 3fr
|
||||||
|
}
|
||||||
|
|
||||||
.repo_listitem {
|
.repo_listitem {
|
||||||
layout: grid;
|
layout: grid;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
import pathlib
|
import pathlib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
|
||||||
from textual.app import ComposeResult
|
from textual.app import ComposeResult
|
||||||
from textual.containers import ScrollableContainer, Container, Horizontal, Vertical
|
from textual.containers import ScrollableContainer, Container, Horizontal, Vertical
|
||||||
@@ -53,26 +54,26 @@ class DashboardScreen(Screen):
|
|||||||
with ScrollableContainer():
|
with ScrollableContainer():
|
||||||
yield Horizontal(
|
yield Horizontal(
|
||||||
Vertical(
|
Vertical(
|
||||||
Label('欢迎使用 "潜进" 启发式辅助记忆调度器'),
|
Label(f'欢迎使用 "潜进" 版本 {version.ver}'),
|
||||||
Label(
|
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(f"全局算法设置: {config_var.get()['algorithm']['default']}"),
|
||||||
Label("选择待学习或待修改的项目:"),
|
classes="column infview",
|
||||||
classes="column",
|
|
||||||
),
|
),
|
||||||
Vertical(
|
Vertical(
|
||||||
Label(f"已加载 {len(self.repostat)} 个单元集", classes='dataview'),
|
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('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"已激活 {reduce(lambda x, y: x + y, map(lambda x: x.get('activated_sum'), self.repostat.values()))} 个单元", classes='dataview'),
|
||||||
Label(""),
|
Label(f"终端尺寸: {os.get_terminal_size()[0]}x{os.get_terminal_size()[1]}"),
|
||||||
classes="column",
|
classes="column dataview",
|
||||||
),
|
),
|
||||||
id="dashboardtop"
|
id="dashboardtop"
|
||||||
)
|
)
|
||||||
|
|
||||||
yield ListView(id="repo-list", classes="repo-list-view")
|
yield ListView(id="repo-list", classes="repo-list-view")
|
||||||
yield Label(f'"潜进" 启发式辅助记忆调度器 版本 {version.ver} ')
|
yield Label(f'"潜进" 启发式辅助记忆调度器 版本 {version.ver} {version.stage.capitalize()}')
|
||||||
yield Footer()
|
yield Footer()
|
||||||
|
|
||||||
def _load_data(self):
|
def _load_data(self):
|
||||||
|
|||||||
@@ -98,11 +98,6 @@ class PrecachingScreen(Screen):
|
|||||||
yield Header(show_clock=True)
|
yield Header(show_clock=True)
|
||||||
with ScrollableContainer(id="precache_container"):
|
with ScrollableContainer(id="precache_container"):
|
||||||
yield Label("[b]音频预缓存[/b]", classes="title-label")
|
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():
|
with Container():
|
||||||
yield Static(
|
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)} 个单元)",
|
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="status", classes="status-info")
|
||||||
yield Static(id="current_item", classes="current-item")
|
yield Static(id="current_item", classes="current-item")
|
||||||
yield ProgressBar(total=100, show_eta=False, id="progress_bar")
|
yield ProgressBar(total=100, show_eta=False, id="progress_bar")
|
||||||
|
with Horizontal(classes="button-group"):
|
||||||
with Horizontal(classes="button-group"):
|
if not self.is_precaching:
|
||||||
if not self.is_precaching:
|
yield Button("开始预缓存", id="start_precache", variant="primary")
|
||||||
yield Button("开始预缓存", id="start_precache", variant="primary")
|
else:
|
||||||
else:
|
yield Button("取消预缓存", id="cancel_precache", variant="error")
|
||||||
yield Button("取消预缓存", id="cancel_precache", variant="error")
|
yield Button("清空缓存", id="clear_cache", variant="warning")
|
||||||
yield Button("清空缓存", id="clear_cache", variant="warning")
|
yield Button("返回", id="go_back", variant="default")
|
||||||
yield Button("返回", id="go_back", variant="default")
|
with Container(classes="cache-info"):
|
||||||
|
yield Static(f"缓存路径: {cache_dir}", classes="cache-path")
|
||||||
yield Static("若您离开此界面, 未完成的缓存进程会自动停止.")
|
yield Static(f"文件数: {self.cache_stats['file_count']}", classes="cache-count")
|
||||||
yield Static('缓存程序支持 "断点续传".')
|
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()
|
yield Footer()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user