docs: 完善README文档与架构图,修复全量注释与日志问题
- README: 补充项目概述、技术栈、架构图(Mermaid)、插件生命周期时序图 - build.py: 补充模块和函数 docstring - core/__init__.py: 修正模块说明(工具箱→插件系统) - log.py: 修复过时注释,清理死代码,抑制第三方库日志刷屏 - plugin_registry.py: 修正矛盾注释,补充缺失日志,隐藏远程路径 - plugins.py: 修正过时注释,清理死代码和无用导入 - plugins_card.py: 修正错误类名注释,补充全量 docstring - main.py: 修正错误注释,补充启动/退出/插件加载日志
This commit is contained in:
+19
-75
@@ -1,64 +1,47 @@
|
||||
"""
|
||||
工具箱模块
|
||||
插件管理模块
|
||||
|
||||
提供工具箱主窗口,包含各种实用工具的入口。
|
||||
提供插件管理主窗口,包含插件卡片列表和安装/更新/卸载入口。
|
||||
使用 PySide6 构建的窗口框架。
|
||||
|
||||
主要功能:
|
||||
- 工具箱主窗口界面
|
||||
- 窗口居中显示功能
|
||||
- 工具分类和导航
|
||||
- 插件管理窗口界面
|
||||
- 插件卡片列表渲染与状态刷新
|
||||
- 插件事件的转发与处理
|
||||
|
||||
Author: Model Team
|
||||
Version: 0.0.1
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import threading
|
||||
import importlib
|
||||
|
||||
from qt_material import apply_stylesheet
|
||||
|
||||
from pathlib import Path
|
||||
from .plugins_ui import Ui_FormPlugins
|
||||
from PySide6.QtGui import QIcon
|
||||
|
||||
from PySide6.QtWidgets import QWidget, QListWidgetItem
|
||||
from PySide6.QtCore import QSize, Signal
|
||||
from PySide6.QtCore import QSize
|
||||
|
||||
from .plugins_card import PluginsCard
|
||||
from .plugin_registry import PluginRegistry
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LOCAL_PLUGINS_PATH = Path("./plugins")
|
||||
REMOTE_PLUGINS_PATH = Path('Y:/SE/xufeifei/plugins')
|
||||
|
||||
class Plugins(QWidget, Ui_FormPlugins):
|
||||
"""工具箱主窗口类
|
||||
|
||||
继承自 QWidget(Qt 窗口基类)和 Ui_FormTools(Qt Designer 生成的 UI 界面)
|
||||
负责显示工具箱的主界面,提供工具的分类和导航功能。
|
||||
|
||||
窗口特性:
|
||||
- 默认尺寸: 400x293 像素
|
||||
- 支持窗口居中显示
|
||||
- 可作为独立窗口或嵌入其他窗口使用
|
||||
|
||||
Attributes:
|
||||
parent: 父窗口对象,默认为 None(顶级窗口)
|
||||
"""插件管理窗口。
|
||||
|
||||
继承自 QWidget 和 Ui_FormPlugins(Qt Designer 生成的 UI 界面),
|
||||
负责展示插件卡片列表,处理插件安装/更新/卸载事件的转发。
|
||||
|
||||
可作为独立窗口或嵌入其他窗口使用。
|
||||
"""
|
||||
update_tool_card = Signal(dict)
|
||||
|
||||
def __init__(self, plugin_registry: PluginRegistry, parent: QWidget = None) -> None:
|
||||
"""初始化插件管理窗口。
|
||||
|
||||
def __init__(self, plugin_registry:PluginRegistry, parent: QWidget = None) -> None:
|
||||
"""初始化工具箱窗口
|
||||
|
||||
创建工具箱窗口实例,初始化 UI 界面。
|
||||
|
||||
Args:
|
||||
parent: 父窗口对象,用于建立父子关系。
|
||||
默认为 None,表示这是顶级窗口。
|
||||
plugin_registry: 插件注册中心实例,用于事件转发
|
||||
parent: 父窗口对象,默认为 None(顶级窗口)
|
||||
"""
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
@@ -72,16 +55,10 @@ class Plugins(QWidget, Ui_FormPlugins):
|
||||
self.plugin_registry.uninstall_completed_signal.connect(self.on_plugin_uninstalled)
|
||||
|
||||
def initUI(self) -> None:
|
||||
"""
|
||||
初始化用户界面
|
||||
|
||||
配置窗口标题、图标、大小和居中显示。
|
||||
"""
|
||||
"""初始化窗口标题和图标。"""
|
||||
self.setWindowTitle("工具箱")
|
||||
self.setWindowIcon(QIcon('resources/tools.ico'))
|
||||
|
||||
# self.update_tool_card.connect(self.on_update_tool_card)
|
||||
|
||||
def load_stylesheet(self) -> None:
|
||||
"""
|
||||
加载 Qt 样式表和自定义样式文件
|
||||
@@ -103,40 +80,7 @@ class Plugins(QWidget, Ui_FormPlugins):
|
||||
except Exception as e:
|
||||
logger.warning(f"样式加载失败,使用默认主题: {e}")
|
||||
|
||||
# def start_load_tools(self):
|
||||
# self.sub_thread = threading.Thread(target= self.load_tool_list,args=(self.tools,))
|
||||
# self.sub_thread.start()
|
||||
|
||||
# def load_tool_list(self, tools:dict):
|
||||
# if not os.path.exists(REMOTE_PLUGINS_PATH):
|
||||
# logger.error("服务器链接错误!")
|
||||
# return
|
||||
# #读取服务器工具信息
|
||||
# sys.path.append(str(REMOTE_PLUGINS_PATH))
|
||||
# for tool in Path(REMOTE_PLUGINS_PATH).glob("*.pyd"):
|
||||
# tool_name = tool.stem
|
||||
# try:
|
||||
# module = importlib.import_module(tool_name)
|
||||
|
||||
# name = module.read_tool_name()
|
||||
# version = module.read_tool_version()
|
||||
# description = module.read_tool_description()
|
||||
# if name in tools.keys():
|
||||
# pass
|
||||
# else:
|
||||
# tools[name] = {}
|
||||
# tools[name]["name"] = tool_name
|
||||
# tools[name]["local version"] = None
|
||||
# tools[name]["local description"] = None
|
||||
# tools[name]["remote version"] = version
|
||||
# tools[name]["remote description"] = description
|
||||
# tools[name]['remote path'] = REMOTE_PLUGINS_PATH
|
||||
# except Exception as e:
|
||||
# logger.error(f"服务器{tool_name}无法加载:{str(e)}")
|
||||
# sys.path.remove(str(REMOTE_PLUGINS_PATH))
|
||||
# self.update_tool_card.emit(tools)
|
||||
|
||||
def on_update_plugins_card(self, plugins:dict):
|
||||
def on_update_plugins_card(self, plugins: dict) -> None:
|
||||
for name in plugins.keys():
|
||||
if name in self.cards:
|
||||
# 卡片已存在,只刷新状态(避免重复创建叠加)
|
||||
|
||||
Reference in New Issue
Block a user