Skip to content

feat: 游戏中心系统插件 (Game Center Plugin) - #289

Draft
qiyinxi wants to merge 2 commits into
dev_v2from
feat/game-center
Draft

feat: 游戏中心系统插件 (Game Center Plugin)#289
qiyinxi wants to merge 2 commits into
dev_v2from
feat/game-center

Conversation

@qiyinxi

@qiyinxi qiyinxi commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

概述

新增「游戏中心」系统插件,统一管理 PC 端和模拟器端游戏的版本检查、下载安装、启动与关闭。以系统插件形式接入主程序,启动时 editable 安装并发布 game_center 服务,其他插件可通过 ctx.service.get("game_center") 消费。

支持的游戏

平台 游戏 Provider
PC 星穹铁道、原神、绝区零 miHoYo (HoYoPlay API + hdiff 增量)
PC 明日方舟 PC、终末地 鹰角 (batch_proxy + AES config.ini)
模拟器 明日方舟安卓、重返未来1999 ADB APK (adb install)

主要功能

  • 插件化: 游戏中心位于 plugins/game_center/,启动时自动 editable 安装,通过 ctx.service.set("game_center", ...) 发布服务,通过 ctx.page.register() 注册前端页面
  • 游戏操作: 检查更新 / 安装更新 / 启动 / 关闭 / 取消安装,安卓模拟器游戏启动时自动拉起关联模拟器 (MuMu / 雷电)
  • 服务契约: 在 auto_mas_core 中新增 GameCenterServiceProtocol,其他插件可声明 wants = ["game_center"] 软依赖并获取类型标注
  • Provider 扩展: 内置 register_provider() 扩展点,其他插件可注册自定义游戏来源

返工清理

  • 移除混入的 MCP 插件门面 (mcp_facade.pyloader/context/__init__ 中的 MCP 引用),该半成品基础设施与游戏中心无关,应独立 PR
  • 还原 mumu.py 模拟器无关改动 (ADB 地址解析重构)
  • 修复前端 pickLocalApkselectFile() 返回类型 bug (string[] 被当作 string 使用)
  • 重新生成前端 API 客户端,确认 closeGameApiGameCenterClosePost 方法存在、无 MCP 相关生成

架构

plugins/game_center/              # 系统插件
├── src/game_center_plugin/
│   ├── plugin.py                 # 插件入口 (on_start/on_stop)
│   └── service.py               # GameCenterService (服务门面)

app/core/game_center/             # 核心域逻辑
├── base.py                       # Provider ABC + ProgressEvent
├── registry.py                   # Provider 注册表 (插件可扩展)
├── manager.py                    # GameCenterManager (asyncio + WS 进度)
├── presets.py                    # 游戏预设
└── providers/
    ├── mihoyo.py                 # miHoYo PC (hdiff 增量)
    ├── hypergryph.py             # 鹰角 PC (门控打补丁)
    ├── hg_crypto.py              # AES-256-CBC 加解密
    └── adb_apk.py                # ADB APK 安装

plugins/auto_mas_core/            # 类型契约
└── src/auto_mas_core/__init__.py # GameCenterServiceProtocol (Protocol)

验证

  • compileall -q app plugins/game_center main.py 通过
  • yarn format / yarn lint 0 错误
  • vue-tsc --noEmit 0 错误
  • 后端启动冒烟:game_center 插件 editable 安装/激活成功,game-center 页面注册成功,无报错
  • 前端 API 客户端已重新生成,closeGameApiGameCenterClosePost 方法存在
  • res/version.json 已更新 (CI 版本检查)
  • 真实游戏目录打补丁测试 (建议在拷贝目录验证)

注意

  • 鹰角自动打补丁默认关闭,需用户显式开启并接受风险提示
  • 终末地等 Unity 游戏无 config.ini,通过 exe 文件版本信息读取本地版本
  • 鹰角 VFS hdiff 打补丁流程有 TODO 标记 (patch.json 字段名需按真实清单对齐)

- Add GameConfig model with Info/Data/Cache fields (preset, platform, provider, install path, emulator binding, Hg auto-patch toggle)
- Add game_center core module: base provider ABC, registry (plugin extensible), manager (asyncio task + WS progress)
- Add three providers:
  - miHoYo PC: getGamePackages version check, hdiff incremental patching, 7z/hpatchz tool location
  - Hypergryph PC: batch_proxy version query, AES-256-CBC config.ini decryption, gated auto-patch with official launcher fallback
  - ADB APK: dumpsys version read, arknights/reverse1999 version strategies, APK download + adb install -r + monkey launch
- Add generic downloader with .part resume, md5 verify, disk space check, parallel multi-part download
- Add 13 API routes: CRUD + check/install/cancel/launch/open_official_launcher/install_local_apk/task_status
- Add frontend gameCenter page: card grid, progress bar (WS), emulator select, Hg advanced toggle with risk confirm, local APK picker
- Register game-center as builtin core page (page_registry + pageDeclarations + AppLayout icon)
- Regenerate OpenAPI client with full lifespan (all plugin routes preserved)
- Add MCP plugin facade (ctx.mcp.tool() registration, plugin lifecycle integration)

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @qiyinxi, your pull request is larger than the review limit of 150000 diff characters

- 游戏中心从 app/core 迁移到 plugins/game_center/ 系统插件,启动时 editable 安装
- 移除混入的 mcp_facade.py 及 loader/context/__init__ 中的 MCP 引用
- 还原 mumu.py 模拟器无关改动
- 新增 /close 端点和前端关闭按钮 (PoweroffOutlined)
- 修复 pickLocalApk 的 selectFile 返回类型 bug
- 安卓游戏启动时自动拉起关联模拟器 (MuMu/雷电)
- 新增 GameCenterServiceProtocol 到 auto_mas_core 供其他插件类型标注
- 更新 res/version.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant