Skip to content

Change To RinUI#106

Merged
Detritalw merged 60 commits intoWindowsfrom
RinUI
Apr 6, 2026
Merged

Change To RinUI#106
Detritalw merged 60 commits intoWindowsfrom
RinUI

Conversation

@Detritalw
Copy link
Copy Markdown
Member

@Detritalw Detritalw commented Mar 2, 2026

close #105


To make Bloret Launcher more beautiful and easier to use, replace PyQt-Fluent-Widgets with RinUI.


To get more information, please view ui.rinlit.cn.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求进行了一次大规模的UI现代化和技术栈升级。通过将UI框架从PyQt-Fluent-Widgets迁移到RinUI,并全面转向PySide6,启动器获得了更美观、更易用且响应更快的界面。此次更新不仅解决了现有UI中的多个痛点,还为未来的功能扩展和用户体验提升奠定了坚实的基础。

Highlights

  • UI框架迁移: 将UI框架从PyQt-Fluent-Widgets全面迁移至RinUI,旨在提供更现代化和流畅的用户体验。
  • PySide6兼容性更新: 所有Python后端代码已从PyQt5更新为PySide6,以适应新的UI框架并提升性能。
  • QML组件重构: 引入了大量新的QML组件,用于构建主页、下载、模组、联机、通行证和设置等核心页面,实现了更灵活和可定制的UI布局。
  • 下载与核心管理优化: 重构了下载逻辑,通过QML信号实现下载进度和对话框的实时更新。新增了核心管理对话框,允许用户更精细地管理Minecraft版本、服务器、模组和资源包。
  • UI/UX问题修复: 解决了QML翻译不生效、QUiLoader兼容性、对话框垃圾回收、UI线程安全、主页布局、上下文菜单显示以及语言列表显示等多个UI/UX问题。
  • 构建与依赖更新: 更新了.gitignore.vscode/launch.jsonBloret-Launcher.spec等构建相关文件,以反映新的依赖和项目结构。
Changelog
  • .gitignore
    • 添加了/temp目录到忽略列表,以避免临时文件被版本控制。
  • .trae/documents/plan_20260226_112133.md
    • 添加了通过在Backend类中添加tr()方法和languageChanged信号来修复QML翻译问题的计划。
  • .trae/documents/plan_20260226_113224.md
    • 添加了通过直接传递文件路径而不是TextIOWrapper来修复QUiLoader.load()兼容性问题的计划。
  • .trae/documents/plan_20260226_113645.md
    • 添加了通过在Backend类中维护对话框引用来解决对话框垃圾回收问题的计划。
  • .trae/documents/plan_20260226_115303.md
    • 添加了通过删除在子线程中创建对话框的重复downloadVanilladownloadFabric方法来解决UI线程问题的计划。
  • .trae/documents/plan_20260226_115648.md
    • 添加了使用RinUI Dialog创建下载对话框的计划,包括新的QML组件和基于信号的进度更新。
  • .trae/documents/plan_20260226_120803.md
    • 添加了在main.qml中导入components目录以解决DownloadDialog找不到问题的计划。
  • .trae/documents/plan_20260226_121111.md
    • 添加了在_install_minecraft_version_threaded中移除旧的download_dialog相关UI更新代码并使用update_progress_ui()的计划。
  • .trae/documents/plan_20260226_122143.md
    • 添加了移除导致缩进错误的残留旧代码的计划。
  • .trae/documents/plan_20260226_123550.md
    • 添加了修复Home.qml布局问题(如启动栏未固定在底部和内容差异)的计划。
  • .trae/documents/plan_20260226_130432.md
    • 添加了修复UI布局问题和实现核心管理功能的计划,提出了Python端对话框或简化的QML组件方案。
  • .trae/documents/修复 ContextMenu 对数组模型的处理.md
    • 添加了通过优先使用modelData进行文本绑定来修复ContextMenu.qml处理数组模型问题的计划。
  • .trae/documents/修复主页布局并实现切换核心对话框.md
    • 添加了修复Home.qml布局、创建LaunchSelectorDialog.qml以及添加后端方法以管理启动项的计划。
  • .trae/documents/修复语言列表显示问题.md
    • 添加了通过将textRole传递给ContextMenu来修复ComboBox.qml中语言列表显示问题的计划。
  • .trae/specs/fix-home-core-manager/checklist.md
    • 添加了修复主页布局和核心管理功能的检查清单。
  • .trae/specs/fix-home-core-manager/spec.md
    • 添加了修复主页布局和核心管理功能的规范文档。
  • .trae/specs/fix-home-core-manager/tasks.md
    • 添加了修复主页布局和核心管理功能的任务列表。
  • .trae/specs/fix-ui-issues/checklist.md
    • 添加了修复各种UI布局和功能问题的检查清单。
  • .trae/specs/fix-ui-issues/spec.md
    • 添加了修复各种UI布局和功能问题的规范文档。
  • .trae/specs/fix-ui-issues/tasks.md
    • 添加了修复各种UI布局和功能问题的任务列表。
  • .vscode/launch.json
    • 更新了Python调试配置,为Bloret-Launcher-v2.py添加了新条目。
  • Bloret-Launcher.spec
    • hiddenimports中移除了sip,因为它不再是PySide6的必需依赖。
  • RinUI/init.py
    • 添加了__version____author__属性,用于RinUI模块的元数据。
  • RinUI/components/Base.qml
    • 添加了基础QML组件,用于定义通用属性和行为。
  • RinUI/components/BasicInput/Button.qml
    • 添加了QML按钮组件。
  • RinUI/components/BasicInput/CheckBox.qml
    • 添加了QML复选框组件。
  • RinUI/components/BasicInput/ColorPicker.qml
    • 添加了QML颜色选择器组件。
  • RinUI/components/BasicInput/ComboBox.qml
    • 添加了QML组合框组件。
  • RinUI/components/BasicInput/DropDownButton.qml
    • 添加了QML下拉按钮组件。
  • RinUI/components/BasicInput/DropDownColorPicker.qml
    • 添加了QML下拉颜色选择器组件。
  • RinUI/components/BasicInput/Hyperlink.qml
    • 添加了QML超链接组件。
  • RinUI/components/BasicInput/PillButton.qml
    • 添加了QML药丸按钮组件。
  • RinUI/components/BasicInput/RadioButton.qml
    • 添加了QML单选按钮组件。
  • RinUI/components/BasicInput/RoundButton.qml
    • 添加了QML圆形按钮组件。
  • RinUI/components/BasicInput/Slider.qml
    • 添加了QML滑块组件。
  • RinUI/components/BasicInput/Switch.qml
    • 添加了QML开关组件。
  • RinUI/components/BasicInput/ToggleButton.qml
    • 添加了QML切换按钮组件。
  • RinUI/components/BasicInput/ToolButton.qml
    • 添加了QML工具按钮组件。
  • RinUI/components/ContextMenu.qml
    • 添加了QML上下文菜单组件。
  • RinUI/components/DateAndTime/Calendar.qml
    • 添加了QML日历组件。
  • RinUI/components/DateAndTime/CalendarDatePicker.qml
    • 添加了QML日历日期选择器组件。
  • RinUI/components/DateAndTime/DatePicker.qml
    • 添加了QML日期选择器组件。
  • RinUI/components/DateAndTime/PickerView.qml
    • 添加了QML选择器视图组件。
  • RinUI/components/DateAndTime/TimePicker.qml
    • 添加了QML时间选择器组件。
  • RinUI/components/DialogsAndFlyouts/Dialog.qml
    • 添加了QML对话框组件。
  • RinUI/components/DialogsAndFlyouts/DialogButtonBox.qml
    • 添加了QML对话框按钮盒组件。
  • RinUI/components/DialogsAndFlyouts/Flyout.qml
    • 添加了QML浮出控件组件。
  • RinUI/components/DialogsAndFlyouts/Popup.qml
    • 添加了QML弹出窗口组件。
  • RinUI/components/FocusIndicator.qml
    • 添加了QML焦点指示器组件。
  • RinUI/components/Icon.qml
    • 添加了QML图标组件。
  • RinUI/components/Indicator.qml
    • 添加了QML指示器组件。
  • RinUI/components/Layout/Expander.qml
    • 添加了QML扩展器组件。
  • RinUI/components/Layout/SettingExpander.qml
    • 添加了QML设置扩展器组件。
  • RinUI/components/Layout/SettingItem.qml
    • 添加了QML设置项组件。
  • RinUI/components/ListAndCollections/Clip.qml
    • 添加了QML剪辑组件。
  • RinUI/components/ListAndCollections/Frame.qml
    • 添加了QML框架组件。
  • RinUI/components/ListAndCollections/ListView.qml
    • 添加了QML列表视图组件。
  • RinUI/components/ListAndCollections/ListViewDelegate.qml
    • 添加了QML列表视图委托组件。
  • RinUI/components/ListAndCollections/SettingCard.qml
    • 添加了QML设置卡片组件。
  • RinUI/components/ListAndCollections/TableView.qml
    • 添加了QML表格视图组件。
  • RinUI/components/ListAndCollections/TableViewDelegate.qml
    • 添加了QML表格视图委托组件。
  • RinUI/components/Media/Avatar.qml
    • 添加了QML头像组件。
  • RinUI/components/MenusAndToolbars/Menu.qml
    • 添加了QML菜单组件。
  • RinUI/components/MenusAndToolbars/MenuBar.qml
    • 添加了QML菜单栏组件。
  • RinUI/components/MenusAndToolbars/MenuItem.qml
    • 添加了QML菜单项组件。
  • RinUI/components/MenusAndToolbars/MenuItemGroup.qml
    • 添加了QML菜单项组组件。
  • RinUI/components/MenusAndToolbars/MenuSeparator.qml
    • 添加了QML菜单分隔符组件。
  • RinUI/components/MenusAndToolbars/TextInputMenu.qml
    • 添加了QML文本输入菜单组件。
  • RinUI/components/MenusAndToolbars/ToolSeparator.qml
    • 添加了QML工具分隔符组件。
  • RinUI/components/Navigation/ErrorPage.qml
    • 添加了QML错误页面组件。
  • RinUI/components/Navigation/NavigationBar.qml
    • 添加了QML导航栏组件。
  • RinUI/components/Navigation/NavigationItem.qml
    • 添加了QML导航项组件。
  • RinUI/components/Navigation/NavigationSubItem.qml
    • 添加了QML导航子项组件。
  • RinUI/components/Navigation/NavigationView.qml
    • 添加了QML导航视图组件。
  • RinUI/components/Navigation/Segmented.qml
    • 添加了QML分段控件组件。
  • RinUI/components/Navigation/SegmentedItem.qml
    • 添加了QML分段项组件。
  • RinUI/components/Navigation/SelectorBar.qml
    • 添加了QML选择器栏组件。
  • RinUI/components/Navigation/SelectorBarItem.qml
    • 添加了QML选择器栏项组件。
  • RinUI/components/ScrollBar.qml
    • 添加了QML滚动条组件。
  • RinUI/components/ScrollView.qml
    • 添加了QML滚动视图组件。
  • RinUI/components/Shadow.qml
    • 添加了QML阴影组件。
  • RinUI/components/StatusAndInfo/BusyIndicator.qml
    • 添加了QML忙碌指示器组件。
  • RinUI/components/StatusAndInfo/InfoBadge.qml
    • 添加了QML信息徽章组件。
  • RinUI/components/StatusAndInfo/InfoBar.qml
    • 添加了QML信息栏组件。
  • RinUI/components/StatusAndInfo/ProgressBar.qml
    • 添加了QML进度条组件。
  • RinUI/components/StatusAndInfo/ProgressRing.qml
    • 添加了QML进度环组件。
  • RinUI/components/StatusAndInfo/Toast.qml
    • 添加了QML吐司通知组件。
  • RinUI/components/StatusAndInfo/ToolTip.qml
    • 添加了QML工具提示组件。
  • RinUI/components/Text/AutoSuggestBox.qml
    • 添加了QML自动建议框组件。
  • RinUI/components/Text/ScrollableTextArea.qml
    • 添加了QML可滚动文本区域组件。
  • RinUI/components/Text/SpinBox.qml
    • 添加了QML微调框组件。
  • RinUI/components/Text/Text.qml
    • 添加了QML文本组件。
  • RinUI/components/Text/TextArea.qml
    • 添加了QML文本区域组件。
  • RinUI/components/Text/TextField.qml
    • 添加了QML文本字段组件。
  • RinUI/components/Text/TextInput.qml
    • 添加了QML文本输入组件。
  • RinUI/components/qmldir
    • 添加了RinUI组件的QML模块定义。
  • RinUI/config/rin_ui.json
    • 添加了RinUI的默认配置,包括主题和背景效果设置。
  • RinUI/core/init.py
    • 添加了RinUI核心模块的__init__.py文件。
  • RinUI/core/config.py
    • 添加了RinUI的配置管理逻辑,包括主题和背景效果的枚举和管理。
  • RinUI/core/launcher.py
    • 添加了RinUIWindow类,用于启动和管理基于RinUI的QML应用程序。
  • RinUI/core/theme.py
    • 添加了RinUI的主题管理逻辑,包括系统主题检测和Windows特定效果的应用。
  • RinUI/core/translator.py
    • 添加了RinUI的翻译器,用于加载多语言文件。
  • RinUI/core/window.py
    • 添加了Windows平台特定的事件过滤和无边框窗口管理逻辑。
  • RinUI/hooks/init.py
    • 添加了PyInstaller钩子的__init__.py文件。
  • RinUI/hooks/hook-RinUI.py
    • 添加了RinUI的PyInstaller钩子,用于收集数据文件。
  • RinUI/languages/en_US.qm
    • 添加了RinUI的英文翻译文件。
  • RinUI/languages/en_US.ts
    • 添加了RinUI的英文翻译源文件。
  • RinUI/languages/zh_CN.ts
    • 添加了RinUI的中文翻译源文件。
  • RinUI/qmldir
    • 添加了RinUI的QML模块定义,聚合了所有组件、主题和工具。
  • RinUI/themes/Appearance.qml
    • 添加了QML Appearance单例,用于管理主题相关的视觉属性。
  • RinUI/themes/Colors.qml
    • 添加了QML Colors单例,用于管理主题相关的颜色属性。
  • RinUI/themes/dark.qml
    • 添加了QML暗色主题的定义。
  • RinUI/themes/light.qml
    • 添加了QML亮色主题的定义。
  • RinUI/themes/qmldir
    • 添加了RinUI主题的QML模块定义。
  • RinUI/themes/theme.qml
    • 添加了QML Theme单例,用于管理当前主题的切换和属性访问。
  • RinUI/themes/utils.qml
    • 添加了QML Utils单例,用于提供通用工具属性和函数。
  • RinUI/utils/Animation.qml
    • 添加了QML动画工具类。
  • RinUI/utils/FloatLayer.qml
    • 添加了QML浮动层组件,用于显示浮动UI元素。
  • RinUI/utils/FontIconLoader.qml
    • 添加了QML字体图标加载器组件。
  • RinUI/utils/Position.qml
    • 添加了QML位置枚举,用于UI布局。
  • RinUI/utils/Severity.qml
    • 添加了QML严重性枚举,用于信息提示。
  • RinUI/utils/Typography.qml
    • 添加了QML排版枚举,用于字体样式管理。
  • RinUI/utils/qmldir
    • 添加了RinUI工具类的QML模块定义。
  • RinUI/windows/CtrlBtn.qml
    • 添加了QML窗口控制按钮组件。
  • RinUI/windows/FluentPage.qml
    • 添加了QML FluentPage组件,用于标准页面布局。
  • RinUI/windows/FluentWindow.qml
    • 添加了QML FluentWindow组件,作为主应用程序窗口的基类。
  • RinUI/windows/FluentWindowBase.qml
    • 添加了QML FluentWindowBase组件,作为自定义窗口的基础。
  • RinUI/windows/TitleBar.qml
    • 添加了QML标题栏组件。
  • RinUI/windows/WindowManager.qml
    • 添加了QML WindowManager单例,用于窗口管理功能。
  • RinUI/windows/qmldir
    • 添加了RinUI窗口组件的QML模块定义。
  • RinUI/windows/window/ApplicationWindow.qml
    • 添加了QML ApplicationWindow组件。
  • RinUI/windows/window/Window.qml
    • 添加了QML Window组件。
  • debug_toolbar.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
  • icon/desktop.ini
    • 重命名了ui/icon/desktop.iniicon/desktop.ini
  • lang/en-GB.json
    • 添加了与新UI元素和设置相关的英文翻译字符串。
  • lang/zh-cn.json
    • 添加了与新UI元素和设置相关的中文翻译字符串。
  • modules/BLDownload.py
    • PyQt5qfluentwidgets导入替换为PySide6,移除了uic的使用,并更新了下载逻辑以与QML信号集成,用于进度更新和对话框管理。
  • modules/BLServer.py
    • qfluentwidgets导入替换为PySide6,以兼容新的UI框架。
  • modules/Bloret_PassPort.py
    • qfluentwidgets导入替换为PySide6,移除了MessageBox的使用,并更新了账户同步逻辑。
  • modules/ShortCut.py
    • PyQt5导入替换为PySide6,移除了uic的使用,并更新了UI创建以使用原生的PySide6组件或QFluentWidgets回退。修改了窗口标志和激活行为。
  • modules/customize.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
  • modules/global_hotkey.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
  • modules/i18n.py
    • 移除了qfluentwidgets导入,添加了reload_language函数,并更新了load_language以处理json.JSONDecodeError
  • modules/install.py
    • qfluentwidgetsPyQt5导入替换为PySide6,移除了uic的使用,添加了load_ui_file函数用于QUiLoader,并重构了下载逻辑以使用QML信号进行进度更新和对话框管理。
  • modules/launch.py
    • qfluentwidgetsPyQt5导入替换为PySide6,添加了新的JVM参数,并更新了JavaWrapper的使用逻辑。
  • modules/links.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
  • modules/log.py
    • PyQt5导入替换为PySide6,移除了uic的使用。
  • modules/modrinth.py
    • qfluentwidgetsPyQt5导入替换为PySide6,以兼容新的UI框架。
  • modules/mwtool.py
    • PyQt5导入替换为PySide6,移除了uic的使用,并更新了UI创建以使用回退方案。
  • modules/plugin.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
  • modules/querys.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
  • modules/safe.py
    • PyQt5导入替换为PySide6,移除了uic的使用。
  • modules/setup_ui.py
    • PyQt5导入替换为PySide6,移除了uic的使用。
  • modules/update.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
  • modules/versions.py
    • PyQt5qfluentwidgets导入替换为PySide6,移除了sip导入,添加了load_ui_file函数用于QUiLoader,并更新了UI更新逻辑。
  • qml/components/CoreManagerDialog.qml
    • 添加了新的QML对话框,用于管理Minecraft核心,包括基本信息、服务器、模组、资源包和高级设置。
  • qml/components/DownloadDialog.qml
    • 添加了新的QML对话框,用于显示下载进度,并提供暂停/恢复/取消功能。
  • qml/components/LaunchSelectorDialog.qml
    • 添加了新的QML对话框,用于选择启动项,并提供管理上下文菜单。
  • qml/main.qml
    • 添加了主QML应用程序文件,定义了窗口结构、导航项,并集成了下载对话框。
  • qml/pages/Download.qml
    • 添加了新的QML页面,用于下载Minecraft版本、Fabric加载器、Java和自定义应用程序。
  • qml/pages/Home.qml
    • 添加了新的QML主页,显示活动信息、Bloriko AI交互、服务器信息和启动栏。
  • qml/pages/Info.qml
    • 添加了新的QML信息页面,显示应用程序详细信息、网站链接和社交媒体链接。
  • qml/pages/Mods.qml
    • 添加了新的QML页面,用于Modrinth搜索、Bloriko AI模组建议以及模组下载/管理。
  • qml/pages/Multiplayer.qml
    • 添加了新的QML页面,用于联机功能,包括IPV6状态和EasyTier设置。
  • qml/pages/PassPort.qml
    • 添加了新的QML页面,用于Bloret通行证和Minecraft账户管理。
  • qml/pages/Settings.qml
    • 添加了新的QML设置页面,管理Minecraft目录、Java路径、语言、主题和日志设置。
  • requirements.txt
    • 更新了依赖项,将PyQt5替换为PySide6PyQt-Fluent-Widgets替换为PySide6-Fluent-Widgets,并移除了sip
  • ui/home_ui.py
    • PyQt5导入替换为PySide6,以兼容新的UI框架。
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/Nuitka-Build.yml
Activity
  • 此拉取请求由Detritalw创建,旨在解决问题迁移至 RinUI #105
  • 主要活动集中在将UI框架从PyQt-Fluent-Widgets迁移到RinUI,并更新所有相关的Python和QML代码以使用PySide6
  • 通过添加大量新的QML组件和重构现有Python模块,实现了UI的现代化和功能增强。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这是一个非常重要的重构,成功地将应用的 UI 从 PyQt-Fluent-Widgets 迁移到了基于 PySide6 和 QML 的新框架 RinUI。代码改动范围很广,几乎触及了所有 UI 和后端逻辑的交互部分。引入一个专门的 Python Backend 类来与 QML 前端交互是一个很好的架构选择,这提高了前后端的分离度。

我主要关注了以下几点:

  • 迁移一致性:大部分代码已成功迁移到 PySide6,但仍有部分复杂的对话框(如 CoreManageDialog)使用 Python Widgets 构建,这可能是为了简化迁移过程的有意选择。
  • 代码正确性:从 PyQt5 到 PySide6 的转换(如信号/槽语法、移除 Q_ARG)看起来是正确的。
  • 后端交互:通过 Backend 类和信号机制来更新 UI 是一种良好、解耦的设计。

我提出了一些具体的改进建议,主要集中在状态管理和代码效率上,希望能帮助你进一步提升代码质量。总的来说,这是一次出色的重构工作!

Comment thread modules/install.py
Comment on lines +13 to +18
_current_download_state = {
'downloader': None,
'is_paused': False,
'backend': None,
'cancelled': False
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

使用全局字典 _current_download_state 来管理下载状态(如下载器实例、暂停状态等)可能会使代码变得脆弱。全局状态难以跟踪,并且如果将来需要同时处理多个下载,这种方式不易扩展。

建议将下载状态封装在一个类中,例如 Backend 类或一个专门的 DownloadManager 类。这样可以使状态管理更加明确和健壮。

例如,Backend 类可以拥有 self.current_downloaderself.is_paused 等属性,而 toggle_current_download_pause 函数可以成为 Backend 类的一个方法。

Comment thread modules/versions.py
Comment on lines +64 to +91
def load_ui_file(ui_file_path):
"""
使用 QUiLoader 加载 UI 文件,兼容 PySide6

Args:
ui_file_path (str): UI 文件的路径

Returns:
QWidget: 加载的 UI 对象,如果失败返回 None
"""
try:
loader = QUiLoader()
# 如果是相对路径,需要转换为绝对路径
if not os.path.isabs(ui_file_path):
script_dir = Path(__file__).parent.parent.absolute()
ui_file_path = os.path.join(script_dir, ui_file_path)

if not os.path.exists(ui_file_path):
log(f"UI 文件不存在: {ui_file_path}", logging.WARNING)
return None

with open(ui_file_path, 'r', encoding='utf-8') as f:
ui = loader.load(f, None)
return ui
except Exception as e:
log(f"加载 UI 文件失败 {ui_file_path}: {e}", logging.ERROR)
return None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

load_ui_file 函数在将 UI 文件内容传递给 QUiLoader 之前,会先将整个文件读入内存。loader.load() 方法可以直接接受文件路径字符串作为参数,这样做内存效率更高。

你的规划文档 .trae/documents/plan_20260226_113224.md 中似乎也提到了这个优化点。

def load_ui_file(ui_file_path):
    """
    使用 QUiLoader 加载 UI 文件,兼容 PySide6
    
    Args:
        ui_file_path (str): UI 文件的路径
    
    Returns:
        QWidget: 加载的 UI 对象,如果失败返回 None
    """
    try:
        loader = QUiLoader()
        # 如果是相对路径,需要转换为绝对路径
        if not os.path.isabs(ui_file_path):
            script_dir = Path(__file__).parent.parent.absolute()
            ui_file_path = os.path.join(script_dir, ui_file_path)
        
        if not os.path.exists(ui_file_path):
            log(f"UI 文件不存在: {ui_file_path}", logging.WARNING)
            return None
        
        # 直接传递文件路径给 loader,而不是先打开文件
        ui = loader.load(ui_file_path, None)
        return ui
    except Exception as e:
        log(f"加载 UI 文件失败 {ui_file_path}: {e}", logging.ERROR)
        return None

Comment thread modules/web.py Fixed
@HanSiqi2008
Copy link
Copy Markdown
Contributor

HanSiqi2008 commented Mar 6, 2026

https://github.com/BloretCrew/Bloret-Launcher/actions/runs/22615419584 中下载的版本无法打开启动器

Twilight@Timeless:~/下载/Bloret-Launcher-Linux(1)> ./Bloret-Launcher
2026-03-06 20:00:33,165 [INFO] [IP.py:7 - ()] 正在获取服务器 IP...
2026-03-06 20:00:33,668 [INFO] [IP.py:15 - ()] 已更新服务器 IP: http://123.129.241.101
Gtk-Message: 20:00:33.800: Failed to load module "lunar-calendar-module"
2026-03-06 20:00:34,648 [INFO] [config.py:23 - ()] 正在检查配置文件路径: /home/Twilight/.local/share/Bloret-Launcher/config.json
2026-03-06 20:00:34,648 [INFO] [config.py:24 - ()] 源配置文件路径: /tmp/_MEI3vklIV/config.json
2026-03-06 20:00:34,648 [INFO] [config.py:25 - ()] 默认配置文件是否存在: True
2026-03-06 20:00:34,648 [INFO] [config.py:59 - ()] 目标配置文件已存在: /home/Twilight/.local/share/Bloret-Launcher/config.json
2026-03-06 20:00:34,648 [INFO] [config.py:62 - ()] 配置文件路径: /home/Twilight/.local/share/Bloret-Launcher/config.json
2026-03-06 20:00:34,648 [INFO] [config.py:66 - ()] 正在读取配置文件: /home/Twilight/.local/share/Bloret-Launcher/config.json
2026-03-06 20:00:34,671 [INFO] [config.py:70 - ()] 成功读取配置文件,正在检查版本字段...
2026-03-06 20:00:34,671 [INFO] [config.py:80 - ()] 当前配置文件版本: 26.0
2026-03-06 20:00:34,672 [INFO] [config.py:81 - ()] 默认配置文件版本: 26.0
2026-03-06 20:00:34,672 [INFO] [config.py:97 - ()] 配置文件版本匹配,无需更新
2026-03-06 20:00:34,672 [INFO] [config.py:126 - ()] 正在读取最终配置文件: /home/Twilight/.local/share/Bloret-Launcher/config.json
2026-03-06 20:00:34,672 [INFO] [config.py:128 - ()] 成功读取配置文件内容: {'minecraft-part': '.minecraft', 'first-run': True, 'ver': '26.0', '123': '123', 'size': 85, 'themelight': False, 'repeat_run': False, 'show_runtime_do': False, 'Customize': [], 'Bloret_PassPort_Login': False, 'Bloret_PassPort_UserName': '', 'Bloret_PassPort_PassWord': '', 'Bloret_PassPort_Admin': False, 'whenCWopen_BLopen': True, 'localmod': False, 'home_show_login_mod': True, 'self-starting': False, 'MaxThread': 64, 'Minecraft_Versions': ['1.21.8', '1.21.7'], 'minecraft_dir': '/home/Twilight/.local/share/Bloret-Launcher/.minecraft', 'Java_Path': 'C:\Program Files\Zulu\zulu-23\bin\java.exe', 'language': 'zh-cn', 'screen_cut_shortcut': 'Ctrl+Alt+A', 'MinecraftAccount': {'logined': False, 'chosen': -1, 'accounts': []}, 'mwtool_switch_open': True, 'ChoosedRun': '1.21.8'}
2026-03-06 20:00:34,672 [INFO] [config.py:131 - ()] Minecraft目录已设置为: '/home/Twilight/.local/share/Bloret-Launcher/.minecraft'
2026-03-06 20:00:34,672 [INFO] [config.py:136 - ()] Minecraft目录存在: /home/Twilight/.local/share/Bloret-Launcher/.minecraft
setHighDpiScaleFactorRoundingPolicy must be called before creating the QGuiApplication instance
darkdetect not supported on this platform
✨ RinUIWindow Initializing
UI Module Path: /tmp/_MEI3vklIV
2026-03-06 20:00:34,829 [CRITICAL] [safe.py:83 - handle_exception()] 未捕获的异常:
2026-03-06 20:00:34,829 [CRITICAL] [safe.py:84 - handle_exception()] 类型: <class 'FileNotFoundError'>
2026-03-06 20:00:34,829 [CRITICAL] [safe.py:85 - handle_exception()] 信息: Cannot find RinUI module: /tmp/_MEI3vklIV
2026-03-06 20:00:34,829 [CRITICAL] [safe.py:86 - handle_exception()] 回溯: [' File "Bloret-Launcher.py", line 2058, in \n', ' File "Bloret-Launcher.py", line 1969, in init\n', ' File "RinUI/core/launcher.py", line 66, in load\n']
Traceback (most recent call last):
File "Bloret-Launcher.py", line 2058, in
File "Bloret-Launcher.py", line 1969, in init
File "RinUI/core/launcher.py", line 66, in load
FileNotFoundError: Cannot find RinUI module: /tmp/_MEI3vklIV
[PYI-10773:ERROR] Failed to execute script 'Bloret-Launcher' due to unhandled exception!
Twilight@Timeless:~/下载/Bloret-Launcher-Linux(1)>

@Detritalw
Copy link
Copy Markdown
Member Author

@HanSiqi2008

Important

若要使更改生效,在 RinUI 分支被合并入 Windows 分支之前,请将 Pull Request 发起至 RinUI 分支。

@Detritalw Detritalw merged commit 985ebf7 into Windows Apr 6, 2026
9 of 10 checks passed
@Detritalw Detritalw deleted the RinUI branch April 6, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

迁移至 RinUI

4 participants