# [Refactor] 重构架构:引入 Controller 与 Adapter 模式实现 UI/逻辑解耦Update gitignore#8
Draft
703519523 wants to merge 15 commits into
Draft
# [Refactor] 重构架构:引入 Controller 与 Adapter 模式实现 UI/逻辑解耦Update gitignore#8703519523 wants to merge 15 commits into
703519523 wants to merge 15 commits into
Conversation
**主要变更:**
* **核心功能:** 新增 `render.quality` 配置选项,支持 "low" (1.0x)、"high" (2.0x)、"ultra" (4.0x) 和 "auto" (基于系统 DPI) 四种模式。
* **控制器:** 在 `EmoteController` 中实现了 `set_render_quality(mode)` API,并通过 `EmoteWidgetQml` 暴露给前端,支持运行时动态切换。
* **前端 (JS):**
* 重构了 `pyside_webview.html`,通过 `currentScaleFactor` 支持动态分辨率缩放。
* 修复了 `isOverCharacter` 点击检测逻辑,确保在不同渲染分辨率下能正确映射鼠标坐标。
* **驱动修改 (`emoteplayer.js`):**
* 实现了 `EmoteDevice.prototype.onResize` 方法,用于在画布尺寸变更时正确更新内部 C++ 缓冲区、渲染纹理和 WebGL 视口。
* 修改了 `EmotePlayer.createRenderCanvas`,现在会复用现有的画布元素并触发新的缩放逻辑,从而防止上下文丢失和视口错位。
* **开发工具:**
* 更新了 `test_qt.py`,在“外观”标签页中添加了渲染画质选择器。
* 更新了 QML 测试器 (`ControlPanel.qml`, `main.qml`),加入了渲染画质控制功能。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景 (Background)
当前项目的核心类
EmoteWidget是一个典型的上帝类 (God Class),它继承自QWebEngineView。目前,所有的业务逻辑(插件系统、口型同步、配置管理、通信桥梁)都与具体的 UI 实现(QWidget/QWebEngineView)深度绑定。
问题 (Problem)
QWebEngineView独立运行。解决方案 (Proposed Solution)
采用 MVVM 思想配合 Adapter (适配器) 模式进行重构。
架构设计
核心控制器 (
EmoteController):QObject类,不依赖任何 GUI 库。Config), 插件加载 (PluginLoader), 音频处理 (LipSync), JS 指令生成。适配器层 (
adapters/):run_js,register_channel等行为。QWebEngineView的具体实现。WebEngineView的具体实现。通信层 (
Bridge):_PythonApiBridge彻底独立,使其能被注入到任何适配器中。预期收益 (Benefits)
Resolves #7