Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc534b72b4 | ||
|
|
6e7c5e602a | ||
|
|
9bd4ac67ef | ||
|
|
2b8ea23074 | ||
|
|
371eb11629 | ||
|
|
655f015038 | ||
|
|
e8c9186a76 | ||
|
|
de523c5323 | ||
|
|
3ce0000215 | ||
|
|
1e80caa255 | ||
|
|
bcfedf5d36 | ||
|
|
9e9ae6f19b | ||
|
|
5a5977f93e | ||
|
|
2513513470 | ||
|
|
ceeb483cfb | ||
|
|
5c647308f4 | ||
|
|
14f72889dd | ||
|
|
66da194b05 | ||
|
|
fd23e88679 | ||
|
|
18df9e5c49 | ||
|
|
e800d55f9f | ||
|
|
7582fd2cfb | ||
|
|
ceeec602be | ||
|
|
21eef18f7b | ||
|
|
d085734c58 | ||
|
|
2a87c8d3b0 | ||
|
|
c91f5901a7 | ||
|
|
0802f77705 | ||
|
|
464ff5683f | ||
|
|
1eb7ac949a | ||
|
|
f20bb61724 | ||
|
|
7b023e5c82 | ||
|
|
5e67d50012 | ||
|
|
5c71ac8482 | ||
|
|
78d76f7353 | ||
|
|
5096d162cc | ||
|
|
29e9153d64 | ||
|
|
90a3509aaa | ||
|
|
354450ddcb | ||
|
|
8969c53644 | ||
|
|
f0b69c252c | ||
|
|
913dbdc6d9 | ||
|
|
af39c861e8 | ||
|
|
0afeac693c | ||
|
|
181c616909 | ||
|
|
007f2ac93c | ||
|
|
86d2da4a04 | ||
|
|
f30d901b7f | ||
|
|
15bc097a94 | ||
|
|
b9d4544a4d | ||
|
|
c70a760603 | ||
|
|
6367d17216 | ||
|
|
460de66ac4 | ||
|
|
338a9ee220 | ||
|
|
eb2b102bd5 | ||
|
|
7697374132 | ||
|
|
b839242716 | ||
|
|
181d952388 | ||
|
|
7abcc64e6f | ||
|
|
0934d9d206 | ||
|
|
003e4a08e7 | ||
|
|
704f68cdce | ||
|
|
ab49d79a71 | ||
|
|
c0f08be124 | ||
|
|
dac10a52bc | ||
|
|
b007f6b445 | ||
|
|
48e75ca665 | ||
|
|
9c8a75448d | ||
|
|
3b26f6117f | ||
|
|
f5ec733230 | ||
|
|
7641a7c948 | ||
|
|
1276050569 | ||
|
|
8acc0c3c23 | ||
|
|
172df5c4d5 | ||
|
|
f85e1aba88 | ||
|
|
a7921e998b | ||
|
|
24f29f806f | ||
|
|
33ac322bb2 | ||
|
|
5000e00780 | ||
|
|
d21ee22c80 | ||
|
|
99e189bef2 | ||
|
|
0ad5652ecd | ||
|
|
4cf1e8ea37 | ||
|
|
31a72892de | ||
|
|
12fa25d089 | ||
|
|
181ad64618 | ||
|
|
1017301682 | ||
|
|
470ed2d30a | ||
|
|
2f1e0bb0e4 | ||
|
|
69803355bf | ||
|
|
d30c694e2f | ||
|
|
8397d15bc5 | ||
|
|
c62bf17d91 | ||
|
|
b2237997f2 | ||
|
|
331d0748a4 | ||
|
|
437aceb580 | ||
|
|
d2cdb3a09a | ||
|
|
e195858a0e | ||
|
|
24acc9d6ed | ||
|
|
ce2a0ed813 | ||
|
|
b2f7f036d8 | ||
|
|
9e4bc98c7d | ||
|
|
8b6073b6b1 | ||
|
|
105ca9c88e |
No files matched your search
@@ -1,32 +1,57 @@
|
||||
name: Bug 反馈
|
||||
description: 报告启动失败、安装异常或界面问题
|
||||
name: Bug Report / Bug 反馈
|
||||
description: Report a crash, startup failure, install error, or UI issue / 报告崩溃、启动失败、装机异常或界面问题
|
||||
title: "[Bug]: "
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for reporting an issue! Both **English** and **Chinese (中文)** are welcome.
|
||||
感谢反馈!支持使用 **中文** 或 **English** 填写,请勿附带真实序列号、MAC 地址、SMC OSK 或任何 Apple 系统镜像。
|
||||
|
||||
- type: dropdown
|
||||
id: area
|
||||
attributes:
|
||||
label: Area / 问题所属阶段或模块
|
||||
description: Select the closest area where the issue occurs / 选择最接近的问题模块
|
||||
options:
|
||||
- Host check & WHPX / 宿主机体检与 WHPX
|
||||
- Portable runtime install & update / 便携运行时安装与更新
|
||||
- macOS installer download & setup / 镜像下载与装机
|
||||
- VM startup, GPU & display / 虚拟机启动、显卡与显示
|
||||
- Performance & disk I/O / 性能与磁盘 I/O
|
||||
- Guest Tools (clipboard, shared folder, sleep) / Guest Tools(剪贴板、共享目录、防休眠)
|
||||
- Plugins, UI & CLI / 插件、界面与命令行
|
||||
- Other / 其他
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: 简述遇到了什么问题,以及预期行为。
|
||||
label: What happened? / 问题描述
|
||||
description: Describe the actual behavior and what you expected / 简述实际现象以及你的预期行为
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: env
|
||||
attributes:
|
||||
label: 宿主机环境
|
||||
description: 建议附带 `reims-go doctor` 输出(请勿包含序列号、MAC 地址或 OSK 等敏感信息)。
|
||||
label: Host & Runtime Environment / 宿主机与运行时环境
|
||||
description: Paste `reims-go doctor` output or fill in the summary below (redact any sensitive info) / 建议粘贴 `reims-go doctor` 输出或填写以下信息
|
||||
placeholder: |
|
||||
- Windows 版本:例如 Windows 11 24H2 / Windows 10 22H2
|
||||
- CPU / 显卡:例如 i7-12700K / RTX 4070 Ti
|
||||
- Reims-Go 版本:例如 v0.2.0
|
||||
- 运行时版本:例如 runtime-3731afd
|
||||
- Windows: e.g. Windows 11 24H2 / Windows 10 22H2 (Build 19045)
|
||||
- CPU / GPU: e.g. i7-12700K / RTX 4070 Ti (Driver version)
|
||||
- Reims-Go: e.g. v0.2.8
|
||||
- Runtime: e.g. runtime-3731afd (stable / alpha)
|
||||
- macOS guest: e.g. macOS 26.x
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: 复现步骤
|
||||
label: Steps to Reproduce / 复现步骤
|
||||
placeholder: |
|
||||
1. ...
|
||||
2. ...
|
||||
@@ -34,5 +59,8 @@ body:
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: 相关日志(可选)
|
||||
label: Logs or Redacted Diagnostics Bundle / 日志或脱敏排障包(可选)
|
||||
description: |
|
||||
You can attach the redacted diagnostics archive exported from the app, or paste relevant QEMU / console logs here.
|
||||
可直接拖入应用导出的「脱敏排障包」,或粘贴相关 QEMU / 日志片段。
|
||||
render: text
|
||||
@@ -1,5 +1,8 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: 开发路线图(Roadmap)
|
||||
- name: Roadmap / 开发路线图
|
||||
url: https://github.com/Nwflower/Reims-Go/blob/main/docs/roadmap.md
|
||||
about: 查看当前进度与已规划功能,避免重复提问
|
||||
about: Check current progress and planned features before opening a duplicate / 查看当前进度与已规划功能,避免重复提问
|
||||
- name: Documentation / 使用文档(中文 · English)
|
||||
url: https://github.com/Nwflower/Reims-Go/blob/main/README.en.md
|
||||
about: Quick start, requirements, and troubleshooting guides / 快速开始、环境要求与常见问题排查
|
||||
@@ -1,16 +1,24 @@
|
||||
name: 功能建议
|
||||
description: 提出新功能想法或体验改进建议
|
||||
name: Feature Request / 功能建议
|
||||
description: Propose a new feature or UX improvement / 提出新功能想法或体验改进建议
|
||||
title: "[Feature]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Both **English** and **Chinese (中文)** are welcome. Feel free to check the [Roadmap](https://github.com/Nwflower/Reims-Go/blob/main/docs/roadmap.md) first.
|
||||
支持使用 **中文** 或 **English** 填写,建议先查阅 [开发路线图](https://github.com/Nwflower/Reims-Go/blob/main/docs/roadmap.md) 确认是否已在规划中。
|
||||
|
||||
- type: textarea
|
||||
id: summary
|
||||
attributes:
|
||||
label: 你希望解决什么问题或新增什么功能?
|
||||
label: Problem or Feature Idea / 你希望解决什么问题或新增什么功能?
|
||||
description: Describe the workflow or pain point this would improve / 说明具体使用场景、痛点或期望能力
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: details
|
||||
attributes:
|
||||
label: 补充说明(可选)
|
||||
description: 使用场景、交互设想或参考案例。
|
||||
label: Proposed Design or References (Optional) / 交互设想或参考案例(可选)
|
||||
description: Mockups, CLI examples, or similar tools / 可附草图、CLI 用法设想或参考产品
|
||||
@@ -0,0 +1,51 @@
|
||||
name: Hardware Compatibility Report / 硬件兼容性反馈
|
||||
description: Share GPU, CPU, or Windows 10/11 vGPU compatibility test results / 反馈显卡、CPU 或 Windows 10/11 的 vGPU 实测兼容情况
|
||||
title: "[Compat]: "
|
||||
labels: ["compatibility"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Help improve the Windows hardware compatibility matrix (GPU Vulkan drivers, hybrid CPUs, Windows 10/11 WHPX). Both **English** and **Chinese (中文)** are welcome.
|
||||
欢迎提交你的宿主机硬件实测结果(NVIDIA / AMD / Intel Arc 显卡驱动、混合架构 CPU、Win10/Win11 WHPX),帮助完善兼容性分级。
|
||||
|
||||
- type: dropdown
|
||||
id: result
|
||||
attributes:
|
||||
label: Result / 实测结果
|
||||
options:
|
||||
- Works cleanly with reims-vgpu / reims-vgpu 硬件加速正常可用
|
||||
- Boots with issues (artifacts, device lost, sleep/reboot issue) / 可启动但存在异常(花屏、设备丢失、休眠或重启异常)
|
||||
- Fails on reims-vgpu, works on VMware SVGA / reims-vgpu 不可用,切换 VMware SVGA 后正常
|
||||
- Fails to boot (WHPX / CPU / kernel-irqchip issue) / 无法启动(WHPX、CPU 或中断控制器问题)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: hardware
|
||||
attributes:
|
||||
label: Hardware & OS Details / 硬件与系统信息
|
||||
description: Paste `reims-go doctor` output (recommended) or fill in the fields below / 建议直接粘贴 `reims-go doctor` 输出,或按模板填写
|
||||
placeholder: |
|
||||
- Windows: e.g. Windows 11 24H2 (Build 26100) / Windows 10 22H2 (Build 19045)
|
||||
- CPU: e.g. Intel Core Ultra 9 285H / Ryzen 7 7840HS
|
||||
- GPU & Driver: e.g. AMD Radeon 780M / RTX 4070 Ti (Driver xx.x.x, Vulkan 1.x)
|
||||
- Reims-Go & Runtime: e.g. v0.2.8 + runtime-3731afd (stable / alpha)
|
||||
- macOS Guest & Controller: e.g. macOS 26.x, 8 vCPU, 16G RAM, NVMe / VirtIO
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: notes
|
||||
attributes:
|
||||
label: Observations & Workarounds / 现象说明与有效绕过方式
|
||||
description: Note whether kernel-irqchip, P-core pinning, or a specific driver version made a difference / 说明是否开启了 kernel-irqchip、P 核绑定,或切换特定显卡驱动后的差异
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant Logs (Optional) / 相关日志片段(可选)
|
||||
description: Redact serial numbers or MAC addresses before posting / 粘贴前请确保不含序列号或 MAC 地址
|
||||
render: text
|
||||
@@ -0,0 +1,68 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 743 180" width="743" height="180" role="img" aria-label="Reims-Go"><svg x="0" y="0" width="180" height="180" viewBox="0 0 1024 1024">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#3b8cff"/>
|
||||
<stop offset="0.55" stop-color="#2f5bea"/>
|
||||
<stop offset="1" stop-color="#3b1fb8"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="gloss" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffffff" stop-opacity="0.28"/>
|
||||
<stop offset="0.45" stop-color="#ffffff" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#6d5dfc"/>
|
||||
<stop offset="0.45" stop-color="#ff7a9a"/>
|
||||
<stop offset="0.8" stop-color="#ffb86b"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="lake" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#2f6bff"/>
|
||||
<stop offset="1" stop-color="#1a2a8f"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="bolt" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffe14d"/>
|
||||
<stop offset="1" stop-color="#ff9f0a"/>
|
||||
</linearGradient>
|
||||
<clipPath id="screen">
|
||||
<rect x="252" y="372" width="520" height="318" rx="26"/>
|
||||
</clipPath>
|
||||
<filter id="shadow" x="-20%" y="-20%" width="140%" height="150%">
|
||||
<feDropShadow dx="0" dy="22" stdDeviation="26" flood-color="#0b0d3a" flood-opacity="0.35"/>
|
||||
</filter>
|
||||
<filter id="iconShadow" x="-10%" y="-10%" width="120%" height="125%">
|
||||
<feDropShadow dx="0" dy="14" stdDeviation="16" flood-color="#000000" flood-opacity="0.22"/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<!-- squircle base -->
|
||||
<g filter="url(#iconShadow)">
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#bg)"/>
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#gloss)"/>
|
||||
</g>
|
||||
|
||||
<!-- VM window -->
|
||||
<g filter="url(#shadow)">
|
||||
<rect x="220" y="268" width="584" height="454" rx="52" fill="#f7f8fc"/>
|
||||
</g>
|
||||
<circle cx="280" cy="322" r="17" fill="#ff5f57"/>
|
||||
<circle cx="332" cy="322" r="17" fill="#febc2e"/>
|
||||
<circle cx="384" cy="322" r="17" fill="#28c840"/>
|
||||
|
||||
<!-- guest display: a lake at dusk -->
|
||||
<g clip-path="url(#screen)">
|
||||
<rect x="252" y="372" width="520" height="318" fill="url(#sky)"/>
|
||||
<circle cx="600" cy="540" r="44" fill="#fff3d6" opacity="0.9"/>
|
||||
<path d="M252 560 L340 470 L400 520 L480 430 L560 505 L620 465 L700 530 L772 480 L772 600 L252 600 Z" fill="#2b2d7a"/>
|
||||
<path d="M252 585 L330 530 L420 575 L500 520 L590 570 L672 535 L772 580 L772 610 L252 610 Z" fill="#1c1f5e"/>
|
||||
<rect x="252" y="598" width="520" height="92" fill="url(#lake)"/>
|
||||
<rect x="560" y="616" width="80" height="6" rx="3" fill="#fff3d6" opacity="0.7"/>
|
||||
<rect x="574" y="636" width="52" height="6" rx="3" fill="#fff3d6" opacity="0.5"/>
|
||||
<rect x="586" y="656" width="28" height="6" rx="3" fill="#fff3d6" opacity="0.35"/>
|
||||
</g>
|
||||
|
||||
<!-- GPU acceleration badge -->
|
||||
<g filter="url(#shadow)">
|
||||
<circle cx="776" cy="724" r="128" fill="#16182e"/>
|
||||
</g>
|
||||
<circle cx="776" cy="724" r="128" fill="none" stroke="#ffffff" stroke-opacity="0.92" stroke-width="16"/>
|
||||
<path d="M800 628 L708 744 L768 744 L748 822 L846 700 L784 700 Z" fill="url(#bolt)" stroke="#ffcf3a" stroke-width="6" stroke-linejoin="round"/>
|
||||
</svg><g transform="translate(206 126)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#f4f5fa"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#f4f5fa"/><path d="M133.5 -64.5V-7.5" stroke="#f4f5fa"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#f4f5fa"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#f4f5fa"/><path d="M340.5 -36H358.5" stroke="#5d6382"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,68 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 743 180" width="743" height="180" role="img" aria-label="Reims-Go"><svg x="0" y="0" width="180" height="180" viewBox="0 0 1024 1024">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#3b8cff"/>
|
||||
<stop offset="0.55" stop-color="#2f5bea"/>
|
||||
<stop offset="1" stop-color="#3b1fb8"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="gloss" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffffff" stop-opacity="0.28"/>
|
||||
<stop offset="0.45" stop-color="#ffffff" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#6d5dfc"/>
|
||||
<stop offset="0.45" stop-color="#ff7a9a"/>
|
||||
<stop offset="0.8" stop-color="#ffb86b"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="lake" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#2f6bff"/>
|
||||
<stop offset="1" stop-color="#1a2a8f"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="bolt" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffe14d"/>
|
||||
<stop offset="1" stop-color="#ff9f0a"/>
|
||||
</linearGradient>
|
||||
<clipPath id="screen">
|
||||
<rect x="252" y="372" width="520" height="318" rx="26"/>
|
||||
</clipPath>
|
||||
<filter id="shadow" x="-20%" y="-20%" width="140%" height="150%">
|
||||
<feDropShadow dx="0" dy="22" stdDeviation="26" flood-color="#0b0d3a" flood-opacity="0.35"/>
|
||||
</filter>
|
||||
<filter id="iconShadow" x="-10%" y="-10%" width="120%" height="125%">
|
||||
<feDropShadow dx="0" dy="14" stdDeviation="16" flood-color="#000000" flood-opacity="0.22"/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<!-- squircle base -->
|
||||
<g filter="url(#iconShadow)">
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#bg)"/>
|
||||
<rect x="80" y="80" width="864" height="864" rx="200" fill="url(#gloss)"/>
|
||||
</g>
|
||||
|
||||
<!-- VM window -->
|
||||
<g filter="url(#shadow)">
|
||||
<rect x="220" y="268" width="584" height="454" rx="52" fill="#f7f8fc"/>
|
||||
</g>
|
||||
<circle cx="280" cy="322" r="17" fill="#ff5f57"/>
|
||||
<circle cx="332" cy="322" r="17" fill="#febc2e"/>
|
||||
<circle cx="384" cy="322" r="17" fill="#28c840"/>
|
||||
|
||||
<!-- guest display: a lake at dusk -->
|
||||
<g clip-path="url(#screen)">
|
||||
<rect x="252" y="372" width="520" height="318" fill="url(#sky)"/>
|
||||
<circle cx="600" cy="540" r="44" fill="#fff3d6" opacity="0.9"/>
|
||||
<path d="M252 560 L340 470 L400 520 L480 430 L560 505 L620 465 L700 530 L772 480 L772 600 L252 600 Z" fill="#2b2d7a"/>
|
||||
<path d="M252 585 L330 530 L420 575 L500 520 L590 570 L672 535 L772 580 L772 610 L252 610 Z" fill="#1c1f5e"/>
|
||||
<rect x="252" y="598" width="520" height="92" fill="url(#lake)"/>
|
||||
<rect x="560" y="616" width="80" height="6" rx="3" fill="#fff3d6" opacity="0.7"/>
|
||||
<rect x="574" y="636" width="52" height="6" rx="3" fill="#fff3d6" opacity="0.5"/>
|
||||
<rect x="586" y="656" width="28" height="6" rx="3" fill="#fff3d6" opacity="0.35"/>
|
||||
</g>
|
||||
|
||||
<!-- GPU acceleration badge -->
|
||||
<g filter="url(#shadow)">
|
||||
<circle cx="776" cy="724" r="128" fill="#16182e"/>
|
||||
</g>
|
||||
<circle cx="776" cy="724" r="128" fill="none" stroke="#ffffff" stroke-opacity="0.92" stroke-width="16"/>
|
||||
<path d="M800 628 L708 744 L768 744 L748 822 L846 700 L784 700 Z" fill="url(#bolt)" stroke="#ffcf3a" stroke-width="6" stroke-linejoin="round"/>
|
||||
</svg><g transform="translate(206 126)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#16182e"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#16182e"/><path d="M133.5 -64.5V-7.5" stroke="#16182e"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#16182e"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#16182e"/><path d="M340.5 -36H358.5" stroke="#a3a8bf"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 39 KiB |
@@ -1,24 +1,101 @@
|
||||
name: Build Portable Runtime (Candidate)
|
||||
name: Build Portable Runtime (Alpha)
|
||||
|
||||
# Daily: build the newest steelbrain/reims-vgpu commit with the patch queue
|
||||
# (patches/series.txt) and publish it as a GitHub prerelease = the alpha
|
||||
# channel (portable-runtime-spec.md section 6). Never publishes stable:
|
||||
# promotion needs a real-host smoke test and a person (AGENTS.md rule 6).
|
||||
on:
|
||||
schedule:
|
||||
- cron: "23 3 * * *" # 03:23 UTC daily; skipped when upstream has not moved
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
upstream_commit:
|
||||
description: "Pinned steelbrain/reims-vgpu commit SHA"
|
||||
required: true
|
||||
default: "3731afd"
|
||||
publish_candidate:
|
||||
description: "Publish as GitHub prerelease (candidate channel only; never stable)"
|
||||
description: "steelbrain/reims-vgpu commit (empty = upstream default branch HEAD)"
|
||||
required: false
|
||||
default: ""
|
||||
publish:
|
||||
description: "Publish as an alpha prerelease (never stable)"
|
||||
type: boolean
|
||||
default: true
|
||||
rebuild:
|
||||
description: "Build a new patch revision (runtime-<commit>-pN) even if this upstream commit is already released"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: build-runtime
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
UPSTREAM_URL: https://github.com/steelbrain/reims-vgpu.git
|
||||
KEEP_ALPHAS: "7" # unpromoted alpha prereleases kept; older ones are deleted
|
||||
|
||||
jobs:
|
||||
build-runtime:
|
||||
resolve:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
commit: ${{ steps.r.outputs.commit }}
|
||||
skip: ${{ steps.r.outputs.skip }}
|
||||
suffix: ${{ steps.r.outputs.suffix }}
|
||||
steps:
|
||||
- id: r
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
WANT: ${{ inputs.upstream_commit }}
|
||||
REBUILD: ${{ inputs.rebuild }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone -q --filter=blob:none --no-checkout "$UPSTREAM_URL" up
|
||||
commit="$(git -C up rev-parse --verify "${WANT:-HEAD}^{commit}")"
|
||||
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
||||
# Already published (alpha or stable) under any short-hash length or -pN revision?
|
||||
max_rev=0
|
||||
for tag in $(gh release list -R "$GITHUB_REPOSITORY" --limit 1000 --json tagName -q '.[].tagName' | grep '^runtime-' || true); do
|
||||
rest="${tag#runtime-}"
|
||||
base="${rest%%-p*}"
|
||||
case "$commit" in
|
||||
"$base"*)
|
||||
rev=1
|
||||
if [ "$rest" != "$base" ]; then
|
||||
num="${rest#"$base"-p}"
|
||||
case "$num" in
|
||||
''|*[!0-9]*) ;;
|
||||
*) rev="$num" ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$rev" -gt "$max_rev" ]; then max_rev="$rev"; fi
|
||||
echo "Upstream $commit is already released as $tag (rev $rev)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
skip=false
|
||||
suffix=""
|
||||
if [ "$max_rev" -gt 0 ]; then
|
||||
if [ "$REBUILD" = "true" ]; then
|
||||
suffix="-p$((max_rev + 1))"
|
||||
echo "Rebuild requested: will publish with suffix $suffix"
|
||||
else
|
||||
skip=true
|
||||
fi
|
||||
fi
|
||||
echo "skip=$skip" >> "$GITHUB_OUTPUT"
|
||||
echo "suffix=$suffix" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: resolve
|
||||
if: needs.resolve.outputs.skip != 'true'
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 120
|
||||
timeout-minutes: 150
|
||||
outputs:
|
||||
short: ${{ steps.patches.outputs.short }}
|
||||
release_id: ${{ steps.patches.outputs.release_id }}
|
||||
applied: ${{ steps.patches.outputs.applied }}
|
||||
merged: ${{ steps.patches.outputs.merged }}
|
||||
conflict: ${{ steps.patches.outputs.conflict }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -38,28 +115,50 @@ jobs:
|
||||
mingw-w64-clang-x86_64-mesa mingw-w64-clang-x86_64-vulkan-loader
|
||||
mingw-w64-clang-x86_64-python mingw-w64-clang-x86_64-python-pip
|
||||
|
||||
- name: Checkout upstream reims-vgpu & verify patch queue
|
||||
- name: Check out upstream and apply the patch queue
|
||||
id: patches
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$work = Join-Path $env:RUNNER_TEMP 'reims-vgpu'
|
||||
$cargoHome = Join-Path $env:RUNNER_TEMP 'cargo'
|
||||
$xdgData = Join-Path $env:RUNNER_TEMP 'xdg-data'
|
||||
$xdgCache = Join-Path $env:RUNNER_TEMP 'xdg-cache'
|
||||
New-Item -ItemType Directory -Force -Path $cargoHome, $xdgData, $xdgCache | Out-Null
|
||||
git clone https://github.com/steelbrain/reims-vgpu.git $work
|
||||
git -C $work checkout ${{ inputs.upstream_commit }}
|
||||
# Verify local patches apply cleanly; fail hard on mismatch (AGENTS.md rule 4).
|
||||
if (Test-Path 'patches/reims-vgpu-cargo-lock.patch') {
|
||||
git -C $work apply --check (Resolve-Path 'patches/reims-vgpu-cargo-lock.patch')
|
||||
git -C $work apply (Resolve-Path 'patches/reims-vgpu-cargo-lock.patch')
|
||||
foreach ($d in 'cargo', 'xdg-data', 'xdg-cache') { New-Item -ItemType Directory -Force -Path (Join-Path $env:RUNNER_TEMP $d) | Out-Null }
|
||||
# The runner's git defaults to core.autocrlf=true; LF patches need an LF
|
||||
# checkout (upstream also rewrites CRLF files to LF, install-ctl.sh).
|
||||
git config --global core.autocrlf false
|
||||
git clone -q $env:UPSTREAM_URL $work
|
||||
if ($LASTEXITCODE) { throw 'clone failed' }
|
||||
git -C $work checkout -q '${{ needs.resolve.outputs.commit }}'
|
||||
if ($LASTEXITCODE) { throw 'checkout failed' }
|
||||
git -C $work submodule update --init --depth 1 vendor/qemu
|
||||
if ($LASTEXITCODE) { git -C $work submodule update --init vendor/qemu }
|
||||
if ($LASTEXITCODE) { throw 'vendor/qemu submodule failed' }
|
||||
$short = (git -C $work rev-parse --short=7 HEAD).Trim()
|
||||
$releaseId = "$short${{ needs.resolve.outputs.suffix }}"
|
||||
"short=$short" >> $env:GITHUB_OUTPUT
|
||||
"release_id=$releaseId" >> $env:GITHUB_OUTPUT
|
||||
|
||||
# Applies what applies, skips what upstream already has, stops on a
|
||||
# conflict without touching the patch (AGENTS.md rule 4).
|
||||
$resultFile = Join-Path $env:RUNNER_TEMP 'patches.json'
|
||||
try {
|
||||
pwsh -NoProfile -File scripts/apply-patch-series.ps1 -ReimsRepo $work -ResultFile $resultFile
|
||||
$ok = $LASTEXITCODE -eq 0
|
||||
} finally {
|
||||
if (Test-Path $resultFile) {
|
||||
$r = Get-Content -Raw $resultFile | ConvertFrom-Json
|
||||
"applied=$(@($r.applied) -join ',')" >> $env:GITHUB_OUTPUT
|
||||
"merged=$(@($r.merged) -join ',')" >> $env:GITHUB_OUTPUT
|
||||
"conflict=$($r.conflict)" >> $env:GITHUB_OUTPUT
|
||||
"APPLIED_PATCHES=$(@($r.applied) -join ',')" >> $env:GITHUB_ENV
|
||||
}
|
||||
}
|
||||
$short = (git -C $work rev-parse --short HEAD).Trim()
|
||||
"UPSTREAM_DIR=$work" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"SHORT_COMMIT=$short" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"CARGO_HOME=$cargoHome" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"XDG_DATA_HOME=$xdgData" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"XDG_CACHE_HOME=$xdgCache" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
if (-not $ok) { throw 'patch queue does not apply' }
|
||||
"UPSTREAM_DIR=$work" >> $env:GITHUB_ENV
|
||||
"SHORT_COMMIT=$short" >> $env:GITHUB_ENV
|
||||
"RELEASE_ID=$releaseId" >> $env:GITHUB_ENV
|
||||
"CARGO_HOME=$(Join-Path $env:RUNNER_TEMP 'cargo')" >> $env:GITHUB_ENV
|
||||
"XDG_DATA_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-data')" >> $env:GITHUB_ENV
|
||||
"XDG_CACHE_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-cache')" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Build upstream runtime in MSYS2 CLANG64
|
||||
shell: msys2 {0}
|
||||
@@ -67,54 +166,126 @@ jobs:
|
||||
REIMS_INSTALL_SKIP_HOST_CHECKS: "1"
|
||||
run: |
|
||||
set -euo pipefail
|
||||
UPSTREAM_UNIX="$(cygpath -u "$UPSTREAM_DIR")"
|
||||
WS_UNIX="$(cygpath -u "$GITHUB_WORKSPACE")"
|
||||
cd "$UPSTREAM_UNIX"
|
||||
# Fetch vendor/qemu at the pinned commit before applying patches.
|
||||
git submodule update --init --depth 1 vendor/qemu || git submodule update --init vendor/qemu
|
||||
for p in \
|
||||
"$WS_UNIX/patches/qemu-whpx-win10-compat.patch" \
|
||||
"$WS_UNIX/patches/qemu-whpx-win10-startup-ipis.patch" \
|
||||
"$WS_UNIX/patches/qemu-whpx-nested-virt-nonfatal.patch"; do
|
||||
[ -f "$p" ] || continue
|
||||
git -C vendor/qemu apply --check "$p"
|
||||
git -C vendor/qemu apply "$p"
|
||||
done
|
||||
# Run upstream's own non-interactive CLANG64 build script.
|
||||
cd "$(cygpath -u "$UPSTREAM_DIR")"
|
||||
# Upstream's own non-interactive CLANG64 build script.
|
||||
bash scripts/install-ctl.sh --yes
|
||||
|
||||
- name: Package candidate runtime & source archives
|
||||
- name: Package alpha runtime and source archives
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$outDir = Join-Path $env:RUNNER_TEMP 'releases'
|
||||
$qemuDir = Join-Path $env:XDG_DATA_HOME 'reims-ctl\qemu\current'
|
||||
$msys2Root = '${{ steps.msys2.outputs.msys2-location }}'
|
||||
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||
pwsh -File scripts/pack-runtime.ps1 `
|
||||
# In-process call, so an empty list (every patch already upstream) binds
|
||||
# as an empty array rather than being dropped as an empty argument.
|
||||
$applied = @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
||||
& ./scripts/pack-runtime.ps1 `
|
||||
-ReimsRepo $env:UPSTREAM_DIR `
|
||||
-CargoHome $env:CARGO_HOME `
|
||||
-QemuDir $qemuDir `
|
||||
-Msys2 $msys2Root `
|
||||
-QemuDir (Join-Path $env:XDG_DATA_HOME 'reims-ctl\qemu\current') `
|
||||
-Msys2 '${{ steps.msys2.outputs.msys2-location }}' `
|
||||
-OutDir $outDir `
|
||||
-TempRoot $env:RUNNER_TEMP `
|
||||
-Channel candidate `
|
||||
-IncludeNestedVirtPatch
|
||||
-Channel alpha `
|
||||
-ReleaseId $env:RELEASE_ID `
|
||||
-Patches $applied
|
||||
|
||||
- name: Upload candidate artifacts
|
||||
- name: Alpha entry gate
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
& ./scripts/check-runtime-alpha.ps1 `
|
||||
-OutDir (Join-Path $env:RUNNER_TEMP 'releases') `
|
||||
-Commit $env:RELEASE_ID -RequireSlim `
|
||||
-Zstd (Join-Path '${{ steps.msys2.outputs.msys2-location }}' 'usr\bin\zstd.exe') `
|
||||
-AppliedPatches @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
||||
|
||||
- name: Upload alpha artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: reims-runtime-win-x64-${{ env.SHORT_COMMIT }}-candidate
|
||||
path: ${{ runner.temp }}/releases/*
|
||||
name: reims-runtime-win-x64-${{ env.RELEASE_ID }}-alpha
|
||||
path: |
|
||||
${{ runner.temp }}/releases/reims-runtime-*.tar.zst
|
||||
${{ runner.temp }}/releases/SHA256SUMS.txt
|
||||
retention-days: 14
|
||||
|
||||
- name: Publish candidate prerelease (never stable)
|
||||
if: ${{ inputs.publish_candidate }}
|
||||
- name: Publish alpha prerelease (never stable)
|
||||
if: github.event_name == 'schedule' || inputs.publish
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
MERGED: ${{ steps.patches.outputs.merged }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$c = $env:RELEASE_ID
|
||||
$short = $env:SHORT_COMMIT
|
||||
$dir = Join-Path $env:RUNNER_TEMP 'releases'
|
||||
$assets = @("reims-runtime-win-x64-$c.tar.zst", "reims-runtime-src-$c.tar.zst", "reims-runtime-msys2-src-$c.tar.zst", "reims-runtime-symbols-$c.tar.zst", 'SHA256SUMS.txt') |
|
||||
ForEach-Object { Join-Path $dir $_ }
|
||||
$applied = if ($env:APPLIED_PATCHES) { ($env:APPLIED_PATCHES -split ',' | ForEach-Object { "- ``$_``" }) -join "`n" } else { '- (none)' }
|
||||
$merged = if ($env:MERGED) { "`n`nAlready upstream, skipped (retire from patches/): $env:MERGED" } else { '' }
|
||||
$notes = @"
|
||||
**Alpha** runtime (``$c``), built automatically from upstream [steelbrain/reims-vgpu@$short](https://github.com/steelbrain/reims-vgpu/commit/${{ needs.resolve.outputs.commit }}).
|
||||
|
||||
Not smoke-tested on a real host. It becomes stable only after ``scripts/smoke-runtime.ps1`` passes on a real Windows host and a person approves (portable-runtime-spec.md section 6).
|
||||
|
||||
Local patches applied (sources and patches are in the attached source packages):
|
||||
$applied$merged
|
||||
|
||||
The optional ``reims-runtime-symbols-$c.tar.zst`` contains matching debug files for crash analysis.
|
||||
|
||||
Build: $env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID
|
||||
"@
|
||||
gh release create "runtime-$c" @assets --prerelease --title "Portable Runtime runtime-$c (alpha)" --notes $notes
|
||||
if ($LASTEXITCODE) { throw "gh release create failed ($LASTEXITCODE)" }
|
||||
|
||||
- name: Prune old alpha prereleases
|
||||
if: github.event_name == 'schedule' || inputs.publish
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$tag = "runtime-$($env:SHORT_COMMIT)"
|
||||
gh release create $tag "$($env:RUNNER_TEMP)/releases/*" `
|
||||
--prerelease `
|
||||
--title "Portable Runtime $tag (candidate)" `
|
||||
--notes "Automated candidate build from upstream $($env:SHORT_COMMIT). Must pass scripts/smoke-runtime.ps1 on a real Windows host and human review before promotion to stable."
|
||||
# Only unpromoted runtime prereleases; stable releases are never touched.
|
||||
$alphas = gh release list -R $env:GITHUB_REPOSITORY --limit 1000 --json tagName,isPrerelease,isDraft,createdAt | ConvertFrom-Json |
|
||||
Where-Object { $_.tagName -like 'runtime-*' -and $_.isPrerelease -and -not $_.isDraft } |
|
||||
Sort-Object createdAt -Descending
|
||||
$alphas | Select-Object -Skip ([int]$env:KEEP_ALPHAS) | ForEach-Object {
|
||||
Write-Host "Deleting old alpha $($_.tagName)"
|
||||
gh release delete $_.tagName -R $env:GITHUB_REPOSITORY --yes --cleanup-tag
|
||||
}
|
||||
|
||||
report:
|
||||
needs: [resolve, build]
|
||||
if: always() && needs.resolve.outputs.skip != 'true' && (failure() || needs.build.outputs.merged != '')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RESULT: ${{ needs.build.result }}
|
||||
COMMIT: ${{ needs.resolve.outputs.commit }}
|
||||
CONFLICT: ${{ needs.build.outputs.conflict }}
|
||||
MERGED: ${{ needs.build.outputs.merged }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# One open issue per kind; later runs add a comment instead of a new issue.
|
||||
file_issue() {
|
||||
local title="$1" body="$2" n
|
||||
n="$(gh issue list -R "$GITHUB_REPOSITORY" --state open --search "in:title \"$title\"" --json number,title -q ".[] | select(.title == \"$title\") | .number" | head -n1)"
|
||||
if [ -n "$n" ]; then
|
||||
gh issue comment "$n" -R "$GITHUB_REPOSITORY" --body "$body"
|
||||
else
|
||||
gh issue create -R "$GITHUB_REPOSITORY" --title "$title" --body "$body"
|
||||
fi
|
||||
}
|
||||
if [ "$RESULT" != "success" ]; then
|
||||
if [ -n "$CONFLICT" ]; then
|
||||
why="Patch \`$CONFLICT\` neither applies to upstream \`$COMMIT\` nor is already there. Per AGENTS.md rule 4 the patch was not edited; a person decides how to rebase or retire it."
|
||||
else
|
||||
why="The build, packaging or alpha gate failed for upstream \`$COMMIT\`; see the log."
|
||||
fi
|
||||
file_issue "Runtime alpha build failed" "$why"$'\n\n'"Run: $RUN_URL"$'\n\n'"No alpha was published."
|
||||
fi
|
||||
if [ -n "$MERGED" ]; then
|
||||
file_issue "Patch queue: patches already upstream" "Upstream \`$COMMIT\` already contains: \`$MERGED\`. They were skipped. Record the merge commit in portable-runtime-spec.md section 5, then remove them from patches/ and patches/series.txt."$'\n\n'"Run: $RUN_URL"
|
||||
fi
|
||||
@@ -26,21 +26,43 @@ jobs:
|
||||
cache: pnpm
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
- name: Frontend build
|
||||
- name: Verify CHANGELOG.md matches current version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$verFile = Get-Content -Raw -LiteralPath 'internal/version/version.go'
|
||||
if ($verFile -notmatch 'var\s+Version\s*=\s*"(v[^"]+)"') {
|
||||
throw 'Could not parse Version from internal/version/version.go'
|
||||
}
|
||||
$ver = $Matches[1]
|
||||
$tmp = Join-Path $env:RUNNER_TEMP "release-notes-$ver.md"
|
||||
& ./scripts/build-release-notes.ps1 -Tag $ver -OutFile $tmp
|
||||
Write-Host "PASS CHANGELOG.md contains valid release notes for $ver ($((Get-Item -LiteralPath $tmp).Length) bytes)"
|
||||
|
||||
- name: Frontend test & build
|
||||
shell: pwsh
|
||||
run: |
|
||||
pnpm --dir frontend install --frozen-lockfile
|
||||
pnpm --dir frontend test
|
||||
pnpm --dir frontend build
|
||||
|
||||
- name: Debug workspace hygiene check & self-test
|
||||
shell: pwsh
|
||||
run: |
|
||||
node scripts/debug/check.mjs
|
||||
node --test scripts/debug/debug.test.mjs
|
||||
|
||||
- name: Go test & vet
|
||||
shell: pwsh
|
||||
run: |
|
||||
go test ./...
|
||||
go vet ./...
|
||||
|
||||
- name: Build CLI & GUI binaries
|
||||
- name: Build reims-go.exe (window + command-line mode)
|
||||
shell: pwsh
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force -Path build/bin | Out-Null
|
||||
go build -trimpath -o build/bin/reims-go-cli.exe ./cmd/reims-go
|
||||
go build -trimpath -tags desktop,production -ldflags "-H windowsgui" -o build/bin/reims-go.exe .
|
||||
# Command-line mode must still answer through a pipe from the GUI-subsystem build.
|
||||
$out = & build/bin/reims-go.exe version | Out-String
|
||||
if ($LASTEXITCODE -ne 0 -or $out -notmatch '^reims-go ') { throw "reims-go.exe version failed: $out" }
|
||||
@@ -0,0 +1,239 @@
|
||||
name: Dev Release (Rolling)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- "README.md"
|
||||
- "README.en.md"
|
||||
- "AGENTS.md"
|
||||
- ".github/ISSUE_TEMPLATE/**"
|
||||
- ".github/readme/**"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: dev-release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
dev-release:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
- name: Resolve rolling dev version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Parse-StableSemVer([string]$v) {
|
||||
if ($v -match '^v([0-9]+)\.([0-9]+)\.([0-9]+)$') {
|
||||
return [PSCustomObject]@{
|
||||
Tag = $v
|
||||
Major = [int]$Matches[1]
|
||||
Minor = [int]$Matches[2]
|
||||
Patch = [int]$Matches[3]
|
||||
}
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Compare-SemVer($a, $b) {
|
||||
if ($a.Major -ne $b.Major) { return [Math]::Sign($a.Major - $b.Major) }
|
||||
if ($a.Minor -ne $b.Minor) { return [Math]::Sign($a.Minor - $b.Minor) }
|
||||
return [Math]::Sign($a.Patch - $b.Patch)
|
||||
}
|
||||
|
||||
$shortSha = (git rev-parse --short=7 HEAD).Trim()
|
||||
if ([string]::IsNullOrWhiteSpace($shortSha)) {
|
||||
throw 'Could not resolve HEAD short commit SHA'
|
||||
}
|
||||
|
||||
$stableTags = @(
|
||||
git tag --list 'v*' |
|
||||
ForEach-Object { Parse-StableSemVer $_.Trim() } |
|
||||
Where-Object { $_ -ne $null } |
|
||||
Sort-Object Major, Minor, Patch -Descending
|
||||
)
|
||||
$latestStable = if ($stableTags.Count -gt 0) { $stableTags[0] } else { $null }
|
||||
|
||||
$codeVer = $null
|
||||
$verFile = Get-Content -Raw -LiteralPath 'internal/version/version.go'
|
||||
if ($verFile -match 'var\s+Version\s*=\s*"(v[0-9]+\.[0-9]+\.[0-9]+)"') {
|
||||
$codeVer = Parse-StableSemVer $Matches[1]
|
||||
}
|
||||
|
||||
if ($latestStable) {
|
||||
if ($codeVer -and (Compare-SemVer $codeVer $latestStable) -gt 0) {
|
||||
$nextBase = $codeVer.Tag
|
||||
} else {
|
||||
$nextBase = "v$($latestStable.Major).$($latestStable.Minor).$($latestStable.Patch + 1)"
|
||||
}
|
||||
$baseStableTag = $latestStable.Tag
|
||||
} elseif ($codeVer) {
|
||||
$nextBase = $codeVer.Tag
|
||||
$baseStableTag = ''
|
||||
} else {
|
||||
$nextBase = 'v0.0.1'
|
||||
$baseStableTag = ''
|
||||
}
|
||||
|
||||
$devVersion = "$nextBase-dev-$shortSha"
|
||||
"DEV_VERSION=$devVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"DEV_COMMIT=$shortSha" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"BASE_STABLE_TAG=$baseStableTag" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Resolved DEV_VERSION=$devVersion (commit=$shortSha, baseStable=$baseStableTag)"
|
||||
|
||||
- name: Generate dev release notes
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$devVersion = $env:DEV_VERSION
|
||||
$runtimeTag = ''
|
||||
$runtimeTitle = ''
|
||||
try {
|
||||
$rels = gh release list -R $env:GITHUB_REPOSITORY --limit 100 --json tagName,name,isPrerelease,isDraft,createdAt | ConvertFrom-Json
|
||||
$stable = $rels |
|
||||
Where-Object { $_.tagName -like 'runtime-*' -and -not $_.isPrerelease -and -not $_.isDraft } |
|
||||
Sort-Object createdAt -Descending |
|
||||
Select-Object -First 1
|
||||
if ($stable) {
|
||||
$runtimeTag = $stable.tagName
|
||||
$runtimeTitle = if ($stable.name) { $stable.name } else { $stable.tagName }
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Could not query latest stable runtime release: $_"
|
||||
}
|
||||
$notesFile = Join-Path $env:RUNNER_TEMP "release-notes-dev.md"
|
||||
& ./scripts/build-release-notes.ps1 `
|
||||
-Tag $devVersion `
|
||||
-Channel dev `
|
||||
-PrevTag $env:BASE_STABLE_TAG `
|
||||
-Commit $env:DEV_COMMIT `
|
||||
-Repo $env:GITHUB_REPOSITORY `
|
||||
-StableRuntimeTag $runtimeTag `
|
||||
-StableRuntimeTitle $runtimeTitle `
|
||||
-OutFile $notesFile
|
||||
"RELEASE_NOTES_FILE=$notesFile" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Generated dev release notes ($((Get-Item -LiteralPath $notesFile).Length) bytes) for $devVersion"
|
||||
|
||||
- name: Build frontend
|
||||
shell: pwsh
|
||||
run: |
|
||||
pnpm --dir frontend install --frozen-lockfile
|
||||
pnpm --dir frontend build
|
||||
|
||||
- name: Go test & vet
|
||||
shell: pwsh
|
||||
run: |
|
||||
go test ./...
|
||||
go vet ./...
|
||||
|
||||
- name: Install Wails CLI
|
||||
shell: pwsh
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.17.1
|
||||
|
||||
- name: Build Windows x64 binary
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ver = $env:DEV_VERSION
|
||||
$dist = 'dist-release'
|
||||
New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
||||
$verPkg = 'github.com/Nwflower/reims-go/internal/version'
|
||||
$guiOut = Join-Path $dist "reims-go-$ver-windows-amd64.exe"
|
||||
wails build -s -trimpath -ldflags "-s -w -X $verPkg.Version=$ver" -o "reims-go-$ver-windows-amd64.exe"
|
||||
if ($LASTEXITCODE) { throw "wails build failed ($LASTEXITCODE)" }
|
||||
Copy-Item (Join-Path 'build\bin' "reims-go-$ver-windows-amd64.exe") $guiOut
|
||||
$zipOut = [IO.Path]::ChangeExtension($guiOut, '.zip')
|
||||
Compress-Archive -LiteralPath @($guiOut, 'LICENSE', 'NOTICE.md') -DestinationPath $zipOut -CompressionLevel Optimal -Force
|
||||
$lines = @(Get-Item -LiteralPath $guiOut, $zipOut | ForEach-Object {
|
||||
$h = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLowerInvariant()
|
||||
"$h $($_.Name)"
|
||||
})
|
||||
[IO.File]::WriteAllText((Join-Path $dist 'SHA256SUMS.txt'), ($lines -join "`n") + "`n", [Text.UTF8Encoding]::new($false))
|
||||
Get-Content (Join-Path $dist 'SHA256SUMS.txt')
|
||||
|
||||
- name: Update rolling dev GitHub Release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$releaseTag = 'dev'
|
||||
$ver = $env:DEV_VERSION
|
||||
$notesFile = $env:RELEASE_NOTES_FILE
|
||||
if (-not (Test-Path -LiteralPath $notesFile) -or (Get-Item -LiteralPath $notesFile).Length -eq 0) {
|
||||
throw "Release notes file is missing or empty: $notesFile"
|
||||
}
|
||||
$title = "Reims-Go Dev ($ver)"
|
||||
$files = @(Get-ChildItem -LiteralPath 'dist-release' -File | Select-Object -ExpandProperty FullName)
|
||||
$keepNames = @($files | ForEach-Object { [IO.Path]::GetFileName($_) })
|
||||
|
||||
# Point the fixed 'dev' tag to the commit being built.
|
||||
git tag -f $releaseTag $env:GITHUB_SHA
|
||||
if ($LASTEXITCODE -ne 0) { throw "git tag -f $releaseTag failed ($LASTEXITCODE)" }
|
||||
git push --force origin "refs/tags/$releaseTag"
|
||||
if ($LASTEXITCODE -ne 0) { throw "git push --force refs/tags/$releaseTag failed ($LASTEXITCODE)" }
|
||||
|
||||
$exists = $true
|
||||
$existingAssets = @()
|
||||
try {
|
||||
$relJson = gh release view $releaseTag --json assets 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$exists = $false
|
||||
} else {
|
||||
$existingAssets = @(($relJson | ConvertFrom-Json).assets)
|
||||
}
|
||||
} catch {
|
||||
$exists = $false
|
||||
}
|
||||
|
||||
if ($exists) {
|
||||
# Upload new assets first so the release is never left empty if upload fails.
|
||||
gh release upload $releaseTag @files --clobber
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release upload failed ($LASTEXITCODE)" }
|
||||
foreach ($asset in $existingAssets) {
|
||||
if ($keepNames -notcontains $asset.name) {
|
||||
Write-Host "Removing stale dev asset $($asset.name)"
|
||||
gh release delete-asset $releaseTag $asset.name --yes
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release delete-asset $($asset.name) failed ($LASTEXITCODE)" }
|
||||
}
|
||||
}
|
||||
gh release edit $releaseTag `
|
||||
--target $env:GITHUB_SHA `
|
||||
--prerelease `
|
||||
--title $title `
|
||||
--notes-file $notesFile
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release edit failed ($LASTEXITCODE)" }
|
||||
} else {
|
||||
gh release create $releaseTag @files `
|
||||
--target $env:GITHUB_SHA `
|
||||
--prerelease `
|
||||
--title $title `
|
||||
--notes-file $notesFile
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release create failed ($LASTEXITCODE)" }
|
||||
}
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release tag to build & publish (e.g. v0.2.1)"
|
||||
description: "Release tag to build & publish (e.g. v0.2.9 or v0.2.9-alpha.1)"
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
@@ -18,6 +18,9 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || '' }}
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
@@ -33,12 +36,57 @@ jobs:
|
||||
cache: pnpm
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
- name: Resolve version tag
|
||||
- name: Resolve version tag and channel
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = if ('${{ github.event_name }}' -eq 'workflow_dispatch') { '${{ inputs.tag }}' } else { '${{ github.ref_name }}' }
|
||||
if (-not $tag.StartsWith('v')) { throw "Release tag must start with 'v', got: $tag" }
|
||||
$tag = $tag.Trim()
|
||||
if ($tag -match '^v[0-9]+\.[0-9]+\.[0-9]+$') {
|
||||
$channel = 'stable'
|
||||
} elseif ($tag -match '^v[0-9]+\.[0-9]+\.[0-9]+-alpha(?:[.-][0-9A-Za-z.-]+)?$') {
|
||||
$channel = 'alpha'
|
||||
} else {
|
||||
throw "Release tag must be stable (vX.Y.Z) or alpha test (vX.Y.Z-alpha[.N]), got: $tag"
|
||||
}
|
||||
"RELEASE_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"RELEASE_CHANNEL=$channel" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Resolved tag=$tag channel=$channel"
|
||||
|
||||
- name: Generate release notes
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = $env:RELEASE_TAG
|
||||
$channel = $env:RELEASE_CHANNEL
|
||||
$runtimeTag = ''
|
||||
$runtimeTitle = ''
|
||||
try {
|
||||
$rels = gh release list -R $env:GITHUB_REPOSITORY --limit 100 --json tagName,name,isPrerelease,isDraft,createdAt | ConvertFrom-Json
|
||||
$stable = $rels |
|
||||
Where-Object { $_.tagName -like 'runtime-*' -and -not $_.isPrerelease -and -not $_.isDraft } |
|
||||
Sort-Object createdAt -Descending |
|
||||
Select-Object -First 1
|
||||
if ($stable) {
|
||||
$runtimeTag = $stable.tagName
|
||||
$runtimeTitle = if ($stable.name) { $stable.name } else { $stable.tagName }
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Could not query latest stable runtime release: $_"
|
||||
}
|
||||
$notesFile = Join-Path $env:RUNNER_TEMP "release-notes-$tag.md"
|
||||
& ./scripts/build-release-notes.ps1 `
|
||||
-Tag $tag `
|
||||
-Channel $channel `
|
||||
-ChangelogPath 'CHANGELOG.md' `
|
||||
-Repo $env:GITHUB_REPOSITORY `
|
||||
-StableRuntimeTag $runtimeTag `
|
||||
-StableRuntimeTitle $runtimeTitle `
|
||||
-OutFile $notesFile
|
||||
"RELEASE_NOTES_FILE=$notesFile" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
Write-Host "Generated $channel release notes ($((Get-Item -LiteralPath $notesFile).Length) bytes) for $tag"
|
||||
|
||||
- name: Build frontend
|
||||
shell: pwsh
|
||||
@@ -56,7 +104,7 @@ jobs:
|
||||
shell: pwsh
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.17.1
|
||||
|
||||
- name: Build Windows x64 GUI & CLI binaries
|
||||
- name: Build Windows x64 binary
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -64,12 +112,14 @@ jobs:
|
||||
$dist = 'dist-release'
|
||||
New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
||||
$verPkg = 'github.com/Nwflower/reims-go/internal/version'
|
||||
# One executable: the window without arguments, command-line mode with a command.
|
||||
$guiOut = Join-Path $dist "reims-go-$tag-windows-amd64.exe"
|
||||
$cliOut = Join-Path $dist "reims-go-cli-$tag-windows-amd64.exe"
|
||||
wails build -s -trimpath -ldflags "-s -w -X $verPkg.Version=$tag" -o "reims-go-$tag-windows-amd64.exe"
|
||||
if ($LASTEXITCODE) { throw "wails build failed ($LASTEXITCODE)" }
|
||||
Copy-Item (Join-Path 'build\bin' "reims-go-$tag-windows-amd64.exe") $guiOut
|
||||
go build -trimpath -ldflags "-s -w -X $verPkg.Version=$tag" -o $cliOut ./cmd/reims-go
|
||||
$lines = @(Get-ChildItem -LiteralPath $dist -File | Sort-Object Name | ForEach-Object {
|
||||
$zipOut = [IO.Path]::ChangeExtension($guiOut, '.zip')
|
||||
Compress-Archive -LiteralPath @($guiOut, 'LICENSE', 'NOTICE.md') -DestinationPath $zipOut -CompressionLevel Optimal -Force
|
||||
$lines = @(Get-Item -LiteralPath $guiOut, $zipOut | ForEach-Object {
|
||||
$h = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLowerInvariant()
|
||||
"$h $($_.Name)"
|
||||
})
|
||||
@@ -83,18 +133,74 @@ jobs:
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = $env:RELEASE_TAG
|
||||
$channel = $env:RELEASE_CHANNEL
|
||||
$notesFile = $env:RELEASE_NOTES_FILE
|
||||
if (-not (Test-Path -LiteralPath $notesFile) -or (Get-Item -LiteralPath $notesFile).Length -eq 0) {
|
||||
throw "Release notes file is missing or empty: $notesFile"
|
||||
}
|
||||
$title = if ($channel -eq 'alpha') { "Reims-Go $tag (Alpha)" } else { "Reims-Go $tag" }
|
||||
$files = @(Get-ChildItem -LiteralPath 'dist-release' -File | Select-Object -ExpandProperty FullName)
|
||||
$exists = $true
|
||||
$existingBody = ''
|
||||
try {
|
||||
gh release view $tag *> $null
|
||||
if ($LASTEXITCODE -ne 0) { $exists = $false }
|
||||
$relJson = gh release view $tag --json body 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$exists = $false
|
||||
} else {
|
||||
$existingBody = (($relJson | ConvertFrom-Json).body | Out-String).Trim()
|
||||
}
|
||||
} catch {
|
||||
$exists = $false
|
||||
}
|
||||
if ($exists) {
|
||||
gh release upload $tag @files --clobber
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release upload failed ($LASTEXITCODE)" }
|
||||
$editArgs = @('release', 'edit', $tag, '--title', $title)
|
||||
if ($channel -eq 'alpha') {
|
||||
$editArgs += '--prerelease'
|
||||
} else {
|
||||
$editArgs += @('--prerelease=false', '--latest')
|
||||
}
|
||||
# Backfill notes if the existing release body is empty or only GitHub's auto-generated compare link.
|
||||
$isAutoOnly = [string]::IsNullOrWhiteSpace($existingBody) -or ($existingBody -match '^\*\*Full Changelog\*\*:\s*https://\S+$')
|
||||
if ($isAutoOnly) {
|
||||
$editArgs += @('--notes-file', $notesFile)
|
||||
}
|
||||
& gh @editArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release edit failed ($LASTEXITCODE)" }
|
||||
} else {
|
||||
gh release create $tag @files `
|
||||
--title "Reims-Go $tag" `
|
||||
--generate-notes
|
||||
$createArgs = @('release', 'create', $tag) + $files + @('--title', $title, '--notes-file', $notesFile)
|
||||
if ($channel -eq 'alpha') {
|
||||
$createArgs += '--prerelease'
|
||||
} else {
|
||||
$createArgs += '--latest'
|
||||
}
|
||||
& gh @createArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw "gh release create failed ($LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
- name: Delete all published alpha test releases after stable release
|
||||
if: env.RELEASE_CHANNEL == 'stable'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
# Only delete app alpha prereleases (vX.Y.Z-alpha*); never touch runtime-* or the rolling dev release.
|
||||
$rels = gh release list -R $env:GITHUB_REPOSITORY --limit 1000 --json tagName,isPrerelease,isDraft | ConvertFrom-Json
|
||||
$alphas = @($rels | Where-Object {
|
||||
$_.isPrerelease -and
|
||||
-not $_.isDraft -and
|
||||
$_.tagName -match '^v[0-9]+\.[0-9]+\.[0-9]+-alpha(?:[.-][0-9A-Za-z.-]+)?$'
|
||||
})
|
||||
if ($alphas.Count -eq 0) {
|
||||
Write-Host "No published alpha test releases to clean up."
|
||||
exit 0
|
||||
}
|
||||
foreach ($rel in $alphas) {
|
||||
Write-Host "Deleting alpha test release $($rel.tagName)"
|
||||
gh release delete $rel.tagName -R $env:GITHUB_REPOSITORY --yes --cleanup-tag
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to delete alpha test release $($rel.tagName) (exit $LASTEXITCODE)"
|
||||
}
|
||||
}
|
||||
@@ -28,3 +28,6 @@ Thumbs.db
|
||||
*.log
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# Local debugging scratch, work orders, run logs, caches, scratch worktrees
|
||||
.debug/
|
||||
@@ -1,47 +1,74 @@
|
||||
# AGENTS.md(reims-go)
|
||||
# AGENTS.md(Reims-Go)
|
||||
|
||||
> 面向在本仓库工作的 AI Agent 与协作者。遵循上级 [`D:\Build\AGENTS.md`](../AGENTS.md) 与 [`D:\Build\DISK-LAYOUT.md`](../DISK-LAYOUT.md)。
|
||||
> 面向在本仓库工作的 AI Agent 与协作者。
|
||||
|
||||
## 仓库定位
|
||||
|
||||
**`reims-go`** 是面向 Windows x86-64 的 **免编译、一站式 `reims-vgpu` macOS 虚拟机桌面启动器与工程工作台**(Go + Wails,GUI 与 CLI 共用内核)。
|
||||
**`reims-go`** 是面向 Windows x86-64 的免编译 `reims-vgpu` macOS 虚拟机桌面启动器与工作台(Go + Wails,GUI 与 CLI 共用核心)。
|
||||
|
||||
它与上游 [steelbrain/reims-vgpu](https://github.com/steelbrain/reims-vgpu) 及研究仓 [`D:\Build\macos-vm-lab`](../macos-vm-lab) 的分工:
|
||||
- `reims-vgpu`:上游底层引擎(QEMU 分支、`reims-graphics-pci`、`metal2vulkan`、`reims-ctl`、`reims-util`)。
|
||||
- `macos-vm-lab`:内核/图形深度研究、M0–M5 实验记录与基准数据。
|
||||
- `reims-go`(本仓库):产品化一站式桌面应用与便携运行时打包/分发流水线,让用户在无需安装 MSYS2、Rust、Git 或本地编译的前提下,开箱运行带 GPU 加速的 macOS 虚拟机(时间目标见 `docs/roadmap.md` 的 M2 DoD),并提供 CoW 派生、快照、P-Core 绑核、QMP/SSH 自动化等工程能力。
|
||||
与上游 [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) 的分工:
|
||||
- **`reims-vgpu`**:底层引擎(QEMU 分支、`reims-graphics-pci`、`metal2vulkan`、`reims-ctl`、`reims-util`)。
|
||||
- **`reims-go`(本仓库)**:桌面应用、命令行包装与便携运行时打包/分发流水线,提供开箱即用的环境体检、离线装机、硬件调优、Guest Tools、恢复点与 CoW 派生能力。
|
||||
|
||||
## 存储与路径硬约束
|
||||
## 存储与产物边界
|
||||
|
||||
1. **代码与文档放仓库**:Go 后端、Wails 前端、打包脚本、CI workflow 与文档位于 `D:\Build\reims-go\`。
|
||||
2. **大体积文件严禁入库**:预编译 QEMU 运行时包(~900 MB 解压 / ~250 MB 压缩)、macOS 镜像、`.qcow2` 磁盘、快照统一放 **`D:\Data\reims-go\`**(开发联调时可复用 `D:\Data\macos-vm-lab\reims\`),**严禁写入 `C:` 或 `F:`**。
|
||||
3. **临时文件放 `D:\Build\Temp\`**:打包草稿、一次性测试目录用完即清。
|
||||
4. **Go 缓存**:本机已配置 `GOPATH=D:\DevCache\go`、`GOBIN=D:\DevTools\go-bin`,直接沿用即可。
|
||||
1. **大体积文件严禁入库**:便携运行时包、macOS 安装包、`.qcow2` 磁盘与快照一律保存在用户或开发者本地指定的 `<DataRoot>`(推荐非系统盘),不得提交到仓库,也不放入 `.debug/`。
|
||||
2. **禁止使用系统临时目录存放任务中间产物**:开发与排查产生的临时脚本、截图、日志、构建/测试缓存与隔离运行产物一律写入仓库根目录的 `.debug/`(已加入 `.gitignore`,严禁提交),不读写系统临时目录(`%TEMP%` / `/tmp`)。
|
||||
3. **临时文件及时退役**:任务完成后清理草稿与会话目录;值得长期保留的探针沉淀为正式单元测试(`*_test.go`)或 `scripts/` 下的工具脚本,不留在 `.debug/`。
|
||||
|
||||
## 调试目录与临时产物纪律(`.debug/`)
|
||||
|
||||
1. **顶层目录白名单**:`.debug/` 顶层只允许 [`scripts/debug/paths.mjs`](scripts/debug/paths.mjs) 声明的 5 个子目录,任何工具与脚本必须写入其中之一,`node scripts/debug/check.mjs` 会拒绝顶层出现其他杂项:
|
||||
- `.debug/tmp/` — 一次性会话临时产物,由 `scripts/debug/tmp.mjs` 创建、记录属主 PID 并回收。
|
||||
- `.debug/work/` — 跨会话工单与交接材料(含 `refs/`、`shots/`、`tmp/` 与 `work.md`),由 `scripts/debug/work.mjs` 管理。
|
||||
- `.debug/cache/` — 可由源码树重建的本地工具缓存。
|
||||
- `.debug/runs/` — 本地运行输出(日志、抓包、报告、追踪与隔离运行目录)。
|
||||
- `.debug/worktrees/` — 临时 Git 工作树,由 `scripts/debug/worktree.mjs` 管理(移除前先解除 Windows Junction / 符号链接,避免误删主树 `frontend/node_modules`)。
|
||||
2. **脚本与命令行红线**:
|
||||
- **禁止在命令行内联长多行脚本**:需要多行脚本时,先写入 `.debug/tmp/`(或所属工单的 `tmp/`)再执行。
|
||||
- **作者修改走编辑工具**:新逻辑、文案与规则变更直接通过编辑工具修改;跨文件机械改造(重命名、批量改路径、语法迁移)可将脚本放在 `.debug/tmp/` 运行,执行后通读完整 `git diff` 并通过全部校验,脚本不得编写新逻辑。
|
||||
3. **一次性临时目录与工单分工**:
|
||||
- 范围明确、当前会话可完成的小修改、只读检查和一次性试验直接进行,不建工单;无中间产物时不创建临时目录。
|
||||
- 用户显式要求工单,或任务需要跨会话恢复、多人/多 Agent 交接、持续积累验收证据时,再通过 `work.mjs` 建立或复用工单。
|
||||
- 一次性产物用 `node scripts/debug/tmp.mjs new <label>` 或 `run <label> -- <command>`(向子进程注入 `REIMS_TMP_DIR`):正常结束(退出码 0)自动删除目录,失败保留证据供排查;超期(24 小时)且属主进程已退出的残留由 `gc --yes` 回收,存活进程与符号链接/Junction 受保护。
|
||||
- 工单按 `draft → active → review → close` 流转;`close` 校验通过后删除整个工单目录。
|
||||
- **持久文档零引用**:`README.md`、`README.en.md`、`CHANGELOG.md`、`AGENTS.md`、`docs/` 与 `patches/README.md` 严禁引用具体工单 ID 或 `.debug/tmp/` 会话实例路径。
|
||||
|
||||
| 命令 | 用途 |
|
||||
| :--- | :--- |
|
||||
| `node scripts/debug/tmp.mjs new <label>` | 在 `.debug/tmp/` 创建带属主记录的会话目录并打印路径 |
|
||||
| `node scripts/debug/tmp.mjs run <label> -- <cmd>` | 注入 `REIMS_TMP_DIR` 执行命令;成功自动删除,失败保留证据 |
|
||||
| `node scripts/debug/tmp.mjs list \| close <id> \| gc [--yes]` | 查看、关闭或回收已退出且超期的临时会话目录 |
|
||||
| `node scripts/debug/work.mjs new <slug> --title "…"` | 在 `.debug/work/` 创建工单及 `refs/`、`shots/`、`tmp/` |
|
||||
| `node scripts/debug/work.mjs start \| verify \| review \| close <id>` | 推进工单状态;`close` 校验后删除工单目录 |
|
||||
| `node scripts/debug/work.mjs path <id> [tmp\|refs\|shots]` | 打印工单材料目录绝对路径;`paths <id>` 打印工单声明的文件列表 |
|
||||
| `node scripts/debug/worktree.mjs add\|remove <path> [ref]` | 在 `.debug/worktrees/` 安全创建或移除临时工作树 |
|
||||
| `node scripts/debug/check.mjs` | 校验 `.debug/` 顶层白名单、临时会话、工单与持久文档引用 |
|
||||
|
||||
## 事实核验与安全规则
|
||||
|
||||
1. **上游行为以一手源码为准**:引用 `reims-ctl` / `reims-vgpu` 行为时附上游 commit 与 `文件:行号`;未实测项显式标「待验证」。
|
||||
2. **不绕过系统安全与人工确认**:UAC 提权启用 WHPX、重启 Windows、macOS GUI 安装向导、发布 Release 等操作由人确认触发。
|
||||
1. **上游行为以一手源码为准**:引用 `reims-ctl` / `reims-vgpu` 行为时核对对应上游 commit 与 `文件:行号`;未实测项显式标注「待验证」。
|
||||
2. **人工确认红线**:UAC 提权启用 WHPX、重启 Windows、macOS 图形安装向导、向上游提交 PR、将运行时升级为 `stable` 正式发布,均须由人确认触发。自动化例外:[`.github/workflows/build-runtime.yml`](.github/workflows/build-runtime.yml) 每日从上游构建,通过 `alpha` 准入检查后自动发布为 GitHub 预发布(`alpha` 通道),并自动清理较旧的未升级 `alpha` 预发布。
|
||||
3. **敏感与专有内容零入库**:严禁提交 SMC OSK、SMBIOS 真实序列号、MAC 地址、任何 Apple IPSW / BaseSystem / 解密固件或闭源二进制。
|
||||
4. **对上游的修改只走补丁队列**:不长期维护 fork。改动以补丁形式放在 `patches/`,在 `docs/portable-runtime-spec.md` 第 5 节登记,目标是清零。补丁打不上就停下报告,不要自动改补丁。向上游提 PR 由人来做。
|
||||
5. **运行时包必须如实声明来源**:`manifest.json` 写清上游 commit、`vendor/qemu` commit 和全部补丁。带补丁的包不能写成「纯上游」。
|
||||
6. **用户只拿 `stable` 通道**:CI 产物只进 `candidate`,经真实宿主冒烟测试并由人确认后才升级(`portable-runtime-spec.md` 第 6 节)。
|
||||
7. **配置只通过 `reims-ctl set` 写入**:不直接改 `vm.toml`,让上游的校验和 OpenCore 重建逻辑生效(`docs/shell-design.md`)。
|
||||
4. **对上游的修改只走补丁队列**:不长期维护 fork。补丁放 [`patches/`](patches/),顺序与状态统一在 [`patches/series.txt`](patches/series.txt) 与 [`patches/README.md`](patches/README.md) 维护,目标是清零。补丁打不上就停下报告,不要自动改写补丁。
|
||||
5. **运行时包如实声明来源**:`manifest.json` 必须写清上游各仓库 commit 与实际应用的全部补丁;带补丁的包不得宣称为纯上游构建。
|
||||
6. **默认用户只拿 `stable` 通道**:CI 产物先入 `alpha`,经真实宿主冒烟并人工确认后才升为 `stable`(见 [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md))。
|
||||
7. **配置写入只走 `reims-ctl set`**:不直接改写 `vm.toml`,保证上游校验与 OpenCore 重建生效(见 [`docs/design-guidelines.md`](docs/design-guidelines.md))。
|
||||
8. **文档维护纪律**:`docs/` 只存放当前生效的长期文档,使用单一事实来源;不写私人本机路径、日期补丁式叙事、易过时的伪代码/ASCII 草图;一次性排查、审视与排期记录留在 Issue 或 PR 中。
|
||||
|
||||
## 开源合规边界
|
||||
|
||||
- `reims-go` 自身代码(Go 后端 + 前端外壳)采用 **MIT** 协议,见 [`LICENSE`](LICENSE)。
|
||||
- 运行时组件(`qemu-system-x86_64.exe` 为 GPLv2,`reims-ctl` / `reims-vgpu` / `metal2vulkan` 为 `GPL-2.0-or-later OR LGPL-3.0-or-later`,以及 CLANG64/libva 动态库)以**独立子进程与独立运行时压缩包**形态集成。发布二进制时必须同时提供**对应源码包**(含本地补丁,只给上游链接不够)和完整许可证文本(`NOTICE.md` / `licenses/`),见 `docs/portable-runtime-spec.md` 第 7 节。
|
||||
- 不打包、不托管任何 Apple 系统文件;macOS 恢复镜像一律由用户端运行 `reims-util` 直连 Apple 服务器拉取或本地导入。
|
||||
- macOS 的软件许可只允许在 Apple 硬件上虚拟化。上游也处在同样的位置,但一键工具公开发布会放大风险。**是否公开发布由人决定**,在此之前 Release 保持私有。
|
||||
- 2026-11-28 已决定:仓库 [`Nwflower/reims-go`](https://github.com/Nwflower/reims-go) 公开,便携运行时通过它的 GitHub Release 分发。因此每个运行时 Release **必须**附带对应源码包和许可证文本,缺一不可。新包先进 `candidate`(GitHub 预发布),经真实宿主冒烟并由人确认后才升为 `stable`。
|
||||
- `reims-go` 自身代码(Go 后端与前端外壳)采用 [Apache-2.0](LICENSE) 协议。
|
||||
- 运行时组件(QEMU、`reims-ctl` / `reims-vgpu` / `metal2vulkan` 及 MSYS2 CLANG64 / libva 动态库)以独立子进程和独立压缩包形式集成。公开仓库通过 GitHub Release 分发运行时时,每个运行时 Release **必须**同处附带对应源码包(含本地补丁与 MSYS2 copyleft 源码)及完整许可证文本([`NOTICE.md`](NOTICE.md) / `licenses/`),详见 [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md)。
|
||||
- 不打包、不托管任何 Apple 系统文件;macOS 安装包与恢复镜像均由用户端直连 Apple 服务器获取或本地导入。
|
||||
|
||||
## 文档导航
|
||||
|
||||
- [`README.md`](README.md) — 项目总览、核心特性与差异化定位
|
||||
- [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md) — 便携运行时剥离实测结论、目录规范与 CI 打包设计
|
||||
- [`docs/architecture.md`](docs/architecture.md) — Go + Wails 分层架构、环境隔离、WHPX/GPU/P-Core 自动调优与控制面设计
|
||||
- [`docs/shell-design.md`](docs/shell-design.md) — 外壳设计原语:配置模型与交互对齐 macOS(Virtualization.framework 与 macOS 人机界面规范)
|
||||
- [`docs/ui-redesign.md`](docs/ui-redesign.md) — 前端改版方案:VM 主面板信息架构、视觉令牌、进度与日志、分阶段计划
|
||||
- [`patches/`](patches/) — 对上游的补丁队列(当前只有 Win10 WHPX 兼容补丁)
|
||||
- [`docs/roadmap.md`](docs/roadmap.md) — M0–M4 里程碑与验收标准
|
||||
- [`README.md`](README.md) / [`README.en.md`](README.en.md) — 项目总览、核心特性与快速开始(中英双语)
|
||||
- [`CHANGELOG.md`](CHANGELOG.md) — 应用版本更新日志
|
||||
- [`docs/roadmap.md`](docs/roadmap.md) — 公开路线图与近期重点
|
||||
- [`docs/architecture.md`](docs/architecture.md) — 系统架构、模块职责与安全边界
|
||||
- [`docs/design-guidelines.md`](docs/design-guidelines.md) — 产品与界面设计规范(配置原语、状态模型、视觉与文案)
|
||||
- [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md) — 便携运行时打包、发布通道与合规规范
|
||||
- [`docs/plugin-architecture.md`](docs/plugin-architecture.md) — 插件系统架构与扩展接口规范
|
||||
- [`patches/README.md`](patches/README.md) — 上游临时补丁队列与 PR 跟踪
|
||||
@@ -0,0 +1,200 @@
|
||||
# 更新日志
|
||||
|
||||
本文件只记录 Reims-Go 桌面应用的变化。便携运行时(`runtime-*`)的版本另见 [Releases](https://github.com/Nwflower/Reims-Go/releases)。
|
||||
|
||||
## v0.2.10 — 2026-11-30
|
||||
|
||||
### 新功能
|
||||
|
||||
- 插件市场默认索引切换至 `reims-go/plugins` 组织仓库并新增 jsDelivr CDN 备选镜像自动回退;新增内置 `ed25519` 公钥环验签机制(`internal/plugin/keyring.go`)与 `reims-go plugin pack` 打包签名命令(自动执行静态门禁、生成 `SHA256SUMS` 与可选 `SHA256SUMS.sig`)。
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- 修复虚拟机键盘打字时偶发字符重复/错序(如 `ABC` 变为 `ABCC`/`ABCAC`/`ABCAB`)及中文拼音首字连发(如 `h` 跳出两个 `h` 变为 `h好的`)的问题([#14](https://github.com/Nwflower/Reims-Go/issues/14)):在运行时补丁中改用 `WM_CHAR` 硬件扫描码区分物理与非物理字符,并在客户端按能力门控 `REIMS_GO_INPUT_URL`(同时受「宿主输入服务与 IME 桥接」插件开关控制),使已安装 `runtime-3731afd-p3` 的用户升级应用后即可直接恢复。
|
||||
- 修复标题栏菜单切换闪烁与浮层焦点提示竞争问题([#16](https://github.com/Nwflower/Reims-Go/pull/16))。
|
||||
- 将界面繁体中文(`zh-TW`)语言标签调整为更中性的表述。
|
||||
|
||||
## v0.2.9 — 2026-11-30
|
||||
|
||||
### 新功能
|
||||
|
||||
- 全新多语种与本地化架构(i18n / L10n v2,来自 [#10](https://github.com/Nwflower/Reims-Go/pull/10)):重构 7 域语言目录、零依赖 ICU 复数/格式引擎与区域回退链,支持系统语言自动跟随与完整第三方语言包插件协议(新增 `reims-go plugin locale init|check` 工具链);全面本地化系统托盘、文件选择器及高 DPI 悬浮安装引导,并为错误信息加入错误码与自动脱敏诊断详情。
|
||||
- 应用内更新新增通道切换:「关于」页支持选择 `stable`(正式版)、`alpha`(测试版)或 `dev`(开发构建)更新通道;切换至测试通道更新时自动保留上一版本备份以便随时回滚。
|
||||
- 完善插件静态安全准入与插件市场能力:
|
||||
- 新增统一静态安全扫描与硬拦截门禁(`internal/plugin/scanner.go`):拦截 L1/L4 插件夹带可执行文件或系统脚本、L3 插件未声明二进制、SVG `<script>`/`on*`/`javascript:` 主动内容、主题/交互脚本宿主逃逸(`window.go`/`window.runtime`/`eval`/`Function`)及未声明网络调用;针对 L3 Sidecar 原生程序如实声明完整 Windows 账户权限并展示可执行文件 SHA-256 与通俗能力说明。
|
||||
- 新增惰性插件市场客户端(`internal/plugin/market.go`):支持静态远程 `index.json` 拉取(环境变量 `REIMS_GO_PLUGIN_MARKET_URL` 自定义镜像或离线模式)、内存/磁盘双层缓存与内嵌离线兜底、软撤回(`withdrawn`)拦截与替代提示、下载前 `engines`/`platforms` 兼容预检与 SHA-256 强校验。
|
||||
- CLI 新增 `reims-go plugin search`、`reims-go plugin update`、`reims-go plugin install <id>` 及支持 `.zip`/`--json` 三段式安全报告的 `reims-go plugin doctor`;界面「插件」页新增「插件市场」标签页、本地包导入前静态安全报告弹窗与已安装插件安全扫描入口。
|
||||
- 支持清理未激活的旧版便携运行时:在「内核」页及命令行均可一键删除不再使用的历史运行时以释放磁盘空间。
|
||||
- 新增宿主侧 CoW backing 链深度体检(无须提权):当虚拟系统盘 CoW 派生链深度 ≥ 2 层或父镜像缺失时,在 `reims-go doctor`、宿主机体检及虚拟机详情/存储设置页一致展示提示。
|
||||
- 「关于」页新增第三方开源许可证查看器,随应用内置完整第三方开源许可证文本。
|
||||
- 新增三层系统盘小文件 I/O 基准与采样工具套件(`scripts/io-bench/`:`darwin/amd64` 客体基准、QMP `query-blockstats` / 延迟直方图采样与语言无关 Windows `PhysicalDisk` 计数器采集),`internal/qmp` 补充通用 `Query` 与块层统计查询方法。
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- OpenCore 引导阶段新增对 FileVault 预启动界面鼠标与数字键盘输入的支持([#6](https://github.com/Nwflower/Reims-Go/pull/6))。
|
||||
- 修复新建虚拟机向导中下载 macOS 安装包时与「安装包」页进度不同步的问题([#13](https://github.com/Nwflower/Reims-Go/pull/13))。
|
||||
- 修复虚拟机重启流程:重启前等待 QEMU 进程完全退出并回收已提交内存,避免连续重启时内存占用叠加或启动失败。
|
||||
- 统一 `qcow2` 建盘选项来源:空间回收(`CompactDisk`)与 CoW 派生(`CreateCoWOverlay`)自动读取源镜像的 `compat`、`cluster_size`、`lazy_refcounts`、`extended_l2`、`refcount_bits` 与 `compression_type` 并原样透传,导入转换统一使用与上游一致的默认选项。
|
||||
- 移除已停用的 GitCode 运行时镜像同步与下载源,并加固多语种插件信任边界、敏感信息脱敏、WCAG 对比度与窄窗口布局。
|
||||
|
||||
## v0.2.8 — 2026-11-29
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- 修复 Windows 10 22H2 等环境下系统自带 `tar.exe` 缺少 `zstd` 解压器导致在线下载或导入本地 `.tar.zst` 运行时包失败的问题([#5](https://github.com/Nwflower/Reims-Go/issues/5)),改为内置纯 Go 解压 `.tar.zst`。
|
||||
- 新增真实 Vulkan 1.3 能力探测与显卡兼容性分级:启动器与 `reims-go doctor` 直接通过 `vulkan-1.dll` 核验 Vulkan 版本、PCI ID 与必需扩展,自动标记不满足门槛的老显卡及 Windows 下存在上游黑屏/设备丢失风险的 AMD Vega/Polaris([#4](https://github.com/Nwflower/Reims-Go/issues/4))与 RX 6600 XT 型号,并在向导与设置页支持一键改用 `VMware SVGA`。
|
||||
- 修复 `ClassifyGPU` 对 AMD 核显(`AMD Radeon Graphics` / `680M/780M/890M` / `Vega`)与 Intel Core Ultra 集成 Arc 显卡的识别,过滤已失效的注册表 ICD 路径;新建虚拟机默认显卡改为 `auto`,避免升级显卡驱动后因 `DriverStore` 路径变化导致配置失效。
|
||||
- 启动虚拟机前预先检查 WHPX 虚拟化平台状态,未开启虚拟化时给出明确中文/英文指引,不再因 QEMU 返回 `-ENOSPC` 误报磁盘空间不足;同时识别启动日志中的 `ERROR_DEVICE_LOST` 与 Vulkan 门槛拒绝并在排障包中记录 GPU 诊断结论。
|
||||
|
||||
## v0.2.7 — 2026-11-29
|
||||
|
||||
### 新功能
|
||||
|
||||
- 全新插件系统上线:新增独立「插件」页面与 `reims-go plugin` 命令行工具,支持内置扩展实时启停、本地插件包导入、开发者目录热重载与安全模式恢复(`--safe-mode`)。
|
||||
- 新增可选内置插件「虚拟机窗口安装引导」(`builtin.install-guide`,来自 [#3](https://github.com/Nwflower/Reims-Go/pull/3)):在虚拟机窗口旁悬浮展示离线安装、在线恢复与内置恢复分步引导,支持一键键入命令、退出恢复模式并重启续接、折叠及跟随明暗主题;停用后零残留回退为主界面内置恢复卡片。
|
||||
- 新增应用内自动更新与独立「关于」页面:自动检查正式版更新,支持在侧栏更新卡片或关于页中下载、续传、`SHA256SUMS.txt` 强校验并一键替换重启;原程序若保留发布文件名则自动更新为新版本名称。
|
||||
- 支持主题插件热重载、配色方案编辑器与 UI 契约校验,并支持通过插件扩展多语种语言包。
|
||||
- 首次启动自动跟随系统语言,新增英文 README,标题栏菜单补充交流群入口。
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- 内置核心整合为始终启用的 `builtin.core`(保留 WHPX 降级与 Win10 冷重启排障开关);Guest Tools 传输服务、剪贴板互通、宿主输入服务与窗口安装引导均可独立启停,停用后彻底停止监听与后台钩子。
|
||||
- 修复 Windows 回调泄漏,新增 WebView2 界面健康看门狗与崩溃恢复提示,并加固插件与运行时内部处理逻辑。
|
||||
- 本地化配置校验与 CLI 错误提示,清理文档结构与残留草稿。
|
||||
|
||||
## v0.2.6 — 2026-11-29
|
||||
|
||||
### 新功能
|
||||
|
||||
- 可为每台虚拟机单独指定使用的 CPU 核心(自动、全部核心、性能核、避开低功耗核或自定义),运行中修改立即生效。
|
||||
- 虚拟机停机后可创建、回滚和删除恢复点。
|
||||
- 新增 SSH 快捷操作:记住用户名,一键打开终端、写入 `~/.ssh/config` 或用 VS Code 远程连接。
|
||||
- 运行中可一键把虚拟机窗口带到前台,或复制当前全分辨率截图到剪贴板。
|
||||
- 把文件拖进应用窗口即可直接传到虚拟机的共享文件夹。
|
||||
- 可在标题处直接给虚拟机起一个显示名称,底层目录和命令名保持不变;宽窗口下预览与配置信息并排显示。
|
||||
- 新增标题栏菜单和侧栏折叠(`Ctrl+B`),侧栏虚拟机支持右键菜单,底部状态栏更简洁。
|
||||
- 系统托盘菜单改版:每台虚拟机有独立子菜单和状态圆点,跟随 Windows 浅色/深色主题,截图和后台出错时弹出系统通知。
|
||||
- 侧栏和未截屏预览按 macOS 大版本显示对应图标;「安装包」页按大版本归组并折叠旧版本,加载失败可直接重试。
|
||||
|
||||
### 优化
|
||||
|
||||
- 虚拟机页按状态突出主要操作,并把实时负载、磁盘和 Guest Tools 状态收进摘要区。
|
||||
- 生成 4K 屏幕预览的内存占用大幅下降,删除虚拟机或长时间运行后及时清理后台资源与过期任务。
|
||||
- 界面各页面和弹窗改为按需加载,减少无谓刷新和显卡开销。
|
||||
- 修复空间分布统计,正确计入虚拟机文件以及数据目录中的其余数据。
|
||||
- Reims-Go 本体开源协议由 MIT 变更为 Apache-2.0;发布时同时提供 `.zip` 压缩包和独立 `.exe`。
|
||||
|
||||
## v0.2.5 — 2026-11-29
|
||||
|
||||
### 新功能
|
||||
|
||||
- 运行时下载与更新检查新增 GitCode 国内镜像源,默认自动优先 GitHub 并在不可达时自动切换 GitCode。
|
||||
- 桌面外壳视觉与交互升级:精简 VM 主页为 Studio Display 预览、2×3 图标规格卡、单行连接分组与可一键复制的技术信息;支持日志抽屉顶部拖拽调整高度。
|
||||
- 侧栏「宿主与运行时」改称「内核」,将应用配置拆分为独立「设置」标签页(新增浅色 / 深色 / 跟随系统外观切换)。
|
||||
- 底部状态栏空闲时实时展示宿主机内存占用百分比、可用内存、数据盘剩余空间与运行中虚拟机数量。
|
||||
|
||||
### 优化与修复
|
||||
|
||||
- 内嵌开源 Inter Variable 字体并按 Windows DirectWrite 特性显式映射多字重中文字体栈,修复默认字重偏轻与中英文混排断层问题。
|
||||
- 修复 GitCode API 将 alpha 运行时预发布返回为 `prerelease=false` 导致稳定通道误报新版本的问题。
|
||||
- 遵循 Windows 系统代理配置并在 GitHub API 触发限流时自动回退网页解析,下载检查失败时提供一键重试。
|
||||
- 按实际图形后端(`reims-vgpu` / `vmware-svga`)显示准确的虚拟机窗口快捷键提示。
|
||||
|
||||
## v0.2.4 — 2026-11-29
|
||||
|
||||
### 新功能
|
||||
|
||||
- 分辨率选项新增「全屏」,原来单独的全屏开关并入其中。
|
||||
- HiDPI 分辨率标出实际显示大小,例如「看起来像 1280 × 800」。
|
||||
- 宿主页显示 Windows 处理器计划(程序优先或后台服务),并可一键以管理员身份打开设置。
|
||||
|
||||
### 优化
|
||||
|
||||
- 分辨率推荐按 macOS 实际进入 HiDPI 的条件判断,只列出放得进屏幕的尺寸;进不了 HiDPI 时会说明怎么办。
|
||||
- 虚拟机自己关机或退出后,界面立即显示已停止,不再最多等 5 秒。
|
||||
- 设置页能正确读出已保存的分辨率、显示器数量、VMware SVGA 显卡后端和不限时的关机等待。
|
||||
- 显示器数量改成多块后可以再改回 1。
|
||||
|
||||
## v0.2.3 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 命令行并入 `reims-go.exe`:双击打开界面,带子命令即在终端运行,不再单独提供命令行版。
|
||||
- 从命令行启动的虚拟机交给 Reims-Go 界面托管,界面没开时自动在托盘后台运行,同样有剪贴板、共享目录和 Win10 自动冷重启。
|
||||
- 同时只运行一个 Reims-Go,再次双击会唤出已打开的窗口。
|
||||
- 可把 Windows 本地磁盘只读共享给 macOS,每台虚拟机单独开启,默认关闭。
|
||||
|
||||
### 优化
|
||||
|
||||
- 虚拟机页面在后台查询虚拟机状态的次数减少约八成。
|
||||
- 屏幕缩略图生成更快、改为每 15 秒刷新,虚拟机窗口在前台时暂停截图,减少对虚拟机的打扰。
|
||||
- 命令行启动失败时直接显示原因。
|
||||
|
||||
## v0.2.2 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- Guest Tools 2.0:支持图片剪贴板,共享目录可直接挂载到 macOS。
|
||||
- 可向虚拟机发送中文和 emoji,宿主机输入法也能直接输入到虚拟机。
|
||||
- 系统托盘驻留,关闭窗口后最小化到托盘,可从托盘启停虚拟机。
|
||||
- 一键开关 macOS 防休眠。
|
||||
- 详情页实时显示虚拟机的 CPU、内存、磁盘占用和运行时长。
|
||||
- 详情页显示虚拟机屏幕缩略图。
|
||||
- 按显示器分辨率和缩放推荐 HiDPI 分辨率。
|
||||
- 可预设 macOS 系统语言,恢复模式和设置助理不再总是英文。
|
||||
- 虚拟磁盘支持停机扩容和回收未用空间。
|
||||
- 可切换音频后端,并检查宿主机的播放和录音设备。
|
||||
- 设置面板改版为 macOS 系统设置风格,改动可逐项撤销。
|
||||
- 运行时候选通道改名为 alpha,每天自动从上游构建。
|
||||
|
||||
### 优化
|
||||
|
||||
- 截取缩略图改用更快的格式,截图时虚拟机的卡顿大幅减少。
|
||||
- 运行中虚拟机的状态识别更准确,相关提示和保护恢复正常。
|
||||
|
||||
## v0.2.1 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 离线装机辅助盘自动完成抹盘和安装命令,装机不用手敲长命令。
|
||||
- 一键进入或退出恢复模式,可挂载离线镜像或下载在线恢复镜像。
|
||||
- Guest Tools:宿主机与 macOS 之间双向剪贴板和共享文件夹。
|
||||
- 已关机的虚拟机可秒级派生出独立副本。
|
||||
- 新建虚拟机时可导入 VMDK 或 RAW 磁盘。
|
||||
- 一键导出已脱敏的排障日志包。
|
||||
- 宿主页显示当前版本并检查更新。
|
||||
|
||||
### 优化
|
||||
|
||||
- 新建虚拟机默认使用 NVMe 磁盘,旧虚拟机可一键升级。
|
||||
- 绑核支持三层大小核,虚拟 CPU 多于性能核时自动避开低功耗核。
|
||||
- Win10 冷重启使用的控制通道只在本机可见,虚拟机内无法访问。
|
||||
- 数据目录在外置盘、网络盘或内存负载过高时给出提示。
|
||||
- 临时文件全部放在数据目录里,不再写入 C 盘。
|
||||
|
||||
## v0.2.0 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 默认用离线安装包装机,装机引导精简为三步。
|
||||
- 新增「安装包」页面,可下载、暂停、续传和删除离线安装包。
|
||||
- 按 Windows 实际可用内存推荐内存大小,新建、修改和启动前都会检查。
|
||||
- 首次启动时先检查 WHPX、显卡和内存,再安装运行时。
|
||||
- 新建助手增加确认页,创建改在后台进行。
|
||||
|
||||
### 优化
|
||||
|
||||
- 宿主页去掉重复信息,运行时合并为一个列表。
|
||||
- 新建时虚拟机重名会提前提示。
|
||||
- 运行时版本列表缓存 10 分钟,避免触发 GitHub 访问次数限制。
|
||||
|
||||
## v0.1.0 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 首个版本:单文件桌面应用,在 Windows x64 上运行带 GPU 加速的 macOS 虚拟机,无需自己编译。
|
||||
- 虚拟机列表、启动和关机、分类设置面板与分步新建助手。
|
||||
- 离线安装包下载,支持暂停和续传。
|
||||
- 运行时在线安装,分稳定版和候选版两个通道。
|
||||
- 宿主机体检,虚拟机启动后自动绑定到性能核。
|
||||
- Win10 上虚拟机内部重启时自动冷重启。
|
||||
@@ -1,21 +1,200 @@
|
||||
MIT License
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Copyright (c) 2026 Reims-Go contributors
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
1. Definitions.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate acts) or agreed
|
||||
to in writing, shall any Contributor be liable to You for damages,
|
||||
including any direct, indirect, special, incidental, or consequential
|
||||
damages of any character arising as a result of this License or out of
|
||||
the use or inability to use the Work (including but not limited to damages
|
||||
for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2026 Reims-Go contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,30 +1,37 @@
|
||||
# Third-Party Notices
|
||||
|
||||
`Reims-Go` itself (Go backend and desktop frontend) is licensed under the MIT
|
||||
License (see `LICENSE`). That license applies to Reims-Go's own code only and
|
||||
is separate from the portable runtime bundle it invokes as an external child
|
||||
process.
|
||||
`Reims-Go` itself (Go backend and desktop frontend) is licensed under the Apache
|
||||
License, Version 2.0 (see `LICENSE`). That license applies to Reims-Go's own code
|
||||
only and is separate from the portable runtime bundle it invokes as an external
|
||||
child process. Local compatibility patches under `patches/` are licensed under
|
||||
terms compatible with their target upstream projects (see `patches/LICENSE`).
|
||||
|
||||
The Reims-Go desktop executable also incorporates open-source Go and frontend
|
||||
libraries (including Wails, React, Radix UI, Lucide, Inter font, Go `golang.org/x`
|
||||
packages, `klauspost/compress`, and `ulikunitz/xz`) under permissive licenses
|
||||
(MIT, BSD, ISC, and SIL OFL 1.1); see `go.mod` and `frontend/package.json` for
|
||||
the complete dependency list.
|
||||
|
||||
The portable runtime bundle (`reims-runtime-win-x64-<commit>.tar.zst`) contains
|
||||
precompiled binaries built from the following upstream open-source projects.
|
||||
Each runtime release ships the matching source package, `NOTICE.md`, and
|
||||
`licenses/` (see `docs/portable-runtime-spec.md` §7):
|
||||
`licenses/` (see `docs/portable-runtime-spec.md` §6):
|
||||
|
||||
1. **reims-vgpu / reims-ctl**
|
||||
- Upstream: https://github.com/steelbrain/reims-vgpu
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
2. **metal2vulkan / metal2vulkan-runtime**
|
||||
- Upstream: https://github.com/steelbrain/metal2vulkan
|
||||
- License: See upstream repository license
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
3. **reims-util**
|
||||
- Upstream: https://github.com/steelbrain/reims-util
|
||||
- License: See upstream repository license
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
4. **QEMU (qemu-reims-vgpu fork)**
|
||||
- Upstream: https://github.com/steelbrain/qemu-reims-vgpu
|
||||
- License: `GPL-2.0-only` / `GPL-2.0-or-later` (and component licenses in QEMU)
|
||||
5. **MSYS2 CLANG64 runtime libraries, libva, Mesa vaon12**
|
||||
- Upstream: https://github.com/msys2/MINGW-packages
|
||||
- License: Respective open-source licenses of each packaged DLL
|
||||
- License: Respective open-source licenses of each packaged DLL (bundled under `licenses/msys2/` in the runtime archive)
|
||||
|
||||
No Apple proprietary files, macOS installers, recovery images, or SMC keys are
|
||||
included in this repository or in any runtime bundle.
|
||||
@@ -0,0 +1,177 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/banner-dark.svg" />
|
||||
<img src="./.github/readme/banner-light.svg" width="440" alt="Reims-Go" />
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<strong>A macOS virtual machine for Windows. GPU-accelerated, ready out of the box.</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/macOS-Tahoe%2026-16182e?logo=apple&logoColor=white" alt="macOS Tahoe 26" />
|
||||
<img src="https://img.shields.io/badge/host-Windows%2010%20%7C%2011-0078D4?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0wIDMuNCA5LjggMnY5LjRIMHptMTEtMS42TDI0IDB2MTEuM0gxMXpNMCAxMi42aDkuOFYyMkwwIDIwLjZ6bTExIDBoMTNWMjRsLTEzLTEuOHoiLz48L3N2Zz4=" alt="Windows 10 | 11" />
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><img src="https://img.shields.io/github/v/release/Nwflower/Reims-Go?label=release&color=3b8cff" alt="release" /></a>
|
||||
<a href="https://github.com/Nwflower/Reims-Go/stargazers"><img src="https://img.shields.io/github/stars/Nwflower/Reims-Go?style=flat&label=stars&logo=github&color=ffb86b" alt="GitHub stars" /></a>
|
||||
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-ff7a9a" alt="license Apache-2.0" /></a>
|
||||
<!-- Go daily list: uncomment after making it; replace %23N with the rank
|
||||
<a href="https://github.com/trending/go?since=daily"><img src="https://img.shields.io/badge/Trending-%23N%20Go%20Repo%20of%20the%20Day-00ADD8?logo=go&logoColor=white" alt="GitHub Trending: Go Repo of the Day" /></a>
|
||||
-->
|
||||
</p>
|
||||
|
||||
<!-- Official Trendshift badge: uncomment once https://trendshift.io/api/badge/repositories/385884 loads
|
||||
<p align="center">
|
||||
<a href="https://trendshift.io/repositories/385884?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-385884" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/385884" alt="Nwflower%2FReims-Go | Trendshift" width="250" height="55"/></a>
|
||||
</p>
|
||||
-->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><strong>Download</strong></a> ·
|
||||
<a href="#quick-start">Quick Start</a> ·
|
||||
<a href="#screenshots">Screenshots</a> ·
|
||||
<a href="./docs/roadmap.md">Roadmap</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="./README.md">简体中文</a> · <strong>English</strong>
|
||||
</p>
|
||||
|
||||
<br />
|
||||
|
||||
<p align="center">
|
||||
<img src="./.github/readme/hero.webp" width="100%" alt="Reims-Go main window showing the VM page in light mode and the Engine page in dark mode" />
|
||||
</p>
|
||||
|
||||
<br />
|
||||
|
||||
Reims-Go is a Windows desktop app for [reims-vgpu](https://github.com/steelbrain/reims-vgpu). Installing the runtime, downloading macOS, creating VMs and using them day to day all happen in one window.
|
||||
|
||||
> Early development. Features and UI will keep changing.
|
||||
|
||||
## Highlights
|
||||
|
||||
- **GPU acceleration**: macOS Metal graphics run on your Windows GPU through Vulkan.
|
||||
- **Nothing to compile**: download one exe and run it. The app installs the runtime for you, with system proxy support and local archive import.
|
||||
- **No typing during install**: installers come straight from Apple. One click in Recovery types the install command, which erases the disk and starts installing.
|
||||
|
||||
Once macOS is running:
|
||||
|
||||
- Clipboard (including images) and shared folders work both ways; drop files on the window to send them to macOS
|
||||
- Type with Windows IMEs and emoji directly
|
||||
- Save a restore point before updates and roll back in one click; clone a stopped VM in seconds
|
||||
- Close the window and it stays in the tray, with clipboard and sharing still working
|
||||
- SSH port forwarding and VS Code Remote-SSH; common tasks also work from the command line
|
||||
|
||||
For everything else, see the [changelog](./CHANGELOG.md).
|
||||
|
||||
## Screenshots
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td width="50%">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/host-dark.webp" />
|
||||
<img src="./.github/readme/host-light.webp" alt="Engine page" />
|
||||
</picture>
|
||||
<p align="center"><sub>Engine</sub></p>
|
||||
</td>
|
||||
<td width="50%">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/vm-dark.webp" />
|
||||
<img src="./.github/readme/vm-light.webp" alt="Virtual machine page" />
|
||||
</picture>
|
||||
<p align="center"><sub>Virtual Machine</sub></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/settings-dark.webp" />
|
||||
<img src="./.github/readme/settings-light.webp" alt="VM settings" />
|
||||
</picture>
|
||||
<p align="center"><sub>VM Settings</sub></p>
|
||||
</td>
|
||||
<td width="50%">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/wizard-dark.webp" />
|
||||
<img src="./.github/readme/wizard-light.webp" alt="New virtual machine wizard" />
|
||||
</picture>
|
||||
<p align="center"><sub>New Virtual Machine</sub></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Requirements
|
||||
|
||||
- Windows 10 / 11 (64-bit) with Intel VT-x or AMD-V enabled in BIOS
|
||||
- A discrete Vulkan GPU, NVIDIA RTX series recommended
|
||||
- 16 GB of RAM or more
|
||||
- 150 GB of free disk space, 60 GB at minimum, ideally not on the system drive
|
||||
|
||||
### Install and set up
|
||||
|
||||
Download `reims-go.exe` from [Releases](https://github.com/Nwflower/Reims-Go/releases) and double-click it.
|
||||
|
||||
1. **First launch**: pick a data folder, check your PC and install the runtime. If virtualization is off, turn it on in one click and restart Windows.
|
||||
2. **Create a VM**: click **+** in the sidebar, choose **Offline installer**, and set CPU, memory and disk size.
|
||||
3. **Install macOS**: start the VM, then click the keyboard icon in Recovery Terminal to type the install command. When Setup Assistant appears, click **Exit recovery mode**.
|
||||
4. **Install Guest Tools**: on the macOS desktop, click **Install…** on the Guest Tools row of the VM page, then run the command it shows in macOS Terminal. Clipboard, shared folders and IME input work after that.
|
||||
|
||||
<details>
|
||||
<summary>Command line</summary>
|
||||
|
||||
Run `reims-go.exe` with no arguments to open the window, or with a subcommand to run it in the terminal:
|
||||
|
||||
```powershell
|
||||
reims-go doctor | Out-Host # Check your PC
|
||||
reims-go runtime fetch | Out-Host # Install the runtime
|
||||
reims-go installer download tahoe | Out-Host # Download an installer (resumable)
|
||||
reims-go vm create macos-tahoe | Out-Host # Create a VM
|
||||
reims-go vm start macos-tahoe | Out-Host # Start the VM
|
||||
reims-go vm stop macos-tahoe | Out-Host # Shut down the VM
|
||||
```
|
||||
|
||||
In PowerShell or cmd, add `| Out-Host` so the terminal waits for the command to finish. `reims-go help` lists every subcommand.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Build from source</summary>
|
||||
|
||||
Requires [Go](https://go.dev/dl/), [Node.js](https://nodejs.org), [pnpm](https://pnpm.io) and [Wails](https://wails.io/docs/gettingstarted/installation):
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/Nwflower/Reims-Go
|
||||
cd Reims-Go
|
||||
wails build
|
||||
```
|
||||
|
||||
The binary is written to `build\bin\reims-go.exe`.
|
||||
|
||||
</details>
|
||||
|
||||
## License & Notice
|
||||
|
||||
- Reims-Go is licensed under [Apache-2.0](./LICENSE). Runtime components such as QEMU ship as separate programs; their licenses are in [`NOTICE.md`](./NOTICE.md), and every runtime release includes the matching source.
|
||||
- Reims-Go contains no Apple system files; installers are downloaded from Apple on your machine. **The macOS license only permits virtualization on Apple hardware**, so assess your own compliance on other hardware. This project is not affiliated with Apple Inc.; macOS is a registered trademark of Apple Inc.
|
||||
|
||||
## Links
|
||||
|
||||
- [LINUX DO](https://linux.do/) — Community forum
|
||||
|
||||
<br />
|
||||
|
||||
## Star History
|
||||
|
||||
<a href="https://www.star-history.com/#Nwflower/Reims-Go&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Nwflower/Reims-Go&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Nwflower/Reims-Go&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Nwflower/Reims-Go&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
@@ -1,15 +1,33 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go">
|
||||
<img src="./assets/logo.png" width="76" height="76" alt="Reims-Go" />
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/banner-dark.svg" />
|
||||
<img src="./.github/readme/banner-light.svg" width="440" alt="Reims-Go" />
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<strong>为 Windows 打造的 macOS 虚拟机。图形加速、开箱即用。</strong>
|
||||
</p>
|
||||
|
||||
<h1 align="center">Reims-Go</h1>
|
||||
|
||||
<p align="center">
|
||||
在 Windows 上开一台带 GPU 加速的 macOS 虚拟机——免编译,开箱即用。
|
||||
<img src="https://img.shields.io/badge/macOS-Tahoe%2026-16182e?logo=apple&logoColor=white" alt="macOS Tahoe 26" />
|
||||
<img src="https://img.shields.io/badge/host-Windows%2010%20%7C%2011-0078D4?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0wIDMuNCA5LjggMnY5LjRIMHptMTEtMS42TDI0IDB2MTEuM0gxMXpNMCAxMi42aDkuOFYyMkwwIDIwLjZ6bTExIDBoMTNWMjRsLTEzLTEuOHoiLz48L3N2Zz4=" alt="Windows 10 | 11" />
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><img src="https://img.shields.io/github/v/release/Nwflower/Reims-Go?label=release&color=3b8cff" alt="release" /></a>
|
||||
<a href="https://github.com/Nwflower/Reims-Go/stargazers"><img src="https://img.shields.io/github/stars/Nwflower/Reims-Go?style=flat&label=stars&logo=github&color=ffb86b" alt="GitHub stars" /></a>
|
||||
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-ff7a9a" alt="license Apache-2.0" /></a>
|
||||
<!-- Go 日榜:上榜后取消注释,把 %23N 改成名次
|
||||
<a href="https://github.com/trending/go?since=daily"><img src="https://img.shields.io/badge/Trending-%23N%20Go%20日榜-00ADD8?logo=go&logoColor=white" alt="GitHub Trending: Go 日榜" /></a>
|
||||
-->
|
||||
</p>
|
||||
|
||||
<!-- Trendshift 官方徽章:https://trendshift.io/api/badge/repositories/385884 能打开后取消注释
|
||||
<p align="center">
|
||||
<a href="https://trendshift.io/repositories/385884?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-385884" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/385884" alt="Nwflower%2FReims-Go | Trendshift" width="250" height="55"/></a>
|
||||
</p>
|
||||
-->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Nwflower/Reims-Go/releases"><strong>下载</strong></a> ·
|
||||
<a href="#快速开始">快速开始</a> ·
|
||||
@@ -17,77 +35,37 @@
|
||||
<a href="./docs/roadmap.md">路线图</a>
|
||||
</p>
|
||||
|
||||
<br />
|
||||
|
||||
<p align="center">
|
||||
<img src="./.github/readme/hero.webp" width="100%" alt="Reims-Go 主窗口:浅色外观下的虚拟机详情页与深色外观下的宿主与运行时页" />
|
||||
<strong>简体中文</strong> · <a href="./README.en.md">English</a>
|
||||
</p>
|
||||
|
||||
<br />
|
||||
|
||||
Reims-Go 是 [reims-vgpu](https://github.com/steelbrain/reims-vgpu) 的 Windows 桌面应用。环境体检、运行时安装、下载 macOS 到创建并管理虚拟机,都在一个窗口里完成。
|
||||
|
||||
> 早期迭代中,功能与界面仍在持续打磨。
|
||||
<p align="center">
|
||||
<img src="./.github/readme/hero.webp" width="100%" alt="Reims-Go 主窗口:浅色外观下的虚拟机页与深色外观下的内核页" />
|
||||
</p>
|
||||
|
||||
<br />
|
||||
|
||||
## 特性
|
||||
Reims-Go 是 [reims-vgpu](https://github.com/steelbrain/reims-vgpu) 的 Windows 桌面应用。装运行时、下载 macOS、建虚拟机和日常使用,都在一个窗口里完成。
|
||||
|
||||
- **开箱即用** — 预编译便携运行时一键在线安装,无需配置 MSYS2、Rust 或本地编译。
|
||||
- **体检与调优** — 一键启用 WHPX、启动前校验提交内存、混合架构智能绑核(P-Core / 避开 LP-E 核),新建默认 NVMe。
|
||||
- **离线装机** — 宿主机直连 Apple 断点续传下载;内置离线辅助盘与「粘贴为键入」,装机无需手敲长命令。
|
||||
- **随时调整** — 运行中即可修改配置并标明生效时机,支持一键进出恢复模式;全部数据留在指定目录,不占 C 盘。
|
||||
- **双端一致** — 浅色 / 深色外观与中英双语,GUI 与命令行共用同一套内核。
|
||||
> 仍在早期迭代,功能和界面会继续调整。
|
||||
|
||||
<br />
|
||||
## 特点
|
||||
|
||||
## 快速开始
|
||||
- **显卡加速**:macOS 的 Metal 图形经 Vulkan 交给 Windows 独显执行。
|
||||
- **免编译**:下载一个 exe 就能用。运行时在应用里一键安装,支持系统代理和本地压缩包导入。
|
||||
- **装机不用敲命令**:安装包直接从 Apple 下载;在恢复模式里点一下,装机命令会自动键入,抹盘和安装随即开始。
|
||||
|
||||
### 环境要求
|
||||
装好之后:
|
||||
|
||||
- Windows 10 / 11(64 位),支持 WHPX 虚拟化
|
||||
- 支持 Vulkan 的独立显卡(推荐 NVIDIA RTX 系列)
|
||||
- 150 GB 以上可用磁盘空间(建议非 C 盘)
|
||||
- 剪贴板(含图片)和共享文件夹与 Windows 互通,文件拖进窗口就能传进 macOS
|
||||
- 中文输入法和 emoji 可以直接输入
|
||||
- 升级系统前留个恢复点,出问题一键回滚;关机的虚拟机能秒级派生副本
|
||||
- 关掉窗口后常驻托盘,剪贴板和共享照常工作
|
||||
- 支持 SSH 端口转发和 VS Code 远程连接,常用操作也能在命令行里完成
|
||||
|
||||
### 安装
|
||||
|
||||
前往 [Releases](https://github.com/Nwflower/Reims-Go/releases) 下载单文件 `reims-go.exe`,双击即可运行。
|
||||
|
||||
<details>
|
||||
<summary>从源码构建</summary>
|
||||
|
||||
需预先安装 [Go](https://go.dev/dl/)、[Node.js](https://nodejs.org)、[pnpm](https://pnpm.io) 与 [Wails](https://wails.io/docs/gettingstarted/installation):
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/Nwflower/Reims-Go
|
||||
cd Reims-Go
|
||||
wails build
|
||||
```
|
||||
|
||||
产物位于 `build\bin\reims-go.exe`。
|
||||
|
||||
</details>
|
||||
|
||||
### 上手步骤
|
||||
|
||||
1. **初始化** — 首次打开按引导选好数据目录、完成宿主机体检(未开 WHPX 可一键启用并重启),在线安装运行时。
|
||||
2. **新建虚拟机** — 点侧边栏 **+**,选择「离线安装包(推荐)」或先在「安装包」页下载镜像,设定 CPU、内存与磁盘。
|
||||
3. **安装 macOS** — 启动后在恢复终端点右侧键盘图标一键键入安装命令,脚本会自动抹盘并完成离线安装;看到「设置助理」后点「退出恢复模式」。
|
||||
4. **日常管理** — 点齿轮图标随时调整设置,或在「更多」菜单中使用「粘贴为键入」与「进入恢复模式」。
|
||||
|
||||
### 命令行
|
||||
|
||||
```powershell
|
||||
reims-go doctor # 环境体检
|
||||
reims-go runtime fetch # 在线安装运行时
|
||||
reims-go installer download tahoe # 下载离线安装包(支持续传)
|
||||
reims-go vm create macos-tahoe # 新建虚拟机
|
||||
reims-go vm start macos-tahoe # 启动虚拟机
|
||||
```
|
||||
|
||||
运行 `reims-go help` 查看全部子命令,加 `--lang en-US` 切换英文输出。
|
||||
|
||||
<br />
|
||||
更多功能见[更新日志](./CHANGELOG.md)。
|
||||
|
||||
## 界面
|
||||
|
||||
@@ -96,16 +74,16 @@ reims-go vm start macos-tahoe # 启动虚拟机
|
||||
<td width="50%">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/host-dark.webp" />
|
||||
<img src="./.github/readme/host-light.webp" alt="宿主与运行时页" />
|
||||
<img src="./.github/readme/host-light.webp" alt="内核页" />
|
||||
</picture>
|
||||
<p align="center"><sub>宿主与运行时</sub></p>
|
||||
<p align="center"><sub>内核</sub></p>
|
||||
</td>
|
||||
<td width="50%">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/readme/vm-dark.webp" />
|
||||
<img src="./.github/readme/vm-light.webp" alt="关于此虚拟机页" />
|
||||
<img src="./.github/readme/vm-light.webp" alt="虚拟机页" />
|
||||
</picture>
|
||||
<p align="center"><sub>关于此虚拟机</sub></p>
|
||||
<p align="center"><sub>虚拟机</sub></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -126,13 +104,74 @@ reims-go vm start macos-tahoe # 启动虚拟机
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
## 快速开始
|
||||
|
||||
### 环境要求
|
||||
|
||||
- Windows 10 / 11(64 位),BIOS 里已开启 Intel VT-x 或 AMD-V
|
||||
- 支持 Vulkan 的独立显卡,推荐 NVIDIA RTX 系列
|
||||
- 内存 16 GB 以上
|
||||
- 磁盘空间 150 GB 以上,最少 60 GB,最好不放在系统盘
|
||||
|
||||
### 安装与上手
|
||||
|
||||
从 [Releases](https://github.com/Nwflower/Reims-Go/releases) 下载 `reims-go.exe`,双击运行。
|
||||
|
||||
1. **初始化**:按引导选数据目录、检查电脑、安装运行时。虚拟化没开的话可以一键开启,之后重启 Windows。
|
||||
2. **新建虚拟机**:点侧边栏的 **+**,安装来源选「离线安装包」,设好 CPU、内存和磁盘。
|
||||
3. **安装 macOS**:启动虚拟机,在恢复终端里点键盘图标,装机命令自动键入。看到「设置助理」后点「退出恢复模式」。
|
||||
4. **安装 Guest Tools**:进入桌面后,在虚拟机页 Guest Tools 一行点「安装…」,再到 macOS 终端运行页面给出的命令。装好后剪贴板、共享文件夹和中文输入就能用了。
|
||||
|
||||
<details>
|
||||
<summary>命令行</summary>
|
||||
|
||||
不带参数运行 `reims-go.exe` 会打开窗口,带上子命令则在终端里执行:
|
||||
|
||||
```powershell
|
||||
reims-go doctor | Out-Host # 检查电脑环境
|
||||
reims-go runtime fetch | Out-Host # 安装运行时
|
||||
reims-go installer download tahoe | Out-Host # 下载安装包(支持续传)
|
||||
reims-go vm create macos-tahoe | Out-Host # 新建虚拟机
|
||||
reims-go vm start macos-tahoe | Out-Host # 启动虚拟机
|
||||
reims-go vm stop macos-tahoe | Out-Host # 关闭虚拟机
|
||||
```
|
||||
|
||||
在 PowerShell 或 cmd 里要加上 `| Out-Host`,终端才会等命令执行完再返回。`reims-go help` 列出全部子命令。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>从源码构建</summary>
|
||||
|
||||
需要 [Go](https://go.dev/dl/)、[Node.js](https://nodejs.org)、[pnpm](https://pnpm.io) 和 [Wails](https://wails.io/docs/gettingstarted/installation):
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/Nwflower/Reims-Go
|
||||
cd Reims-Go
|
||||
wails build
|
||||
```
|
||||
|
||||
产物在 `build\bin\reims-go.exe`。
|
||||
|
||||
</details>
|
||||
|
||||
## 许可与声明
|
||||
|
||||
- **开源协议**:Reims-Go 本体采用 [MIT](./LICENSE) 协议;独立调用的便携运行时组件及其许可证见 [`NOTICE.md`](./NOTICE.md),每个运行时 Release 均附带对应源码包。
|
||||
- **关于 macOS**:Reims-Go 不包含、不分发任何 Apple 系统文件,安装包由本机直连 Apple 服务器获取。**macOS 软件许可协议仅允许在 Apple 硬件上虚拟化**,在非 Apple 硬件上使用请自行评估合规责任。本项目与 Apple Inc. 无关,macOS 为 Apple Inc. 注册商标。
|
||||
- Reims-Go 采用 [Apache-2.0](./LICENSE) 协议。运行时里的 QEMU 等组件作为独立程序随附,许可证见 [`NOTICE.md`](./NOTICE.md),每个运行时 Release 都附带对应源码。
|
||||
- Reims-Go 不包含、不分发任何 Apple 系统文件,安装包由本机直接从 Apple 下载。**macOS 软件许可协议只允许在 Apple 硬件上虚拟化**,在其他硬件上使用请自行评估。本项目与 Apple Inc. 无关,macOS 是 Apple Inc. 的注册商标。
|
||||
|
||||
## 友情链接
|
||||
|
||||
- [LINUX DO](https://linux.do/) — 新的理想型社区
|
||||
|
||||
<br />
|
||||
|
||||
## Star History
|
||||
|
||||
<a href="https://www.star-history.com/#Nwflower/Reims-Go&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Nwflower/Reims-Go&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Nwflower/Reims-Go&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Nwflower/Reims-Go&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
@@ -1,726 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/config"
|
||||
"github.com/Nwflower/reims-go/internal/driver/reims"
|
||||
"github.com/Nwflower/reims-go/internal/guesttools"
|
||||
"github.com/Nwflower/reims-go/internal/host"
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
"github.com/Nwflower/reims-go/internal/qmp"
|
||||
rt "github.com/Nwflower/reims-go/internal/runtime"
|
||||
"github.com/Nwflower/reims-go/internal/version"
|
||||
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
type PendingChange struct {
|
||||
Field string `json:"field"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type AppState struct {
|
||||
Config *config.Config `json:"config"`
|
||||
Host host.Report `json:"host"`
|
||||
Optimizations []host.Optimization `json:"optimizations"`
|
||||
Runtimes []rt.Installed `json:"runtimes"`
|
||||
ActiveRuntime *rt.Installed `json:"active_runtime,omitempty"`
|
||||
VMs []reims.VMListItem `json:"vms"`
|
||||
Transitions map[string]string `json:"transitions"`
|
||||
PendingChanges map[string][]PendingChange `json:"pending_changes"`
|
||||
// NeedsSetup is true on first launch, until a data folder is chosen (setup.go).
|
||||
NeedsSetup bool `json:"needs_setup"`
|
||||
AppVersion string `json:"app_version"`
|
||||
}
|
||||
|
||||
type rebootWatcherEntry struct {
|
||||
id uint64
|
||||
cancel context.CancelFunc
|
||||
}
|
||||
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
mu sync.Mutex
|
||||
cfg *config.Config
|
||||
transitions map[string]string
|
||||
pendingChanges map[string][]PendingChange
|
||||
rebootWatchers map[string]rebootWatcherEntry
|
||||
nextWatcherID uint64
|
||||
stopPoll context.CancelFunc
|
||||
guestTools *guesttools.Server
|
||||
recentLogs []string
|
||||
needsSetup bool
|
||||
}
|
||||
|
||||
func NewApp() *App {
|
||||
cfg, needsSetup, err := config.Resolve()
|
||||
if err != nil {
|
||||
cfg = config.Default()
|
||||
}
|
||||
return &App{
|
||||
cfg: cfg,
|
||||
needsSetup: needsSetup,
|
||||
transitions: make(map[string]string),
|
||||
pendingChanges: make(map[string][]PendingChange),
|
||||
rebootWatchers: make(map[string]rebootWatcherEntry),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
pollCtx, cancel := context.WithCancel(ctx)
|
||||
a.stopPoll = cancel
|
||||
go a.registerExistingGuestTools(pollCtx)
|
||||
go a.pollVMs(pollCtx)
|
||||
}
|
||||
|
||||
func (a *App) shutdown(ctx context.Context) {
|
||||
if a.stopPoll != nil {
|
||||
a.stopPoll()
|
||||
}
|
||||
tasks.cancelAll()
|
||||
stopAllVMMonitors()
|
||||
a.mu.Lock()
|
||||
for name, entry := range a.rebootWatchers {
|
||||
entry.cancel()
|
||||
delete(a.rebootWatchers, name)
|
||||
}
|
||||
gt := a.guestTools
|
||||
a.mu.Unlock()
|
||||
if gt != nil {
|
||||
shutCtx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
_ = gt.Close(shutCtx)
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) pollVMs(ctx context.Context) {
|
||||
ticker := time.NewTicker(2 * time.Second)
|
||||
defer ticker.Stop()
|
||||
// Cache static hybrid P-core mask once instead of querying host every tick.
|
||||
a.mu.Lock()
|
||||
initRoot := a.cfg.DataRoot
|
||||
a.mu.Unlock()
|
||||
cachedHost := host.Inspect(initRoot)
|
||||
var lastSig string
|
||||
pinnedPIDs := make(map[int]bool)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
vms, err := a.listVMsInternal(ctx)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
type pinCandidate struct {
|
||||
name string
|
||||
pid int
|
||||
}
|
||||
var toPin []pinCandidate
|
||||
a.mu.Lock()
|
||||
loc := a.cfg.Locale
|
||||
autoPin := a.cfg.AutoPinPCores
|
||||
var b strings.Builder
|
||||
for _, vm := range vms {
|
||||
if tr, ok := a.transitions[vm.Name]; ok {
|
||||
if (tr == "starting" && vm.State == "running") || (tr == "stopping" && vm.State == "stopped") {
|
||||
delete(a.transitions, vm.Name)
|
||||
if vm.State == "stopped" {
|
||||
delete(a.pendingChanges, vm.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
if autoPin && vm.State == "running" && vm.PID != nil && *vm.PID > 0 && !pinnedPIDs[*vm.PID] {
|
||||
if cachedHost.HasHybridCores && cachedHost.PCoreMask > 0 {
|
||||
pinnedPIDs[*vm.PID] = true
|
||||
toPin = append(toPin, pinCandidate{name: vm.Name, pid: *vm.PID})
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(&b, "%s:%s:%s;", vm.Name, vm.State, a.transitions[vm.Name])
|
||||
}
|
||||
sig := b.String()
|
||||
a.mu.Unlock()
|
||||
for _, cand := range toPin {
|
||||
vmCPUs := 0
|
||||
if c, cerr := a.client(); cerr == nil {
|
||||
if det, derr := c.Show(ctx, cand.name); derr == nil {
|
||||
vmCPUs = det.CPUs
|
||||
}
|
||||
}
|
||||
plan := host.SelectSafeAffinity(cachedHost, vmCPUs)
|
||||
switch plan.Mode {
|
||||
case "all":
|
||||
if loc == i18n.ZhCN {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] 跳过绑核:虚拟机配置了 %d vCPU,超过可用安全绑定线程上限(P 核仅 %d 线程),已使用全部核心避免超售卡顿",
|
||||
vmCPUs, plan.PThreads))
|
||||
} else {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] Skipped CPU pinning: VM has %d vCPUs, exceeding safe headroom (only %d P-core threads); using all host CPUs to avoid spinlock stall",
|
||||
vmCPUs, plan.PThreads))
|
||||
}
|
||||
continue
|
||||
case "non_lpe":
|
||||
if err := host.PinProcessToPCores(uint32(cand.pid), plan.Mask); err == nil {
|
||||
if loc == i18n.ZhCN {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] 虚拟机配置了 %d vCPU(超过 %d 个 P 核线程),已自动将 QEMU (PID %d) 绑定到 P+E 核(%d 核 / %d 线程,掩码 %s;仅排除 %d 个慢速 LP-E 核)",
|
||||
vmCPUs, plan.PThreads, cand.pid, plan.CoreCount, plan.ThreadCount, plan.MaskHex, cachedHost.LPECoreCount))
|
||||
} else {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] VM has %d vCPUs (exceeds %d P-core threads); pinned QEMU (PID %d) to P+E cores (%d cores / %d logical CPUs, mask %s; %d slow LP-E cores excluded)",
|
||||
vmCPUs, plan.PThreads, cand.pid, plan.CoreCount, plan.ThreadCount, plan.MaskHex, cachedHost.LPECoreCount))
|
||||
}
|
||||
} else {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] Warning: P+E core pinning failed for PID %d: %v", cand.pid, err))
|
||||
}
|
||||
default:
|
||||
if err := host.PinProcessToPCores(uint32(cand.pid), plan.Mask); err == nil {
|
||||
if loc == i18n.ZhCN {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] 已将 QEMU (PID %d) 绑定到 %d 个 P 核(%d 个逻辑线程,掩码 %s;未占用 %d 个 E 核)",
|
||||
cand.pid, plan.CoreCount, plan.ThreadCount, plan.MaskHex, cachedHost.ECoreCount+cachedHost.LPECoreCount))
|
||||
} else {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] Pinned QEMU (PID %d) to %d P-cores (%d logical CPUs, mask %s; %d E/LP-E cores excluded)",
|
||||
cand.pid, plan.CoreCount, plan.ThreadCount, plan.MaskHex, cachedHost.ECoreCount+cachedHost.LPECoreCount))
|
||||
}
|
||||
} else {
|
||||
a.emitLog(cand.name, fmt.Sprintf("[CPU] Warning: P-core pinning failed for PID %d: %v", cand.pid, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
if sig != lastSig {
|
||||
lastSig = sig
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) client() (*reims.Client, error) {
|
||||
a.mu.Lock()
|
||||
cfg := a.cfg
|
||||
a.mu.Unlock()
|
||||
active, err := rt.ResolveActive(cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s", i18n.T(cfg.Locale, "err.runtime_not_installed"))
|
||||
}
|
||||
return reims.NewClient(cfg, *active), nil
|
||||
}
|
||||
|
||||
func (a *App) listVMsInternal(ctx context.Context) ([]reims.VMListItem, error) {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.List(ctx)
|
||||
}
|
||||
|
||||
func (a *App) emitLog(source, line string) {
|
||||
redacted := reims.RedactLogLine(line)
|
||||
ts := time.Now().Format("15:04:05")
|
||||
a.mu.Lock()
|
||||
a.recentLogs = append(a.recentLogs, fmt.Sprintf("%s [%s] %s", ts, source, redacted))
|
||||
if len(a.recentLogs) > 1000 {
|
||||
a.recentLogs = a.recentLogs[len(a.recentLogs)-1000:]
|
||||
}
|
||||
a.mu.Unlock()
|
||||
if a.ctx == nil {
|
||||
return
|
||||
}
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:log", map[string]string{
|
||||
"ts": ts,
|
||||
"source": source,
|
||||
"line": redacted,
|
||||
})
|
||||
}
|
||||
|
||||
type logWriter struct {
|
||||
emit func(string)
|
||||
buf strings.Builder
|
||||
}
|
||||
|
||||
func (w *logWriter) Write(p []byte) (int, error) {
|
||||
sc := bufio.NewScanner(strings.NewReader(string(p)))
|
||||
for sc.Scan() {
|
||||
line := strings.TrimSpace(sc.Text())
|
||||
if line != "" {
|
||||
w.emit(line)
|
||||
}
|
||||
}
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (a *App) GetState() AppState {
|
||||
a.mu.Lock()
|
||||
cfgCopy := *a.cfg
|
||||
trCopy := make(map[string]string, len(a.transitions))
|
||||
for k, v := range a.transitions {
|
||||
trCopy[k] = v
|
||||
}
|
||||
pcCopy := make(map[string][]PendingChange, len(a.pendingChanges))
|
||||
for k, v := range a.pendingChanges {
|
||||
pcCopy[k] = append([]PendingChange(nil), v...)
|
||||
}
|
||||
needsSetup := a.needsSetup
|
||||
a.mu.Unlock()
|
||||
|
||||
rep := host.Inspect(cfgCopy.DataRoot)
|
||||
runtimes, _ := rt.List(&cfgCopy)
|
||||
active, _ := rt.ResolveActive(&cfgCopy)
|
||||
vms, _ := a.listVMsInternal(context.Background())
|
||||
|
||||
var activePatches []string
|
||||
if active != nil {
|
||||
for _, p := range active.Manifest.Patches {
|
||||
activePatches = append(activePatches, p.Name)
|
||||
}
|
||||
}
|
||||
opts := host.EvaluateOptimizations(rep, activePatches)
|
||||
|
||||
return AppState{
|
||||
Config: &cfgCopy,
|
||||
Host: rep,
|
||||
Optimizations: opts,
|
||||
Runtimes: runtimes,
|
||||
ActiveRuntime: active,
|
||||
VMs: vms,
|
||||
Transitions: trCopy,
|
||||
PendingChanges: pcCopy,
|
||||
NeedsSetup: needsSetup,
|
||||
AppVersion: version.Version,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) GetVMDetail(name string) (reims.VMDetail, error) {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return reims.VMDetail{}, err
|
||||
}
|
||||
d, err := c.Show(context.Background(), name)
|
||||
if err != nil {
|
||||
return d, err
|
||||
}
|
||||
d.RecoveryMode = isRecoveryModeActive(d)
|
||||
a.populateGuestToolsDetail(&d)
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (a *App) SetLocale(raw string) error {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
a.cfg.Locale = i18n.Normalize(raw)
|
||||
return config.Save("", a.cfg)
|
||||
}
|
||||
|
||||
func (a *App) SetAutoPinPCores(enabled bool) error {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
a.cfg.AutoPinPCores = enabled
|
||||
return config.Save("", a.cfg)
|
||||
}
|
||||
|
||||
func (a *App) SetDataRoot(dir string) error {
|
||||
dir = strings.TrimSpace(dir)
|
||||
if dir == "" {
|
||||
return fmt.Errorf("data root cannot be empty")
|
||||
}
|
||||
a.mu.Lock()
|
||||
a.cfg.DataRoot = dir
|
||||
err := a.cfg.EnsureDirs()
|
||||
if err == nil {
|
||||
err = config.Save("", a.cfg)
|
||||
}
|
||||
if err == nil {
|
||||
err = config.SaveLocation(dir)
|
||||
}
|
||||
a.mu.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) PickDirectory(title string) (string, error) {
|
||||
return wailsRuntime.OpenDirectoryDialog(a.ctx, wailsRuntime.OpenDialogOptions{
|
||||
Title: title,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) PickFile(title, pattern string) (string, error) {
|
||||
opts := wailsRuntime.OpenDialogOptions{Title: title}
|
||||
if pattern != "" {
|
||||
opts.Filters = []wailsRuntime.FileFilter{{DisplayName: pattern, Pattern: pattern}}
|
||||
}
|
||||
return wailsRuntime.OpenFileDialog(a.ctx, opts)
|
||||
}
|
||||
|
||||
func (a *App) EnableWHPX() error {
|
||||
a.emitLog("host", "Requesting Windows UAC to enable HypervisorPlatform...")
|
||||
return host.EnableWHPXElevated()
|
||||
}
|
||||
|
||||
func (a *App) InstallRuntimeArchive(archivePath string) (*rt.Installed, error) {
|
||||
a.mu.Lock()
|
||||
cfg := a.cfg
|
||||
a.mu.Unlock()
|
||||
a.emitLog("runtime", "Installing portable runtime: "+archivePath)
|
||||
inst, err := rt.InstallFromArchive(cfg, archivePath)
|
||||
if err != nil {
|
||||
a.emitLog("runtime", "Install failed: "+err.Error())
|
||||
return nil, err
|
||||
}
|
||||
a.mu.Lock()
|
||||
a.cfg.ActiveRuntime = inst.Commit
|
||||
_ = config.Save("", a.cfg)
|
||||
a.mu.Unlock()
|
||||
a.emitLog("runtime", fmt.Sprintf("Runtime %s installed & activated -> %s", inst.Commit, inst.Dir))
|
||||
return inst, nil
|
||||
}
|
||||
|
||||
func (a *App) UseRuntime(commit string) error {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
a.cfg.ActiveRuntime = commit
|
||||
return config.Save("", a.cfg)
|
||||
}
|
||||
|
||||
func (a *App) ValidateCreate(opts reims.CreateOpts) []reims.ValidationIssue {
|
||||
a.mu.Lock()
|
||||
root := a.cfg.DataRoot
|
||||
a.mu.Unlock()
|
||||
issues := reims.ValidateCreate(opts, host.Inspect(root))
|
||||
// reims-ctl refuses a name already registered; say so before the create runs.
|
||||
if vms, err := a.listVMsInternal(context.Background()); err == nil {
|
||||
for _, vm := range vms {
|
||||
if strings.EqualFold(vm.Name, strings.TrimSpace(opts.Name)) {
|
||||
issues = append(issues, reims.ValidationIssue{Field: "name", Code: "name_taken", Message: "A VM named " + vm.Name + " already exists"})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return issues
|
||||
}
|
||||
|
||||
func (a *App) PreviewCreate(opts reims.CreateOpts) (string, error) {
|
||||
return reims.PreviewCreateCommand(opts)
|
||||
}
|
||||
|
||||
func (a *App) CreateVM(opts reims.CreateOpts) error {
|
||||
return a.createVMFlow(opts)
|
||||
}
|
||||
|
||||
func (a *App) ValidateSet(opts reims.SetOpts) ([]reims.ValidationIssue, error) {
|
||||
cur, err := a.GetVMDetail(opts.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.mu.Lock()
|
||||
root := a.cfg.DataRoot
|
||||
a.mu.Unlock()
|
||||
return reims.ValidateSet(opts, cur, host.Inspect(root)), nil
|
||||
}
|
||||
|
||||
func (a *App) ApplyVMSettings(opts reims.SetOpts) error {
|
||||
cur, err := a.GetVMDetail(opts.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.mu.Lock()
|
||||
root := a.cfg.DataRoot
|
||||
a.mu.Unlock()
|
||||
if issues := reims.ValidateSet(opts, cur, host.Inspect(root)); len(issues) > 0 {
|
||||
return fmt.Errorf("%s", issues[0].Message)
|
||||
}
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w := &logWriter{emit: func(line string) { a.emitLog(opts.Name, line) }}
|
||||
if err := c.Set(context.Background(), opts, w, w); err != nil {
|
||||
a.emitLog(opts.Name, "Set error: "+err.Error())
|
||||
return err
|
||||
}
|
||||
if cur.State == "running" {
|
||||
var diffs []PendingChange
|
||||
if opts.CPUs > 0 && opts.CPUs != cur.CPUs {
|
||||
diffs = append(diffs, PendingChange{Field: "cpus", From: fmt.Sprintf("%d", cur.CPUs), To: fmt.Sprintf("%d", opts.CPUs)})
|
||||
}
|
||||
if opts.Memory != "" && !strings.EqualFold(opts.Memory, cur.Memory) {
|
||||
diffs = append(diffs, PendingChange{Field: "memory", From: cur.Memory, To: opts.Memory})
|
||||
}
|
||||
if opts.Resolution != "" && opts.Resolution != cur.Resolution {
|
||||
diffs = append(diffs, PendingChange{Field: "resolution", From: cur.Resolution, To: opts.Resolution})
|
||||
}
|
||||
if opts.GPU != "" && opts.GPU != cur.GPU {
|
||||
diffs = append(diffs, PendingChange{Field: "gpu", From: cur.GPU, To: opts.GPU})
|
||||
}
|
||||
if len(diffs) > 0 {
|
||||
a.mu.Lock()
|
||||
a.pendingChanges[opts.Name] = append(a.pendingChanges[opts.Name], diffs...)
|
||||
a.mu.Unlock()
|
||||
}
|
||||
}
|
||||
a.emitLog(opts.Name, "Updated VM settings for "+opts.Name)
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) needsColdRebootWorkaround() bool {
|
||||
a.mu.Lock()
|
||||
root := a.cfg.DataRoot
|
||||
a.mu.Unlock()
|
||||
return host.Inspect(root).NeedsColdRebootWorkaround
|
||||
}
|
||||
|
||||
func (a *App) cancelRebootWatcher(name string) {
|
||||
a.mu.Lock()
|
||||
if entry, ok := a.rebootWatchers[name]; ok {
|
||||
entry.cancel()
|
||||
delete(a.rebootWatchers, name)
|
||||
}
|
||||
a.mu.Unlock()
|
||||
}
|
||||
|
||||
func (a *App) watchWin10ColdReboot(name, qmpAddr string) {
|
||||
a.cancelRebootWatcher(name)
|
||||
baseCtx := a.ctx
|
||||
if baseCtx == nil {
|
||||
baseCtx = context.Background()
|
||||
}
|
||||
watchCtx, cancel := context.WithCancel(baseCtx)
|
||||
a.mu.Lock()
|
||||
a.nextWatcherID++
|
||||
myID := a.nextWatcherID
|
||||
a.rebootWatchers[name] = rebootWatcherEntry{id: myID, cancel: cancel}
|
||||
a.mu.Unlock()
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
cancel()
|
||||
a.mu.Lock()
|
||||
if cur, ok := a.rebootWatchers[name]; ok && cur.id == myID {
|
||||
delete(a.rebootWatchers, name)
|
||||
}
|
||||
a.mu.Unlock()
|
||||
}()
|
||||
|
||||
reason, err := qmp.WatchShutdownReason(watchCtx, qmpAddr)
|
||||
if err != nil {
|
||||
if watchCtx.Err() == nil {
|
||||
a.emitLog(name, "Win10 WHPX cold-reboot monitor disconnected: "+err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
if reason != "guest-reset" {
|
||||
if reason != "" {
|
||||
a.emitLog(name, "Win10 WHPX cold-reboot: VM exited ("+reason+"), not restarting")
|
||||
}
|
||||
return
|
||||
}
|
||||
a.mu.Lock()
|
||||
tr := a.transitions[name]
|
||||
a.mu.Unlock()
|
||||
if tr == "stopping" {
|
||||
return
|
||||
}
|
||||
|
||||
a.emitLog(name, "Win10 WHPX cold-reboot: guest requested reboot (guest-reset), restarting in a fresh Hyper-V partition...")
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
a.emitLog(name, "Win10 WHPX cold-reboot aborted: "+err.Error())
|
||||
return
|
||||
}
|
||||
// Wait briefly for QEMU to finish exiting cleanly under -no-reboot.
|
||||
deadline := time.Now().Add(12 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
if watchCtx.Err() != nil {
|
||||
return
|
||||
}
|
||||
vms, err := c.List(watchCtx)
|
||||
if err == nil {
|
||||
stopped := false
|
||||
for _, vm := range vms {
|
||||
if vm.Name == name && vm.State == "stopped" {
|
||||
stopped = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if stopped {
|
||||
break
|
||||
}
|
||||
}
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
}
|
||||
if watchCtx.Err() != nil {
|
||||
return
|
||||
}
|
||||
if err := a.StartVM(name); err != nil {
|
||||
a.emitLog(name, "Win10 WHPX cold-reboot start failed: "+err.Error())
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (a *App) StartVM(name string) error {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := a.checkStartMemory(c, name); err != nil {
|
||||
a.emitLog(name, "Start refused: "+err.Error())
|
||||
return err
|
||||
}
|
||||
a.cancelRebootWatcher(name)
|
||||
|
||||
a.mu.Lock()
|
||||
root := a.cfg.DataRoot
|
||||
tmpDir := a.cfg.TempDir()
|
||||
a.mu.Unlock()
|
||||
rep := host.Inspect(root)
|
||||
curDetail, _ := c.Show(context.Background(), name)
|
||||
|
||||
a.syncOfflineHelper(c, name, &curDetail)
|
||||
a.syncGuestTools(c, name, &curDetail)
|
||||
a.syncRecoveryBootPicker(c, name, &curDetail)
|
||||
a.applyProbedWHPXCompat(c, name, rep, &curDetail)
|
||||
var qmpAddr string
|
||||
if rep.NeedsColdRebootWorkaround {
|
||||
sockPath := qmp.RebootSocketPath(curDetail.Directory, tmpDir, name)
|
||||
_ = os.MkdirAll(filepath.Dir(sockPath), 0o755)
|
||||
_ = os.Remove(sockPath)
|
||||
merged := qmp.MergeWin10RebootUnixArgs(curDetail.ExtraArgs, sockPath)
|
||||
if err := c.Set(context.Background(), reims.SetOpts{Name: name, ExtraArgs: &merged}, io.Discard, io.Discard); err != nil {
|
||||
a.emitLog(name, "Win10 cold-reboot extra-args setup skipped: "+err.Error())
|
||||
} else {
|
||||
qmpAddr = "unix:" + sockPath
|
||||
curDetail.ExtraArgs = merged
|
||||
}
|
||||
}
|
||||
|
||||
a.mu.Lock()
|
||||
a.transitions[name] = "starting"
|
||||
delete(a.pendingChanges, name)
|
||||
a.mu.Unlock()
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
|
||||
startAt := time.Now()
|
||||
a.emitStartSummary(name, curDetail, rep, qmpAddr)
|
||||
w := &logWriter{emit: func(line string) { a.emitLog(name, line) }}
|
||||
a.emitLog(name, "Starting "+name+"...")
|
||||
if err := c.StartWithCompat(context.Background(), name, w, w, func(msg string) {
|
||||
a.emitLog(name, msg)
|
||||
}); err != nil {
|
||||
a.mu.Lock()
|
||||
delete(a.transitions, name)
|
||||
a.mu.Unlock()
|
||||
a.emitLog(name, "Start error: "+err.Error())
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
return err
|
||||
}
|
||||
if qmpAddr != "" {
|
||||
a.watchWin10ColdReboot(name, qmpAddr)
|
||||
}
|
||||
a.startVMMonitor(name, curDetail, startAt)
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) StopVM(name string, force bool) error {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.cancelRebootWatcher(name)
|
||||
stopVMMonitor(name)
|
||||
a.mu.Lock()
|
||||
a.transitions[name] = "stopping"
|
||||
a.mu.Unlock()
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
|
||||
w := &logWriter{emit: func(line string) { a.emitLog(name, line) }}
|
||||
a.emitLog(name, fmt.Sprintf("Stopping %s (force=%v)...", name, force))
|
||||
if force {
|
||||
err = c.StopForce(context.Background(), name, w, w)
|
||||
} else {
|
||||
err = c.Stop(context.Background(), name, w, w)
|
||||
}
|
||||
if err != nil {
|
||||
a.mu.Lock()
|
||||
delete(a.transitions, name)
|
||||
a.mu.Unlock()
|
||||
a.emitLog(name, "Stop error: "+err.Error())
|
||||
return err
|
||||
}
|
||||
a.mu.Lock()
|
||||
delete(a.pendingChanges, name)
|
||||
a.mu.Unlock()
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RestartVM(name string) error {
|
||||
if err := a.StopVM(name, false); err != nil {
|
||||
return err
|
||||
}
|
||||
return a.StartVM(name)
|
||||
}
|
||||
|
||||
func (a *App) EjectInstaller(name string) error {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w := &logWriter{emit: func(line string) { a.emitLog(name, line) }}
|
||||
a.emitLog(name, "Ejecting installer from "+name+"...")
|
||||
if err := c.Eject(context.Background(), name, w, w); err != nil {
|
||||
a.emitLog(name, "Eject error: "+err.Error())
|
||||
return err
|
||||
}
|
||||
a.emitLog(name, "Installer ejected.")
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) DeleteVM(name string, keepFiles bool) error {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.cancelRebootWatcher(name)
|
||||
stopVMMonitor(name)
|
||||
w := &logWriter{emit: func(line string) { a.emitLog(name, line) }}
|
||||
a.emitLog(name, fmt.Sprintf("Deleting VM %s (keepFiles=%v)...", name, keepFiles))
|
||||
if err := c.Delete(context.Background(), name, keepFiles, w, w); err != nil {
|
||||
a.emitLog(name, "Delete error: "+err.Error())
|
||||
return err
|
||||
}
|
||||
a.mu.Lock()
|
||||
delete(a.pendingChanges, name)
|
||||
delete(a.transitions, name)
|
||||
a.mu.Unlock()
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
return nil
|
||||
}
|
||||
|
||||
// OpenVMFolder shows the VM's directory in File Explorer.
|
||||
func (a *App) OpenVMFolder(name string) error {
|
||||
d, err := a.GetVMDetail(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if d.Directory == "" {
|
||||
return fmt.Errorf("VM %s has no directory", name)
|
||||
}
|
||||
return host.OpenFolder(d.Directory)
|
||||
}
|
||||
|
||||
func (a *App) ReadVMLogs(name string, serial bool) (string, error) {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return c.ReadLogs(context.Background(), name, serial)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 539 141" width="539" height="141" role="img" aria-label="Reims-Go"><g transform="translate(4 107)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#f4f5fa"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#f4f5fa"/><path d="M133.5 -64.5V-7.5" stroke="#f4f5fa"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#f4f5fa"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#f4f5fa"/><path d="M340.5 -36H358.5" stroke="#5d6382"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 539 141" width="539" height="141" role="img" aria-label="Reims-Go"><g transform="translate(4 107)"><defs><linearGradient id="wm" gradientUnits="userSpaceOnUse" x1="376" y1="0" x2="531" y2="0"><stop offset="0" stop-color="#3b8cff"/><stop offset="0.5" stop-color="#6d5dfc"/><stop offset="1" stop-color="#ff7a9a"/></linearGradient><linearGradient id="wmb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd43b"/><stop offset="1" stop-color="#ff9f0a"/></linearGradient></defs><g fill="none" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5" stroke="#16182e"/><path d="M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93" stroke="#16182e"/><path d="M133.5 -64.5V-7.5" stroke="#16182e"/><circle cx="133.5" cy="-94" r="9" fill="#ff7a9a"/><path d="M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5" stroke="#16182e"/><path d="M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98" stroke="#16182e"/><path d="M340.5 -36H358.5" stroke="#a3a8bf"/><path d="M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01" stroke="url(#wm)"/><path d="M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25" stroke="url(#wm)"/><path d="M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01" stroke="url(#wm)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,327 @@
|
||||
// Command i18ngen compiles and validates the canonical JSON message catalogs
|
||||
// under locales/{zh-CN,en-US}/*.json, enforcing:
|
||||
// - 100% key parity between zh-CN and en-US in every domain
|
||||
// - valid lightweight ICU AST syntax across every entry
|
||||
// - identical {var} placeholder sets between zh-CN, en-US, and optional $params
|
||||
//
|
||||
// Outputs:
|
||||
// - internal/i18n/catalog_gen.go
|
||||
// - frontend/src/i18n/keys.gen.ts
|
||||
// - frontend/src/i18n/domains/{core,vm,wizard,settings,plugins}.gen.ts
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
)
|
||||
|
||||
var (
|
||||
allDomains = []string{"core", "vm", "wizard", "settings", "plugins", "native", "macos-glossary"}
|
||||
goDomains = []string{"native", "macos-glossary", "core"}
|
||||
feEagerDomains = []string{"core", "vm"}
|
||||
feLazyDomains = []string{"wizard", "settings", "plugins"}
|
||||
)
|
||||
|
||||
type parsedEntry struct {
|
||||
Message string
|
||||
Params []string
|
||||
Comment string
|
||||
MaxLength int
|
||||
}
|
||||
|
||||
func main() {
|
||||
root := "."
|
||||
if _, err := os.Stat("locales/zh-CN/core.json"); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: must be run from repository root: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
zhByDomain := make(map[string]map[string]parsedEntry)
|
||||
enByDomain := make(map[string]map[string]parsedEntry)
|
||||
keyOwnerDomain := make(map[string]string)
|
||||
|
||||
var validationErrors []string
|
||||
|
||||
for _, dom := range allDomains {
|
||||
zhPath := filepath.Join(root, "locales", "zh-CN", dom+".json")
|
||||
enPath := filepath.Join(root, "locales", "en-US", dom+".json")
|
||||
|
||||
zhMap, err := readCatalogFile(zhPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: read %s: %v\n", zhPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
enMap, err := readCatalogFile(enPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: read %s: %v\n", enPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for k := range zhMap {
|
||||
if prevDom, exists := keyOwnerDomain[k]; exists {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("duplicate key %q across domains %q and %q", k, prevDom, dom))
|
||||
}
|
||||
keyOwnerDomain[k] = dom
|
||||
if _, ok := enMap[k]; !ok {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] key %q exists in zh-CN but missing in en-US", dom, k))
|
||||
}
|
||||
}
|
||||
for k := range enMap {
|
||||
if _, ok := zhMap[k]; !ok {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] key %q exists in en-US but missing in zh-CN", dom, k))
|
||||
}
|
||||
}
|
||||
|
||||
keys := sortedKeys(zhMap)
|
||||
for _, k := range keys {
|
||||
ze, ok := zhMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
ee, ok := enMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
_, zhVars, zErr := i18n.ParseICU(ze.Message)
|
||||
if zErr != nil {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] zh-CN %q invalid ICU syntax: %v", dom, k, zErr))
|
||||
continue
|
||||
}
|
||||
_, enVars, eErr := i18n.ParseICU(ee.Message)
|
||||
if eErr != nil {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] en-US %q invalid ICU syntax: %v", dom, k, eErr))
|
||||
continue
|
||||
}
|
||||
if !reflect.DeepEqual(zhVars, enVars) {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] placeholder mismatch for %q: zh-CN=%v vs en-US=%v", dom, k, zhVars, enVars))
|
||||
}
|
||||
if len(ze.Params) > 0 {
|
||||
decl := append([]string(nil), ze.Params...)
|
||||
sort.Strings(decl)
|
||||
if !reflect.DeepEqual(decl, zhVars) {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] zh-CN $params %v does not match template vars %v for %q", dom, ze.Params, zhVars, k))
|
||||
}
|
||||
}
|
||||
if len(ee.Params) > 0 {
|
||||
decl := append([]string(nil), ee.Params...)
|
||||
sort.Strings(decl)
|
||||
if !reflect.DeepEqual(decl, enVars) {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("[%s] en-US $params %v does not match template vars %v for %q", dom, ee.Params, enVars, k))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zhByDomain[dom] = zhMap
|
||||
enByDomain[dom] = enMap
|
||||
}
|
||||
|
||||
if len(validationErrors) > 0 {
|
||||
for _, msg := range validationErrors {
|
||||
fmt.Fprintln(os.Stderr, "ERROR:", msg)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := writeGoCatalog(root, zhByDomain, enByDomain); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: write Go catalog: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := writeFrontendCatalogs(root, zhByDomain, enByDomain); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "i18ngen: write frontend catalogs: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("i18ngen: OK")
|
||||
}
|
||||
|
||||
func readCatalogFile(path string) (map[string]parsedEntry, error) {
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var rawMap map[string]json.RawMessage
|
||||
if err := json.Unmarshal(raw, &rawMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make(map[string]parsedEntry, len(rawMap))
|
||||
for k, v := range rawMap {
|
||||
if strings.HasPrefix(k, "$") {
|
||||
continue
|
||||
}
|
||||
var plain string
|
||||
if err := json.Unmarshal(v, &plain); err == nil {
|
||||
out[k] = parsedEntry{Message: plain}
|
||||
continue
|
||||
}
|
||||
var meta struct {
|
||||
Message string `json:"message"`
|
||||
Params []string `json:"$params"`
|
||||
Comment string `json:"$comment"`
|
||||
MaxLength int `json:"$maxLength"`
|
||||
}
|
||||
if err := json.Unmarshal(v, &meta); err != nil {
|
||||
return nil, fmt.Errorf("key %q: %w", k, err)
|
||||
}
|
||||
out[k] = parsedEntry{
|
||||
Message: meta.Message,
|
||||
Params: meta.Params,
|
||||
Comment: meta.Comment,
|
||||
MaxLength: meta.MaxLength,
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func sortedKeys[V any](m map[string]V) []string {
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
func writeGoCatalog(root string, zhByDom, enByDom map[string]map[string]parsedEntry) error {
|
||||
zhMerged := make(map[string]string)
|
||||
enMerged := make(map[string]string)
|
||||
params := make(map[string][]string)
|
||||
|
||||
for _, dom := range goDomains {
|
||||
for k, e := range zhByDom[dom] {
|
||||
zhMerged[k] = e.Message
|
||||
if len(e.Params) > 0 {
|
||||
params[k] = e.Params
|
||||
} else if ee := enByDom[dom][k]; len(ee.Params) > 0 {
|
||||
params[k] = ee.Params
|
||||
} else {
|
||||
_, vars, _ := i18n.ParseICU(e.Message)
|
||||
if len(vars) > 0 {
|
||||
params[k] = vars
|
||||
}
|
||||
}
|
||||
}
|
||||
for k, e := range enByDom[dom] {
|
||||
enMerged[k] = e.Message
|
||||
}
|
||||
}
|
||||
|
||||
keys := sortedKeys(zhMerged)
|
||||
var b bytes.Buffer
|
||||
b.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n\npackage i18n\n\n")
|
||||
b.WriteString("var catalog = map[Locale]map[string]string{\n")
|
||||
b.WriteString("\tZhCN: {\n")
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, "\t\t%q: %q,\n", k, zhMerged[k])
|
||||
}
|
||||
b.WriteString("\t},\n\tEnUS: {\n")
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, "\t\t%q: %q,\n", k, enMerged[k])
|
||||
}
|
||||
b.WriteString("\t},\n}\n\n")
|
||||
|
||||
paramKeys := sortedKeys(params)
|
||||
b.WriteString("var paramOrder = map[string][]string{\n")
|
||||
for _, k := range paramKeys {
|
||||
p := params[k]
|
||||
quoted := make([]string, len(p))
|
||||
for i, name := range p {
|
||||
quoted[i] = fmt.Sprintf("%q", name)
|
||||
}
|
||||
fmt.Fprintf(&b, "\t%q: {%s},\n", k, strings.Join(quoted, ", "))
|
||||
}
|
||||
b.WriteString("}\n")
|
||||
|
||||
return os.WriteFile(filepath.Join(root, "internal/i18n/catalog_gen.go"), b.Bytes(), 0o644)
|
||||
}
|
||||
|
||||
func writeFrontendCatalogs(root string, zhByDom, enByDom map[string]map[string]parsedEntry) error {
|
||||
feDir := filepath.Join(root, "frontend/src/i18n")
|
||||
domDir := filepath.Join(feDir, "domains")
|
||||
if err := os.MkdirAll(domDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Merge macos-glossary into frontend core domain as well so UI components can use official glossary keys.
|
||||
feDomains := []string{"core", "vm", "wizard", "settings", "plugins"}
|
||||
var allFEKeys []string
|
||||
|
||||
for _, dom := range feDomains {
|
||||
zhMap := make(map[string]string)
|
||||
enMap := make(map[string]string)
|
||||
for k, v := range zhByDom[dom] {
|
||||
zhMap[k] = v.Message
|
||||
}
|
||||
for k, v := range enByDom[dom] {
|
||||
enMap[k] = v.Message
|
||||
}
|
||||
if dom == "core" {
|
||||
for k, v := range zhByDom["macos-glossary"] {
|
||||
zhMap[k] = v.Message
|
||||
}
|
||||
for k, v := range enByDom["macos-glossary"] {
|
||||
enMap[k] = v.Message
|
||||
}
|
||||
}
|
||||
|
||||
keys := sortedKeys(zhMap)
|
||||
allFEKeys = append(allFEKeys, keys...)
|
||||
|
||||
isLazy := false
|
||||
for _, ld := range feLazyDomains {
|
||||
if ld == dom {
|
||||
isLazy = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
b.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n")
|
||||
if isLazy {
|
||||
b.WriteString("import { registerBuiltinDomain } from '../runtime'\n\n")
|
||||
} else {
|
||||
b.WriteString("\n")
|
||||
}
|
||||
fmt.Fprintf(&b, "export const %sZh: Record<string, string> = {\n", dom)
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, " %s: %s,\n", tsQuoted(k), tsQuoted(zhMap[k]))
|
||||
}
|
||||
b.WriteString("}\n\n")
|
||||
fmt.Fprintf(&b, "export const %sEn: Record<string, string> = {\n", dom)
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(&b, " %s: %s,\n", tsQuoted(k), tsQuoted(enMap[k]))
|
||||
}
|
||||
b.WriteString("}\n")
|
||||
if isLazy {
|
||||
fmt.Fprintf(&b, "\nregisterBuiltinDomain(%sZh, %sEn)\n", dom, dom)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(filepath.Join(domDir, dom+".gen.ts"), b.Bytes(), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(allFEKeys)
|
||||
var kb bytes.Buffer
|
||||
kb.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n\n")
|
||||
kb.WriteString("export type I18nKey =\n")
|
||||
for i, k := range allFEKeys {
|
||||
sep := ""
|
||||
if i == len(allFEKeys)-1 {
|
||||
sep = ";"
|
||||
}
|
||||
fmt.Fprintf(&kb, " | %s%s\n", tsQuoted(k), sep)
|
||||
}
|
||||
return os.WriteFile(filepath.Join(feDir, "keys.gen.ts"), kb.Bytes(), 0o644)
|
||||
}
|
||||
|
||||
func tsQuoted(s string) string {
|
||||
raw, _ := json.Marshal(s)
|
||||
return string(raw)
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/config"
|
||||
"github.com/Nwflower/reims-go/internal/driver/reims"
|
||||
"github.com/Nwflower/reims-go/internal/host"
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
"github.com/Nwflower/reims-go/internal/installer"
|
||||
"github.com/Nwflower/reims-go/internal/qmp"
|
||||
rt "github.com/Nwflower/reims-go/internal/runtime"
|
||||
"github.com/Nwflower/reims-go/internal/version"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := run(os.Args[1:]); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func run(args []string) error {
|
||||
fs := flag.NewFlagSet("reims-go", flag.ContinueOnError)
|
||||
langFlag := fs.String("lang", "", "UI/CLI language: zh-CN | en-US")
|
||||
dataRootFlag := fs.String("data-root", "", "Override reims-go data root directory")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cfgPath := ""
|
||||
if *dataRootFlag != "" {
|
||||
cfgPath = filepath.Join(*dataRootFlag, "reims-go.json")
|
||||
}
|
||||
cfg, err := config.Load(cfgPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if *dataRootFlag != "" {
|
||||
cfg.DataRoot = *dataRootFlag
|
||||
}
|
||||
if *langFlag != "" {
|
||||
cfg.Locale = i18n.Normalize(*langFlag)
|
||||
}
|
||||
loc := cfg.Locale
|
||||
|
||||
rest := fs.Args()
|
||||
if len(rest) == 0 {
|
||||
printUsage(loc)
|
||||
return nil
|
||||
}
|
||||
|
||||
switch rest[0] {
|
||||
case "doctor":
|
||||
return cmdDoctor(cfg, loc, rest[1:])
|
||||
case "runtime":
|
||||
return cmdRuntime(cfg, loc, rest[1:])
|
||||
case "vm":
|
||||
return cmdVM(cfg, loc, rest[1:])
|
||||
case "installer":
|
||||
return cmdInstaller(cfg, loc, rest[1:])
|
||||
case "version", "-v", "--version":
|
||||
fmt.Printf("reims-go %s\n", version.Version)
|
||||
return nil
|
||||
case "help", "-h", "--help":
|
||||
printUsage(loc)
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("unknown command %q", rest[0])
|
||||
}
|
||||
}
|
||||
|
||||
func printUsage(loc i18n.Locale) {
|
||||
if loc == i18n.ZhCN {
|
||||
fmt.Println("reims-go - Windows 一站式免编译 reims-vgpu 启动器与 CLI")
|
||||
fmt.Println("\n用法:")
|
||||
fmt.Println(" reims-go [--lang zh-CN|en-US] [--data-root DIR] <命令> [参数]")
|
||||
fmt.Println("\n命令:")
|
||||
fmt.Println(" doctor 宿主机环境体检(WHPX / 显卡 ICD / P-E 核 / 磁盘 / 运行时)")
|
||||
fmt.Println(" runtime available 列出 GitHub 上发布的运行时(--candidate 含候选版)")
|
||||
fmt.Println(" runtime fetch [commit] 在线下载、校验并安装运行时(默认最新;Ctrl+C 暂停,再次运行续传)")
|
||||
fmt.Println(" runtime install <archive> 导入并校验本地运行时包(.tar.zst 或 .zip)")
|
||||
fmt.Println(" runtime list 查看已安装的便携运行时版本")
|
||||
fmt.Println(" runtime use <commit> 切换当前激活运行时")
|
||||
fmt.Println(" vm list 列出已创建的虚拟机")
|
||||
fmt.Println(" vm create [options] <name> 创建 macOS 虚拟机(可指定目录/核数/内存/硬盘/显卡)")
|
||||
fmt.Println(" vm set [options] <name> 修改虚拟机配置(下次启动生效)")
|
||||
fmt.Println(" vm start|stop|eject <name> 启动 / 停止 / 弹出安装盘")
|
||||
fmt.Println(" vm type <name> [文本] 把文本按美式键盘敲进运行中的虚拟机(不给文本则读标准输入)")
|
||||
fmt.Println(" installer list 列出 Apple 提供的离线安装包版本(需联网)")
|
||||
fmt.Println(" installer download <版本> 下载离线安装包(如 26.7.1、tahoe、latest;Ctrl+C 暂停,再次运行续传)")
|
||||
fmt.Println(" installer cached 查看已下载的安装包及占用空间")
|
||||
fmt.Println(" installer delete <文件名> 删除已下载的安装包(正在使用或下载中的会被拒绝)")
|
||||
fmt.Println(" version 查看当前版本")
|
||||
return
|
||||
}
|
||||
fmt.Println("reims-go - Portable one-stop reims-vgpu launcher & CLI for Windows")
|
||||
fmt.Println("\nUsage:")
|
||||
fmt.Println(" reims-go [--lang zh-CN|en-US] [--data-root DIR] <command> [args]")
|
||||
fmt.Println("\nCommands:")
|
||||
fmt.Println(" doctor Inspect host (WHPX / Vulkan GPUs / P-E cores / disk / runtime)")
|
||||
fmt.Println(" runtime available List runtimes published on GitHub (--candidate includes candidates)")
|
||||
fmt.Println(" runtime fetch [commit] Download, verify and install a runtime (newest by default; Ctrl+C pauses)")
|
||||
fmt.Println(" runtime install <archive> Verify and install a local runtime package (.tar.zst or .zip)")
|
||||
fmt.Println(" runtime list List installed portable runtimes")
|
||||
fmt.Println(" runtime use <commit> Activate an installed runtime version")
|
||||
fmt.Println(" vm list List virtual machines")
|
||||
fmt.Println(" vm create [options] <name> Create a macOS VM (custom dir, CPUs, RAM, disk size, GPU)")
|
||||
fmt.Println(" vm set [options] <name> Update VM settings (applies on next start)")
|
||||
fmt.Println(" vm start|stop|eject <name> Start / stop / eject installer")
|
||||
fmt.Println(" vm type <name> [text] Type text into a running VM as US-keyboard keys (stdin if no text)")
|
||||
fmt.Println(" installer list List offline macOS installers Apple offers (needs network)")
|
||||
fmt.Println(" installer download <ver> Download an offline installer (26.7.1, tahoe, latest; Ctrl+C pauses, rerun resumes)")
|
||||
fmt.Println(" installer cached List downloaded installers and the space they take")
|
||||
fmt.Println(" installer delete <name> Delete a downloaded installer (refused if in use or downloading)")
|
||||
fmt.Println(" version Show current version")
|
||||
}
|
||||
|
||||
func cmdDoctor(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
fs := flag.NewFlagSet("doctor", flag.ContinueOnError)
|
||||
asJSON := fs.Bool("json", false, "Output JSON")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
rep := host.Inspect(cfg.DataRoot)
|
||||
active, _ := rt.ResolveActive(cfg)
|
||||
|
||||
if *asJSON {
|
||||
payload := map[string]any{
|
||||
"host": rep,
|
||||
"config": cfg,
|
||||
"runtime": active,
|
||||
}
|
||||
enc := json.NewEncoder(os.Stdout)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(payload)
|
||||
}
|
||||
|
||||
fmt.Printf("=== %s ===\n", i18n.T(loc, "doctor.title"))
|
||||
fmt.Printf("%-36s: %s/%s\n", i18n.T(loc, "doctor.os"), rep.OS, rep.Arch)
|
||||
fmt.Printf("%-36s: %dC / %dT\n", i18n.T(loc, "doctor.cpu"), rep.PhysicalCores, rep.LogicalCPUs)
|
||||
if rep.HasHybridCores {
|
||||
fmt.Printf("%-36s: %d cores, mask %s (CPUs %v)\n", i18n.T(loc, "doctor.pcores"), rep.PCoreCount, rep.PCoreMaskHex, rep.PCoreLogicalCPUs)
|
||||
fmt.Printf("%-36s: %d cores (CPUs %v)\n", i18n.T(loc, "doctor.ecores"), rep.ECoreCount, rep.ECoreLogicalCPUs)
|
||||
}
|
||||
if rep.TotalRAMGB > 0 {
|
||||
fmt.Printf("%-36s: %.1f GB total / %.1f GB avail\n", i18n.T(loc, "doctor.ram"), rep.TotalRAMGB, rep.AvailRAMGB)
|
||||
}
|
||||
if rep.FreeDiskGB > 0 {
|
||||
fmt.Printf("%-36s: %.1f GB (%s)\n", i18n.T(loc, "doctor.disk"), rep.FreeDiskGB, rep.DataRoot)
|
||||
}
|
||||
|
||||
whpxKey := "doctor.whpx.unsupported"
|
||||
switch rep.WHPX {
|
||||
case host.WHPXReady:
|
||||
whpxKey = "doctor.whpx.ok"
|
||||
case host.WHPXNoHypervisor:
|
||||
whpxKey = "doctor.whpx.no_hv"
|
||||
case host.WHPXMissing:
|
||||
whpxKey = "doctor.whpx.missing"
|
||||
}
|
||||
fmt.Printf("%-36s: %s\n", i18n.T(loc, "doctor.whpx"), i18n.T(loc, whpxKey))
|
||||
|
||||
if len(rep.GPUs) == 0 {
|
||||
fmt.Printf("%-36s: %s\n", i18n.T(loc, "doctor.gpu"), i18n.T(loc, "doctor.gpu.none"))
|
||||
} else {
|
||||
fmt.Printf("%s:\n", i18n.T(loc, "doctor.gpu"))
|
||||
for _, g := range rep.GPUs {
|
||||
rec := ""
|
||||
if rep.RecommendedGPU != nil && rep.RecommendedGPU.VulkanICD == g.VulkanICD {
|
||||
rec = " [" + i18n.T(loc, "doctor.gpu.recommended") + "]"
|
||||
}
|
||||
fmt.Printf(" - [%s] %s%s\n ICD: %s\n", g.Kind, g.Name, rec, g.VulkanICD)
|
||||
}
|
||||
}
|
||||
|
||||
if active == nil {
|
||||
fmt.Printf("%-36s: %s\n", i18n.T(loc, "doctor.runtime"), i18n.T(loc, "doctor.runtime.none"))
|
||||
} else {
|
||||
fmt.Printf("%-36s: %s\n", i18n.T(loc, "doctor.runtime"), i18n.T(loc, "doctor.runtime.active", active.Commit, active.Dir))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cmdRuntime(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("usage: reims-go runtime <available|fetch|install|list|use>")
|
||||
}
|
||||
switch args[0] {
|
||||
case "install":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go runtime install <archive.tar.zst|zip>")
|
||||
}
|
||||
inst, err := rt.InstallFromArchive(cfg, args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg.ActiveRuntime = inst.Commit
|
||||
if err := config.Save("", cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(i18n.T(loc, "runtime.installed", inst.Commit, inst.Dir))
|
||||
return nil
|
||||
case "list":
|
||||
list, err := rt.List(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(list) == 0 {
|
||||
fmt.Println(i18n.T(loc, "runtime.empty"))
|
||||
return nil
|
||||
}
|
||||
for _, item := range list {
|
||||
mark := " "
|
||||
if item.Active {
|
||||
mark = "*"
|
||||
}
|
||||
fmt.Printf("%s %s %s (%s)\n", mark, item.Commit, item.Manifest.QemuVersion, item.Dir)
|
||||
}
|
||||
return nil
|
||||
case "use":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go runtime use <commit>")
|
||||
}
|
||||
list, err := rt.List(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, item := range list {
|
||||
if item.Commit == args[1] {
|
||||
cfg.ActiveRuntime = item.Commit
|
||||
if err := config.Save("", cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(i18n.T(loc, "runtime.activated", item.Commit))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("runtime %q not found", args[1])
|
||||
case "available":
|
||||
return cmdRuntimeAvailable(cfg, loc, args[1:])
|
||||
case "fetch":
|
||||
return cmdRuntimeFetch(cfg, loc, args[1:])
|
||||
default:
|
||||
return fmt.Errorf("unknown runtime subcommand %q", args[0])
|
||||
}
|
||||
}
|
||||
|
||||
func cmdVM(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("usage: reims-go vm <list|create|set|start|stop|eject|type>")
|
||||
}
|
||||
active, err := rt.ResolveActive(cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s", i18n.T(loc, "err.runtime_not_installed"))
|
||||
}
|
||||
client := reims.NewClient(cfg, *active)
|
||||
ctx := context.Background()
|
||||
|
||||
switch args[0] {
|
||||
case "list":
|
||||
vms, err := client.ListRaw(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(vms) == 0 {
|
||||
fmt.Println(i18n.T(loc, "vm.empty"))
|
||||
return nil
|
||||
}
|
||||
enc := json.NewEncoder(os.Stdout)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(vms)
|
||||
case "create":
|
||||
fs := flag.NewFlagSet("vm create", flag.ContinueOnError)
|
||||
dir := fs.String("dir", "", "Custom VM directory")
|
||||
macos := fs.String("macos", "tahoe", "macOS version (e.g. tahoe)")
|
||||
cpus := fs.Int("cpus", 8, "vCPU count")
|
||||
mem := fs.String("memory", "16G", "RAM size (e.g. 8G, 16G)")
|
||||
diskSize := fs.String("disk-size", "128G", "New disk size (e.g. 128G)")
|
||||
gpu := fs.String("gpu", "auto", "GPU selector or Vulkan ICD JSON path")
|
||||
capture := fs.Bool("capture", false, "Capture keyboard and mouse on window click")
|
||||
logs := fs.Bool("logs", true, "Keep graphics and serial logs")
|
||||
start := fs.Bool("start", false, "Start VM immediately after creation")
|
||||
if err := fs.Parse(args[1:]); err != nil {
|
||||
return err
|
||||
}
|
||||
if fs.NArg() < 1 {
|
||||
return fmt.Errorf("usage: reims-go vm create [flags] <name>")
|
||||
}
|
||||
name := fs.Arg(0)
|
||||
startAfterCreate := *start
|
||||
opts := reims.CreateOpts{
|
||||
Name: name,
|
||||
Dir: *dir,
|
||||
MacOS: *macos,
|
||||
CPUs: *cpus,
|
||||
Memory: *mem,
|
||||
DiskSize: *diskSize,
|
||||
GPU: *gpu,
|
||||
Capture: capture,
|
||||
Logs: logs,
|
||||
Start: false,
|
||||
}
|
||||
existingVMs, _ := client.List(ctx)
|
||||
if removed, rerr := reims.CleanAbortedCreateDir(cfg.XDGDataDir(), opts, existingVMs); rerr == nil && removed != "" {
|
||||
fmt.Fprintf(os.Stderr, "Removed unfinished directory from earlier interrupted create: %s\n", removed)
|
||||
}
|
||||
if installer.ShouldPrefetchOcBinaryData(active.Manifest.UtilCommit, active.Manifest.UtilVersion) {
|
||||
if err := installer.EnsureCachedAsset(ctx, cfg.XDGCacheDir(), installer.OcBinaryDataAsset, nil, nil); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "OpenCore resource pre-fetch skipped (reims-ctl will retry): %v\n", err)
|
||||
}
|
||||
}
|
||||
if err := client.Create(ctx, opts, os.Stdout, os.Stderr); err != nil {
|
||||
return err
|
||||
}
|
||||
if postSet, ok := reims.PostCreateSetOpts(opts); ok {
|
||||
if serr := client.Set(ctx, postSet, os.Stdout, os.Stderr); serr != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: could not apply post-create defaults: %v\n", serr)
|
||||
}
|
||||
}
|
||||
if startAfterCreate {
|
||||
if err := client.StartWithCompat(ctx, name, os.Stdout, os.Stderr, func(msg string) {
|
||||
fmt.Fprintln(os.Stderr, msg)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fmt.Println("\n" + i18n.T(loc, "vm.install_guide.title"))
|
||||
fmt.Println(i18n.T(loc, "vm.install_guide.step1"))
|
||||
fmt.Println(i18n.T(loc, "vm.install_guide.step2"))
|
||||
fmt.Println(i18n.T(loc, "vm.install_guide.step3", name))
|
||||
return nil
|
||||
case "set":
|
||||
fs := flag.NewFlagSet("vm set", flag.ContinueOnError)
|
||||
cpus := fs.Int("cpus", 0, "vCPU count")
|
||||
mem := fs.String("memory", "", "RAM size")
|
||||
gpu := fs.String("gpu", "", "GPU selector or Vulkan ICD JSON")
|
||||
res := fs.String("resolution", "", "Window resolution WIDTHxHEIGHT")
|
||||
if err := fs.Parse(args[1:]); err != nil {
|
||||
return err
|
||||
}
|
||||
if fs.NArg() < 1 {
|
||||
return fmt.Errorf("usage: reims-go vm set [flags] <name>")
|
||||
}
|
||||
return client.Set(ctx, reims.SetOpts{
|
||||
Name: fs.Arg(0),
|
||||
CPUs: *cpus,
|
||||
Memory: *mem,
|
||||
GPU: *gpu,
|
||||
Resolution: *res,
|
||||
}, os.Stdout, os.Stderr)
|
||||
case "start":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go vm start <name>")
|
||||
}
|
||||
return client.StartWithCompat(ctx, args[1], os.Stdout, os.Stderr, func(msg string) {
|
||||
fmt.Fprintln(os.Stderr, msg)
|
||||
})
|
||||
case "stop":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go vm stop <name>")
|
||||
}
|
||||
return client.Stop(ctx, args[1], os.Stdout, os.Stderr)
|
||||
case "eject":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go vm eject <name>")
|
||||
}
|
||||
return client.Eject(ctx, args[1], os.Stdout, os.Stderr)
|
||||
case "type":
|
||||
// Paste as keystrokes: the text argument, else stdin.
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("usage: reims-go vm type <name> [text] (no text: read stdin)")
|
||||
}
|
||||
text := strings.Join(args[2:], " ")
|
||||
if len(args) < 3 {
|
||||
b, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
text = strings.TrimRight(string(b), "\r\n")
|
||||
}
|
||||
d, err := client.Show(ctx, args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := qmp.TypeIntoVM(ctx, d.Directory, text, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(i18n.T(loc, "vm.typed", n))
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("unknown vm subcommand %q", strings.Join(args, " "))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//go:build !windows
|
||||
|
||||
package main
|
||||
|
||||
// attachConsole is only needed for Windows GUI-subsystem builds.
|
||||
func attachConsole() {}
|
||||
@@ -0,0 +1,58 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var (
|
||||
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
procAttachConsole = kernel32.NewProc("AttachConsole")
|
||||
)
|
||||
|
||||
const attachParentProcess = ^uintptr(0) // ATTACH_PARENT_PROCESS, (DWORD)-1
|
||||
|
||||
// attachConsole gives command-line mode somewhere to write. reims-go.exe is
|
||||
// a GUI-subsystem program, so Windows starts it without a console. Handles
|
||||
// the caller passed in (a pipe, a file: how agents and scripts run it) are
|
||||
// kept; only missing ones are pointed at the console of the terminal that
|
||||
// launched it.
|
||||
func attachConsole() {
|
||||
out, errOut, in := usable(os.Stdout), usable(os.Stderr), usable(os.Stdin)
|
||||
if out && errOut && in {
|
||||
return
|
||||
}
|
||||
if r, _, _ := procAttachConsole.Call(attachParentProcess); r == 0 {
|
||||
return // started from Explorer or a shortcut: nowhere to write
|
||||
}
|
||||
if !out || !errOut {
|
||||
if f, err := os.OpenFile("CONOUT$", os.O_RDWR, 0); err == nil {
|
||||
if !out {
|
||||
os.Stdout = f
|
||||
}
|
||||
if !errOut {
|
||||
os.Stderr = f
|
||||
}
|
||||
}
|
||||
}
|
||||
if !in {
|
||||
if f, err := os.OpenFile("CONIN$", os.O_RDWR, 0); err == nil {
|
||||
os.Stdin = f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// usable reports whether f wraps a real handle the caller passed in.
|
||||
func usable(f *os.File) bool {
|
||||
if f == nil {
|
||||
return false
|
||||
}
|
||||
h := syscall.Handle(f.Fd())
|
||||
if h == 0 || h == syscall.InvalidHandle {
|
||||
return false
|
||||
}
|
||||
t, err := syscall.GetFileType(h)
|
||||
return err == nil && t != syscall.FILE_TYPE_UNKNOWN
|
||||
}
|
||||
@@ -1,129 +1,120 @@
|
||||
# 系统架构设计(Architecture)
|
||||
# 系统架构(Architecture)
|
||||
|
||||
> 技术栈:**Go + Wails**(Windows x86-64 优先,GUI 与 CLI 共用核心逻辑)
|
||||
> 技术栈:**Go + Wails(React / TypeScript)**,面向 Windows x86-64,桌面界面与命令行共用同一份 Go 核心。
|
||||
|
||||
## 1. 设计目标与原则
|
||||
---
|
||||
|
||||
1. **零编译上手**:用户拿到单个 `reims-go.exe`(或便携压缩包),首次启动向导自动检测环境 → 下载/导入便携运行时 → 创建并启动 macOS Tahoe。
|
||||
2. **不重复造 `reims-ctl` 的轮子**:`reims-go` 通过受控子进程包装 `reims-ctl`(及 `qemu-img`),避免像手写 PowerShell 启动脚本那样在每次上游变更参数时失效。
|
||||
3. **GUI 与 CLI 同源**:所有核心能力落在 `internal/` Go 包中;既可双击启动 Wails 桌面界面,也可通过 `reims-go <subcommand>` 在终端或 CI 中自动化调用。
|
||||
4. **C 盘零污染**:所有运行时、下载缓存、VM 磁盘与快照严格留在用户选定的 `<DataRoot>` 下。
|
||||
5. **Day-1 中英双语(`zh-CN` / `en-US`)**:前端界面、装机引导文案(默认贴合简体中文 macOS 恢复与安装界面术语,如「磁盘工具 → 抹掉为 APFS → 重新安装 macOS」)与 CLI 输出从第一天即内置双语字典,自动跟随系统语言并支持在界面顶部实时切换(持久化到 `reims-go.json`)。
|
||||
6. **跨平台开发友好**:虽然宿主机运行目标优先面向 Windows x86-64(WHPX),但所有 Windows 原生 API(`WinHvPlatform.dll`、注册表 Vulkan ICD、`GetLogicalProcessorInformationEx`、进程亲和性)严格隔离在 `*_windows.go` 构建标签中,提供 `*_other.go` 桩实现,确保在中文 macOS 开发环境上也能直接进行前端开发、`go build` 与 `go test ./...`。
|
||||
7. **面向未来扩展**:驱动层抽象出 `Engine` 接口,当前实现 `reims`(macOS x86-64 WHPX),预留扩展位以对接后续 `vphone`(iOS)或远程宿主模式。
|
||||
## 1. 设计原则
|
||||
|
||||
## 2. 总体分层架构
|
||||
1. **免编译开箱**:用户仅需单个 `reims-go.exe`,由应用内完成宿主机体检、便携运行时下载、离线安装包获取与虚拟机管理。
|
||||
2. **包装而非重写引擎**:通过受控子进程调用上游 `reims-ctl`、`reims-util` 与 `qemu-img`,不手写易随上游演进失效的 QEMU 启动参数拼接逻辑。
|
||||
3. **GUI 与 CLI 单文件同源**:所有业务逻辑下沉在 `internal/`。无参数启动 Wails 桌面窗口,带子命令(`reims-go <subcommand>`)进入命令行模式,供终端、脚本与自动化工具调用。
|
||||
4. **数据目录隔离**:运行时、下载缓存、虚拟机磁盘、快照与临时文件全部落在用户选定的 `<DataRoot>` 下,不污染系统盘。
|
||||
5. **同构多语言与语言包扩展**:单一事实源分域 JSON 词表(`locales/`)在编译期同时生成 Go 与 TypeScript 类型安全字典,前后端共用轻量 ICU 消息语法与多跳区域回退链;主程序内置 `zh-CN` 与 `en-US`(默认 `auto` 跟随系统并支持热切换),其他语种通过 L1 声明式语言包插件按需扩展并覆盖桌面界面、Win32 原生浮层、系统托盘与命令行。
|
||||
6. **跨平台开发友好**:所有 Windows 原生 API(WHPX、注册表、处理器拓扑、进程亲和性、系统代理、托盘)严格隔离在 `*_windows.go`,提供 `*_other.go` 桩实现,确保非 Windows 环境也能执行 `go build` 与 `go test ./...`。
|
||||
|
||||
---
|
||||
|
||||
## 2. 总体分层
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph UI["交互层"]
|
||||
GUI["Wails 桌面界面\n(React / Vite + WebView2)"]
|
||||
CLI["CLI 子命令\n(reims-go doctor/runtime/vm/clone/exec)"]
|
||||
GUI["Wails 桌面界面\n(frontend/src, React + Vite)"]
|
||||
CLI["命令行模式\n(internal/cli, 与 GUI 同 exe)"]
|
||||
end
|
||||
|
||||
subgraph Core["Go 核心服务层 (internal/)"]
|
||||
Preflight["host/ 环境体检与调优\n(WHPX检测与一键提权、提交内存预检、\nVulkan ICD扫描、P/E核亲和性绑核)"]
|
||||
RuntimeMgr["runtime/ 便携运行时管理\n(Release拉取、SHA256校验、\n原子解压、版本切换与回滚)"]
|
||||
InstallerMgr["installer/ 离线安装包下载管理\n(reims-util --json 宿主机直连下载、\n断点续传、版本目录与缓存清理)"]
|
||||
VMMgr["vm/ 生命周期与工作流\n(向导创建、日志流、eject、\nGolden Image、CoW 派生与快照)"]
|
||||
Control["control/ 带外控制\n(独立QMP客户端、SSH执行、\n截屏与状态监控)"]
|
||||
Orchestration["app/ & vmstart/\n编排、任务、监控、启动准备"]
|
||||
Host["host/ & netproxy/\nWHPX/内存/GPU/大小核体检、代理"]
|
||||
Assets["runtime/ & installer/\n便携运行时与离线安装包管理"]
|
||||
Engine["driver/reims/ & opencore/\nreims-ctl/qemu-img 包装与引导预设"]
|
||||
Bridge["qmp/ guesttools/ thumb/ tray/\n键入/截屏/冷重启、剪贴板/WebDAV、托盘"]
|
||||
end
|
||||
|
||||
subgraph External["外部运行时(独立子进程,全部在 DataRoot 下)"]
|
||||
subgraph External["独立子进程运行时 (<DataRoot>/runtimes/)"]
|
||||
ReimsCtl["reims-ctl.exe + reims-util.exe"]
|
||||
QEMU["qemu-system-x86_64.exe + qemu-img.exe\n(含 reims-graphics-pci + 71 DLLs)"]
|
||||
QEMU["qemu-system-x86_64.exe + qemu-img.exe"]
|
||||
end
|
||||
|
||||
GUI --> Preflight & RuntimeMgr & InstallerMgr & VMMgr & Control
|
||||
CLI --> Preflight & RuntimeMgr & InstallerMgr & VMMgr & Control
|
||||
InstallerMgr --> ReimsCtl
|
||||
VMMgr --> ReimsCtl
|
||||
VMMgr --> QEMU
|
||||
Control --> QEMU
|
||||
GUI --> Orchestration
|
||||
CLI --> Orchestration & Host & Assets & Engine
|
||||
Orchestration --> Host & Assets & Engine & Bridge
|
||||
Assets --> ReimsCtl
|
||||
Engine --> ReimsCtl & QEMU
|
||||
Bridge --> QEMU
|
||||
ReimsCtl --> QEMU
|
||||
```
|
||||
|
||||
## 3. 核心模块设计
|
||||
---
|
||||
|
||||
### 3.1 `internal/host` — 宿主机体检与自动硬件调优
|
||||
- **WHPX 检测与引导**:
|
||||
- 直接加载 `WinHvPlatform.dll` 调用 `WHvGetCapability`(与 `reims-ctl` 逻辑一致),同时查询 `Win32_OptionalFeature`(`HypervisorPlatform` / `VirtualMachinePlatform`),**无需管理员权限即可准确判断**。
|
||||
- 仅在检测到未启用时,GUI 提供「开启 Hypervisor Platform(需要 UAC)」按钮,调用 `ShellExecuteW(..., "runas", ...)` 弹出标准桌面 UAC 并提示重启。
|
||||
- **提交内存(Commit Limit)实时预检(2026-11-28 实测沉淀)**:
|
||||
- 实测 32 GB 宿主在开启日常软件后,剩余可提交内存可能仅 `14.7 GiB`,QEMU 启动时 `CreateFileMapping` 一次性提交 `16G` 直接报错退出。
|
||||
- `internal/host` 通过 `GlobalMemoryStatusEx` 同时采集物理内存与当前可用提交内存(`AvailPageFile`),建机向导默认预留 ≥ 2.5–3 GiB 给宿主机并推荐安全档位(32 GB 宿主默认推荐 `8G–12G`);启动 VM 前若可用提交内存不足,GUI 直接拦截并给出「一键调小内存」或「关闭宿主机程序后重试」。
|
||||
- **GPU / Vulkan ICD 自动选卡**:
|
||||
- 读取注册表显示适配器类键下的 `VulkanDriverName` 与 `DriverDesc`,自动区分独立显卡(NVIDIA/AMD)、核显(Intel UHD)与虚拟显示适配器(ToDesk / GameViewer 等),默认推荐并可一键锁定独显 ICD 传给 `reims-ctl --gpu <json>`。
|
||||
- **Alder Lake / 异构大小核 P-Core 绑核**:
|
||||
- 通过 `GetLogicalProcessorInformationEx(RelationProcessorCore)` 解析 `EfficiencyClass`,计算 P-Core 逻辑 CPU 亲和性掩码(如 i7-12700K 的 `0xFFFF`)。
|
||||
- VM 启动后,自动将对应 `qemu-system-x86_64.exe` 进程设置 `SetProcessAffinityMask` 到 P-Core(支持按 VM 开关)。
|
||||
## 3. 模块与目录职责
|
||||
|
||||
### 3.2 `internal/runtime` — 便携运行时管理
|
||||
- 维护 `<DataRoot>\runtimes\` 下的多版本便携运行时包:
|
||||
- **可选 CDN / 镜像端点 + 环境自动探测**:支持配置多下载端点(`GitHub 官方`、可选国内加速镜像或用户自定义镜像前缀)及「导入本地 `.tar.zst` 包」离线安装;拉取前对已启用端点并行发轻量 `HEAD` 探测(2 秒超时),按延迟自动择优,也允许用户在设置中手动锁定端点;
|
||||
- 校验 `manifest.json` 与 SHA256 后解压至 `<commit>.tmp` 再原子重命名,失败不破坏现有版本;
|
||||
- 统一构造子进程环境(`XDG_*`、`REIMS_CTL_QEMU`、`PATH`),彻底消除对用户全局环境变量与 C 盘的依赖;
|
||||
- **可承接上游未来官方发布**:运行时源采用清单化拉取协议,若上游 `steelbrain/reims-vgpu` 日后提供官方 Windows 预编译包,可直接切换源承接。
|
||||
| 路径 | 职责 |
|
||||
| :--- | :--- |
|
||||
| `main.go`、`console_*.go` | 统一入口:无参数启动 Wails GUI,带子命令进入 `internal/cli`;处理 GUI 子系统下的父控制台句柄接管 |
|
||||
| `internal/app` | Wails 绑定与桌面编排(启停、安装、快照、CoW 派生、磁盘扩容/回收、SSH、脱敏排障包、任务状态、运行监视) |
|
||||
| `internal/vmstart` | GUI 与 CLI 共用的启动前准备:提交内存预检、离线辅助盘、恢复模式引导、客体语言重放、WHPX 兼容处理、启动后 CPU 绑核 |
|
||||
| `internal/cli` | 命令行子命令实现、单实例参数解析与向界面进程交接 `vm start` |
|
||||
| `internal/host` | 宿主机体检与硬件调优:WHPX 检测与 UAC 启用、提交内存预检、Vulkan ICD 扫描、三层大小核拓扑与实时绑核、显示器 HiDPI 推荐、音频与磁盘总线探测、窗口置前、IME 文本钩子 |
|
||||
| `internal/runtime` | 便携运行时拉取(GitHub Releases)、原子解压、多版本切换与子进程环境变量构造 |
|
||||
| `internal/fetch` | 发布附件下载:HTTP `Range` 续传与按发布页 `SHA256SUMS.txt` 强制校验,运行时安装与应用内更新共用 |
|
||||
| `internal/selfupdate` | 应用内更新:把已校验的新版 `reims-go.exe` 换入运行中程序的位置、重新拉起与残留清理 |
|
||||
| `internal/installer` | 包装 `reims-util --json` 实现 macOS 离线安装包查询、宿主机直连下载、断点续传、互斥锁保护与缓存清理 |
|
||||
| `internal/driver/reims` | `reims-ctl` 与 `qemu-img` 受控子进程包装、输出解析、快照/派生/导入操作、日志与配置脱敏 |
|
||||
| `internal/qmp` | QMP 客户端:键盘键入、截屏与 Win10 冷重启监视 |
|
||||
| `internal/guesttools` | 本地回环鉴权 HTTP/WebDAV 服务:图文双向剪贴板、共享目录、Windows 盘符只读共享、防休眠开关与 `REIMSTOOLS` 辅助盘生成 |
|
||||
| `internal/opencore` | 改写 OpenCore 镜像中的 `prev-lang:kbd`,实现系统外预设 macOS 语言 |
|
||||
| `internal/netproxy` | 统一 HTTP Transport:优先环境变量代理,回退读取 Windows 系统代理配置 |
|
||||
| `locales/`、`cmd/i18ngen` | 单一事实源分域 JSON 词表(含译者上下文 `$comment` 与 Apple macOS 官方多语种词汇表)及编译期前后端字典代码生成器 |
|
||||
| `internal/config`、`internal/i18n` | 应用配置持久化(`reims-go.json`)、轻量 ICU 格式化引擎、多跳语言回退链与带稳定排障码的结构化错误(`CodedError`) |
|
||||
| `internal/thumb`、`internal/tray`、`internal/version` | 4K 截屏行级缩放预览、Windows 系统托盘常驻、版本信息与新版本检查 |
|
||||
| `frontend/src` | 桌面界面:`components/`(页面与对话框)、`ui/`(Radix 基件封装)、`lib/`(格式化、日志与任务)、`styles/`(设计令牌) |
|
||||
| `patches/` | 上游临时补丁队列与 PR 跟踪,见 [`patches/README.md`](../patches/README.md) |
|
||||
| `scripts/` | 便携运行时打包、二进制裁剪与符号分离、MSYS2 源码归档、`alpha` 准入与冒烟脚本,以及 `scripts/debug/` 本地调试目录管理与卫生校验脚本 |
|
||||
|
||||
### 3.3 `internal/installer` — GUI 离线安装包下载管理器(2026-11-28 实测沉淀)
|
||||
- **背景与痛点**:实测通过在线恢复镜像(`--macos tahoe`)在 Guest Recovery 内经 QEMU 用户态 NAT(`slirp`)拉取 ~17 GB 系统包时,受限于 Apple CDN 频繁 `Peer disconnected` 与 `OSISDownloadOperation` 抗断流能力弱,极易在耗时数十分钟后接近完成时失败重来。
|
||||
- **方案设计(基于 `reims-util 0.1.0` 一手 CLI 能力)**:
|
||||
1. **动态版本列表**:调用 `reims-util.exe offline-installer list --json` 获取 Apple 目录可用的 macOS Tahoe 精确版本(如 `26.7.3`),供 GUI 下拉选择(同时保留在线恢复模式作为备选)。
|
||||
2. **下载路由可选 + 环境自动探测(合规直连 Apple 官方源)**:macOS 系统包一律从 Apple 官方软件更新目录拉取并校验 chunklist 哈希(不接入第三方非官方镜像)。支持在设置与下载页配置路由模式:`自动探测(推荐)` / `直连 Apple CDN(绕过系统代理,清空代理环境变量并注入 NO_PROXY=*)` / `跟随系统代理` / `自定义 HTTP/SOCKS5 代理`。自动模式下在下载前花 1–2 秒并行探测直连与系统代理访问 Apple 目录的连通性与首字节延迟,国内环境自动命中 Apple 国内边缘节点(2026-11-28 实测直连 `220.194.76.155` 稳定 11.2 MiB/s、零断流),直连受限时自动回退系统代理。
|
||||
3. **宿主机直连下载 + 结构化进度条**:调用 `reims-util.exe offline-installer <version> -o <DataRoot>\data\reims-ctl\installers --json`(或在建机时走 `reims-ctl create --macos <version> --offline --network false` 共享同一缓存目录)。`reims-util --json` 原生按行输出 JSON 进度事件,Go 后端实时解析并通过 Wails `EventsEmit` 推送进度百分比、已下载字节、速率与断流重试状态,无需脆弱正则匹配。
|
||||
4. **暂停 / 断点续传与空间预警**:`reims-util` 原生支持中断后重跑同命令自动断点续传;GUI 提供「暂停/取消」与「继续下载」按钮,并在目标盘剩余空间不足 40 GB 时前置预警。
|
||||
5. **缓存复用与可视化清理**:已下载的离线镜像常驻 `<DataRoot>\data\reims-ctl\installers\`,GUI 包装 `reims-ctl downloads` 与 `reims-ctl downloads delete <NAME>` 展示体积并支持一键清理;后续新建 VM 直接通过 `--installer <path>` 复用本地镜像,零重复下载。
|
||||
6. **离线装机 3 步引导卡**:使用离线包创建 VM 时默认开启 `--network false`(遵从 `reims-ctl create --help` 建议,阻止安装器联网拉更新),并在 GUI 突出提示:① 磁盘工具抹掉最大 `QEMU HARDDISK Media` 为 APFS → ② 打开终端执行 `sh /Volumes/Installer/install-macos.sh` → ③ 装完点击「弹出安装盘并恢复网络」。
|
||||
---
|
||||
|
||||
### 3.4 `internal/driver/reims` — `reims-ctl` 受控包装器
|
||||
- 包装 `list --json`、`show`、`create`、`start`、`stop`、`set`、`eject`、`delete`、`logs`、`command`、`doctor`、`downloads`。
|
||||
- 流式捕获 stdout/stderr 与串口日志,实时推送到 Wails 前端事件总线(`runtime.EventsEmit`),让用户在安装 macOS Tahoe 期间直观看到进度与内核启动日志。
|
||||
- **Win10 自动冷重启补偿(2026-11-28 实测沉淀)**:Win10 19045 缺少 `WHvResetPartition`,Guest 内部热重启时 QEMU 会停在 `WHPX: Unexpected VP exit code 4`。在 Win10 宿主上可通过 `--extra-args "-no-reboot"` 让 QEMU 收到 Guest 重启请求时干净退出,再由 `reims-go` 自动重新 `start` 建立新分区,实现无感重启体验(待实测验证)。
|
||||
- **QMP 不抢上游的 socket**:上游 `reims-ctl` 自己就有 QMP 客户端,走每台 VM 的 `qmp.sock`(Windows 上是 Winsock AF_UNIX,`crates/reims-ctl/src/qmp.rs:1-8`、`vm.rs:1000-1027`)。QEMU 的一个 `-qmp` 同一时间只接受一个客户端,第二个连接会一直等到超时(同上 `qmp.rs` 注释,引自 QEMU `chardev/char-socket.c`)。所以 `reims-go` **不连这个 socket**,否则会卡住 `reims-ctl stop` 等命令;它通过 `reims-ctl set --extra-args` 另开一个自己的 monitor(`-qmp tcp:127.0.0.1:<port>,server=on,wait=off`)。QEMU 允许多个 `-qmp`,但与上游参数是否冲突仍**待 M3.2 实测**。
|
||||
- **配置写入只用 `set`**:`reims-ctl set` 的修改在**下次启动**时生效(`cli.rs:73`);改图形会在 VM 停止时重建 OpenCore 镜像(`cli.rs:242`)。可改字段见 `cli.rs:551-616`,外壳如何呈现见 [`shell-design.md`](shell-design.md)。
|
||||
## 4. 关键机制与安全边界
|
||||
|
||||
### 3.5 `internal/vm` 与 `internal/control` — 开发者进阶能力(M3)
|
||||
- **CoW 秒级派生**:使用便携运行时自带的 `qemu-img.exe create -f qcow2 -F qcow2 -b <golden> <overlay>` 生成写时复制派生盘,挂入临时实例,实现秒级拉起与无痕销毁(待验证 `reims-ctl create --disk <overlay> --disk-mode in-place` 对 backing file 的兼容性)。
|
||||
- **带外控制**:通过 QMP 查询运行态、优雅关机(失败再回退终止,避免粗暴 `taskkill` 伤盘)、截屏与键鼠注入;结合 `--ssh-port` 提供命令执行通道。
|
||||
### 4.1 启动编排与单实例交接
|
||||
- `internal/vmstart` 承载 GUI 与 CLI 共用的启动步骤;只有常驻进程才能维持的能力(Guest Tools 桥接、Win10 冷重启监视)由界面进程托管。
|
||||
- CLI 执行 `vm start` 时,默认交由桌面进程启动:界面已在运行时通过 Wails 单实例锁(`WM_COPYDATA`)发消息不弹窗拉起;未运行时以 `--background` 启动隐藏到托盘的后台界面进程,结果经 `<DataRoot>\tmp\cli-start-*.json` 回传并带退出码返回。
|
||||
- 仅在 CLI 显式指定 `--data-root` 时由命令进程直接启动,此时不包含 Guest Tools 桥接与 Win10 冷重启监视。
|
||||
- `reims-go.exe` 编译为 Windows GUI 子系统程序,命令行模式下保留调用方管道/文件句柄,缺失时通过 `AttachConsole` 挂载父控制台;在交互式 PowerShell/cmd 中加 `| Out-Host` 可等待命令执行完毕。
|
||||
|
||||
## 4. 建议代码目录结构
|
||||
### 4.2 两条隔离的 QMP 通道
|
||||
- **短连接控制通道**:上游 `reims-ctl` 为每台 VM 创建 Winsock `AF_UNIX` 套接字 `qmp.sock`。由于 QEMU 单个 `-qmp` 同一时间只服务一个客户端,键入(`qmp.TypeIntoVM`)与截屏(`qmp.Screendump`)按 VM 串行复用短连接,键入期间暂停截屏。
|
||||
- **Win10 冷重启监视通道**:Windows 10 19045 缺少 `WHvResetPartition`,客体热重启会导致 WHPX 退出异常。在 Win10 宿主上,启动时附加 `-no-reboot` 并另开一条独立的 `AF_UNIX` QMP 通道监听重启退出事件,干净退出后自动重新拉起。使用 `AF_UNIX` 而非 TCP,避免客体经 SLIRP 的 `10.0.2.2` 访问宿主机监控接口。
|
||||
|
||||
```text
|
||||
reims-go/
|
||||
├── cmd/
|
||||
│ └── reims-go/ # 主入口(无参启动 Wails GUI,带子命令走 CLI 模式)
|
||||
├── internal/
|
||||
│ ├── config/ # reims-go.json(含 locale: zh-CN|en-US、DataRoot、P-Core 开关)
|
||||
│ ├── i18n/ # Go 端中英双语消息字典与结构化错误码
|
||||
│ ├── host/ # WHPX、提交内存预检、Vulkan ICD、P/E 核拓扑、进程亲和性(*_windows.go + *_other.go)
|
||||
│ ├── runtime/ # 便携运行时下载/导入、校验、解压、环境构造
|
||||
│ ├── installer/ # reims-util --json 离线安装包下载、断点续传、缓存管理
|
||||
│ ├── driver/
|
||||
│ │ └── reims/ # reims-ctl 子进程包装与 JSON/日志解析
|
||||
│ ├── qmp/ # 独立 QMP TCP 客户端
|
||||
│ └── vm/ # VM 编排、CoW 派生、向导状态机
|
||||
├── frontend/ # Wails 前端(轻量 React + Vite + TypeScript + zh-CN/en-US i18n)
|
||||
├── patches/ # 上游临时补丁队列(合入即退役)
|
||||
├── scripts/
|
||||
│ └── pack-runtime.ps1 # 从本地构建打包便携运行时(tar.zst + manifest)
|
||||
└── docs/
|
||||
```
|
||||
### 4.3 Guest Tools 与宿客安全边界
|
||||
- Guest Tools 服务仅监听 `127.0.0.1`,每台虚拟机分配独立的 256-bit 随机 Token(Bearer / Basic 鉴权)。
|
||||
- WebDAV 共享目录(`/dav/<vm>/`)严格校验路径防目录穿越;Windows 盘符只读共享(`/dav/<vm>/drives/<盘符>/`)默认全部关闭,服务端同时限制 HTTP 写方法与只读打开标志、校验持久化 Volume GUID 防盘符漂移、限制 `PROPFIND Depth` 并校验 Junction/符号链接解析目标仍在授权盘符内。
|
||||
|
||||
## 5. 与 `Reims-GUI-Win` 的核心差异
|
||||
### 4.4 宿主机体检与硬件调优
|
||||
- **免提权 WHPX 检测**:通过 `WinHvPlatform.dll`(`WHvGetCapability`)与系统功能查询判断状态,仅在缺失且用户确认时通过 `ShellExecuteW(..., "runas", ...)` 触发 UAC 启用。
|
||||
- **提交内存预检**:通过 `GlobalMemoryStatusEx` 检查可用提交内存(`AvailPageFile`),因为 QEMU 在 Windows 上会一次性提交整块客体内存;建机时推荐安全档位,启动前余量不足时提前拦截。
|
||||
- **GPU 与大小核**:扫描注册表 Vulkan ICD 并过滤虚拟显示适配器;解析 `GetLogicalProcessorInformationEx` 识别 P / E / LP-E 三层混合核心,支持按 VM 实时调整进程亲和性,避免超售卡顿。
|
||||
|
||||
> 本节关于 `Reims-GUI-Win` 的数据(Release 约 1.68 GB、PySide6 + PowerShell 7、双套 QEMU)没有附来源,按事实核验规则标为**待验证**。另外注意,上游 `reims-ctl` 自带一个终端界面,有创建和编辑表单(`crates/reims-ctl/src/tui.rs`、`form.rs`)。`reims-go` 的 GUI 要比它多出价值,而不是重做一遍,见 [`shell-design.md`](shell-design.md) 第 5 节。
|
||||
### 4.5 应用内更新
|
||||
- 界面启动后检查一次新版本,之后每 6 小时检查一次(后端缓存 10 分钟),只看 `vX.Y.Z` 正式版,忽略草稿与预发布。有新版本时侧栏顶部显示更新胶囊卡片,关于页提供同样的操作。
|
||||
- 下载作为 `app-update` 任务进行,落在 `<DataRoot>\downloads\app\`,支持取消后续传。发布页没有 `SHA256SUMS.txt`、或文件与其中记录不符时拒绝安装;安装前再次校验,防止下载后被改动。
|
||||
- 安装不依赖独立的更新程序:Windows 不允许覆盖运行中的 exe,但允许重命名,因此把运行中的程序改名为 `<exe>.old`,把新文件放到原路径(失败即回滚),再以 `--wait-pid=<旧进程 PID>` 拉起新程序后退出。新进程先等旧进程退出再占用单实例锁,启动后清理 `.old` 与下载文件。程序文件名若仍是发布时的带版本号名称(`reims-go-vX.Y.Z-windows-amd64.exe`),更新后改为新版本的名称;其他名称(如 `reims-go.exe`)保持不变,指向它的快捷方式继续有效。
|
||||
- 虚拟机是独立进程,更新期间继续运行;Guest Tools 桥接与输入法桥接在新界面启动后自动恢复。Win10 冷重启监视不会接回已在运行的虚拟机,这些虚拟机下次客体重启后需要手动启动,确认对话框会提示。
|
||||
- 开发构建(`wails dev`,`dev` 标签)与非 Windows 平台不支持应用内更新;程序所在目录不可写(如未提权的 `Program Files`)时提示改为手动更新。
|
||||
|
||||
| 维度 | `Reims-GUI-Win`(社区参考) | `reims-go`(本设计) |
|
||||
### 4.6 资源回收与内存约束
|
||||
- 按 VM 生命周期分配的状态(缩略图锁、Guest Tools 注册与 WebDAV handler、进程采样、绑核记录、文本队列与 worker)在删除 VM 或轮询发现外部删除时立即回收。
|
||||
- 日志监视器对单行无换行输出设 **64 KiB** 内存上限(原始日志文件完整保留);已结束任务在 10 分钟后从前后端状态中清理。
|
||||
- 4K 屏幕预览采用按行流式缩放降低单帧分配;手动复制截图仍保留全分辨率。不在热路径中人为调用 `debug.FreeOSMemory`。
|
||||
|
||||
---
|
||||
|
||||
## 5. 与上游 `reims-vgpu` 的边界
|
||||
|
||||
| 层次 | 归属 | 职责 |
|
||||
| :--- | :--- | :--- |
|
||||
| 外壳与体积 | Python + PySide6 + PowerShell 7 + 双套 QEMU(Release ~1.68 GB) | Go + Wails(WebView2 原生)+ 单套 `zstd` 便携运行时(实测运行时仅 `160.4 MB`) |
|
||||
| 上游耦合方式 | 手写 PowerShell 拼 QEMU 参数与 `fatsync` 改 OpenCore | 直接包装 `reims-ctl` / `reims-util`,上游升级只需替换运行时包 |
|
||||
| 装机下载体验 | 依赖 Recovery 在线下载或手工准备镜像 | GUI 内置 `reims-util --json` 离线包下载器(宿主机直连、断点续传、缓存复用) |
|
||||
| 硬件调优与防呆 | CPU 预设 + SMBIOS 伪装 | WHPX + 提交内存预检 + 过滤虚拟显卡锁定独显 ICD + 异构大小核 P-Core 绑核 |
|
||||
| 开发者能力 | 基础创建/启停,`taskkill` 强杀 | GUI + CLI 双模、串口日志流、CoW 派生、独立 QMP/SSH 自动化接口 |
|
||||
| **虚拟化引擎与内核** | 上游 [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) | vGPU 设备、`metal2vulkan`、Guest Kexts、OpenCore 引导、QEMU WHPX 补丁、`reims-ctl` / `reims-util` 核心 CLI。底层缺陷以临时补丁记录并优先向上游提交 PR。 |
|
||||
| **桌面产品与便携分发** | 本仓库 `reims-go` | Windows 免编译便携运行时打包与 `alpha`→`stable` 通道筛选、数据目录隔离、硬件体检与自动调优、离线安装包管理器、桌面界面与命令行外壳、Guest Tools、恢复点与 CoW 工程工作流。 |
|
||||
|
||||
## 6. 与上游 `reims-vgpu` 的演进边界
|
||||
|
||||
| 层次 | 归属方 | 具体职责 |
|
||||
| :--- | :--- | :--- |
|
||||
| **引擎与内核层** | 上游 `steelbrain/reims-vgpu` | vGPU 设备、Metal2Vulkan、Guest Kexts、OpenCore/Ambrosia 引导、QEMU WHPX/KVM 补丁、`reims-ctl` / `reims-util` 核心 CLI。本仓发现的底层 Bug(如 Win10 WHPX 崩溃、Win10 `kernel-irqchip`)优先向上游提 PR。 |
|
||||
| **便携与产品工作台层** | 本仓库 `reims-go` | Windows 免编译便携运行时分发(`stable` 冒烟通道)、C 盘零污染隔离、WHPX/提交内存/GPU/P-Core 自动体检与调优、GUI 离线包断点续传下载器、对齐 macOS 的设置与向导、CoW 秒级派生与独立 QMP/SSH 工程工作流。 |
|
||||
> 关于面向第三方扩展的插件系统演进构想,另见草案 [`docs/plugin-architecture.md`](plugin-architecture.md)。
|
||||
@@ -0,0 +1,117 @@
|
||||
# 产品与界面设计规范(Design Guidelines)
|
||||
|
||||
> 本文定义 Reims-Go 桌面外壳的交互原语、配置模型、视觉规则与文案约束。设计令牌的具体数值以 [`frontend/src/styles/tokens.css`](../frontend/src/styles/tokens.css) 为准,本文只记录长期生效的设计原则。
|
||||
|
||||
---
|
||||
|
||||
## 1. 设计定位
|
||||
|
||||
Reims-Go 的桌面外壳遵循「**macOS 的结构与词表,Windows 的平台工艺**」:
|
||||
|
||||
- **结构与概念对齐 macOS**:配置分类与命名参考 Apple [Virtualization.framework](https://developer.apple.com/documentation/virtualization) 的 `VZVirtualMachineConfiguration`(平台、引导、CPU、内存、存储、网络、图形与显示器、音频、键盘与指针、串口);交互结构参考 macOS 人机界面规范(侧栏选实例、右侧看详情、分步新建向导、分页式设置面板)。
|
||||
- **渲染与系统行为对齐 Windows**:适配 Windows DirectWrite 字体渲染与多档 DPI 缩放(100% / 125% / 150%),窗口控件位于右上角,支持浅色、深色与跟随系统外观。
|
||||
- **宿主与客体边界清晰**:Windows 专有能力(WHPX 启用、处理器计划、Vulkan ICD、运行时通道与数据目录)集中在「内核」与「设置」页,不混入单台虚拟机的配置表单。
|
||||
|
||||
---
|
||||
|
||||
## 2. 配置原语
|
||||
|
||||
| 原语 | 规范 |
|
||||
| :--- | :--- |
|
||||
| **声明式配置** | 一台虚拟机对应一份声明式配置,界面只编辑配置项,不让用户直接拼 QEMU 命令行参数。 |
|
||||
| **先校验,后保存** | 保存前在 Go 端完成前置校验(CPU 核数、可用提交内存上限、Vulkan ICD 路径存在性、切换磁盘控制器前是否已弹出安装盘),非法值在提交前拦截。 |
|
||||
| **随时可编辑,标明生效时机** | 无论虚拟机运行与否,设置面板均可打开编辑;每项设置明确标注生效时机。运行中保存「下次启动生效」的修改时,详情页汇总待生效项并提供「重启以应用」。 |
|
||||
|
||||
**写入约束**:凡属于上游 `reims-ctl` 管理的配置项,一律通过 `reims-ctl set` 写入,不直接改写 `vm.toml`,确保上游校验与 OpenCore 重建逻辑照常生效。
|
||||
|
||||
---
|
||||
|
||||
## 3. 配置分类与生效时机
|
||||
|
||||
| 类别 | 界面配置项 | 生效时机 | 约束与说明 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **平台** | Mac 机型、序列号、MLB、UUID、ROM | 只读 | 界面仅展示是否已配置,不展示原始敏感值;日志与排障包一律脱敏 |
|
||||
| **引导** | 系统语言(`prev-lang:kbd`)、重建 OpenCore、恢复模式切换 | 停机时 / 下次启动 | 预设语言会在重建 OpenCore 与启动前自动重放 |
|
||||
| **系统来源** | Apple 离线安装包、本地安装器、导入 VMDK / RAW | 仅创建时 | 安装完成后引导弹出安装盘(`eject`)并恢复网络 |
|
||||
| **CPU** | 核心数、CPU 亲和性策略(自动/全部/性能核/避开低功耗核/自定义) | 核心数下次启动;亲和性立即生效 | 亲和性由 Reims-Go 在宿主机侧实时绑定 |
|
||||
| **内存** | 客体内存大小 | 下次启动 | 按宿主机可用提交内存推荐安全档位,启动前拦截超额配置 |
|
||||
| **存储** | 磁盘控制器(NVMe / VirtIO / SATA)、停机扩容、空间回收、恢复点 | 停机时 / 下次启动 | 切换控制器前须先弹出安装盘;扩容与空间回收仅在停机状态执行 |
|
||||
| **网络** | 网络开关、SSH 端口转发、MAC 地址 | 下次启动 | MAC 属于敏感字段,默认隐藏 |
|
||||
| **图形与显示器** | 显卡后端、显示器数量(1–4)、分辨率 / HiDPI / 全屏、宿主 GPU | 下次启动(改后端需停机) | GPU 列表自动过滤虚拟显示适配器;按主屏分辨率与 DPI 推荐清晰 HiDPI 档位 |
|
||||
| **音频** | 音频开关、音频后端 | 下次启动 | 展示宿主播放/录音设备可用状态 |
|
||||
| **键盘与指针** | 点击窗口捕获键鼠 | 下次启动 | 按实际图形后端展示准确的快捷键提示 |
|
||||
| **串口与日志** | 日志开关与级别 | 下次启动 | 原始输出与串口日志统一收在底部日志抽屉 |
|
||||
| **高级** | 关机等待时间、额外 QEMU 参数、环境变量 | 下次启动 | Reims-Go 内部注入参数与用户自定义 `--extra-args` 隔离合并,互不覆盖 |
|
||||
| **宿客协作** | Guest Tools 剪贴板、共享文件夹、Windows 盘符只读共享、防休眠 | 立即生效 | 仅本机回环鉴权;盘符共享默认全部关闭,系统盘展示隐私提示 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 虚拟机状态模型
|
||||
|
||||
在上游 `reims-ctl list --json` 的三种基础状态(`stopped`、`running`、`broken`)之上,补充 Reims-Go 发起操作时的过渡态:
|
||||
|
||||
| 显示状态 | 触发来源 | 页头主操作(每视图至多 1 个) | 允许的次要操作 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **正在创建** | 创建流程进行中 | 无(展示分步进度) | 取消创建 |
|
||||
| **已停止** | 上游 `stopped` | **启动** | 设置、恢复点、更多(派生副本、扩容/回收、打开目录、删除) |
|
||||
| **正在启动** | 发起 `start` 至 `running` | 启动中(忙碌态,禁用) | 设置、强制关机 |
|
||||
| **运行中** | 上游 `running` | **显示 VM 窗口** | 关机、截屏、设置、更多(重启、强制关机、发送文本、进入/退出恢复模式、导出排障包) |
|
||||
| **正在停止** | 发起 `stop` 至 `stopped` | 停止中(忙碌态,禁用) | 强制关机 |
|
||||
| **配置损坏** | 上游 `broken` | **查看问题** | 打开目录、删除 |
|
||||
|
||||
- 暂不提供暂停或运行中热快照状态(`paused` / `saving` / `restoring`),直到上游验证 `reims-vgpu` 显存与设备状态序列化。
|
||||
- 禁用按钮不占据主操作位置;状态变化时直接切换为当前最合适的主操作。
|
||||
|
||||
---
|
||||
|
||||
## 5. 布局与信息层级
|
||||
|
||||
### 5.1 窗口框架
|
||||
- **可折叠侧栏**(`Ctrl+B`):展示虚拟机列表(按 macOS 大版本显示图标,支持右键菜单与键盘上下选择)、新建入口(`+` / `Ctrl+N`)以及底部的「安装包」「内核」「设置」入口。
|
||||
- **主内容区**:虚拟机页的操作区位于详情页头而非全局顶栏,避免切换非 VM 页面时按钮跳动。页面遵循「视觉预览与名称 → 一行核心摘要与主操作 → 上下文提示(待生效修改/装机引导) → 连接与资源分组 → 折叠的技术信息 → 底部快捷键脚注」的自上而下层次。
|
||||
- **常驻状态栏 + 底部日志抽屉**:状态栏左侧显示活动任务进度(空载时显示宿主机内存、磁盘与运行中 VM 摘要),右侧显示错误计数徽标与日志抽屉开关(`Ctrl+L`)。
|
||||
|
||||
### 5.2 防堆叠约束
|
||||
- **每条事实只说一次**:同一项规格或状态不在一页内重复展示。
|
||||
- **每个操作只有一个出口**:同屏不重复摆放相同动作按钮;破坏性操作(删除、强制关机)仅出现在菜单与确认弹窗中。
|
||||
- **边框最多一层**:用分组容器或留白表达层级,二选一,禁止卡片套卡片。
|
||||
- **原生与自绘统一**:表单选择控件统一使用自绘弹出选择器(`PopupSelect`),避免混入风格割裂的系统原生 `<select>`。
|
||||
|
||||
---
|
||||
|
||||
## 6. 视觉、图标与无障碍基线
|
||||
|
||||
- **样式令牌化**:所有颜色、字号、间距(4 px 网格)、圆角与阴影统一引用 [`frontend/src/styles/tokens.css`](../frontend/src/styles/tokens.css) 中的 CSS 变量,禁止在组件内联写死颜色或字号。
|
||||
- **字体与区域排印**:内嵌开源 Inter Variable 作为拉丁字体,并通过动态 `<html lang dir>` 与 `:lang()` 选择器按区域分离东亚字体栈(简体、繁体、日文、韩文各自优先匹配对应系统 UI 字体,避免 Han Unification 异体字混用);繁体与日文正文采用 `400` 字重与更舒展的行高防止高笔画糊字,开启中西文自动盘古间距;Win32 原生引导浮层按脚本分级探测 GDI 字体并支持卡片宽度自适应与长按钮纵向堆叠。语言包插件可附带沙箱校验的 `.woff2` 字体补齐缺字宿主。
|
||||
- **按钮层级**:每视图至多 1 个实底主按钮;常用操作用次按钮或图标按钮;破坏性操作仅用红字出现在菜单与确认框。
|
||||
- **纯图标按钮边界**:仅当图标含义通用(启动、停止、设置、更多、新建、复制、关闭、刷新、日志)且既非主操作也非破坏性操作时才允许纯图标;所有纯图标按钮必须具备悬停 Tooltip(含快捷键)、`aria-label` 与 ≥ 28×28 px 的点击热区。领域专有操作(如「弹出安装盘」「显示 VM 窗口」「重启以应用」)必须保留文字。
|
||||
- **键盘与缩放**:所有可交互项必须为原生 `<button>` 或带完整 ARIA 语义的 Radix 基件,提供 `:focus-visible` 焦点环;全局快捷键包括 `Ctrl+N`(新建)、`Ctrl+B`(折叠侧栏)、`Ctrl+,`(设置)、`Ctrl+L`(日志)。最小窗口尺寸 960×640,需在 100% / 125% / 150% DPI 下无文字截断。
|
||||
|
||||
---
|
||||
|
||||
## 7. 文案、人话化与反馈规则
|
||||
|
||||
### 7.1 内容人话化
|
||||
主视图只展示用户能直接理解的信息,上游原始字符串、路径与内部标识统一收进「技术信息」折叠区并提供一键复制:
|
||||
|
||||
| 原始值 | 主视图展示 | 原始值去向 |
|
||||
| :--- | :--- | :--- |
|
||||
| Vulkan ICD 完整路径 | 显卡名称(如「NVIDIA GeForce RTX 4070 Ti」) | 技术信息 |
|
||||
| `Skylake-Client-noTSX-IBRS` | 不在主视图展示 | 技术信息 |
|
||||
| `x86-64 macOS guest (q35 and OpenCore, WHPX)` | 本地化简述(如「macOS · Intel · WHPX 加速」) | 技术信息 |
|
||||
| `user (MAC configured), ssh on 127.0.0.1:2222` | 「NAT · SSH 2222」 | 技术信息 |
|
||||
| 环境变量或底层参数名(如 `REIMS_VGPU_LOG`) | 用效果命名标题,不把变量名放进标题 | 描述或技术信息 |
|
||||
| 内部错误原始文本 | 本地化的一句话说明 + 稳定错误码徽标(如 `[E_VM_CLONE_RUNNING]`) | 详情折叠区保留原始英文技术输出并支持一键复制完整诊断信息 |
|
||||
|
||||
格式化逻辑统一集中在 [`frontend/src/lib/format.ts`](../frontend/src/lib/format.ts)(数字、列表与相对时间统一经原生 `Intl` API 按当前语种格式化),不在组件中零散拼接。跨宿主与客户机语言的安装引导提示(如宿主机中文操作英文 macOS 恢复环境)自动采用「宿主译名 (`Guest Term`)」双标,同语种则单标。开发模式下提供 `en-XA` 伪本地化语种用于排查硬编码与长词截断。
|
||||
|
||||
### 7.2 文案风格
|
||||
- **克制直接**:标题用名词;按钮用 2–5 字动词;描述控制在清晰的一句话;不使用「请」「您」「成功」和感叹号;按钮和短提示末尾不加句号。
|
||||
- **不写内部引用**:面向用户的文案中严禁出现仓库路径、内部文档名、PR 编号或开发者术语。
|
||||
- **英文统一句首大写(Sentence case)**,避免每词首字母大写。
|
||||
- **去重复标题**:设置窗口标题只写实例名,分组标题与行标题不同名,不写自明标题(如「配置概览」)。
|
||||
|
||||
### 7.3 进度、日志与操作反馈
|
||||
- **进度归进度,日志归日志**:下载、建机、扩容等耗时任务统一通过结构化任务事件推送到状态栏;日志抽屉默认收起,**绝不因新日志到达而自动弹出**,仅在出错时通过 Toast 提醒并附「查看日志」入口。
|
||||
- **即时反馈**:每次点击操作立即进入忙碌态防重复触发;成功时给出简洁 Toast(「对象 + 结果」,如「macos-tahoe 已关机」),失败时说明原因与恢复动作。
|
||||
- **破坏性确认**:删除虚拟机等不可逆操作一律使用自定义确认对话框(含影响范围与「保留磁盘文件」选项),不使用浏览器原生 `window.confirm`。
|
||||
@@ -0,0 +1,447 @@
|
||||
# 插件系统架构(Plugin Architecture)
|
||||
|
||||
> 状态:**核心内核、内置扩展、主题引擎、Sidecar 托管与 CLI/GUI 管理已落地**;市场远端索引与 L2 脚本层按需迭代。
|
||||
> 关联文档:[`architecture.md`](architecture.md) · [`design-guidelines.md`](design-guidelines.md) · [`portable-runtime-spec.md`](portable-runtime-spec.md) · [`patches/README.md`](../patches/README.md)
|
||||
|
||||
---
|
||||
|
||||
## 1. 目标、约束与非目标
|
||||
|
||||
### 1.1 目标插件类型
|
||||
|
||||
| 类型 | 典型形态 |
|
||||
| :--- | :--- |
|
||||
| **主题与美化** | 宿主**不提供主题包,只提供主题扩展接口**;接口须能承载多套配色、字体、部件级样式、状态驱动装饰与交互增强并存的复杂主题(以 DSH 主题 dsh-claude-style 为参照) |
|
||||
| **运行时** | 自定义构建或镜像源的 `reims-vgpu` 运行时、上游 QEMU/OVMF 等其他运行时种类 |
|
||||
| **非 macOS 虚拟机** | 以 Linux 虚拟机为代表的客体平台驱动,复用体检、内存预检、绑核、QMP、任务与托盘能力 |
|
||||
| **Hook 与自动化** | 体检、建机、启停前后的拦截与观察;自定义命令;排障采集器;宿主侧桥接与兼容补偿 |
|
||||
|
||||
### 1.2 硬约束
|
||||
|
||||
| 约束 | 要求 |
|
||||
| :--- | :--- |
|
||||
| **第三方代码不进主进程** | 除编译期内置扩展外,任何插件代码都不在 `reims-go.exe` 进程内执行;插件崩溃、死循环或内存失控不得拖垮主窗口与运行中的 VM |
|
||||
| **零外部运行时依赖** | 用户无需安装 Node.js / Bun / Python / MSYS2 即可使用任一官方插件层级 |
|
||||
| **数据目录隔离** | 插件包、私有数据、日志与第三方运行时全部位于 `<DataRoot>` 下 |
|
||||
| **许可证防火墙** | Apache-2.0 本体与 GPL/LGPL 组件只经独立子进程 + 协议通信协作,禁止静态链接或进程内耦合 |
|
||||
| **配置写入铁律** | 对 `reims-ctl` 管理的 VM,插件只能提交「意图」,由宿主统一经 `reims-ctl set` 落盘,严禁直改 `vm.toml` |
|
||||
| **人工确认红线** | UAC 提权、重启 Windows、macOS 图形安装向导等不提供任何插件权限,插件只能请求宿主弹出确认 |
|
||||
| **敏感字段零外泄** | 序列号、MLB、UUID、ROM、MAC 不进入任何插件可读的数据面;插件贡献的排障内容必经宿主脱敏 |
|
||||
| **GUI 与 CLI 同源** | 插件管理、驱动路由、Hook 管线位于 `internal/`,桌面与 `reims-go <subcommand>` 行为一致 |
|
||||
|
||||
### 1.3 非目标
|
||||
|
||||
- 不采用 Go 原生 `plugin` 包(不支持 Windows,且强耦合编译器与依赖版本),不进程内加载第三方 DLL。
|
||||
- 不把核心拆成「万物皆插件」的全动态微内核:体检、单实例托盘、Wails 窗口与 CLI 路由保持静态编译。
|
||||
- 不用插件、DLL 注入或 API Hook 替代上游引擎补丁(见 §5.5)。
|
||||
- 不发布官方主题插件包:除内置浅色/深色外不提供任何主题,但完整保留主题扩展接口(§5.1)。
|
||||
- 不托管、不分发任何 Apple 专有文件;插件市场拒收此类包。
|
||||
|
||||
---
|
||||
|
||||
## 2. 参考系统与取舍
|
||||
|
||||
| 维度 | Magpie(Go 宿主 + Bun 插件宿主) | DSH(Cordis「万物皆插件」) | Reims-Go 取舍 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| 内核 | 编译期内置插件注册表(`Requires/Provides/Apply/OnDispose`)+ 社区插件管理器,两者在扩展点交汇 | 极小 DI 内核,所有功能皆插件,依赖就绪自动激活、缺失级联卸载 | 取 Magpie 的**单注册表、两种来源**;取 DSH 的**可逆副作用**与依赖驱动激活;不做全动态微内核 |
|
||||
| 执行隔离 | 按能力分层:进程内 JS(µs 级热路径,无 I/O,严格时限)/ 共享 Bun 子进程 / 沙箱 iframe | 全部进程内同权限,`node:vm` 与同源 iframe 明确声明非安全边界 | Reims-Go **无微秒级热路径**,进程内脚本收益不足以抵消风险 → 所有插件代码进程外执行,且**每插件独立进程** |
|
||||
| 失败策略 | 每个扩展点显式 fail-open / fail-closed | 可选插件失败继续、必需清单失败退出;UI 单元格错误边界 | 扩展点契约中写明分发模式与失败策略 |
|
||||
| UI | `sandbox=allow-scripts` iframe + `connect-src 'none'` + bridge + 服务端二次校验 + 主题变量 | 类型化 Slot(声明即占有)+ 主题令牌 + SVG 校验;共享 React 实例随宿主升级易碎 | 声明式贡献由宿主原生渲染为主;iframe 面板为逃生舱;不共享前端依赖 |
|
||||
| 分发 | npm/git/本地 + 带 sha512 的兜底分发分支;远端索引 + 内嵌副本 | 事务安装(快照回滚、包名版本核对、下载前兼容预检)、安全模式恢复;无签名 | 事务安装 + 下载前预检 + SHA-256 + 签名分级 + 远端索引与内嵌兜底 |
|
||||
| 已知教训 | Windows 上包管理器并发写丢失;孤儿进程(需按进程树终止);`Origin: null` 绕过 CORS;空列表保存抹掉全部插件;嵌入引擎无内存上限 | 进程内插件一个未捕获异常拖垮宿主;整段配置替换难用 | 不引入包管理器;Job Object;严格 Origin 校验;状态文件「读失败即报错」;内存上限靠进程级限制 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 总体架构
|
||||
|
||||
### 3.1 一个注册表 + 分层执行
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph Exe["reims-go.exe(可信核心)"]
|
||||
Reg["扩展点注册表\n依赖解析 · 可逆副作用 · Reconcile"]
|
||||
Builtin["内置扩展(编译期注册)\n核心:reims 驱动 · 默认主题 · 启动准备 · 兼容补偿\n可选:宿客桥接 · 剪贴板 · 输入服务 · 窗口安装引导 · reims-vgpu 运行时种类"]
|
||||
Mgr["插件管理器\n清单校验 · 事务安装 · 状态 · 安全模式"]
|
||||
Broker["Host API 代理\n权限校验 · 脱敏 · 限流 · 审计"]
|
||||
Sup["进程监管器\nJob Object · 重启退避 · 健康检查"]
|
||||
Asset["插件资源路由\nCSP · 路径校验 · Origin 校验"]
|
||||
end
|
||||
subgraph L1["L1 声明层(纯数据)"]
|
||||
D1["主题 · 图标 · 语言 · VM 模板 · 运行时源 · 规则 Hook"]
|
||||
end
|
||||
subgraph RT["运行时包(原生二进制)"]
|
||||
R1["仅由驱动以子进程调用"]
|
||||
end
|
||||
subgraph L2["L2 脚本宿主(预留)"]
|
||||
S1["reims-go 隐藏子命令进程\n内嵌 JS 引擎 · 进程级内存/CPU 上限"]
|
||||
end
|
||||
subgraph L3["L3 Sidecar(任意语言 exe)"]
|
||||
X1["Linux 驱动 · 代码 Hook · 命令 · 排障采集"]
|
||||
end
|
||||
subgraph L4["L4 UI"]
|
||||
U1["声明式贡献(原生渲染)· 沙箱 iframe 面板(后置)"]
|
||||
end
|
||||
Builtin --> Reg
|
||||
Mgr --> Reg
|
||||
L1 --> Mgr
|
||||
RT --> Mgr
|
||||
L2 & L3 <-->|"JSON-RPC 2.0 / stdio"| Sup --> Broker --> Reg
|
||||
L4 <-->|"bridge"| Asset --> Broker
|
||||
```
|
||||
|
||||
| 层 | 执行机制 | 隔离 | 宿主可强制的约束 | 典型插件 |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| **Builtin** | Go 代码,编译期注册到同一注册表 | 可信 | 全部 | reims 驱动、宿客桥接、兼容补偿、默认主题 |
|
||||
| **L1 声明层** | JSON + 静态资源,由宿主解析 | 无代码 | 全部(Schema 白名单) | 主题、图标、语言、VM 模板、运行时源、规则 Hook |
|
||||
| **运行时包** | 原生二进制,**只被驱动以子进程调用**,自身不注册扩展点 | 进程级 | 来源、哈希、签名 | `reims-vgpu` 变体、Linux 用 QEMU/OVMF |
|
||||
| **L2 脚本宿主(预留)** | 由 `reims-go.exe` 以隐藏子命令拉起的独立进程,内嵌纯 Go JS 引擎运行单文件脚本;无文件/网络能力,仅宿主注入的 API | 进程级 + 引擎沙箱 | 全部;Job Object 限制内存与 CPU | 轻量 Hook、体检规则、日志告警 |
|
||||
| **L3 Sidecar** | 独立 exe,每插件一个进程,双向 JSON-RPC 2.0 | 进程级;**OS 权限等同当前用户** | 仅 Host API 访问面 | Linux 驱动、代码 Hook、CLI 命令、排障采集 |
|
||||
| **L4 UI** | 声明式贡献由宿主原生组件渲染;复杂交互用沙箱 iframe | 强 | 全部 | 驱动专属表单、菜单项、状态卡片、自定义面板 |
|
||||
|
||||
**L2 的定位**:Hook 发生在秒级的 VM 生命周期上,没有 Magpie 那样的微秒级热路径,因此不把脚本引擎嵌入主进程。若出现「低信任 + 需要逻辑」的刚需,复用同一个 `reims-go.exe` 以隐藏子命令拉起脚本宿主进程:既不增加分发物、不要求用户装运行时,又获得进程级崩溃隔离与 Job Object 内存上限(纯 Go JS 引擎本身没有堆上限)。在此之前,L1 规则 Hook 与 L3 Sidecar 覆盖需求。
|
||||
|
||||
**多合一包**:一个插件可在 `contributes` 中同时声明多种能力,例如 Linux 插件同时提供 L3 驱动、运行时源、规则 Hook 与创建向导 Schema。
|
||||
|
||||
### 3.2 内置功能先插件化
|
||||
|
||||
扩展点先由内置功能使用一遍再对外开放。内置功能分两类,判断标准是用户关掉它之后,是「少了一项功能」还是「已有功能坏掉」:
|
||||
|
||||
- **核心** `builtin.core`:Reims-Go 离开它就无法运行 macOS 虚拟机的部分,包括 reims 驱动(驱动 id 仍为 `builtin.driver.reims-macos`)、默认主题(主题 id 仍为 `builtin.theme.default`)、启动准备(离线辅助盘、恢复模式引导切换、引导语言重放)与宿主兼容补偿(WHPX 降级、Win10 冷重启)。它是**系统插件**:始终启用,不能停用或卸载,插件页显示为一行「始终启用」,不参与「使用中」检查。两项兼容补偿作为核心的应用级设置保留开关,仅供排障。启动准备在同一个 `vm.beforeStart` 处理器里按固定顺序执行,引导语言重放必须在恢复模式切换(可能重建 OpenCore)之后。
|
||||
- **可选内置扩展**:Guest Tools 传输服务、剪贴板互通、宿主输入服务、虚拟机窗口安装引导。经同一注册表注册、可独立启停、停用后零残留,停用即真正停止(不被其他调用方重新拉起)。首批示例为默认开启的剪贴板互通(见 §5.4)。
|
||||
|
||||
核心由曾经拆开的七个内置插件合并而来(`builtin.RetiredIDs`)。启动时删除 `state.json` 中这些旧 ID 的记录,关闭过的兼容补偿转为对应的核心设置;启动 VM 时,参数归属账本中旧 ID 名下的片段移交给核心,继续沿用而不是被当作已卸载插件的残留剥离。
|
||||
|
||||
---
|
||||
|
||||
## 4. 内核机制
|
||||
|
||||
### 4.1 注册表与可逆副作用
|
||||
|
||||
- 每个已启用插件(含内置)拥有一个作用域,所有注册行为(提供服务、贡献扩展点、订阅事件、后台服务、Win32 钩子、QMP 监视)都登记一个释放函数;停用、卸载或升级时**逆序释放**,激活中途失败则回滚已登记项。
|
||||
- 插件声明 `requires` / `provides`(服务名 + 版本范围)。Reconcile 先关后开:先释放不再需要的插件及依赖其服务的插件,再按依赖求不动点激活。状态为 `off / pending / active / degraded / failed`。
|
||||
- **使用中不可移除**:仍有 VM 归属的驱动、仍被 VM 使用的运行时,不可停用或卸载;使用情况查询失败按「使用中」处理。
|
||||
- 内置扩展通过 `pluginApi` 版本做兼容检查;激活 panic 转为 `failed` 并回滚。
|
||||
|
||||
### 4.2 扩展点目录
|
||||
|
||||
| 扩展点 | 来源层 | 基数 | 失败策略 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `themes`(令牌、配色方案、字体、图标、背景、提示音、样式表、状态装饰) | Builtin · L1 | 按 id,同一时刻仅一个主题包生效 | 回退内置默认主题 |
|
||||
| `uiScripts`(交互主题脚本) | 主窗口受信任脚本 | 随所属主题包 | 单个功能出错只停用该功能;整体失败回退到无脚本的主题 |
|
||||
| `locales`(声明式语言包:分域 `files`、可选包内 `.woff2` 字体、`pluginOverrides` 跨插件翻译覆盖) | Builtin · L1(纯 JSON + WOFF2,免高危权限) | 按 BCP-47 语种与信任等级合并,覆盖 GUI、Win32 浮层、托盘与 CLI | 缺失词条沿有界多跳 `fallback` 链回退至内置语种;单条坏模板自动回退不崩宿主 |
|
||||
| `inputFilters` | Builtin · L1(仅声明式规则) | 有序列表 | 规则非法即忽略;宿主输入服务异常时卸载钩子、放行原始输入 |
|
||||
| `vmTemplates` | Builtin · L1 | 列表 | 跳过非法项 |
|
||||
| `runtimeSources` | Builtin · L1 | 列表 | 跳过该源,回退其他源 |
|
||||
| `runtimeKinds` / `runtimes` | Builtin · 运行时包 | 按种类 | 不激活,相关 VM 提示运行时不可用 |
|
||||
| `guestDrivers` | Builtin · L3 | 按 id | 该驱动的 VM 标记「驱动不可用」,其他 VM 不受影响 |
|
||||
| `hooks` | Builtin · L1 · L2 · L3 | 有序列表 | 按事件模式(§4.3) |
|
||||
| `commands` | Builtin · L2 · L3 | 按 id | 报错并提示 |
|
||||
| `menus` / `vmCards` / `settingsPages` / `statusItems` | 声明式 | 列表,设数量上限 | 隐藏该项 |
|
||||
| `panels` | L4 iframe | 限定槽位 | 错误占位 + 重试 |
|
||||
| `diagnostics` | Builtin · L3 | 列表 | 跳过;输出强制脱敏 |
|
||||
|
||||
UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`、`settings.plugin`,后续按真实需求再增加 `sidebar.footer`、`statusbar.right`、`create.source`;插件只能向已声明槽位贡献。
|
||||
|
||||
### 4.3 Hook 事件与分发模式
|
||||
|
||||
分发模式与失败策略是事件契约的一部分:
|
||||
|
||||
| 事件 | 触发位置 | 模式 | 时限 | 失败策略 |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| `host.preflight` | 体检完成后 | 收集:追加优化建议/警告 | 500 ms | 丢弃该插件结果 |
|
||||
| `vm.beforeCreate` | 校验通过后、创建前 | 拦截:校验错误或默认值补丁 | 2 s | 补丁丢弃、放行 |
|
||||
| `vm.afterCreate` | 创建成功后 | 观察 | 异步 30 s | 只记录 |
|
||||
| `vm.beforeStart` | 启动准备阶段 | 拦截:返回启动意图(§4.4) | 每插件 2 s,链路 10 s | 意图丢弃、放行;仅声明 `blocking` 且用户启用的守卫可阻断 |
|
||||
| `vm.afterStart` | 拿到 PID / QMP / SSH 端口后 | 观察:注册后台监视、通知 | 异步 | 只记录 |
|
||||
| `vm.beforeStop` / `vm.afterStop` / `vm.deleted` | 关机/删除前后 | 观察 | 异步 | 只记录 |
|
||||
| `log.onLine` | VM 日志行进入监视器 | 观察:里程碑、告警、修复建议 | 批量投递,超时丢弃 | 背压时丢弃,绝不阻塞日志 |
|
||||
| `command.invoke` | 菜单点击或 CLI 调用 | 请求/响应 | 30 s | 报错 |
|
||||
|
||||
同一事件的处理器按「内置 → 用户排序」执行;连续超时或异常达阈值的插件自动降级为 `degraded` 并在插件页提示原因,不阻断 VM 启停。
|
||||
|
||||
### 4.4 启动意图与参数归属账本
|
||||
|
||||
`vm.beforeStart` 处理器不能直接调用 `reims-ctl`,只能返回启动意图:
|
||||
|
||||
| 意图项 | 约束 |
|
||||
| :--- | :--- |
|
||||
| QEMU 参数片段 | 带归属(插件 id);只允许宿主白名单内的选项族;同一选项多方设置时按优先级取一并告警 |
|
||||
| 子进程环境变量 | 仅限插件命名空间前缀,或宿主白名单变量 |
|
||||
| 前置检查 | 人话化的警告或阻断理由 |
|
||||
| 启动后动作 | 由宿主执行的受控动作(打开端口转发、注册监视等) |
|
||||
|
||||
宿主合并所有意图后,对 `reims-ctl` 管理的 VM **一次**经 `reims-ctl set --extra-args` 写入,并在 VM 目录维护**参数归属账本**,记录每个片段的归属。插件停用或卸载时按账本精确剥离其片段;现有按功能各写一对合并/剥离函数的做法(离线辅助盘、Guest Tools、`kernel-irqchip=off`、Win10 冷重启 QMP 通道)统一迁到账本之上。用户在「高级」中手写的 `--extra-args` 不属于任何插件,永不被自动剥离。
|
||||
|
||||
---
|
||||
|
||||
## 5. 四类插件专项设计
|
||||
|
||||
### 5.1 主题与美化(宿主只提供接口)
|
||||
|
||||
除内置浅色/深色外,Reims-Go 不发布主题包,但主题扩展接口按能承载 dsh-claude-style 级复杂主题设计。该主题在 DSH 上的实践表明:宿主没有稳定契约时,主题只能依附带哈希的类名、自建页面观察总线与帧管线、按结构写覆盖层,宿主改版即失效,样式匹配性能也受拖累。Reims-Go 由宿主主动提供这些契约。
|
||||
|
||||
**UI 契约(`uiApi`,随 `pluginApi` 版本化,由前端构建生成 `ui-contract.json` 供主题作者校验)**
|
||||
|
||||
| 契约 | 内容 |
|
||||
| :--- | :--- |
|
||||
| 设计令牌 | 单一来源(令牌数据同时生成 CSS 变量与前端常量),覆盖颜色、字体排印、形状、阴影、动效时长与缓动、层级;动效档位(含系统「减少动态效果」)在一处解析为文档属性,样式与脚本读同一个值 |
|
||||
| 部件 | 关键区域与控件挂稳定的部件类名(如 `rg-p-sidebar`、`rg-p-vm-header`、`rg-p-statusbar`),每个部件一个独立类名,便于浏览器按类名分桶匹配;主题选择器只允许使用部件、状态属性与令牌,不得依赖内部类名或界面文字 |
|
||||
| 状态属性 | 文档与区域上的只读状态:外观、当前视图、VM 显示状态、忙碌态、是否有错误、侧栏折叠 |
|
||||
| 槽位锚点 | 装饰与扩展内容的挂载点(如侧栏底部、VM 预览四角、状态栏、空状态区) |
|
||||
|
||||
契约内的部件、状态属性与令牌的重命名或删除属于 `uiApi` 主版本变更;前端构建检查契约中的每个部件仍由某个组件输出。
|
||||
|
||||
**三档主题能力**
|
||||
|
||||
| 档位 | 能力 | 层级与信任 | 对应复杂主题的典型需求 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **令牌主题** | 配色方案集合:少量种子色 + 声明式派生规则(按浅/深外观对种子做亮度、色度、透明度偏移)生成整套表面/文字/边框色阶;用户在宿主提供的编辑器中改种子、新建/复制/重命名/删除方案。字体(包内字体或用户字体目录)、图标与品牌标记替换、背景、按事件配置的提示音 | L1,宿主校验 | 多套配色预设与方案管理、自带字体、品牌标记、提示音 |
|
||||
| **样式主题** | 面向部件契约的样式表(宿主以 `@layer` 固定层叠顺序:基础 → 主题 → 用户);声明式状态装饰(按状态表达式切换精灵图/动画帧,锚定槽位,如随 VM 启停与任务进度变化的吉祥物) | L1,宿主校验与清洗 | 窗框/侧栏/排印样式、状态动画吉祥物 |
|
||||
| **交互主题** | 主窗口内运行的受信任 UI 脚本,只经宿主 UI SDK 工作 | 高信任(`ui:script`) | 滚动、折叠、悬停预览等交互增强 |
|
||||
|
||||
**UI SDK**(交互主题的唯一受支持接口):
|
||||
|
||||
- 生命周期:主题脚本导出装载函数,所有订阅、计时器与挂载都登记释放函数;切换或停用主题时逆序拆除,单个功能抛错不影响其余功能。
|
||||
- 只读状态订阅:非敏感的 VM 摘要、任务进度、当前视图、外观;不提供原始路径与敏感字段。
|
||||
- 宿主提供的页面观察总线、帧读写管线与按部件查询:主题不自建节点观察者,也不整页查询文档。
|
||||
- 槽位挂载:框架无关的 DOM 挂载,不共享宿主的 React 实例,避免随宿主依赖升级断裂。
|
||||
- 受限动作:仅开放非破坏性界面动作(折叠侧栏、打开设置、前置 VM 窗口等);启停、删除、配置写入不在 SDK 中。
|
||||
- 主题设置:由 `settings` Schema 定义,宿主渲染设置页。
|
||||
|
||||
**边界**:
|
||||
|
||||
- 主窗口同一 JS 环境内的脚本不是安全边界(可操作 DOM),交互主题按高信任处理:需 `ui:script` 权限与显式确认,`community` 级默认不可启用;宿主在加载主题脚本前收起 Wails 绑定的全局对象,SDK 是唯一受支持的接口。
|
||||
- 样式清洗:禁止外部 `url()` 与远程 `@import`,资源只能引用包内清单中的文件;窗口拖拽区、焦点环与最小点击热区等可用性属性由宿主在更高层保留,不被主题覆盖。
|
||||
- 同一时刻只启用一个主题包,切换时先停用旧主题再装载新主题;安全模式一律回到内置主题。
|
||||
- 首帧前按当前主题内联令牌防闪烁;无边框窗口的标题栏由前端绘制,可随主题变化。
|
||||
- 主题只改视觉与交互呈现,不改文案、信息层级与操作入口([`design-guidelines.md`](design-guidelines.md) 的主操作与破坏性操作约束由宿主守住)。
|
||||
- 需要读写用户文件或常驻服务的主题,以同包 L3 Sidecar 实现。
|
||||
- 开发支持:`reims-go plugin link` 链接本地目录并热重载;`reims-go plugin doctor` 校验样式只使用契约内的部件、状态属性与令牌。
|
||||
|
||||
### 5.2 运行时(运行时种类 + 运行时包)
|
||||
|
||||
- `internal/runtime` 从单一 `reims-vgpu` 泛化为**运行时种类注册表**:内置 `reims-vgpu` 种类;插件可提供新种类(如上游 QEMU + OVMF)或同种类的社区构建。
|
||||
- 运行时 `manifest.json` 在 schema 2 基础上增加:`kind`;`runtime_api`(驱动依赖的命令行契约版本,含 `reims-ctl` 子命令集与输出格式);`capabilities`(补丁与特性标识,替代按补丁名子串判断)。
|
||||
- 驱动声明所需运行时种类与 `runtime_api` 范围;不兼容时禁止启动并给出人话提示。
|
||||
- 存量布局 `runtimes/<commit>/` 保持不变,视为 `reims-vgpu` 种类;新种类安装到 `runtimes/<kind>/<version>/`,避免迁移存量数据。
|
||||
- 复用现有下载、续传、`SHA256SUMS.txt` 强校验、原子解压与多版本切换;第三方运行时不进入官方 `stable` 通道,安装前展示来源、许可证与补丁清单,并要求提供对应源码包(GPL 义务由分发者承担,市场审核把关)。
|
||||
|
||||
### 5.3 非 macOS 虚拟机(客体驱动,L3)
|
||||
|
||||
**驱动抽象**:当前 `internal/app`、`internal/vmstart`、`internal/cli` 直接依赖 `internal/driver/reims` 的具体类型。抽象后:
|
||||
|
||||
| 层 | 内容 |
|
||||
| :--- | :--- |
|
||||
| 通用 VM 模型 | 驱动 id + 名称、状态(`stopped / running / broken` 与过渡态)、CPU / 内存 / 磁盘摘要、目录、能力位 |
|
||||
| 驱动专有数据 | 不透明扩展字段 + 驱动提供的创建/设置 JSON Schema(宿主原生渲染,标注生效时机) |
|
||||
| 能力位 | `snapshot`、`cow_clone`、`resize`、`qmp`、`ssh`、`guest_tools`、`affinity`、`opencore`、`recovery`、`cloud_init`、`uefi_iso` 等;UI 与 CLI 按能力位显隐操作 |
|
||||
| 驱动动作 | `List / Show / ValidateCreate / Create / ValidateSet / Set / Start / Stop / Delete`,可选快照、派生、扩容与通用 `InvokeAction` |
|
||||
|
||||
- **VM 归属**:VM 目录内标记文件记录驱动 id;无标记的存量 VM 自动归属 `builtin.driver.reims-macos`,零迁移。CLI 增加 `vm create --driver <id>`,其余 `vm` 子命令按归属自动路由。
|
||||
- **宿主共享服务**(驱动经反向调用复用):体检报告、提交内存预检、大小核绑核、QMP 截屏与键入、缩略图、Guest Tools 注册、进程退出监视、任务进度、日志通道、托盘菜单。
|
||||
- **VM 进程归宿主托管**:驱动不直接派生 QEMU,而是请求宿主代为启动并返回 PID。这样 VM 进程不随驱动进程的 Job Object 被回收(驱动崩溃或重启不误杀 VM),绑核、退出监视与冷重启补偿也只在宿主实现一份。
|
||||
- **配置写入**:`reims-ctl set` 铁律约束 reims 管理的 VM;Linux 驱动自管配置文件,同样不允许 UI 拼接原始命令行。
|
||||
- **Linux 驱动的自身难点**:WHPX 直接启动与 Win10 冷重启补偿复用;显示路径(QEMU 窗口或 virtio-gpu,3D 加速**待验证**);cloud-init seed 生成;发行版镜像下载与校验;客体代理(qemu-guest-agent 或 Guest Tools Linux 版)。上游 `reims-ctl` 是否支持非 macOS 客体**待验证**;若将来支持,Linux 驱动可退化为其薄封装。
|
||||
- 官方 Linux 驱动作为独立仓库的一方插件交付,用于验证驱动抽象;主程序不为它写特例代码。
|
||||
|
||||
### 5.4 Hook 与自动化
|
||||
|
||||
- **L1 规则 Hook**:条件 + 动作的声明式规则,条件只能引用宿主定义的事实(Windows 版本、GPU、驱动、能力位、运行时能力),动作只能产出 §4.4 的意图或受控动作,不图灵完备。覆盖「某宿主条件下追加参数」「启动后打开 SSH 终端」等大多数场景。
|
||||
- **L3 代码 Hook**:Sidecar 订阅事件,经同一意图通道生效;`log.onLine` 以批量形式投递。
|
||||
- **L2 脚本 Hook**:预留,启用条件见 §3.1。
|
||||
|
||||
#### 首批示例插件
|
||||
|
||||
| 示例 | 形态 | 默认 | 演示的机制 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **剪贴板互通** `builtin.bridge.clipboard` | 内置 Go 扩展 | 开启 | 服务依赖(依赖 Guest Tools 传输服务)、运行中启停与完整拆除、按 VM 设置立即生效、宿主与客体的功能协商、隐私(内容不入日志) |
|
||||
|
||||
**剪贴板互通**
|
||||
|
||||
- 拆分 Guest Tools:回环 HTTP 鉴权、客体代理、`REIMSTOOLS` 辅助盘与 VM 注册作为内置「Guest Tools 传输服务」,对外提供路由注册与客体功能协商;剪贴板、共享文件夹、盘符只读共享、防休眠与文本输入是其上的功能扩展,剪贴板第一个迁出。
|
||||
- 激活时向传输服务注册剪贴板路由并启动宿主剪贴板监视,停用时二者随作用域释放;客体代理从配置接口得知功能关闭后停止轮询,旧版代理请求已关闭的路由时得到明确的「功能关闭」应答并退避。
|
||||
- 设置:全局开关 + 按 VM 覆盖;方向(双向 / 仅宿主到客体 / 仅客体到宿主);是否同步图片与大小上限;均立即生效。
|
||||
- `vm.card` 显示连接状态;排障包只记录次数与错误,不记录剪贴板内容。
|
||||
|
||||
#### 其余内置扩展(由现有模块迁入)
|
||||
|
||||
| 内置扩展 | 对应现有模块 | 使用的扩展点 |
|
||||
| :--- | :--- | :--- |
|
||||
| `builtin.bridge.guest-tools` | `internal/guesttools`、`guesttools_flow.go` | 提供传输服务 + `vm.beforeStart`(注入桥接参数与环境变量)+ `vm.afterStart` + `vm.card`;共享文件夹、盘符共享、防休眠逐步拆为功能扩展 |
|
||||
| `builtin.input` | `host/ime_hook_windows.go` | 提供输入服务与 `inputFilters`;IME 桥成为其上的功能,停用时卸载钩子线程 |
|
||||
| `builtin.install-guide` | `internal/installguide`、`internal/app/install_guide.go` | 提供 `ui.install-guide` 服务 + `vm.afterStop` / `vm.deleted` 观察钩子;在虚拟机窗口悬浮展示安装与恢复引导,停用时立即关闭全部浮层并回退主界面恢复卡片 |
|
||||
| `builtin.core`(系统插件) | `driver/reims_adapter.go`、`vmstart.Prepare` 各步骤、`app.go` 冷重启监视 | `guestDrivers` + `themes` + `host.preflight` + 一个按序执行全部启动准备的 `vm.beforeStart`(离线辅助盘 → 恢复模式引导 → 引导语言 → WHPX 降级 → Win10 冷重启)+ `vm.afterStart` / `vm.afterStop`(冷重启监视);设置 `whpx_fallback`、`win10_cold_reboot` |
|
||||
|
||||
### 5.5 与上游补丁队列的边界
|
||||
|
||||
| 类别 | 归属 | 原则 |
|
||||
| :--- | :--- | :--- |
|
||||
| 引擎内部崩溃与 Hypervisor 层修复(WHPX 兼容、协程、构建锁文件等) | [`patches/`](../patches/)(编译期) | 外部插件无法等价替代;坚持上游 PR,合入即退役 |
|
||||
| 窗口内部消息循环拦截(如 SDL 窗口内字符消息) | `patches/`,宿主侧做部分补偿 | 跨进程拦截需 DLL 注入,杀软误报风险高,不做成插件 |
|
||||
| 宿主侧绕过、兜底补偿与宿客桥接 | 内置扩展(§5.4) | 运行时缺少对应补丁时平滑降级;依据运行时 `capabilities` 判断 |
|
||||
|
||||
---
|
||||
|
||||
## 6. 插件包与清单
|
||||
|
||||
### 6.1 包格式与目录
|
||||
|
||||
- 插件包为 zip 归档,根目录含 `plugin.json`、`SHA256SUMS` 与可选签名(ed25519,签名覆盖 `SHA256SUMS`)。
|
||||
|
||||
| 路径(位于 `<DataRoot>/plugins/`) | 用途 |
|
||||
| :--- | :--- |
|
||||
| `state.json` | 启用状态、版本钉选、已批准权限快照、冲突偏好;写入用临时文件 + rename + `.bak`;**读取失败即报错,绝不视为空表** |
|
||||
| `pkgs/<id>/<version>/` | 解压后的只读包体,多版本并存,回滚即切换 |
|
||||
| `data/<id>/` | 插件私有可写目录,同时是 Sidecar 的工作目录 |
|
||||
| `logs/<id>.log` | 插件 stderr 与宿主审计记录,限额轮转 |
|
||||
| `index-cache.json` | 市场索引缓存(另有内嵌兜底副本) |
|
||||
|
||||
### 6.2 清单字段(`plugin.json`)
|
||||
|
||||
| 字段 | 说明 |
|
||||
| :--- | :--- |
|
||||
| `schema` | 清单格式版本 |
|
||||
| `id` / `version` | 反向域名 id;SemVer |
|
||||
| `name` / `description` | 多语种本地化文本(内置 `zh-CN` / `en-US` 及任意 BCP-47 扩展键),**无需执行插件代码即可读取** |
|
||||
| `l10n` | 可选的包内私有词表目录(如 `"locales"`),存放 `<locale>.json` 供插件自身 UI、iframe 面板与 Sidecar 使用;独立语言包可通过 `pluginOverrides` 在外部补充或覆盖任意第三方插件的清单字段与私有词条 |
|
||||
| `publisher` / `license` / `homepage` | 来源与许可,市场审核依据 |
|
||||
| `engines` | `reims-go` 版本范围与 `pluginApi` 范围,**下载前预检** |
|
||||
| `platforms` | 如 `windows-x64` |
|
||||
| `entry` | Sidecar 可执行文件、脚本文件、面板 HTML 根目录;层级由内容推导,不信任自报 |
|
||||
| `contributes` | 各扩展点贡献(§4.2) |
|
||||
| `requires` / `provides` | 服务与运行时依赖、提供的服务 |
|
||||
| `permissions` | Host API 能力(§7.1) |
|
||||
| `activation` | `onStartup` / `onVMEvent` / `onCommand` / `onPanel`,默认惰性激活 |
|
||||
| `settings` | JSON Schema;扩展标注 `x-secret`(不回显、不进日志)、`x-effect`(立即生效 / 下次启动生效)与 `x-scope`(`app` 全局 / `vm` 按虚拟机,后者渲染在 VM 设置对应分组) |
|
||||
| `defaultEnabled` | 安装或首次启动时的默认启用状态;仅内置扩展与随主程序附带的插件可为 `true` |
|
||||
| `provenance` | **运行时包必填**:上游仓库与 commit、补丁清单与哈希、源码包文件名 |
|
||||
|
||||
---
|
||||
|
||||
## 7. 权限、信任与安全边界
|
||||
|
||||
### 7.1 权限分级
|
||||
|
||||
| 等级 | 权限 | 审批 |
|
||||
| :--- | :--- | :--- |
|
||||
| **低** | `vm:read`(通用模型,不含敏感字段)、`ui:notify`、`task:progress`、`fs:plugin_data`、`log:read` | 启用时展示说明 |
|
||||
| **中** | `vm:intent`、`runtime:source`、`net:<origin>`(经宿主代理发出)、`ui:slot`、`input:filter`(声明输入过滤规则) | 首次启用逐项确认 |
|
||||
| **高** | `driver:vm`、`runtime:provider`、`process:spawn`、`vm:control`、`qmp:write`、`fs:vm_dir`、`fs:shared`、`host:clipboard`、`ui:script` | 强提示(展示可执行文件或脚本路径、SHA-256、发布者、许可证)并显式勾选;升级新增高危权限时暂停并要求重新批准 |
|
||||
| **不存在** | 敏感字段读取、UAC 提权、重启 Windows、直写 `vm.toml` | 插件只能请求宿主发起人工确认流程 |
|
||||
|
||||
### 7.2 如实声明的信任边界
|
||||
|
||||
- L1、L2、L4 的权限由宿主强制。**L3 是原生代码,OS 层面无法约束**,权限只约束其对 Host API 的访问;安装与启用 L3 插件时明确告知「此插件能以你的账户身份执行任意操作」。
|
||||
- 信任等级:`official`(官方密钥签名)、`verified`(审核 + 发布者签名)、`community`(仅哈希)、`dev`(本地链接,需开启开发者模式)。`community` 级 L3 插件默认不可启用,需二次确认。
|
||||
- 以 AppContainer 或低完整性级别运行 Sidecar 作为后续增强项评估。
|
||||
|
||||
### 7.3 UI 与本地接口安全
|
||||
|
||||
- 插件资源经 Wails AssetServer 的独立路由提供,路径带每次运行随机生成的令牌,校验目录穿越,附 `X-Content-Type-Options: nosniff` 与 CSP;SVG 一律禁脚本。
|
||||
- iframe 面板(后置):`sandbox="allow-scripts"`、`connect-src 'none'`;bridge 只应答来源窗口为自身 iframe 的消息,所有读取在 Go 侧按 `permissions` 二次校验并限流;主题令牌经 bridge 下发。
|
||||
- 宿主本地 HTTP 接口(如 Guest Tools)拒绝 `Origin: null`、跨站请求与 `Sec-Fetch-Dest: iframe` 请求,防止被沙箱 iframe 或外部网页借道调用。
|
||||
|
||||
---
|
||||
|
||||
## 8. 进程监管与通信协议
|
||||
|
||||
- **协议**:stdin/stdout 双向 JSON-RPC 2.0,采用 `Content-Length` 分帧(LSP 风格);握手交换 `pluginApi` 版本、能力、当前生效语种(`locale` / `fallbackChain`)及合并后的插件私有词表(`l10nBundle`),运行期切换界面语言时向已运行 Sidecar 广播 `plugin/localeChanged` 通知(不唤醒休眠进程);stdout 只走协议帧,日志一律走 stderr 并由宿主采集。截图、磁盘镜像等大对象不进 JSON,经插件数据目录内的文件路径传递。
|
||||
- **进程模型**:每个 L3 插件独立进程;全部放入设置 `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE` 的 Job Object,宿主退出或崩溃时进程树一并回收;L2 脚本宿主额外设置进程内存与 CPU 时间上限。
|
||||
- **健壮性**:单写协程 + 有界队列提供背压;所有请求可取消;回收依据进程句柄而非管道 EOF;子进程不继承协议管道,工作目录固定为 `data/<id>/`;崩溃后指数退避重启,连续失败熔断为 `failed`;升级与配置变更采用「先起新进程、旧进程处理完在途请求再退出」。
|
||||
- **惰性与回收**:按 `activation` 惰性拉起;空闲超时回收;托盘常驻模式下只保留有活动 VM 或后台服务的 Sidecar。
|
||||
- **GUI / CLI**:插件宿主位于核心包。需要常驻进程的能力(Sidecar、后台服务)由界面进程托管,与 Guest Tools 一致;CLI 经现有单实例交接走界面进程,`--data-root` 直连模式按需临时拉起所需 Sidecar,命令结束即回收。
|
||||
|
||||
### 8.1 资源预算(零外部插件零开销)
|
||||
|
||||
未安装任何外部插件时,插件系统不得明显增加占用。以引入插件系统前的版本为基线,在同一宿主上对比:
|
||||
|
||||
| 指标 | 预算 |
|
||||
| :--- | :--- |
|
||||
| 常驻内存(空闲、托盘常驻) | 增加 ≤ 3 MB |
|
||||
| 冷启动到主窗口可交互 | 增加 ≤ 20 ms |
|
||||
| 常驻进程、后台轮询与全局输入钩子 | 不新增 |
|
||||
| `reims-go.exe` 体积 | 增加 ≤ 1.5 MB |
|
||||
| 前端主包 | 插件管理页与 Schema 表单渲染器按需加载,不计入主包 |
|
||||
| VM 启动前的 `reims-ctl set` 调用 | 不多于改造前(意图合并后至多一次) |
|
||||
|
||||
保障预算的实现纪律:
|
||||
|
||||
- 事件只在有订阅者时分发,无订阅者时不构造事件对象(尤其是 `log.onLine`)。
|
||||
- 不引入状态轮询:Reconcile 只由安装、启停、设置变更触发;文件监视仅在开发者模式的本地链接上启用。
|
||||
- 不预热:Sidecar、脚本宿主、iframe 面板与市场索引均在首次使用时创建或拉取。
|
||||
- 只使用内置主题时不注入额外样式,UI SDK 仅在启用交互主题时加载。
|
||||
- 体积较大的依赖(如嵌入式 JS 引擎)不默认编入主程序,引入前单独评估体积代价。
|
||||
|
||||
---
|
||||
|
||||
## 9. 分发、更新与恢复
|
||||
|
||||
- **安装来源**:本地包导入(首批)、市场索引(后续)、开发者模式本地目录链接。
|
||||
- **随主程序附带的插件**:需要时可以标准插件包形式嵌入 `reims-go.exe`,信任等级为 `official`,版本跟随主程序;可启用/停用,不可卸载。
|
||||
- **事务安装与静态准入门禁**:下载到 `tmp` → 校验 `SHA256SUMS` 与签名 → 核对包内 `id` / `version` 与预期一致(防偷换)→ 兼容预检 → 静态安全门禁(拦截 L1/L4 夹带可执行/系统脚本、L3 未声明二进制、SVG 主动脚本、`ui:script` 宿主逃逸或未声明联网、市场红线)→ 原子 rename 到 `pkgs/<id>/<version>` → 提交 `state.json`。任一步失败都不改变现状。对 L3 原生程序不声称“代码扫描安全”,仅核对清单完整性与 SHA-256 并向用户如实展示完整当前 Windows 账户权限说明。
|
||||
- **市场索引与软撤回**:独立仓库发布轻量静态 `index.json`(二进制包托管在 GitHub Releases,复用运行时下载与代理逻辑;可通过 `REIMS_GO_PLUGIN_MARKET_URL` 配置镜像或 `off` 强制离线),含版本、`engines`、`platforms`、下载地址、SHA-256、签名者与软撤回列表(`withdrawn`,阻止新装并对存量用户展示替代建议);首次打开市场或执行市场 CLI 命令时惰性拉取,使用内存 + `<DataRoot>/plugins/index-cache.json` 双层缓存与主程序内嵌兜底副本,网络失败不覆写有效缓存。
|
||||
- **更新与回滚**:新旧版本并存、切换指针,保留最近若干版本;插件同样区分 `alpha` / `stable` 通道,默认只取 `stable`。
|
||||
- **安全模式**:`reims-go --safe-mode` 跳过全部第三方插件,界面顶部显示横幅与插件管理入口;以启动哨兵文件检测上次插件初始化阶段异常退出,下次启动询问是否进入安全模式。
|
||||
- **市场红线**:拒收含 Apple 专有文件、SMBIOS 真值或闭源固件的包;运行时包必须附源码与许可证。
|
||||
|
||||
---
|
||||
|
||||
## 10. GUI 与 CLI 接入
|
||||
|
||||
| 入口 | 内容 |
|
||||
| :--- | :--- |
|
||||
| CLI | `reims-go plugin list / search / install <zip\|id> / update [id] / pack <dir> / link <dir> / enable [--approve-high-risk] / disable / remove [--purge] / info / doctor [--json] [dir\|zip\|id] / locale <init\|check> / run <id> <command>`;`vm create --driver <id>` |
|
||||
| 应用设置 → 插件 | 提供「已安装 / 插件市场」双视图(市场索引惰性加载):核心置顶、显示「始终启用」且无开关;其余显示来源与信任标签、权限摘要、安全扫描报告入口、启用开关、故障状态与日志入口;本地包导入前先展示三段式静态安全报告并执行硬门禁拦截 |
|
||||
| 插件设置页 | 由 `settings` Schema 渲染,复用现有设置控件,标注生效时机 |
|
||||
| VM 页面 | 按能力位显隐操作;`vm.toolbar` 菜单项支持 `when` 条件;`vm.card` 展示驱动或插件提供的键值信息 |
|
||||
| 创建向导 | 先选驱动,再按驱动 `CreateSchema` 渲染专属表单 |
|
||||
|
||||
所有插件文案遵守 [`design-guidelines.md`](design-guidelines.md) §7,插件贡献的按钮与菜单不得占用页头主操作位。
|
||||
|
||||
---
|
||||
|
||||
## 11. 技术难点
|
||||
|
||||
1. **驱动抽象重构**:VM 详情模型与前端(VM 页、设置面板、托盘、CLI)深度耦合 macOS / reims 字段,需在不回归现有功能的前提下拆出通用模型与能力位,是工作量最大的一步。
|
||||
2. **意图合并与参数归属**:多插件意图的冲突仲裁、账本与 `reims-ctl set` 的一致性、OpenCore 重建后重放(如客体语言)的时序。
|
||||
3. **运行时契约脆弱**:`reims-ctl show` 目前为文本解析,第三方运行时若改变输出即破坏驱动;需以 `runtime_api` 严格版本化,并推动上游提供结构化输出。
|
||||
4. **Windows 进程管理**:Job Object 与 VM 进程归属分离、孤儿进程、未签名 Sidecar 被杀软或 SmartScreen 拦截、非 ASCII 用户名路径。
|
||||
5. **原生插件安全**:L3 无法沙箱化,只能依靠签名、审核、信任分级与透明告知。
|
||||
6. **UI 一致性与自由度**:严格设计规范下以声明式贡献为主,iframe 面板需同步主题令牌、DPI、焦点与快捷键。
|
||||
7. **UI 契约维护**:部件类名、状态属性与令牌成为公共 API 后,前端重构须连同 `uiApi` 版本与契约检查一起演进;交互主题脚本在主窗口内运行,只能靠信任分级与 SDK 约束,无法物理隔离。
|
||||
8. **全局输入钩子**:低级鼠标钩子影响整个系统的输入延迟,回调必须极短且按需安装;SDL 捕获模式下的行为与杀软启发式误报需真机验证。
|
||||
9. **公共 API 稳定性**:v0.x 核心演进快,首批扩展点必须克制并版本化,保持对上一 `pluginApi` 主版本的兼容窗口。
|
||||
10. **Linux 客体图形与集成**:Windows 上缺少与 `reims-vgpu` 等价的 Linux 加速路径,cloud-init 与客体代理需要额外工程。
|
||||
11. **合规**:第三方运行时的源码义务、插件许可证声明、插件排障内容的强制脱敏。
|
||||
12. **资源占用**:惰性激活、空闲回收与面板释放,守住 §8.1 的资源预算与现有内存约束。
|
||||
|
||||
---
|
||||
|
||||
## 12. 分阶段演进与验收标准
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
P0["Phase 0\n内部抽象\n(不对外)"] --> P1["Phase 1\n插件底座 + L1\n(主题/模板/运行时源/规则 Hook)"]
|
||||
P1 --> P2["Phase 2\n运行时种类"]
|
||||
P1 --> P3["Phase 3\nL3 Sidecar + Host API"]
|
||||
P3 --> P4["Phase 4\n官方 Linux 驱动"]
|
||||
P3 --> P5["Phase 5\n生态:签名/市场/iframe/L2"]
|
||||
```
|
||||
|
||||
| 阶段 | 范围 | 验收标准 |
|
||||
| :--- | :--- | :--- |
|
||||
| **Phase 0** | 注册表与可逆作用域;驱动抽象(reims 为内置驱动);启动准备与宿客桥接迁为内置扩展;Guest Tools 拆出传输服务与**剪贴板互通示例**;输入服务(IME 键盘钩子迁入);参数归属账本;UI 契约 v1(令牌单一来源、部件类名、状态属性) | `go test ./...` 与前端构建通过;存量 VM 零迁移、行为零回归;剪贴板互通可在 VM 运行中开关且关闭后零残留(无残留路由与剪贴板监视);可选内置扩展同样可独立停用且零残留,核心始终启用;满足 §8.1 资源预算 |
|
||||
| **Phase 1** | 插件包与清单、事务安装、`state.json`、安全模式;插件管理页与 `reims-go plugin`;`inputFilters`;令牌主题与样式主题接口;图标、VM 模板、运行时源、规则 Hook | 以不发布的测试主题与示例声明式插件验证配色方案、字体、部件样式、状态装饰与启停零残留;损坏包与不兼容包在落盘前被拒绝;仍满足 §8.1 资源预算 |
|
||||
| **Phase 2** | 运行时种类注册表、`runtime_api` 与 `capabilities`、来源展示 | 第二种运行时与官方运行时并存切换;不兼容组合被拦截并给出提示 |
|
||||
| **Phase 3** | JSON-RPC 协议 v1、进程监管、反向 Host API、权限审批、代码 Hook、插件命令、排障采集、轻量 Go SDK | 死循环或崩溃的示例 Sidecar 不影响主窗口与运行中 VM;退出或禁用后无孤儿进程 |
|
||||
| **Phase 4** | 独立仓库的官方 Linux 驱动 | 不修改主程序源码,经 GUI 与 CLI 完成 Linux VM 创建、WHPX 启动、绑核、截屏、SSH 与快照;真机验证 |
|
||||
| **Phase 5** | 签名体系与市场索引、iframe 面板、交互主题 UI SDK、按需引入 L2 脚本宿主 | 第三方插件经审核上架;iframe 面板无法越权读取或联网;参照 dsh-claude-style 的功能清单逐项确认可由三档主题能力承载或列出缺口 |
|
||||
|
||||
---
|
||||
|
||||
## 13. 待决事项
|
||||
|
||||
1. **L2 脚本宿主是否需要**:仅当出现 L1 规则无法表达、又不适合要求作者交付原生 exe 的真实需求时引入;届时在纯 Go JS 引擎与 WASM 之间选型。
|
||||
2. **市场形态与审核责任**:首批仅本地包导入;社区索引的维护者、审核流程与签名密钥托管方式待定。
|
||||
3. **Sidecar 原生沙箱**:AppContainer / 低完整性级别的兼容性与维护成本待评估。
|
||||
4. **上游结构化输出**:是否向上游提议 `reims-ctl show --json`,以及非 macOS 客体支持的计划,需核对上游实际进展(待验证)。
|
||||
@@ -1,56 +1,30 @@
|
||||
# 便携运行时规范(Portable Runtime Spec)
|
||||
|
||||
> 实测日期:2026-11-28
|
||||
> 基准上游:`steelbrain/reims-vgpu` commit `3731afd9b13416a24f74ec27a90b3913aef2dcc0`(QEMU `11.1.90`,`reims-util 0.1.0`)
|
||||
> **本地补丁**:本机实测用的 QEMU **不是纯上游构建**。`vendor/qemu`(`4571bc5`)的 `target/i386/whpx/whpx-all.c` 带着一个未提交的修改,内容与 [`macos-vm-lab/patches/qemu-whpx-win10-compat.patch`](../../macos-vm-lab/patches/qemu-whpx-win10-compat.patch)(SHA256 `3eed7895…0304b8`,无 BOM、LF 行尾)一致。没有它,Win10 19045 上 VM 起不来。见第 5 节。
|
||||
> 本文定义 Reims-Go Windows x86-64 便携运行时的打包结构、目录隔离、CI 自动构建、`alpha` → `stable` 发布通道以及开源合规义务。
|
||||
|
||||
## 1. 脱离 MSYS2 / Rust / 源码仓库的实测结论
|
||||
---
|
||||
|
||||
2026-11-28 在本机(Windows 10 19045 x64 + i7-12700K + RTX 4070 Ti)构造了纯净临时环境:
|
||||
- `PATH` 仅保留便携 `bin\` 与 Windows 系统目录(`System32` / `Wbem` / `WindowsPowerShell`),**完全不含** `MSYS2`、`Cargo/Rust`、`Git`、`reims-vgpu` 源码目录。
|
||||
- 通过 `XDG_CONFIG_HOME`、`XDG_DATA_HOME`、`XDG_CACHE_HOME` 将所有读写重定向至隔离目录。
|
||||
## 1. 自包含前提与上游耦合
|
||||
|
||||
实测结果:
|
||||
`reims-vgpu` 的 Windows 运行时在二进制层面可以脱离 MSYS2、Rust 工具链与源码树独立运行:
|
||||
|
||||
| 检查项 | 结果 | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| `qemu-system-x86_64.exe -device help` | ✅ PASS | 正确列出 `reims-graphics-pci`(71 个 CLANG64/libva DLL 已由上游 `install-ctl.sh:783-797` 随 `bin\` 打包) |
|
||||
| `reims-util.exe --version` | ✅ PASS | 输出 `reims-util 0.1.0` |
|
||||
| `reims-ctl.exe list --json` | ✅ PASS | 输出 `[]`,无报错 |
|
||||
| `reims-ctl.exe doctor` — `host` / `files` / `qemu` / `audio` / `hypervisor platform` / `vulkan` / `sound` / `desktop` / `reims-util` | ✅ 9/9 PASS | 全部 `ok`,正确识别 RTX 4070 Ti(`nv-vk64.json`)与 XDG 数据路径 |
|
||||
| `reims-ctl.exe doctor` — `checkout` | ❌ FAIL(预期内) | 见第 2 节源码分析:仅因 `install.toml` 缺少必填 `repo` 字段,且 `checkout` 仅用于 `reims-ctl update` |
|
||||
- **内嵌引导与驱动资源**:`reims-ctl.exe` 编译时已内嵌 `ReimsGraphics.rom` 与 Guest Kexts,运行时按内容哈希释放到 `<XDG_DATA_HOME>/reims-ctl/prebuilt/`。
|
||||
- **XDG 路径重定向**:传入 Windows 绝对路径格式的 `XDG_CONFIG_HOME`、`XDG_DATA_HOME`、`XDG_CACHE_HOME` 后,`reims-ctl` 与 `reims-util` 均遵守重定向,不写入 `%USERPROFILE%`(仅短路径 socket 使用 `%TEMP%\reims-ctl`)。
|
||||
- **QEMU 定位优先级**:`reims-ctl` 优先使用 `REIMS_CTL_QEMU` 指定的 `qemu-system-x86_64.exe`,并在同级目录定位 `qemu-img.exe`。
|
||||
- **版本强耦合约束**:`reims-ctl.exe`、`reims-util.exe` 与 `qemu/` 必须来自同一个上游 commit,作为单个版本目录原子安装与回滚,避免协议或内嵌 kext 错配。
|
||||
|
||||
**结论**:`reims-vgpu` 的 Windows 运行时在二进制层面**已经自包含,可以脱离 MSYS2 与编译环境独立运行**。
|
||||
---
|
||||
|
||||
**限定条件**:这次实测的 `qemu/` 带着第 5 节的 Win10 补丁。纯上游构建在 Win10 19045 上已于 2026-11-28 实测必现两处崩溃(见第 5 节证据)。所以运行时包必须说明自己带了哪些补丁,不能写成「纯上游 `3731afd`」。
|
||||
## 2. 运行时包与用户目录规范
|
||||
|
||||
## 2. 上游源码关键发现(`3731afd`)
|
||||
|
||||
1. **Option ROM 与 Guest Kext 已内嵌**(`crates/reims-ctl/src/prebuilt.rs:1-32`):
|
||||
- `reims-ctl.exe` 编译时已将 `ReimsGraphics.rom` 与 `guest/prebuilt/set.toml` 内的全部 kext 嵌入二进制,运行时按内容哈希释放到 `<XDG_DATA_HOME>/reims-ctl/prebuilt/`,不依赖源码树。
|
||||
2. **XDG 路径重定向在 Windows 原生生效**(`crates/reims-ctl/src/paths.rs:54-77`):
|
||||
- 只要传入 Windows 绝对路径格式的 `XDG_CONFIG_HOME`、`XDG_DATA_HOME`、`XDG_CACHE_HOME`,`reims-ctl` 与 `reims-util` 均遵守重定向,不会写入 `%USERPROFILE%`。
|
||||
- 唯一仍在系统盘的是临时运行目录 `%TEMP%\reims-ctl`(用于短路径 socket,体积极小)。
|
||||
- 上游另有两个专用变量,优先级高于 XDG:`REIMS_CTL_CONFIG_DIR`(`paths.rs:61-66`)和 `REIMS_CTL_DATA_DIR`(`paths.rs:68-73`)。它们直接给出 `reims-ctl` 的目录,不再拼 `reims-ctl` 子目录。缓存目录没有专用变量,只认 `XDG_CACHE_HOME`(`paths.rs:75-77`)。`reims-util` 是否认这两个变量**待验证**,所以 `reims-go` 先继续注入 XDG 三件套。
|
||||
3. **QEMU 定位优先级**(`crates/reims-ctl/src/install.rs:85-101`):
|
||||
- 优先读取环境变量 `REIMS_CTL_QEMU`(`qemu-img.exe` 自动从其同级目录查找);
|
||||
- 未设置时回退到 `<XDG_DATA_HOME>\reims-ctl\qemu\current\bin\qemu-system-x86_64.exe`。
|
||||
4. **`install.toml` 的 `repo` 字段**(`crates/reims-ctl/src/install.rs:34-50`):
|
||||
- `Install.repo` 没有 `#[serde(default)]`,省略会导致 `Install::load()` 返回 `None`,令 `doctor` 报 `FAIL checkout`。
|
||||
- `reims-go` **不调用 `reims-ctl update`**,而是由自带的 Runtime Manager 下载新版预编译包并原子切换版本目录;自检模块直接消费 `reims-go` 的健康检查,不依赖 `checkout` 项。
|
||||
|
||||
## 3. 便携运行时体积与目录规范
|
||||
|
||||
本机实测未压缩体积:**917.8 MB**(`qemu/` 828.5 MB + `reims-ctl.exe` 58.0 MB + `reims-util.exe` 31.3 MB);2026-11-28 实测使用 `zstd -T0 -15` 打包 `reims-runtime-win-x64-3731afd.tar.zst` 后仅 **`160.4 MB`**(压缩率 **17.5%**,不到同类 PySide6 打包方案 1.68 GB 的十分之一)。
|
||||
|
||||
### 3.1 运行时发布包结构(`reims-runtime-win-x64-<commit>.tar.zst`)
|
||||
### 2.1 运行时压缩包结构(`reims-runtime-win-x64-<commit>.tar.zst`)
|
||||
|
||||
```text
|
||||
reims-runtime-<commit>/
|
||||
├── manifest.json # 上游 commit、vendor/qemu commit、补丁清单与哈希、通道、构建日期、各文件 SHA256
|
||||
├── NOTICE.md # 上游源码链接与第三方许可声明
|
||||
├── licenses/ # GPL-2.0、LGPL-3.0 等许可证原文
|
||||
├── patches/ # 本包打上的补丁原文(与 manifest.json 的补丁清单一一对应)
|
||||
├── manifest.json # 上游各仓库 commit、补丁清单与哈希、构建通道、可执行文件 SHA-256、符号包索引
|
||||
├── NOTICE.md # 上游来源与第三方许可声明
|
||||
├── licenses/ # GPL-2.0、LGPL-3.0 等许可证全文
|
||||
├── patches/ # 实际应用的全部补丁原文(与 manifest.json 一一对应)
|
||||
├── bin/
|
||||
│ ├── reims-ctl.exe
|
||||
│ └── reims-util.exe
|
||||
@@ -59,102 +33,102 @@ reims-runtime-<commit>/
|
||||
│ ├── qemu-system-x86_64.exe
|
||||
│ ├── qemu-img.exe
|
||||
│ ├── reims-vgpu-compile.exe
|
||||
│ └── *.dll # 71 个自包含 CLANG64 + libva/vaon12 DLL
|
||||
└── share/ # QEMU pc-bios / edk2 / keymaps 等数据文件
|
||||
│ └── *.dll # 自包含 CLANG64 与 libva/vaon12 运行库
|
||||
└── share/ # x64 pc-bios / edk2 / keymaps 等数据文件
|
||||
```
|
||||
|
||||
> **版本耦合约束**:`reims-ctl.exe`、`reims-util.exe` 与 `qemu/` 必须来自**同一个上游 commit**,作为单一版本目录原子安装与回滚,避免协议或内嵌 kext 版本错配。
|
||||
### 2.2 裁剪与调试符号分离
|
||||
|
||||
### 3.2 用户数据目录结构(由用户在向导中选择,默认非系统盘如 `D:\Data\reims-go\`)
|
||||
打包脚本 [`scripts/stage-runtime-binaries.ps1`](../scripts/stage-runtime-binaries.ps1) 执行两项体积优化,在缩小下载体积的同时保留完整调试能力:
|
||||
|
||||
1. **裁剪非必要工具与异架构固件**:仅移除 Windows x64 启动器不会调用的 `qemu-system-x86_64w.exe`、`elf2dmp.exe`、`qemu-edid.exe`、`qemu-io.exe`、`qemu-nbd.exe`、`qemu-storage-daemon.exe`,以及 ARM64、RISC-V、LoongArch64 的 EDK2 固件与描述文件;完整保留 x64 固件、BIOS、ROM、keymaps、动态加载的 `libva` 视频驱动与全部 DLL。
|
||||
2. **独立发布调试符号**:使用 MSYS2 CLANG64 的 `llvm-objcopy` 从 5 个主可执行文件(`reims-ctl.exe`、`reims-util.exe`、`qemu-system-x86_64.exe`、`qemu-img.exe`、`reims-vgpu-compile.exe`)提取 `.debug` 符号并写入 GNU debug link,打包为同 Release 下的 `reims-runtime-symbols-<commit>.tar.zst`(客户端默认不下载符号包)。`manifest.json` 记录最终剥离后可执行文件的 SHA-256。
|
||||
|
||||
### 2.3 用户数据目录与子进程环境
|
||||
|
||||
用户首次启动时自选非系统盘数据目录 `<DataRoot>`:
|
||||
|
||||
```text
|
||||
<DataRoot>/
|
||||
├── reims-go.json # reims-go 自身配置(数据目录、默认硬件参数、镜像加速等)
|
||||
├── reims-go.json # 应用配置(数据目录、语言、外观、代理与通道设置等)
|
||||
├── runtimes/
|
||||
│ ├── <commit>/ # 解压后的便携运行时(含 bin/ 与 qemu/)
|
||||
│ └── current -> <commit> # 当前激活版本(目录联接或配置文件指向)
|
||||
├── config/ # 注入为 XDG_CONFIG_HOME(含 reims-ctl/vms.toml)
|
||||
├── data/ # 注入为 XDG_DATA_HOME(含 reims-ctl/vms/、installers/、prebuilt/)
|
||||
├── cache/ # 注入为 XDG_CACHE_HOME
|
||||
└── images/ # Golden Images 与 CoW backing files(M3)
|
||||
│ ├── <commit>/ # 解压后的便携运行时
|
||||
│ └── current # 当前激活版本指向
|
||||
├── config/ # 注入为 XDG_CONFIG_HOME(含 reims-ctl/vms.toml)
|
||||
├── data/ # 注入为 XDG_DATA_HOME(含 reims-ctl/vms/、installers/、prebuilt/)
|
||||
├── cache/ # 注入为 XDG_CACHE_HOME
|
||||
├── shared/ # Guest Tools 共享目录
|
||||
├── reports/ # 导出的脱敏排障日志包
|
||||
└── tmp/ # 临时文件与 CLI 启动回传状态
|
||||
```
|
||||
|
||||
调用 `reims-ctl.exe` 时,`reims-go` 在子进程环境变量中统一注入:
|
||||
调用 `reims-ctl.exe` / `reims-util.exe` 时,由 `internal/runtime` 统一注入隔离环境变量:
|
||||
- `XDG_CONFIG_HOME=<DataRoot>\config`
|
||||
- `XDG_DATA_HOME=<DataRoot>\data`
|
||||
- `XDG_CACHE_HOME=<DataRoot>\cache`
|
||||
- `REIMS_CTL_QEMU=<DataRoot>\runtimes\<active>\qemu\bin\qemu-system-x86_64.exe`
|
||||
- `PATH=<DataRoot>\runtimes\<active>\bin;<System32>...`(确保 `reims-ctl` 能直接找到同目录的 `reims-util.exe`)
|
||||
- `PATH=<DataRoot>\runtimes\<active>\bin;<System32>...`
|
||||
|
||||
## 4. 打包与发布流水线(M0 / M4)
|
||||
---
|
||||
|
||||
- **本地打包验证(M0)**:编写 `scripts/pack-runtime.ps1`,直接从本机已编译的 `reims-vgpu` 产物生成 `reims-runtime-win-x64-3731afd.tar.zst` 与 `manifest.json`(含 SHA256),验证纯净解压启动。
|
||||
- **本地打包与发布(2026-11-28 起)**:`pwsh -File scripts/pack-runtime.ps1 -Channel candidate` 一次产出三个文件:运行时包、对应源码包 `reims-runtime-src-<commit>.tar.zst`、覆盖两者的 `SHA256SUMS.txt`。
|
||||
- **打包前的检查**:脚本先核对每个补丁是否与构建目录里的 diff 完全一致;不一致、或者构建目录里有未登记的改动,就直接停止,不会自动修改补丁。
|
||||
- **manifest 版本 2**:比版本 1 多记录 `vendor_qemu_commit`、`util_commit`、`metal2vulkan_commit`、`patches`(名称、作用对象、SHA256)、`channel`、`source_package`。`dll_count` 改为按实际文件统计;版本 1 的统计有误,记为 0。
|
||||
- **发布位置**:运行时发布在 [`Nwflower/reims-go`](https://github.com/Nwflower/reims-go/releases) 的 GitHub Release。tag 为 `runtime-<commit>`,附件就是上面三个文件。GitHub 的预发布对应 `candidate`,正式发布对应 `stable`。三个附件缺任何一个,客户端就不会列出这个版本。
|
||||
- **客户端安装**(`internal/runtime/remote.go`):从 GitHub API 列出版本 → 下载运行时包,支持续传 → 对照 `SHA256SUMS.txt` 校验,不一致就丢弃 → 用原有的导入流程解压并激活 → 删除下载的压缩包。
|
||||
- **已发布**:`runtime-3731afd`,候选版。实测从 GitHub 下载 169 MB、校验、解压、激活,全程约 75 秒。
|
||||
- **自动化 CI(M4)**:在 GitHub Actions `windows-latest` runner 上使用 MSYS2 CLANG64,先打上第 5 节的补丁队列,再执行上游构建脚本,产出 `reims-runtime-win-x64-<commit>.tar.zst`、`SHA256SUMS.txt` 和对应源码包(第 7 节)。CI 产物只进 `candidate` 通道,不直接发给用户(第 6 节)。
|
||||
- **CI 测不到 Win10**:`windows-latest` 是 Windows Server 2022/2025,复现不了第 5 节的 Win10 问题,而且 GitHub 托管 runner 一般不提供 WHPX。CI 只能保证「能构建、`-device help` 列出 `reims-graphics-pci`」,能不能启动 VM 要靠第 6 节的本机冒烟测试。
|
||||
## 3. 打包与 CI 自动构建
|
||||
|
||||
## 5. 补丁队列(把上游当内核来优化的方式)
|
||||
### 3.1 本地打包
|
||||
运行 `pwsh -File scripts/pack-runtime.ps1 -Channel alpha` 一次产出以下发布附件:
|
||||
1. `reims-runtime-win-x64-<commit>.tar.zst`(运行时主体)
|
||||
2. `reims-runtime-symbols-<commit>.tar.zst`(独立调试符号包)
|
||||
3. `reims-runtime-src-<commit>.tar.zst`(上游源码 + 补丁原文 + 重建说明)
|
||||
4. `reims-runtime-msys2-src-<commit>.tar.zst`(MSYS2 copyleft DLL 源码包,由 [`scripts/pack-msys2-sources.ps1`](../scripts/pack-msys2-sources.ps1) 生成)
|
||||
5. `SHA256SUMS.txt`(覆盖上述压缩包的统一校验清单)
|
||||
|
||||
原则:**不长期维护 fork,补丁数以清零为目标。** 每个补丁都要经过「本地带着发 → 由人向上游提 PR → 上游合并后删掉本地副本」这个周期。
|
||||
打包前脚本会核对构建目录的 `git diff` 是否与声明的补丁逐字节一致;存在未声明修改或补丁不匹配时立即停止。
|
||||
|
||||
| 补丁 | 作用对象 | 解决的问题 | 状态 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `qemu-whpx-win10-compat.patch` | `vendor/qemu` 的 `target/i386/whpx/whpx-all.c` | ① `whpx_tsc_deadline_refused()`(`3210-3230`)原实现在真实分区上建、删 vCPU 0,Win10 19045 上随后 `whpx_init_vcpu()` 再次创建 vCPU 0 时必现 `WHvCreateVirtualProcessor` 返回 `E_INVALIDARG`(`hr=80070057`),改为独立临时探测分区;② `whpx_set_registers()`(`534`)直接调用 `WHvResetPartition` 未判空,Win10 19045 的 `WinHvPlatform.dll` 不导出该接口导致重置阶段必现 `0xc0000005 at 0x0` 崩溃(已核对导出表,10 个 supplemental API 中仅此一处漏判空) | 2026-11-28 实测复现并修复,待提交上游 PR(由人操作) |
|
||||
| `qemu-whpx-win10-startup-ipis.patch` | 同上(在前一项之后应用) | Win10 开启内核 irqchip 时转发多核 INIT/SIPI,避免 XNU 从核启动停住 | 已合入补丁队列,客体冷重启待验证,待提交上游 PR |
|
||||
| `qemu-whpx-nested-virt-nonfatal.patch` | 同上(在前两项之后应用) | 部分 Win11 宿主 `WHvSetPartitionProperty(NestedVirtualization)` 返回 `hr=0x80370302`(`WHV_E_UNKNOWN_PROPERTY`)导致 QEMU 在 `whpx-all.c:3479-3483` 直接致命退出,改为非致命警告并清零 `Bank1.NestedVirtSupport`,保留 `kernel-irqchip=on` 内核态 x2APIC 加速 | 2026-11-28 新增补丁,待编入下一版 candidate 运行时并在 Win11 真机冒烟验证后提 PR |
|
||||
### 3.2 每日 CI 构建
|
||||
[`.github/workflows/build-runtime.yml`](../.github/workflows/build-runtime.yml) 每日定时(也支持手动指定 commit)在 `windows-latest`(MSYS2 CLANG64)执行:
|
||||
1. 读取上游默认分支 `HEAD`;若已存在 `runtime-<commit>` Release(不论 `alpha` 或 `stable`)则跳过。
|
||||
2. 由 [`scripts/apply-patch-series.ps1`](../scripts/apply-patch-series.ps1) 按 [`patches/series.txt`](../patches/series.txt) 顺序打补丁:可正常应用的直接应用;已合入上游的自动跳过并开 Issue 提醒退役;遇到冲突则中止构建。
|
||||
3. 执行上游 `scripts/install-ctl.sh --yes` 编译,调用 `scripts/pack-runtime.ps1 -Channel alpha` 打包。
|
||||
4. 运行 [`scripts/check-runtime-alpha.ps1`](../scripts/check-runtime-alpha.ps1) 校验 5 个附件、`SHA256SUMS.txt`、`manifest.json` 哈希一致、许可证齐全,以及在不含 MSYS2 的纯净 `PATH` 下验证 vGPU 设备枚举、CLI 版本与 `qcow2` 创建读取。
|
||||
5. 通过后发布为 GitHub 预发布(`alpha`),并自动清理超过保留上限(最近 7 个)的旧 `alpha` 预发布;正式版不受影响。
|
||||
|
||||
### 5.1 本机实测排障与待验证优化沉淀(2026-11-28,Win10 19045)
|
||||
1. **Win10 下默认关闭 `kernel-irqchip` 导致高 CPU 开销(待验证优化)**:
|
||||
- Win10 19045 因缺少 `WHvCapabilityCodeProcessorPerfmonFeatures`(`hr=80370300`)进入 `whpx_is_legacy_os()` 分支(`whpx-all.c:3347-3397`),默认关闭 `kernel-irqchip`,导致上游专为 WHPX 实现的无锁 MSI-X(`whpx_send_msi_direct`)和无 BQL 运行(`whpx_vcpu_pre_run`,见上游 `docs/qemu.md:135-136`)全部失效;实测在 Guest 内以 6.7–10 MB/s 写入磁盘时 QEMU 消耗达 1.7–2.7 个满核 CPU 与 ~15,530 ops/s。
|
||||
- 最小 WHP 实验发现,同一从核首次启动并进入 `HLT` 后,第二次由客体发送的 SIPI 超时;经 `WHvRequestInterrupt` 转发可连续启动。[`qemu-whpx-win10-startup-ipis.patch`](../patches/qemu-whpx-win10-startup-ipis.patch) 只在 Win10、内核 irqchip 和多核同时启用时转发 INIT/SIPI。8 核两次冷启动和 12 核冷启动均已进入桌面,x2APIC、FileVault、SSH 和图形登录通过;默认启动及正常关机也通过。客体冷重启仍待验证。
|
||||
2. **Windows 提交内存(Commit Limit)硬拦截**:
|
||||
- 32 GB 物理内存宿主在开启常见软件后,实测可用提交内存(`FreeVirtualMemory`)仅 `14.7 GiB`(即使空闲物理内存仍有 `17.3 GiB`);QEMU 启动时一次性 `CreateFileMapping` 提交全部 Guest RAM,分配 `16G` 直接退出报 `Cannot set up guest memory 'ram': 系统资源不足`。`reims-go` 必须在体检与启动前检测提交内存并动态限位(详见 [`architecture.md`](architecture.md) 3.1 节)。
|
||||
3. **在线 Recovery 拉取 17 GB 极易因 Apple CDN 断流失败**:
|
||||
- 实测拉取 961 MB 恢复镜像期间 Apple CDN 即出现 6 次 `Peer disconnected`;在 Recovery 内经 QEMU 用户态 NAT(`slirp`)拉取 ~17 GB 系统包时,`OSISDownloadOperation` 抗断流能力差,易在接近完成(实测 `disk.qcow2` 已达 `16.95 GiB`)时失败。因此 `reims-go` GUI 默认改为宿主机调用 `reims-util offline-installer --json` 断点续传下载离线安装包(详见 [`architecture.md`](architecture.md) 3.3 节)。
|
||||
> **CI 边界**:GitHub 托管的 Windows Server runner 不提供 WHPX,也无法复现 Windows 10 兼容性问题。CI 只验证可编译与控制面基本可用,实际能否启动 macOS 桌面必须经过第 5 节的真机冒烟。
|
||||
|
||||
规则:
|
||||
1. 补丁原文的权威副本放在 `reims-go/patches/`。macos-vm-lab 的那份是研究时的原始记录。
|
||||
2. 每次跟进上游 commit 时,先 `git apply --check`。打不上就停在 `candidate`,不要自动改补丁。
|
||||
3. 补丁文件必须是**无 BOM、LF 行尾**,由 `.gitattributes` 的 `*.patch -text` 保证。用 PowerShell 5.1 的 `Out-File` 或 `>` 生成的补丁会带 BOM 和 CRLF,`git apply` 不认(2026-11-28 实测,原始副本就是这样)。
|
||||
4. 上游合并之后,在表里记下合并 commit,然后删掉补丁。
|
||||
### 3.3 客户端下载与安装
|
||||
`internal/runtime` 默认从 GitHub Releases(tag `runtime-<commit>`)拉取,沿用环境变量与 Windows 系统代理,支持 HTTP `Range` 续传、强制 `SHA256SUMS.txt` 校验、临时目录原子解压与多版本切换。
|
||||
|
||||
## 6. 发布通道(已验证通道)
|
||||
---
|
||||
|
||||
上游变动非常快(2026-11-21 到 11-28 有 100 多个提交,截至 2026-11-28 没有任何 GitHub Release),出现过某个提交弄坏 `reims-ctl` 安装的情况([issue #138](https://github.com/steelbrain/reims-vgpu/issues/138))。所以运行时**不跟上游最新 commit**,而是分两级:
|
||||
## 4. 补丁队列
|
||||
|
||||
| 通道 | 来源 | 进入条件 |
|
||||
本仓库不维护长期 fork,所有尚未合入上游的最小兼容性补丁统一维护在 [`patches/`](../patches/)。补丁清单、作用对象、上游化进展与退役检查表见:
|
||||
- 机器清单:[`patches/series.txt`](../patches/series.txt)
|
||||
- 维护文档:[`patches/README.md`](../patches/README.md)
|
||||
|
||||
运行时包的 `manifest.json` 必须如实列出所有实际应用的补丁与哈希,带补丁的构建不得标注为纯上游版本。
|
||||
|
||||
---
|
||||
|
||||
## 5. 发布通道(`alpha` → `stable`)
|
||||
|
||||
上游提交频率高且无稳定 Release,默认用户不能直接暴露在未验证的上游 `HEAD` 下。运行时采用两级通道:
|
||||
|
||||
| 通道 | GitHub Release 形态 | 准入条件 |
|
||||
| :--- | :--- | :--- |
|
||||
| `candidate` | CI 按指定上游 commit 构建并打补丁 | 能构建;`qemu-system-x86_64.exe -device help` 列出 `reims-graphics-pci`;SHA256 清单齐全 |
|
||||
| `stable` | 从 `candidate` 升级 | 在一台真实 Win10 或 Win11 宿主上跑通冒烟测试:`doctor` 的运行时检查全部通过,用 golden 镜像启动到 macOS 桌面,截一张屏,正常关机。由人确认后升级 |
|
||||
| **`alpha`** | 预发布(Pre-release) | CI 每日自动构建并通过 `scripts/check-runtime-alpha.ps1` 全部校验 |
|
||||
| **`stable`** | 正式发布(Release) | 从 `alpha` 晋升:在真实 Windows 10/11 宿主运行 [`scripts/smoke-runtime.ps1`](../scripts/smoke-runtime.ps1),验证纯净目录 `doctor`、启动至 macOS 桌面、截屏与正常关机,经人工确认后晋升 |
|
||||
|
||||
`reims-go` 客户端默认只拉 `stable`,`candidate` 要用户主动打开。这层筛选是 `reims-go` 相对于「自己跑上游安装脚本」的主要价值之一。
|
||||
- 客户端默认仅获取 `stable` 通道;`alpha` 需用户在界面开启「接收 Alpha 版」或在 CLI 传入 `--alpha`。
|
||||
- 晋升 `stable` 不重新打包,仅将既有 GitHub 预发布转为正式发布,确保用户下载的二进制与冒烟验证的资产完全一致(因此包内 `manifest.json` 的构建通道字段保持 `alpha`,客户端以 Release 状态区分通道)。
|
||||
|
||||
升级记录:
|
||||
---
|
||||
|
||||
| 运行时 | 候选版发布 | 冒烟测试 | 升为稳定版 |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `runtime-3731afd` | 2026-11-28 | 真实宿主 Windows 10 19045,启动到 macOS 桌面并正常关机,由人确认通过 | 2026-11-28 |
|
||||
## 6. 许可证与源码分发义务
|
||||
|
||||
升级不重新打包,只把 GitHub Release 从预发布改为正式发布,所以用户拿到的文件与冒烟测试用的完全相同。包内 `manifest.json` 的 `channel` 字段记录的是构建时的通道,会一直是 `candidate`;客户端只看 Release 的发布状态。
|
||||
Reims-Go 本体(Go 后端与前端外壳)采用 [Apache-2.0](../LICENSE) 协议,仅通过独立子进程调用运行时组件,不进行静态或动态链接。
|
||||
|
||||
## 7. 许可证与源码义务
|
||||
由于便携运行时包含 GPLv2(QEMU)、`GPL-2.0-or-later OR LGPL-3.0-or-later`(`reims-vgpu` / `reims-ctl` / `metal2vulkan`)以及 MSYS2 CLANG64 / libva 动态库,每个公开运行时 Release **必须同处附带完整对应源码与许可证文本**:
|
||||
|
||||
发布二进制,就要同时提供对应的源码。只给上游链接不够,因为本地补丁不在上游。每个运行时 Release 附带:
|
||||
- `reims-vgpu`(含 `reims-ctl`)、`qemu-reims-vgpu`(**含本地补丁**)、`metal2vulkan`、`reims-util` 在所用 commit 的源码包;
|
||||
- 运行时里 MSYS2 CLANG64 DLL 对应的包名、版本,以及其中 LGPL/GPL 组件(如 glib)的源码或获取方式(具体清单**待 M0.1 打包时列出**);
|
||||
- `licenses/` 里的许可证全文。
|
||||
|
||||
2026-11-28 的做法(`runtime-3731afd`):
|
||||
- **源码包内容**:四个上游仓库在对应 commit 的原始源码树(用 `git archive` 导出),加上构建时下载的 QEMU meson 子项目、`patches/` 里的补丁原文和重建说明。补丁不预先打在源码树上,由使用者按说明自行应用;已实测两个补丁都能直接打到这份源码上。
|
||||
- **DLL**:71 个 DLL 全部来自 55 个 MSYS2 包,`MSYS2-PACKAGES.txt` 按 DLL 列出所属包和版本,并给出源码下载地址(`repo.msys2.org/mingw/sources/` 和 MINGW-packages)。
|
||||
- **MSYS2 包的源码(2026-11-28 决定单独打包)**:只给下载地址不够稳妥,因为 MSYS2 删掉旧版本后链接就会失效。所以许可证要求提供源码的包,其源码作为同一个 Release 的第四个附件 `reims-runtime-msys2-src-<commit>.tar.zst` 发布。这满足 GPLv2 §3 和 LGPL-2.1 §6「在同一处提供源码」的要求。由 `scripts/pack-msys2-sources.ps1` 生成,`pack-runtime.ps1` 会自动调用它。
|
||||
- **筛选规则**:从本机 pacman 数据库读取每个包的 `%BASE%` 和 `%LICENSE%`。只要有一项许可证的所有可选项都含 GPL、LGPL 或 MPL,就需要附源码。如果有可选的宽松许可证(例如 freetype 可选 FTL,zstd 可选 BSD),就不附。只适用于文档的条目(`documentation:`)不算。
|
||||
- **内容**:`repo.msys2.org/mingw/sources/` 上原样的 `<base>-<version>.src.tar.zst`,内含 PKGBUILD、上游源码和 MSYS2 的补丁。每个都附 `.sig` 签名文件;打包时用 `gpgv` 和 MSYS2 密钥逐个校验,校验不过就停止。同时附一份 README,列出全部 55 个包的许可证,以及哪些附了源码。
|
||||
- **`runtime-3731afd` 的结果**:22 个源码包,110 MB,签名全部通过。下载的源码缓存在 `D:\Data\reims-go\releases\msys2-sources-cache`,下次打包会复用。
|
||||
|
||||
`reims-go` 外壳用 MIT,前提是它和这些组件只通过独立进程交互,不链接它们。
|
||||
1. **上游源码包(`reims-runtime-src-<commit>.tar.zst`)**:导出所用 commit 的四个上游仓库源码树、构建所需的 QEMU meson 子项目、`patches/` 中的全部补丁原文及重建说明。
|
||||
2. **MSYS2 copyleft 源码包(`reims-runtime-msys2-src-<commit>.tar.zst`)**:由 [`scripts/pack-msys2-sources.ps1`](../scripts/pack-msys2-sources.ps1) 根据本机 pacman 元数据自动筛选全部无宽松替代协议的 GPL / LGPL / MPL 依赖包,下载官方 `.src.tar.zst` 并使用 `gpgv` 与 MSYS2 密钥逐一验签,同时附带 `MSYS2-PACKAGES.txt` 说明全部 DLL 归属与许可。
|
||||
3. **许可证与声明**:运行时包根目录内置 [`NOTICE.md`](../NOTICE.md) 与 `licenses/` 全文。
|
||||
4. **不含 Apple 专有文件**:任何仓库目录或运行时 Release 均不包含 macOS 安装包、恢复镜像、解密固件或 SMC 密钥;系统安装包均由用户端直连 Apple 服务器获取。
|
||||
@@ -1,120 +1,76 @@
|
||||
# 开发路线图与里程碑(Roadmap)
|
||||
# 路线图(Roadmap)
|
||||
|
||||
> 原则:先打通“最小可用闭环”(本地打包便携运行时 → Go 核心驱动 → Wails GUI),再扩展自动化与 CI 自动发版。每个里程碑均有明确的可验证验收标准(DoD)。
|
||||
> Reims-Go 的规划从真实用户任务出发:先让用户在 Windows 上顺畅装到桌面、稳定用于日常开发、改坏环境可回退,再按需补齐进阶开发工作流。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
M0["M0 便携包与环境验证\n(2–3 天)"] --> M1["M1 Go 核心层与 CLI\n(1 周)"]
|
||||
M1 --> M2["M2 Wails 桌面 GUI MVP\n(1–2 周)"]
|
||||
M2 --> M3["M3 硬件调优与 CoW/QMP\n(1–2 周)"]
|
||||
M3 --> M4["M4 CI 自动构建与发版\n(1 周)"]
|
||||
```
|
||||
## 口径说明
|
||||
|
||||
- **已实现**:代码或脚本已合并进主分支并随版本发布,不代表已覆盖所有 Windows 版本、显卡和 macOS 版本的真机组合。
|
||||
- **真机验收**:需要在明确记录的 Windows、GPU、运行时和 macOS 组合上完成端到端任务验证;单元测试和 CI 编译通过不替代真机验证。
|
||||
|
||||
---
|
||||
|
||||
## M0:便携运行时打包与纯净验证
|
||||
## 已实现能力(截至 v0.2.6)
|
||||
|
||||
**目标**:把本机已验证可用的 `reims-vgpu` 产出一份标准、可复现、可校验的便携运行时压缩包,并在纯净目录中验证完整建机/启动闭环。
|
||||
### 1. 免编译与环境初始化
|
||||
- **便携运行时体系**:剥离 MSYS2 / Rust / 源码仓库依赖,支持 GitHub Release(含系统代理)在线下载、断点续传、SHA-256 校验、原子切换与本地 `.tar.zst` 导入。
|
||||
- **宿主机体检与引导**:免提权检测 WHPX(缺失时支持 UAC 一键开启)、物理与可用提交内存预检、Vulkan 独立显卡识别、大小核(P/E/LP-E)拓扑与处理器计划检查、数据盘总线类型风险提示。
|
||||
- **统一发布物**:桌面界面与命令行共用单个 `reims-go.exe`,支持浅色/深色外观与中英双语。
|
||||
|
||||
- [x] **M0.0**:把 Win10 补丁的来龙去脉记清楚:在 `vendor/qemu` 里 `git diff` 与 `patches/qemu-whpx-win10-compat.patch` 比对一致;并在 `patches/README.md` 与 `docs/upstream-pr-prep.md` 归档复现与修复证据。
|
||||
- [x] **M0.1**:编写 `scripts/pack-runtime.ps1`,从本地 `reims-vgpu` 安装产物打包 `reims-runtime-win-x64-<commit>.tar.zst`、`manifest.json`(含 SHA256、`vendor/qemu` commit、补丁清单与哈希)、`patches/`、`NOTICE.md` 与 `licenses/`,并附 `pack-msys2-sources.ps1` 打包对应 MSYS2 copyleft 源码。
|
||||
- [x] **M0.2**:在独立路径解压并发布稳定版运行时 `runtime-3731afd`,验证在不依赖 MSYS2 / Rust / 源码仓库的条件下可正常 `list --json`、`doctor` 并拉起 macOS 桌面。
|
||||
- [x] **M0.3**:初始化 `go.mod` 与 Wails v2 工具链并完成可执行文件构建。
|
||||
### 2. 装机与虚拟机管理
|
||||
- **离线安装包管理器**:宿主机直连 Apple 目录下载完整 macOS 安装包,支持断点续传、空间预检、缓存复用与可视化清理。
|
||||
- **装机引导与自动化**:离线辅助盘自动抹盘与安装、QMP 一键键入恢复终端命令、系统外预设 macOS 界面语言(`prev-lang:kbd`)、对称的「进入/退出恢复模式」、VMDK / RAW 磁盘导入。
|
||||
- **设置与运维**:运行中可编辑配置并标明生效时机(立即生效或下次启动生效)、待生效变更汇总与一键重启应用、停机扩容与空间回收、CoW 秒级派生、停机恢复点(创建/回滚/删除)、脱敏排障日志包导出。
|
||||
|
||||
**DoD**:
|
||||
- 存在可重复生成的便携运行时包及其 SHA256 清单;
|
||||
- 脱离 MSYS2 后实测可成功引导 macOS Tahoe 桌面,且 C 盘无新增 reims 文件。
|
||||
### 3. 日常使用与宿客互通
|
||||
- **显示与性能**:按屏幕分辨率与缩放推荐 HiDPI 档位、无边框全屏、按 VM 自定义 CPU 亲和性(自动/全部/性能核/避开低功耗核/自定义,运行中立即生效)、VM 屏幕预览与全分辨率截图复制、前置 VM 窗口。
|
||||
- **Guest Tools**:纯本地回环鉴权的双向图文剪贴板、WebDAV 挂载式共享文件夹(含文件拖入投递与按盘符开启的 Windows 只读共享)、防休眠守护、Windows IME 中文与表情输入转发。
|
||||
- **常驻与远程连接**:系统托盘常驻与每台 VM 独立子菜单、SSH 快捷键(记住用户名、打开终端、写入 `~/.ssh/config`、VS Code Remote-SSH)。
|
||||
|
||||
---
|
||||
|
||||
## M1:Go 核心层与 CLI(`reims-go` 无界面闭环)
|
||||
## 近期重点(P0)
|
||||
|
||||
**目标**:先用纯 Go 打通所有底层能力与单元测试,确保 CLI 单独就能跑完整个生命周期。
|
||||
优先打磨和验证已有能力,在 P0 任务稳定前不堆砌新子系统。
|
||||
|
||||
- [x] **M1.1**:`internal/config` + `internal/i18n` — 实现配置持久化(`locale: zh-CN | en-US`、`data_root`)与双语消息字典;`internal/host` 实现 Windows 原生体检(`*_windows.go`:含 WHPX、**物理内存与可用提交内存 `FreeVirtualMemory` 安全档位推荐**、Vulkan ICD、三层 P/E/LP-E 核拓扑、磁盘总线类型探测)与非 Windows 桩(`*_other.go`)。
|
||||
- [x] **M1.2**:`internal/runtime` — 实现便携运行时导入(本地 `.tar.zst` 与 HTTP 下载)、SHA256 校验、原子解压、版本切换与子进程环境变量构造(`XDG_*` + `REIMS_CTL_QEMU`)。
|
||||
- 2026-11-28:补上在线安装,运行时从本仓库的 GitHub Release 下载(`runtime-<commit>` tag,候选版和稳定版两个通道),支持续传,并对照 `SHA256SUMS.txt` 校验。CLI 用 `reims-go runtime available` 和 `reims-go runtime fetch [commit]`;界面在宿主页和首次启动页。细节见 `portable-runtime-spec.md` 第 4 节。
|
||||
- [x] **M1.3**:`internal/installer` — 封装 `reims-util offline-installer list --json`、`reims-util offline-installer <ver> -o <DataRoot>\data\reims-ctl\installers --json` 与 `reims-ctl downloads`:实现结构化 JSON 进度流解析、取消/断点续传与缓存清理。
|
||||
- 2026-11-28 完成。
|
||||
- CLI:`reims-go installer list | download <版本> | cached | delete <文件名>`。
|
||||
- GUI 绑定:`ListOfflineReleases`、`DownloadInstaller`、`ListInstallers`、`DeleteInstaller`;下载进度通过任务事件推送(见 `ui-redesign.md` B1)。
|
||||
- 依据上游 `3731afd` 的 `crates/reims-ctl/src/reims_util.rs` 和 `downloads.rs`:
|
||||
- 参数顺序是 `reims-util --json offline-installer <版本> -o <目录>`,`--json` 放在子命令前面;
|
||||
- 事件格式见 `reims_util.rs:423-431`;
|
||||
- 暂停就是结束进程,再次运行同一条命令会接着下载(`reims_util.rs:30-31`);
|
||||
- 删除走 `reims-ctl downloads delete NAME --yes`,VM 正在使用或正在下载的文件会被拒绝(`downloads.rs:108-123`)。
|
||||
- 与 reims-ctl 互斥:下载期间对 `installers/.lock` 持有排他锁,Windows 上用 `LockFileEx`,和 Rust 的 `File::try_lock` 相同。已实测:reims-go 持锁时,真实的 `reims-ctl downloads delete` 会以「正在下载」拒绝。测试是 `internal/installer` 的 `TestLockExcludesReimsCtl`,需要设置 `REIMS_GO_TEST_CTL`。
|
||||
- 实测(2026-11-28,reims-util 0.1.0):
|
||||
- `offline-installer list` 读取 Apple 的目录约需 10 秒,返回字段为 product、title、version、build、posted、size、url、integrity_url、digest;
|
||||
- 下载一开始就会创建一个与完整镜像同样大小的 `.part` 文件(26.7.3 为 19.7 GB),**磁盘可用空间当场减少约 20 GB**;M2.2 的下载管理器要在开始前检查剩余空间;
|
||||
- 暂停后重新开始,会从中断处继续,不会从头下载。
|
||||
- 未实测:
|
||||
- 完整跑完一次离线安装包下载(18.4 GB);
|
||||
- 下载完成时 `done` 事件里是否带 `installer.build` 字段(代码按可选处理)。
|
||||
- [x] **M1.4**:`internal/driver/reims` — 封装 `reims-ctl` 的 `list --json`、`show`、`create`、`start`、`stop`、`set`、`insert`、`eject`、`update-opencore`、`delete`、`logs`、`downloads` 与 `qemu-img` 转换/CoW 派生,带单元测试。
|
||||
- [x] **M1.5**:`cmd/reims-go` — 提供 `doctor`、`runtime available/fetch/install/list/use`、`installer list/download/cached/delete`、`vm list/create/set/start/stop/eject/type`、`version` 子命令,支持 `--lang zh-CN|en-US` 与中英双语输出。
|
||||
### 1. 首次装机与发版闭环
|
||||
- 在 GitHub Actions 上实跑 `build-runtime.yml` 每日构建与 `alpha` 准入流程,验证公开资产的 `manifest.json`、补丁队列与源码包一致性。
|
||||
- 在多种受支持的 Windows 10 / 11、GPU 与 macOS 组合上跑通完整开箱流程(干净目录 → 体检 → 安装运行时 → 下载离线包 → 装机 → 退出恢复模式)。
|
||||
- 完善中断与异常场景的故障恢复(断网续传、磁盘不足、取消 UAC、运行时损坏),确保失败后可安全重试且不残留半配置虚拟机。
|
||||
|
||||
**DoD**:
|
||||
- 在一个从未 dot-source `reims-env.ps1` 的全新 PowerShell 中,仅运行 `reims-go` CLI 即可完成体检、导入运行时、断点续传下载离线包、启动/查看 VM;
|
||||
- `go test ./...` 全通过。
|
||||
### 2. 日常主力体验与上游性能跟进
|
||||
- 持续跟进上游 [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) 的 Windows 图形与窗口改进(热切全屏、无黑边窗口缩放、原生 Windows Vulkan 后端、首帧延迟优化、自由指针 `Win → Command` 映射),合入后经 `alpha` 冒烟升级至 `stable`(跟踪明细见 [patches/README.md](../patches/README.md))。
|
||||
- 推动当前本地兼容性补丁上游化,并逐步清零 `patches/` 队列。
|
||||
- 在真实宿主完成长时间开发负载验证(编译、浏览器、多任务、图文剪贴板、WebDAV 挂载、Windows 盘符只读共享、音频/麦克风与休眠唤醒恢复)。
|
||||
- 修复 WebDAV 共享目录可经 Junction 逃逸的路径校验缺陷,并把共享目录与只读盘统一到基于 `os.Root` 的路径安全层;随后按测量结果推进小文件 I/O 优化。
|
||||
|
||||
### 3. 恢复点与磁盘操作可靠性
|
||||
- 对停机恢复点(创建/回滚/删除)、CoW 派生启动、大容量 VMDK 转换以及停机扩容/空间回收完成真机中断与边界测试,确保空间不足或中途中断不会破坏原盘与 backing file 链。
|
||||
- 补充数据目录离线备份与迁移说明(明确快照不等于跨盘备份)。
|
||||
|
||||
---
|
||||
|
||||
## M2:Wails 桌面 GUI MVP(一站式开箱体验)
|
||||
## 下一步计划(P1)
|
||||
|
||||
**目标**:做成真正给普通开发者/自己点几下就能用的轻量桌面应用。
|
||||
|
||||
- [x] **M2.1**:**首次启动向导(中英双语实时切换)** — 自动识别系统语言(支持切换 `中文 / English`);引导选择非 C 盘数据目录(外置盘风险提示)、展示环境体检(WHPX 一键提权启用、Vulkan 显卡、提交内存推荐值)并一键在线安装/导入便携运行时。
|
||||
- [x] **M2.2**:**离线安装包下载管理器(核心体验)** — 调用 `reims-util --json` 展示可选 macOS Tahoe 精确版本,在 GUI 内直接触发宿主机直连下载、实时显示进度条 / 速率 / 已下体积 / 自动重试状态、支持「暂停/取消」与「断点续传」,并可视化管理 `<DataRoot>\data\reims-ctl\installers` 缓存。
|
||||
- 2026-11-28(v0.2):侧边栏新增「安装包」页。上半部分是已下载的安装包:可以继续未下载完的、删除(两步确认,删除走 `reims-ctl downloads delete`)。下半部分是 Apple 提供的版本:下载、进度、暂停。下载前检查剩余空间(按安装包大小加 10% 计,因为一开始就会占满整个镜像的空间)。速率显示在进度的悬停提示里。暂停后再次下载会接着下。
|
||||
- [x] **M2.3**:**VM 主面板与创建/装机引导(贴合简体中文 / 英文 macOS 界面术语)** — 实例列表、实时状态、一键启停与串口/图形日志抽屉;新建默认推荐复用本地离线包 + 默认 `NVMe` 磁盘控制器,启动前校验提交内存;离线安装通过纯 Go HFS+ 辅助盘 `REIMSHELP` 自动绕过 macOS 26.7.3 缺 `pkgutil` / `installer -target` 失效,支持空白盘自动 APFS 抹盘 + QMP 一键键入;提供对称的「进入/退出恢复模式」切换与约 1 GB 在线恢复镜像兜底拉取。
|
||||
- [x] **M2.4**:打包为单文件 `reims-go.exe`(~13.3 MB)与命令行版 `reims-go-cli.exe`(~11.5 MB)。无代码签名,冷启动时间待量化实测。
|
||||
- [x] **M2.5**:**设置面板(对齐 macOS)** — 按 [`shell-design.md`](shell-design.md) 类别分页;VM 运行中可改并标出生效时机;保存前在 Go 侧校验提交内存与 ICD,写入仅走 `reims-ctl set`。
|
||||
- [x] **M2.6**:**待生效修改** — 详情页列出「已保存、下次启动才生效」的修改并提供「重启以应用」按钮。
|
||||
- [x] **M2.7**:**主窗口结构** — 侧边栏 + 详情 + 工具栏,分步新建助手并在最后一步预览完整 `reims-ctl` 命令。
|
||||
|
||||
**DoD**:
|
||||
- 双击 `reims-go.exe` 即可走完「体检 → 导入运行时 → GUI 断点续传下载离线安装包 → 创建/启动 VM → 离线装完并退出恢复模式」全流程,无需打开命令行。
|
||||
- VM 运行中修改 CPU / 内存 / 显示器数量并保存,重启后 `reims-ctl show` 显示新值;非法输入(如内存超过宿主可用提交内存、ICD 文件不存在)在保存前被拦下。
|
||||
- **可测量的时间目标**:从首次双击到出现 macOS 安装界面 ≤ 10 分钟(不计入开启 WHPX 重启、运行时下载与 Apple 安装包下载)。macOS 离线安装第二阶段耗时受宿主磁盘与 `kernel-irqchip` 影响,继续实测记录。
|
||||
### 开发者网络与工作流增强
|
||||
- 支持自定义多条宿客 TCP 端口转发(含端口冲突检测),无需手写 `--extra-args`。
|
||||
- 在 Guest Tools 中提供可选的宿主机代理快捷开关(显式开启、一键清除),方便客体内的 Homebrew / Xcode / npm 下载。
|
||||
|
||||
---
|
||||
|
||||
## M3(v0.3):硬件自动调优、宿客互通与开发者进阶能力
|
||||
## 按需评估
|
||||
|
||||
**目标**:拉平并超越社区 Windows 管理器体验,补齐宿客互通、安全边界与工程化能力。
|
||||
以下能力仅在有明确场景和可验证方案后才进入版本排期:
|
||||
|
||||
- [x] **M3.1**:**三层大小核防超售绑核与 WHPX 兼容自愈** — 识别三层混合架构(P + E + LP-E,如 Intel Core Ultra 200 无超线程 CPU),`vCPU < P 核逻辑线程数` 时绑 P 核,超出时自动改绑 `P + E`(仅排除慢速 LP-E 核)避免自旋锁超售卡顿;自动探测 Win11 `hr=0x80370302` 嵌套虚拟化属性并预置/补丁化处理;新建 VM 默认 `NVMe` 控制器。
|
||||
- [x] **M3.2**:**安全 AF_UNIX QMP 通道与键入** — Win10 冷重启辅助 QMP 通道已迁至 Windows `AF_UNIX` 套接字(杜绝 SLIRP 下 `10.0.2.2:<port>` 宿主机逃逸风险,自动清理旧 TCP 参数);已基于 `reims-ctl` 的 `qmp.sock` 实现 QMP 键盘一键键入。后续按需补齐优雅关机增强与 QMP 截屏。
|
||||
- [x] **M3.3(v0.3 核心)**:**安全鉴权 Guest Tools(双向剪贴板 + 共享目录)** — 内置仅监听 `127.0.0.1` 的纯 Go HTTP 宿客桥接(每台 VM 独立 256-bit 随机 Bearer Token + 严格共享目录路径隔离),通过纯 Go HFS+ 辅助盘 `REIMSTOOLS` 一键安装免 Xcode/Python 的 macOS LaunchAgent,支持双向 UTF-8 剪贴板与 `~/Desktop/ReimsShare` ↔ `<DataRoot>/shared/<vm>` 双向文件同步。**(macOS 桌面端真机联调待验证)**
|
||||
- [x] **M3.4(v0.3 后续)**:**退出恢复模式自动升级 `NVMe` + 存储/内存性能诊断** — 对旧 `AHCI` VM 在退出恢复模式时自动切至 `NVMe`,并在 VM 主页提供一键升级按钮;自动检测外置 USB/网络盘(`GetDriveTypeW` + `IOCTL_STORAGE_QUERY_PROPERTY` `BusTypeUsb`)与高内存负载(≥ 85%)并展示可操作提示。
|
||||
- [x] **M3.5(v0.3 后续)**:**一键导出脱敏排障日志包(`.zip`)** — 收集体检报告、运行时清单、VM 配置、自动脱敏(序列号/MAC/SMC OSK/Bearer Token)的 QEMU、串口与应用日志,一键导出到 `<DataRoot>/reports/` 并定位目录(已通过单测验证零敏感信息泄漏)。
|
||||
- [x] **M3.6(v0.3 后续)**:**磁盘导入增强(VMDK / RAW 自动转 qcow2)** — 复用便携运行时内置 `qemu-img convert`,新建向导支持直接选择 `.vmdk` / `.raw` 并自动转为 `.qcow2` 导入。**(真机大容量 VMDK 转换待验证)**
|
||||
- [x] **M3.7(v0.4 差异化王牌)**:**Golden Image 与 CoW 秒级派生** — 已停止的已装系统 VM 支持在「更多」里通过 `qemu-img create -f qcow2 -b <golden> -F qcow2` + `reims-ctl create --disk --disk-mode in-place` 秒级派生独立身份副本,原盘只读不改。**(真机 CoW 派生启动待验证)**
|
||||
|
||||
**DoD**:
|
||||
- 三层大小核防超售绑核、`AF_UNIX` QMP、Guest Tools 剪贴板与共享目录、CoW 派生在真实宿主均有实测通过记录。
|
||||
|
||||
---
|
||||
|
||||
## M4(v0.4):上游性能/窗口跟进与 CI 自动发布
|
||||
|
||||
**目标**:自动化跟进上游 Windows 性能与窗口体验改进,建立 `candidate` → `stable` 冒烟发布闭环。
|
||||
|
||||
- [ ] **M4.1**:**上游窗口与性能 PR 跟进(运行时升级,持续跟踪)** — 已建立跟踪清单 [`docs/upstream-pr-prep.md`](upstream-pr-prep.md),跟踪上游 [`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) 关键 Windows PR(`#153`、`#152`、`#107`、`#123`、`#172` 与 Win→Command)合入后触发 `build-runtime.yml` 升级 `candidate` 运行时。
|
||||
- [x] **M4.2**:编写 GitHub Actions workflow([ci.yml](../.github/workflows/ci.yml) + [build-runtime.yml](../.github/workflows/build-runtime.yml)):CI 自动先构建前端再跑 `go test` / `go vet` 并编译 CLI 与 GUI;手动运行时构建 workflow 在 `windows-latest` 上通过 MSYS2 CLANG64 拉取 `vendor/qemu`、硬校验并应用 `patches/`、调用上游 `scripts/install-ctl.sh --yes` 并执行 `scripts/pack-runtime.ps1` 产出 `candidate` 预发布包与对应源码包。**(GitHub Actions 运行时编译待首次手动触发实跑验证)**
|
||||
- [x] **M4.3**:**`candidate` → `stable` 冒烟脚本** — 已编写 [scripts/smoke-runtime.ps1](../scripts/smoke-runtime.ps1),支持校验 SHA-256、在干净隔离目录(无 MSYS2 PATH)解压并跑 `reims-ctl doctor` / `list --json` 与合规文件核查,产出供人工评审的 Markdown 冒烟报告。
|
||||
- [x] **M4.4**:**客户端自动发布与在线更新检查** — 已新增 [.github/workflows/release.yml](../.github/workflows/release.yml)(打 `v*` tag 自动跑测、构建 `reims-go-<tag>-windows-amd64.exe` / `reims-go-cli-<tag>-windows-amd64.exe` + `SHA256SUMS.txt` 并发布 GitHub Release);客户端与 CLI 接入 `internal/version` 版本号与稳定版在线更新检查(`HostView` 一键检查/跳转下载,运行时支持多版本回滚切换);合规文件(`NOTICE.md`、`LICENSE`、运行时源码包与 `MSYS2-PACKAGES.txt`)已随构建脚本落盘。
|
||||
- [ ] **M4.5**:**补丁上游化(人工提交 PR)** — 已在 [`docs/upstream-pr-prep.md`](upstream-pr-prep.md) 整理好 3 个 QEMU WHPX 补丁的根因、复现步骤与实测证据,待人工向上游提 PR 并合入后从 `patches/` 队列清零。
|
||||
|
||||
**DoD**:
|
||||
- 触发一次 tag/手动 workflow 即可产出完整的 `candidate`(App + Runtime + SHA256 + 源码包);冒烟通过并经人确认后升为 `stable`;在干净目录下载 `stable` 后,按 M2 的时间目标跑通。
|
||||
- **扩展与插件体系**:架构草案见 [docs/plugin-architecture.md](plugin-architecture.md),待核心体验稳定后分阶段评估。
|
||||
- **Windows USB 设备直通**:依赖 WinUSB / UsbDk 驱动替换,签名与稳定性风险较高,仅在确有 iPhone 真机调试或硬件密钥刚需时做最小原型评估。
|
||||
- **独立导出/迁移与备份调度**:先验证数据目录离线备份方案是否足够,再评估独立归档格式与恢复校验。
|
||||
|
||||
---
|
||||
|
||||
## 不做的事
|
||||
|
||||
- **不维护长期 fork**:对上游的改动只走补丁队列,目标是清零(见 `portable-runtime-spec.md` 第 5 节)。
|
||||
- **不跟踪上游最新 commit**:用户只拿到冒烟过的 `stable`。
|
||||
- **暂不做 TAP / Wi-Fi MacNAT 虚拟网卡驱动安装器**:维护与签名风险高,优先服务好 SLIRP + SSH 端口转发 + Guest Tools 共享目录。
|
||||
- **暂不兼容已淘汰的 `apple-gfx` 旧图形栈**,暂不实现 `vphone` 等其他 `Engine`(接口位置保留)。
|
||||
- **不长期维护上游 fork**:对 `reims-vgpu` / QEMU 的改动只走临时补丁队列,上游合入即退役。
|
||||
- **不向默认用户分发未验证的上游最新提交**:CI 产物先进入 `alpha` 预发布,经真机冒烟并人工确认后才升级为 `stable`。
|
||||
- **暂不做 TAP / 虚拟网卡驱动安装器**:维护与驱动签名成本高,优先做好用户态网络、端口转发与 Guest Tools。
|
||||
- **暂不做运行中内存热快照(`savevm`)**:在 `reims-vgpu` 显存与设备状态序列化未获上游验证前,以停机恢复点和 CoW 派生为准。
|
||||
- **不兼容已淘汰的旧图形栈**:不引入 `apple-gfx` 等旧后端,不为堆砌参数列表而增加复杂界面。
|
||||
@@ -1,101 +0,0 @@
|
||||
# 外壳设计原语(对齐 macOS)
|
||||
|
||||
> 2026-11-28 起草。上游行为引自 `steelbrain/reims-vgpu` commit `3731afd`,路径相对 `crates/reims-ctl/src/`。
|
||||
|
||||
## 1. 「对齐 macOS」指什么
|
||||
|
||||
两层意思,都要做到:
|
||||
|
||||
1. **配置模型对齐 Apple 的虚拟化概念**。界面上的分类、字段名和校验方式,以 Apple [Virtualization.framework](https://developer.apple.com/documentation/virtualization) 的 [`VZVirtualMachineConfiguration`](https://developer.apple.com/documentation/virtualization/vzvirtualmachineconfiguration) 为词表:平台、引导、CPU、内存、存储、网络、图形与显示器、音频、键盘与指针、串口。macOS 用户和做 macOS 开发的人对这套分类最熟悉,以后做 arm64 宿主或者对接 Apple 宿主时,也能直接对上。
|
||||
2. **交互对齐 macOS 的人机界面规范**([Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines)):
|
||||
- 主窗口:左边侧边栏列出 VM,右边是详情,顶部工具栏放常用操作;
|
||||
- 创建:用分步助手;
|
||||
- 修改:设置面板按类别分页,像 macOS 的「系统设置」。
|
||||
|
||||
外壳跑在 Windows 上:**结构和术语按 macOS 来做**(侧边栏、分步助手、设置分页、VZ 词表),**渲染层面按 Windows 平台来做**(字体用 Segoe UI / 微软雅黑,窗口控件放右上角,适配 Windows 的 DPI 缩放)。2026-11-28 按 [`ui-redesign.md`](ui-redesign.md) 第 9 节 D4 修订,原先的写法是「视觉也按 macOS」。Windows 特有的部分(UAC、WHPX、Vulkan ICD)集中放在「宿主」页,不混进 VM 设置。
|
||||
|
||||
## 2. 三条原语
|
||||
|
||||
| 原语 | 含义 | 来源 |
|
||||
| :--- | :--- | :--- |
|
||||
| **配置是一份声明式文档** | 一台 VM 等于一份配置,界面只编辑它,不直接拼 QEMU 参数 | 对应 `VZVirtualMachineConfiguration`;上游落到 `vm.toml` |
|
||||
| **先校验,后保存** | 保存前在 Go 里检查一遍(CPU 数、内存上限、GPU ICD 文件是否存在、磁盘控制器切换前是否已弹出安装盘),不合法就不提交 | 对应 `VZVirtualMachineConfiguration.validate()` |
|
||||
| **随时可编辑,标明生效时机** | 不管 VM 运行与否,设置面板都能打开、能改。每个字段标出何时生效;VM 正在运行时,保存后显示「下次启动生效」和「重启以应用」按钮 | 上游所有 `set` 修改都在下次启动时生效(`cli.rs:73`) |
|
||||
|
||||
写入一律通过 `reims-ctl set`,不直接改 `vm.toml`。这样上游的校验和「改图形时重建 OpenCore 镜像」(`cli.rs:242`)都会照常执行。
|
||||
|
||||
## 3. 配置项映射
|
||||
|
||||
生效时机分三种:**下次启动**;**停机时**(只能在 VM 停止时修改,或者修改会触发额外操作);**仅创建时**。
|
||||
|
||||
| 类别(对齐 VZ) | 界面字段 | `reims-ctl` 参数(`cli.rs:551-616`) | 生效时机 | 备注 |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| 平台 | Mac 机型、序列号、MLB、UUID、ROM | 存在 OpenCore 的 `config.plist`,`update-opencore` 时保留(`cli.rs:236-248`) | 只读 | 界面只显示是否已设置,**不显示具体值**;日志和排障包里一律脱敏 |
|
||||
| 引导 | OpenCore 镜像、启动选择 | `update-opencore`、`--boot-selection` | 停机时 | 「重建引导镜像」放在高级操作里 |
|
||||
| 系统来源 | 下载 Apple 版本 / 本地安装器 / 已有磁盘 | `create --macos`、`--installer`、`--disk`、`--disk-mode` | 仅创建时 | 装好后提示「弹出安装盘」(`eject`) |
|
||||
| CPU | 核数 | `--cpus` | 下次启动 | 推荐 4 或 8;绑 P 核的开关属于 `reims-go` 自己的功能 |
|
||||
| 内存 | 大小 | `--memory` | 下次启动 | 上限按宿主物理内存校验 |
|
||||
| 存储 | 磁盘控制器(SATA / NVMe / virtio) | `--disk-controller` | 下次启动 | 切换前必须先弹出安装盘,否则 OpenCore 可能又从安装盘启动(`cli.rs` 中该参数的说明) |
|
||||
| 存储 | 磁盘大小 | `create --disk-size` | 仅创建时 | 创建后能否扩容**待验证** |
|
||||
| 网络 | 开关、SSH 端口转发、MAC | `--network`、`--ssh-port`、`--mac` | 下次启动 | MAC 属于敏感值,默认隐藏 |
|
||||
| 图形与显示器 | 显卡类型、显示器数量(1–4)、分辨率、无边框全屏、宿主 GPU | `--graphics`、`--displays`、`--resolution`、`--borderless`、`--gpu` | 下次启动;改显卡类型要停机 | GPU 下拉框由 `reims-go` 扫描 ICD 后生成,过滤掉虚拟显示适配器 |
|
||||
| 音频 | 开关、后端 | `--audio`、`--audio-backend` | 下次启动 | Windows 上的可选后端**待验证** |
|
||||
| 键盘与指针 | 点击窗口时捕获键鼠 | `--capture` | 下次启动 | — |
|
||||
| 串口与日志 | 日志开关、日志级别 | `--logs`、`--log-level` | 下次启动 | 日志在详情页抽屉里实时查看 |
|
||||
| 高级 | 关机等待时间、额外 QEMU 参数、环境变量 | `--stop-timeout`、`--extra-args`、`--env` | 下次启动 | `reims-go` 自己注入的 QMP 参数要和用户填的分开存放、合并写入,不能互相覆盖 |
|
||||
| (VZ 有,上游没有) | 共享目录、剪贴板、vsock | 无 | — | 先不做,界面上也不放占位 |
|
||||
|
||||
## 4. 状态模型
|
||||
|
||||
上游 `list --json` 只给三种状态:`running`、`stopped`、`broken`(`cli.rs:816-830`)。
|
||||
|
||||
`reims-go` 在此基础上加上自己发起操作时的过渡状态,名称对齐 `VZVirtualMachine.State`:
|
||||
|
||||
| 显示状态 | 来源 | 可用操作 |
|
||||
| :--- | :--- | :--- |
|
||||
| 已停止 | 上游 `stopped` | 启动、设置、复制派生、删除 |
|
||||
| 正在启动 | `reims-go` 发起 `start` 到出现 `running` 之间 | 查看日志 |
|
||||
| 运行中 | 上游 `running` | 关机、强制关机、截屏、弹出安装盘、设置(下次启动生效) |
|
||||
| 正在停止 | `reims-go` 发起 `stop` 到出现 `stopped` 之间 | 强制关机 |
|
||||
| 配置损坏 | 上游 `broken` | 打开排障、删除 |
|
||||
|
||||
暂停、保存和恢复状态(VZ 的 `paused`、`saving`、`restoring`)**先不提供**,因为上游没有文档化快照功能,QMP `savevm` 在 reims-vgpu 下能否用**待验证**。
|
||||
|
||||
状态每秒刷新一次,和上游 TUI 的做法一样(`tui.rs:1-6`),这样在 CLI 里或直接关掉 VM 窗口造成的变化也能及时反映出来。
|
||||
|
||||
## 5. 界面结构
|
||||
|
||||
```text
|
||||
┌ 标题栏:reims-go ─ □ ✕ ┐
|
||||
├──────────────┬───────────────────────────────────────────────────────────────┤
|
||||
│ 虚拟机 [+] │ m0 ● 运行中 [主操作] ■ ⚙ ⋯ │
|
||||
│ ● m0 │ 概览:CPU / 内存 / 磁盘、GPU、SSH 端口 │
|
||||
│ ○ golden │ 待生效的修改(有才显示):cpus 8→12 [重启以应用] │
|
||||
│ ○ run-01 │ 日志抽屉:QEMU 输出 / 串口 │
|
||||
│ ───────── │ │
|
||||
│ 宿主 │ │
|
||||
└──────────────┴───────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- **VM 操作放在详情页页头,不放顶部工具栏**:操作离对象近,切到宿主页时也不会出现整排按钮消失、布局跳动的问题。主操作随状态切换,其余操作是纯图标按钮或收进「⋯」菜单(2026-11-28 按 `ui-redesign.md` D1 修订)。
|
||||
- **新建助手**(弹出式分步):① 系统来源 → ② CPU 与内存 → ③ 存储 → ④ 图形与 GPU → ⑤ 摘要与校验 → 创建。每一步都能返回,最后一步列出将要执行的 `reims-ctl create` 命令。
|
||||
- **设置面板**:左边是第 3 节的类别列表,右边是表单。顶部显示 VM 当前状态,以及这一页修改的生效时机。
|
||||
- **宿主页**:WHPX 状态和启用按钮(UAC)、GPU 与 ICD 列表、P/E 核拓扑、数据目录与空间、运行时版本和通道。
|
||||
|
||||
和上游 TUI 相比,`reims-go` 多出这些东西:
|
||||
- 「待生效修改」对比和一键重启以应用;
|
||||
- 保存前在 Go 里预先校验;
|
||||
- GPU 列表过滤掉虚拟显示适配器;
|
||||
- 绑 P 核;
|
||||
- 复制派生(CoW);
|
||||
- 截屏;
|
||||
- 运行时通道管理。
|
||||
|
||||
基础的创建和编辑表单,上游已经有了(`tui.rs`、`form.rs`),不需要再做一套新逻辑,GUI 只换一种呈现方式。
|
||||
|
||||
## 6. 待验证
|
||||
|
||||
- `reims-ctl show` 能不能输出 JSON;不能的话,读取配置要解析文本或直接读 `vm.toml`(只读)。
|
||||
- 磁盘创建后能否扩容。
|
||||
- Windows 上可用的 `--audio-backend` 取值。
|
||||
- `reims-go` 注入的 `-qmp tcp:` 与用户的 `--extra-args` 合并后,上游会不会原样传给 QEMU。
|
||||
@@ -1,351 +0,0 @@
|
||||
# 前端改版方案(VM 主面板)
|
||||
|
||||
> 2026-11-28 起草。针对 M2 GUI 当前实现(`frontend/src/App.tsx`、`styles.css`)的体验问题提出改版。交互结构仍遵循 [`shell-design.md`](shell-design.md);本文只改「怎么呈现」,不改配置模型和状态模型。
|
||||
> 标「待决策」的项需要人拍板;标「待验证」的项尚未实测。
|
||||
|
||||
## 1. 现状问题(改版要解决什么)
|
||||
|
||||
| # | 问题 | 现象(截图 / 代码) |
|
||||
| :-- | :-- | :-- |
|
||||
| P1 | 主角错位 | VM 在运行,页面主体却是一份只读配置清单;没有「显示 VM 窗口」、运行时长、连接方式等用户真正关心的信息 |
|
||||
| P2 | 操作重复、层级乱 | 「弹出安装盘」出现 3 次,「串口日志」2 次,「运行中」2 次;工具栏有两个主按钮;被禁用的「启动」仍占主按钮位;正常步骤用黄色警告样式;「删除」常驻页头 |
|
||||
| P3 | 实现细节外泄 | 主视图出现 ICD 路径 `C:\Windows\System32\DriverStore\...\nv-vk64.json`、`Skylake-Client-noTSX-IBRS`、`runtime 3731afd` |
|
||||
| P4 | 本地化只做一半 | 中文界面里,副标题 `x86-64 macOS guest (...)` 和全部日志是英文(后端原样透传) |
|
||||
| P5 | 用日志冒充进度 | 下载 OpenCore 时每 1% 打一行;每条日志都强制展开抽屉(`App.tsx:54`),抽屉截断内容;日志不自动滚到底,看到的是最早的行 |
|
||||
| P6 | 操作无反馈 | `runAction` 没有忙碌态;错误直接 `String(e)`;删除用原生 `window.confirm`,且永远 `keepFiles=false`(`App.tsx:262`),后端支持保留文件但界面没给入口 |
|
||||
| P7 | 没有视觉系统 | 字号有 11 / 11.5 / 12 / 12.5 / 12.8 / 13 / 13.5 七档;内联样式到处都是;字体栈首选 SF Pro / PingFang,在 Windows 上实际落到雅黑;只有暗色 |
|
||||
| P8 | 交互基本功缺失 | 侧边栏是 `div onClick`,不能用键盘操作,没有焦点样式;没有空状态、损坏态页面;没有快捷键、右键菜单 |
|
||||
| P9 | 代码结构 | 一个 400 行的 `App.tsx` 同时承担布局、状态、动作、日志;零 UI 依赖,Dialog / Menu / Toast / Progress 全部手搓或缺失 |
|
||||
|
||||
## 2. 设计原则
|
||||
|
||||
1. **一个视图只有一个主操作。** 主操作跟着状态走:停止时是「启动」,运行时是「显示 VM 窗口」。其余操作降级为次要按钮或收进「更多」菜单。
|
||||
2. **每个操作只有一个出口。** 同一个动作在同一屏里只出现一次。引导文案可以提到按钮,但不再复制按钮。
|
||||
3. **默认说人话,细节可展开。** 主视图只显示用户能理解的值(「RTX 4070 Ti」「16 GB」「8 核」)。路径、哈希、QEMU 内部名放进「技术信息」折叠区,并提供复制按钮。
|
||||
4. **进度归进度,日志归日志。** 长任务用进度条和任务状态呈现,日志只是排障工具,默认收起,出错时才提醒。
|
||||
5. **颜色只表达语义。** 强调色只用于主操作和选中态;绿 / 黄 / 红 / 灰只用于状态;破坏性操作的红色只出现在菜单项和确认框里。
|
||||
6. **每次点击都有回应。** 任何操作在 100 ms 内给出视觉反馈(按钮进入忙碌态或状态点变化),完成或失败时给出 Toast。
|
||||
7. **文案克制,通用操作用图标。** 含义通用的次要操作只放图标;界面已经表达清楚的事不再用文字解释。图标的边界和文案规则见 4.5。
|
||||
|
||||
## 3. 信息架构
|
||||
|
||||
### 3.1 窗口框架
|
||||
|
||||
```text
|
||||
┌ 标题栏 40px ─────────────────────────────────────────────────────── ─ □ ✕ ┐
|
||||
│ [R] reims-go │
|
||||
├──────────────┬───────────────────────────────────────────────────────────┤
|
||||
│ 虚拟机 [+] │ VM 页头:名称 · 状态 · 运行时长 [主操作] [⚙] [⋯] │
|
||||
│ ● macos-tahoe│ ───────────────────────────────────────────────────────── │
|
||||
│ ○ golden │ 内容区(随状态切换,见 3.2) │
|
||||
│ ◐ run-01 45% │ │
|
||||
│ │ │
|
||||
│ ──────────── │ │
|
||||
│ ⚙ 宿主与运行时│ │
|
||||
│ ● 就绪 │ │
|
||||
├──────────────┴───────────────────────────────────────────────────────────┤
|
||||
│ 状态栏 28px:⟳ OpenCore 1.0.8 ▓▓▓▓░░ 45% ⚠ 2 >_ │
|
||||
└──────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
与现状相比的变化:
|
||||
|
||||
- **工具栏的 VM 操作移到 VM 页头。** 标题栏只保留品牌和窗口控件。原因:操作作用于当前选中的 VM,放在页头离对象最近;切到「宿主」页时也不会出现整排按钮突然消失、布局跳动的问题。(`shell-design.md` 第 5 节画的是顶部工具栏,这里是对它的修订,见第 9 节待决策 D1。)
|
||||
- **「新建」改成侧边栏标题旁的 `+`**,和列表放在一起,同时保留 `Ctrl+N`。
|
||||
- **中英切换移到「宿主与运行时 → 偏好设置」**。首次启动向导里仍然保留切换(M2.1)。
|
||||
- **侧边栏底部的 `runtime 3731afd` 改为「宿主与运行时」条目下的一行状态**(「就绪」/「需要处理」),哈希放进宿主页。
|
||||
- **底部日志抽屉改为常驻状态栏**,见第 5 节。
|
||||
|
||||
### 3.2 VM 详情页:按状态切换内容
|
||||
|
||||
| 状态 | 页头主操作 | 页头次要 | 「⋯」菜单 | 内容区 |
|
||||
| :-- | :-- | :-- | :-- | :-- |
|
||||
| 正在创建 | — | — | 取消创建(待验证) | 创建步骤进度:创建磁盘 → 下载 OpenCore → 生成引导镜像 → 完成 |
|
||||
| 已停止 | **启动** | 设置 | 打开所在文件夹、复制派生(M3)、删除… | 概要卡片 + 详细配置(折叠) |
|
||||
| 正在启动 | 启动中…(忙碌态,不可点) | 设置 | 强制关机 | 同上,状态点闪烁 |
|
||||
| 运行中 | **显示 VM 窗口** | 关机、设置 | 重启、强制关机、截屏(M3)、打开所在文件夹 | 待生效修改横幅(有才显示)→ 装机引导(有安装盘才显示)→ 连接信息 → 概要卡片 → 详细配置(折叠) |
|
||||
| 正在停止 | 停止中…(忙碌态) | — | 强制关机 | 同上 |
|
||||
| 配置损坏 | **查看问题** | — | 打开所在文件夹、删除… | 错误说明 + 原始输出 + 建议操作 |
|
||||
|
||||
「删除」只在「⋯」菜单里出现,不再常驻页头。
|
||||
|
||||
### 3.3 运行中 + 装机阶段的页面草图
|
||||
|
||||
```text
|
||||
macos-tahoe ● 运行中 · 12 分钟 [▣ 显示 VM 窗口] ■ ⚙ ⋯
|
||||
|
||||
┌──────────────────────────────────────────────────────────────── 2 / 3 ┐
|
||||
│ ✓ 抹掉磁盘 ─── ● 安装 macOS ─── ○ 弹出安装盘 │
|
||||
│ │
|
||||
│ 在 VM 窗口中选择「重新安装 macOS」 │
|
||||
│ ‹ [继续 →] │
|
||||
└────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
>_ ssh -p 2222 <用户名>@127.0.0.1 ⧉
|
||||
|
||||
▦ 8 核 ▤ 16 GB ⛁ 64 GB · SATA ▣ RTX 4070 Ti · 1080p
|
||||
|
||||
▸ 技术信息
|
||||
```
|
||||
|
||||
(`■` `⚙` `⋯` `⧉` 是纯图标按钮,悬停显示「关机」「设置」「更多」「复制」。概要行每一项悬停时显示全称,如「处理器」。第 3 步的内容区只有一个「⏏ 弹出安装盘」主按钮。)
|
||||
|
||||
要点:
|
||||
|
||||
- **装机引导做成步骤条,替代三行纯文本。** 前两步在宿主侧无法检测,由用户手动点「下一步」推进;进度按 VM 存在 reims-go 自己的配置里,不写 `vm.toml`。「弹出安装盘」只在第 3 步出现一次,页头和横幅里不再放。引导文案以 roadmap M2.3 为准,注意那里写的是离线脚本 `install-macos.sh`,和截图里的「重新安装」两个版本需要统一。
|
||||
- **「显示 VM 窗口」**把 QEMU 的显示窗口置前;如果窗口被最小化,就先还原再置前。需要后端新增接口(第 6 节 B5)。
|
||||
- **概要改成一行「图标 + 数值」**,不再用四张带标题的卡片;取值全部人话化(规则见 4.3)。「已用 21 GB」「已绑定性能核」这类运行时信息在后端支持之前先不显示,不放占位;支持之后放进对应项的 Tooltip。
|
||||
- **详细配置默认折叠**,展开后是现在的那张清单,加上复制按钮。
|
||||
|
||||
### 3.4 其他状态页
|
||||
|
||||
- **空状态**(还没有 VM):一个插图,一句「创建第一台 macOS 虚拟机」,一个主按钮「新建虚拟机」。运行时没装或 WHPX 没开时,主按钮换成「先完成环境检查 →」并跳到宿主页,不再弹出 `noRuntimeAlert` 横幅。
|
||||
- **正在创建**:侧边栏立刻出现这台 VM,状态显示「创建中 45%」;详情页显示分步进度。
|
||||
- **配置损坏**:讲清楚是哪份文件、哪一行出了问题(上游能给多少就给多少),附原始输出折叠区,以及「打开所在文件夹」「删除」两个出口。
|
||||
|
||||
## 4. 视觉与内容规范
|
||||
|
||||
### 4.1 设计令牌(`src/styles/tokens.css`)
|
||||
|
||||
| 类别 | 取值 |
|
||||
| :-- | :-- |
|
||||
| 字体 | 正文 `"Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", sans-serif`;等宽 `"Cascadia Mono", Consolas, monospace`。不再把 SF Pro、PingFang 放在首位,以 Windows 上的实际渲染为准 |
|
||||
| 字阶(只用整数) | 12 说明 / 13 次要正文 / 14 正文 / 16 小标题 / 20 页标题 / 24 空状态标题。中文正文不小于 13 |
|
||||
| 字重 | 400 / 600 两档 |
|
||||
| 间距 | 4 的倍数:4、8、12、16、24、32 |
|
||||
| 圆角 | 4 小控件 / 6 按钮与输入框 / 8 卡片 / 12 对话框 |
|
||||
| 表面 | `--surface-0` 底色、`--surface-1` 卡片、`--surface-2` 浮层,三级,深浅两套 |
|
||||
| 语义色 | `--accent`(主操作、选中)、`--status-running`、`--status-busy`、`--status-error`、`--status-idle`、`--danger`。状态色不用于按钮底色 |
|
||||
| 动效 | 120 ms 状态切换,200 ms 面板展开;遵守 `prefers-reduced-motion` |
|
||||
|
||||
所有组件只引用令牌,禁止内联 `style={{...}}` 写颜色、字号和间距。
|
||||
|
||||
### 4.2 按钮层级
|
||||
|
||||
| 层级 | 用途 | 每个视图的数量 |
|
||||
| :-- | :-- | :-- |
|
||||
| 主按钮(强调色实底) | 当前状态下最该做的事 | ≤ 1 |
|
||||
| 次按钮(描边) | 其他常用操作 | ≤ 3 |
|
||||
| 幽灵按钮 / 图标按钮 | 设置、更多、复制 | 不限 |
|
||||
| 破坏性(红字) | 删除、强制关机 | 只在菜单和确认框里出现 |
|
||||
|
||||
禁用的按钮不占主按钮的位置:状态不满足时,直接换成当前状态下合适的主操作。
|
||||
|
||||
### 4.3 内容人话化规则
|
||||
|
||||
| 原始值 | 主视图显示 | 原始值去向 |
|
||||
| :-- | :-- | :-- |
|
||||
| Vulkan ICD 路径 | 用 `host.gpus[].vulkan_icd` 反查出显卡名称,如「NVIDIA GeForce RTX 4070 Ti」 | 技术信息 |
|
||||
| `Skylake-Client-noTSX-IBRS` | 不显示 | 技术信息 |
|
||||
| `16G` | 「16 GB」 | — |
|
||||
| `disk.qcow2 (qcow2, SATA)` + `AHCI` | 「64 GB · SATA」(容量待后端提供) | 技术信息 |
|
||||
| `x86-64 macOS guest (q35 and OpenCore, WHPX)` | 「macOS · Intel · WHPX 加速」,按语言翻译 | 技术信息 |
|
||||
| `runtime 3731afd` | 「运行时:就绪」 | 宿主页 |
|
||||
| `String(e)` | 本地化的一句话 + 建议操作 +「详情」折叠 | 详情折叠区、日志 |
|
||||
|
||||
格式化函数统一放在 `src/lib/format.ts`,不在组件里拼字符串。
|
||||
|
||||
### 4.5 图标与文案
|
||||
|
||||
**纯图标按钮的条件**(三条同时满足):
|
||||
|
||||
1. 含义通用,在主流桌面软件里已经约定俗成:▶ 启动、■ 关机、⚙ 设置、⋯ 更多、+ 新建、⧉ 复制、✕ 关闭、文件夹、刷新、展开 / 收起、日志;
|
||||
2. 不是当前视图的主操作;
|
||||
3. 不是破坏性操作。
|
||||
|
||||
纯图标按钮必须带三样东西:
|
||||
|
||||
- 悬停 400 ms 后出现的 Tooltip,写名称,有快捷键的附上快捷键,例如「设置 Ctrl+,」;
|
||||
- `aria-label`;
|
||||
- 不小于 28 × 28 的点击区域。
|
||||
|
||||
**必须保留文字的情况:**
|
||||
|
||||
- **主操作**:图标加文字。用户第一眼要知道最该做什么。
|
||||
- **领域专有操作**:弹出安装盘、显示 VM 窗口、重启以应用。这些没有通用图标,只放图标就只能靠猜。
|
||||
- **破坏性操作**:删除、强制关机。它们只出现在菜单里,菜单项一律图标加文字。
|
||||
- **状态**:不能只靠颜色区分。侧边栏用形状区分(● 运行、○ 停止、◐ 进行中、⚠ 出错),配 Tooltip;状态文字只在页头写一次。
|
||||
- **首次流程**:新建助手、空状态、宿主页的环境检查。用户还不熟悉界面,文字不能省。
|
||||
|
||||
**用数值代替标签**:值自带单位时不写标签。「8 核」「16 GB」前面放图标即可,不写「处理器」「内存」,悬停时显示全称。内存和磁盘都用 GB,靠图标区分。
|
||||
|
||||
**文案规则:**
|
||||
|
||||
| 规则 | 反例(现状) | 正例 |
|
||||
| :-- | :-- | :-- |
|
||||
| 界面已经表达的不再用文字解释 | 「当前挂载了 macOS 安装盘。完成系统安装并进入桌面后,请点击上方『弹出安装盘』。」 | 删掉,步骤条已经表达了 |
|
||||
| 按钮用动词,2–5 字 | 「已进入桌面,弹出安装盘 →」 | 「继续」「弹出安装盘」 |
|
||||
| 不用「请」「您」「成功」和感叹号;按钮与短提示不加句号 | 「请点击」「操作成功!」 | 「已关机」 |
|
||||
| 提示只写一句,中文不超过 25 字 | 装机步骤每步两三个分句 | 「在 VM 窗口中选择『重新安装 macOS』」 |
|
||||
| 安抚性说明只在有风险的那一刻出现一次 | 装机步骤里写「不会影响本机 Windows 数据」 | 只在新建助手选择数据目录时写一次 |
|
||||
| 错误写「发生了什么 + 怎么办」,最多两句 | `exit status 1` | 「启动失败:WHPX 未启用。前往宿主页启用」 |
|
||||
| Toast 写「对象 + 结果」 | 「macos-tahoe 关机操作已成功完成」 | 「macos-tahoe 已关机」 |
|
||||
| 不写自明的分组标题 | 「配置概览」 | 删掉,用间距分组 |
|
||||
| 状态词统一用两三个字 | 「运行中」「Running」混用 | 运行中、已停止、启动中、停止中、出错 |
|
||||
|
||||
英文文案同样遵守这些规则,统一用句首大写(sentence case),不用每词首字母大写(Title Case)。
|
||||
|
||||
### 4.6 主题
|
||||
|
||||
跟随系统的深色 / 浅色(`prefers-color-scheme`),偏好设置里可以手动指定。Windows 用户里浅色模式占比不低,只有暗色会显得像个开发工具。(待决策 D3)
|
||||
|
||||
## 5. 进度、日志与反馈
|
||||
|
||||
### 5.1 状态栏(常驻,28 px)
|
||||
|
||||
- **左侧**:当前任务,形如「⟳ OpenCore 1.0.8 ▓▓▓░ 45%」。任务所属的 VM 和完整描述放在 Tooltip 里。同时有多个任务时显示「⟳ 2」,点开是任务列表。
|
||||
- **右侧**:警告和错误计数徽标,加上一个纯图标的日志开关。
|
||||
|
||||
### 5.2 日志面板
|
||||
|
||||
- **默认收起,不再因为来了新日志就自动展开。** 只有出现错误时才弹 Toast,Toast 上带「查看日志」按钮。
|
||||
- 面板高度可拖动,默认 240 px,记住用户上次的高度。
|
||||
- 三个页签:
|
||||
- **活动**:结构化的里程碑,例如「已创建磁盘」「OpenCore 下载完成」「已启动」;
|
||||
- **输出**:原始输出,可按 VM 和级别筛选;
|
||||
- **串口**:当前 VM 的串口日志。
|
||||
- **自动跟随到底部**:用户手动往上翻时暂停跟随,并出现「跳到最新」按钮。
|
||||
- **进度行合并**:同一个下载任务的 `x% of y MB` 只占一行并原地更新,不再一行一个百分比。
|
||||
- 保留最近 2000 行,超过就截断;行数多了再考虑虚拟滚动。
|
||||
|
||||
### 5.3 操作反馈
|
||||
|
||||
- 每个 VM 操作都通过 `useVMAction` 发起,返回 `pending` 状态。按钮进入忙碌态(转圈 + 禁用),防止重复点击。
|
||||
- 操作成功:轻量 Toast(「macos-tahoe 已关机」),3 秒后自动消失。
|
||||
- 操作失败:Toast 显示本地化的错误 + 建议操作 + 「查看日志」。不再用红色横幅占住内容区顶部。
|
||||
- 删除改用自定义确认框(Radix AlertDialog),内容包括:
|
||||
- 将删除的内容和磁盘占用;
|
||||
- 勾选项「保留磁盘文件」,对应后端已有的 `keepFiles` 参数;
|
||||
- 「此操作无法撤销」的提示。
|
||||
|
||||
## 6. 后端配合改动
|
||||
|
||||
改版需要后端补的接口。按优先级排列,P0 列标「是」的属于第一阶段。
|
||||
|
||||
| # | 改动 | 说明 | P0 |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| B1 | 结构化任务事件 `reims:task` | `{id, vm, kind, phase, percent, done_bytes, total_bytes, status, error_code}`。由 `logWriter` 解析上游的进度行生成;上游输出格式出自哪个文件、哪一行**待验证**,拿到上游 commit 和行号后再写解析器 | 已完成(2026-11-28,见表下说明) |
|
||||
| B2 | 日志带级别和类别 | `LogEntry` 增加 `level`(info / warn / error)和 `kind`(milestone / progress / raw) | 否 |
|
||||
| B3 | 用户可见文案改成发 i18n 键 | `emitLog` 里的 `"Starting "+name` 这类拼接改为 `{key, params}`,由前端翻译;上游原始输出保持原样,归入 `raw` | 否 |
|
||||
| B4 | 结构化错误 | 错误返回 `{code, message, hint}`,`message` 和 `hint` 已经本地化 | 否 |
|
||||
| B5 | `FocusVMWindow(name)` | 按 QEMU 的 PID 枚举顶层窗口,还原并置前(Win32 `EnumWindows` + `SetForegroundWindow`)。系统的前台锁限制下能否成功**待验证** | 否 |
|
||||
| B6 | 运行时信息 | `uptime`(来自进程启动时间)、是否已绑核、磁盘虚拟容量与实际占用(`qemu-img info`,现有 `VMDetail` 只有文件名)。CPU / 内存占用留到 M3.2 的 QMP | 否 |
|
||||
| B7 | 「正在创建」状态 | `CreateVM` 开始时写入 `transitions[name]="creating"`,侧边栏立刻出现这台 VM | 否 |
|
||||
| B8 | `OpenVMFolder(name)` | 在资源管理器中打开 VM 目录 | 是(很简单) |
|
||||
|
||||
前端在 P0 阶段先自己处理 B1、B2 能覆盖的部分:用正则把进度行合并成一行,按 `error` 关键字粗略分级。等 B1、B2 上线后删掉这段兼容代码。
|
||||
|
||||
**B1 已完成(2026-11-28)**:
|
||||
|
||||
- **后端**:`tasks.go` 维护任务列表,通过 `reims:task` 事件推送。字段有 `kind`、`subject`、`step`、`done`、`total`、`percent`、`rate`、`status`、`cancelable`。每个任务的进度事件最多每 200 ms 发一次,步骤变化和结束状态总是立即发出。
|
||||
- **进度来源**:
|
||||
- 安装包下载直接读 reims-util 的 JSON 事件;
|
||||
- 创建 VM 时,把 reims-ctl 输出里的进度行转成任务进度。进度行格式见上游 `3731afd` 的 `reims_util.rs:480-488`。日志里每个步骤只记一行。
|
||||
- **前端**:用正则合并进度行的兼容代码已删除。状态栏显示当前任务的中文标题和百分比;Tooltip 里是上游原文的步骤、已下载 / 总量和速度。下载可以暂停。
|
||||
- **验证情况**:在实际界面中验证过下载进度、暂停、续传和暂停提示。创建 VM 时的任务进度只有单元测试覆盖。
|
||||
|
||||
## 7. 前端工程
|
||||
|
||||
### 7.1 依赖(待决策 D2)
|
||||
|
||||
| 依赖 | 用途 | 理由 |
|
||||
| :-- | :-- | :-- |
|
||||
| `@radix-ui/react-*`(Dialog、AlertDialog、DropdownMenu、ContextMenu、Tooltip、Toast、Tabs、Progress、Collapsible) | 无样式的交互基件 | 焦点管理、键盘操作、无障碍都现成,样式完全由我们的令牌控制 |
|
||||
| `lucide-react` | 图标 | 替代手写的 `Icons.tsx`,风格统一 |
|
||||
| `zustand` | 状态 | 把 `App.tsx` 里的十几个 `useState` 拆成 store,事件订阅集中管理 |
|
||||
|
||||
不引入 Tailwind,也不引入完整组件库(MUI、Ant Design 之类),保持体积小、外观可控。
|
||||
|
||||
### 7.2 目录结构
|
||||
|
||||
```text
|
||||
src/
|
||||
app/ AppShell, TitleBar, Sidebar, StatusBar
|
||||
features/
|
||||
vm/ VMPage, VMHeader, VMActionsMenu, InstallGuide, SummaryRow, TechDetails, BrokenState, EmptyState
|
||||
create/ CreateWizard(沿用现有逻辑,换成新组件)
|
||||
settings/ SettingsModal(同上)
|
||||
host/ HostView, Preferences
|
||||
tasks/ taskStore, TaskIndicator
|
||||
logs/ logStore, LogPanel, useStickToBottom
|
||||
ui/ Button, IconButton, Badge, StatusDot, Card, Dialog, Menu, Toast, Tooltip, Progress, Tabs(对 Radix 的封装)
|
||||
lib/ format.ts, i18n.ts, errors.ts
|
||||
store/ appStore(state, selection, 事件订阅)
|
||||
styles/ tokens.css, base.css
|
||||
```
|
||||
|
||||
### 7.3 键盘与无障碍
|
||||
|
||||
- 侧边栏做成 listbox:`↑` / `↓` 选择,`Enter` 进入;右键菜单与「⋯」菜单内容一致。
|
||||
- 快捷键:
|
||||
- `Ctrl+N` 新建
|
||||
- `Ctrl+,` 设置
|
||||
- `Ctrl+L` 日志
|
||||
- `Ctrl+Enter` 执行当前主操作
|
||||
- 所有可交互元素都是真正的 `<button>` 或带 role 的元素,并有 `:focus-visible` 焦点环。
|
||||
|
||||
### 7.4 窗口与 DPI
|
||||
|
||||
- 最小窗口尺寸 960 × 640。
|
||||
- 内容区最大宽度 960,概要卡片用 `grid-template-columns: repeat(auto-fit, minmax(180px, 1fr))` 自动换行。
|
||||
- 在 100% / 125% / 150% 缩放下逐一检查,不允许出现截断。
|
||||
|
||||
## 8. 分阶段计划
|
||||
|
||||
### 阶段 0:修硬伤(1–2 天,不改后端,除了 B8)
|
||||
|
||||
> 2026-11-28 已完成,B8 也已上线(`OpenVMFolder`)。以下内容原属阶段 1,这次提前做了,避免在旧结构上返工:
|
||||
> - VM 页头和「⋯」菜单(D1);
|
||||
> - Toast;
|
||||
> - 概要行(图标 + 数值)和技术信息折叠区;
|
||||
> - 引入 Radix 和 lucide。
|
||||
>
|
||||
> 装机步骤条还是静态的三步列表,可交互、能记住进度的步骤条留到阶段 1。
|
||||
|
||||
- 去掉重复的操作出口(工具栏里的弹出安装盘、页头的删除、配置概览旁的串口日志)。
|
||||
- 日志抽屉不再自动展开、自动跟随到底部、合并进度行。
|
||||
- 显卡名称反查,隐藏 ICD 路径、CPU 型号和运行时哈希。
|
||||
- 操作按钮加忙碌态;删除改为自定义确认框,并提供「保留磁盘文件」。
|
||||
- 引入 `tokens.css`、统一字阶和 Windows 字体栈;清掉内联样式。
|
||||
- 按 4.5 精简文案:次要操作改成纯图标按钮并加 Tooltip,删掉安装盘横幅和「配置概览」标题,统一状态词。
|
||||
- 侧边栏支持键盘操作,补上焦点样式。
|
||||
|
||||
**完成标准**:
|
||||
|
||||
- 截图里列出的 P2、P3、P5、P6 现象全部消失;
|
||||
- 同一屏里任何操作只出现一次;
|
||||
- 主视图不出现路径、哈希或 QEMU 内部名。
|
||||
|
||||
### 阶段 1:结构改版(约 1 周,需要 B1–B4、B7)
|
||||
|
||||
- 引入 Radix、lucide、zustand,按 7.2 拆分目录。
|
||||
- 实现新页头(按状态切换主操作)、「⋯」菜单、右键菜单。
|
||||
- 状态栏 + 任务进度 + 三页签日志面板。
|
||||
- 装机步骤条、概要卡片、技术信息折叠区。
|
||||
- 空状态、正在创建、配置损坏三个状态页。
|
||||
- 后端文案全部 i18n,错误结构化。
|
||||
|
||||
**完成标准**:
|
||||
|
||||
- 中文界面下除原始日志以外没有英文;
|
||||
- 任一操作点击后 100 ms 内有视觉反馈;
|
||||
- 只用键盘就能走完「选中 VM → 启动 → 打开设置」;
|
||||
- 125% 和 150% 缩放下没有截断。
|
||||
|
||||
### 阶段 2:体验补全(与 M3 并行)
|
||||
|
||||
- 「显示 VM 窗口」(B5)、运行时长与绑核状态(B6)。
|
||||
- 浅色主题。
|
||||
- 截屏缩略图(依赖 M3.2 的 QMP)、复制派生入口(M3.3)。
|
||||
- 一键导出排障包入口(M3.4)。
|
||||
|
||||
## 9. 决策记录
|
||||
|
||||
2026-11-28:D1–D4 全部按推荐方案采纳;`shell-design.md` 第 1 节和第 5 节已同步修订。D2 中的 Radix 和 lucide 在阶段 0 就引入,用来实现删除确认框、菜单和 Tooltip,避免先手写一遍再重做;zustand 和目录拆分仍放在阶段 1。
|
||||
|
||||
| # | 问题 | 推荐(已采纳) | 备选 |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| D1 | VM 操作放在顶部工具栏,还是放在 VM 页头 | **页头**:操作离对象近,切页时布局不跳。若采纳,同步修订 `shell-design.md` 第 5 节 | 保留工具栏,但只放当前状态的主操作,加一个「⋯」 |
|
||||
| D2 | 是否引入 Radix、lucide、zustand | **引入**:Dialog、菜单、Toast、焦点管理自己写成本高,而且容易做不完整 | 继续零依赖,手写这些基件 |
|
||||
| D3 | 主题 | **跟随系统,深浅两套** | 只做暗色 |
|
||||
| D4 | 「对齐 macOS」的边界 | **结构和术语对齐 macOS**(侧边栏、分步助手、设置分页、VZ 词表),**渲染层面按 Windows 平台来**(字体、窗口控件、DPI)。若采纳,修订 `shell-design.md` 第 1 节「视觉按 macOS 来做」这句 | 视觉也继续模仿 macOS |
|
||||
@@ -1,66 +0,0 @@
|
||||
# 上游 PR 跟进与补丁上游化准备(M4.1 / M4.5)
|
||||
|
||||
> 遵循 [`AGENTS.md`](../AGENTS.md) 规则 4:本仓库不维护长期 fork,所有对上游的改动仅以补丁队列存于 [`patches/`](../patches/),向上游提交 PR 由人工确认执行。
|
||||
|
||||
---
|
||||
|
||||
## 一、上游 Windows 重点 PR 跟踪清单(M4.1)
|
||||
|
||||
目标上游仓库:[`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu)(当前稳定运行时基准 commit:`3731afd`)。
|
||||
|
||||
| 上游 PR | 方向 | 价值与影响 | 建议动作 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `#153` | 图形呈现 | Windows NVIDIA MAILBOX 经 FIFO 首帧优化,改善高帧率与首帧延迟 | 合入后触发 `build-runtime.yml` 产出 `candidate` 并跑冒烟 |
|
||||
| `#152` | 平台层 | 原生 Windows Vulkan 后端,减少 Windows 图形适配开销 | 合入后升级运行时并对比帧率/稳定性 |
|
||||
| `#107` | 图形内存 | 采样纹理回读就地消费,降低显存/内存拷贝开销 | 合入后随运行时一并纳入 |
|
||||
| `#123` | 窗口体验 | `Ctrl+Alt+Enter` 热切全屏 | 合入后在前端文档/帮助提示同步快捷键 |
|
||||
| `#172` | 窗口体验 | Windows 拖动窗口贴合,消除缩放黑边 | 合入后验证高 DPI 与多显示器缩放 |
|
||||
| Win → Command | 键位映射 | 自由指针下 Windows 键映射为 macOS Command | 优先向上游提议/提交 PR,避免长期维护私有补丁 |
|
||||
|
||||
---
|
||||
|
||||
## 二、待提交上游 PR 的本地补丁证据汇总(M4.5)
|
||||
|
||||
目标上游仓库:[`steelbrain/qemu-reims-vgpu`](https://github.com/steelbrain/qemu-reims-vgpu)(基准 commit:`4571bc5`),修改文件均为 `target/i386/whpx/whpx-all.c`。
|
||||
|
||||
### PR 1:`whpx: probe TSC deadline on throwaway partition and guard WHvResetPartition`
|
||||
|
||||
- **补丁文件**:[`patches/qemu-whpx-win10-compat.patch`](../patches/qemu-whpx-win10-compat.patch)
|
||||
- **影响环境**:Windows 10 22H2(Build 19045)启用 WHPX 的 x86-64 宿主。
|
||||
- **复现与根因**:
|
||||
1. `whpx_tsc_deadline_refused()`(`target/i386/whpx/whpx-all.c:3211`)在正式 `whpx_global.partition` 上临时创建并删除 vCPU 0;Windows 10 19045 上随后 `whpx_init_vcpu()` 再次为 vCPU 0 调用 `WHvCreateVirtualProcessor` 必现失败,返回 `E_INVALIDARG (0x80070057)`。
|
||||
2. `whpx_set_registers()`(`target/i386/whpx/whpx-all.c:530`)在复位状态直接调用 `whp_dispatch.WHvResetPartition`,但该 API 在 Windows 11 才新增;Windows 10 上函数指针为空,引发空指针解引用崩溃(`0xc0000005`)。
|
||||
- **最小修复**:
|
||||
1. 改在一次性探测 partition 上测试 `WHvX64RegisterTscDeadline`,测完即销毁探测 partition;
|
||||
2. 调用 `WHvResetPartition` 前判断 `whp_dispatch.WHvResetPartition != NULL`。
|
||||
- **实测证据**:已在 Windows 10 19045 真机通过多轮冷启动与日常使用验证(见 `runtime-3731afd` 稳定版运行时)。
|
||||
|
||||
### PR 2:`whpx: forward INIT/SIPI via WHvRequestInterrupt on legacy Windows 10 with kernel-irqchip`
|
||||
|
||||
- **补丁文件**:[`patches/qemu-whpx-win10-startup-ipis.patch`](../patches/qemu-whpx-win10-startup-ipis.patch)(依赖 PR 1)
|
||||
- **影响环境**:Windows 10 19045 开启 `kernel-irqchip=on` 且多核(`smp.max_cpus > 1`)的 macOS 客体。
|
||||
- **复现与根因**:
|
||||
- Win10 上开启 WHPX 内核态 APIC 仿真后,XNU 启动从核(AP)发出的 INIT/SIPI 可能无法唤醒已 halt 的从核,导致客体卡在多核拉起阶段。
|
||||
- **最小修复**:
|
||||
- 仅在 `whpx_is_legacy_os() && whpx_irqchip_in_kernel() && ms->smp.max_cpus > 1` 且宿主支持 `X64ApicInitSipiExitTrap` 时开启捕获,并在 `WHvRunVpExitReasonX64ApicInitSipiTrap` 退出中通过 `WHvRequestInterrupt` 转发 INIT/SIPI(忽略 INIT level deassert)。
|
||||
- **实测证据**:Win10 19045 上 8 核两次冷启动、12 核冷启动均验证 x2APIC、FileVault、SSH 与图形登录通过;客体软重启仍由外层 `AF_UNIX` QMP 监控兜底(待进一步观测纯补丁下软重启行为)。
|
||||
|
||||
### PR 3:`whpx: make nested virtualization property failure non-fatal`
|
||||
|
||||
- **补丁文件**:[`patches/qemu-whpx-nested-virt-nonfatal.patch`](../patches/qemu-whpx-nested-virt-nonfatal.patch)(依赖 PR 1 & PR 2)
|
||||
- **影响环境**:部分 Windows 11 宿主(如 24H2 / Home 或 Core Ultra 200 系列)。
|
||||
- **复现与根因**:
|
||||
- `WHvGetCapability` 返回 `Bank1.NestedVirtSupport = 1`,但实际调用 `WHvSetPartitionProperty(WHvPartitionPropertyCodeNestedVirtualization)` 时返回 `hr=0x80370302`(`WHV_E_UNKNOWN_PROPERTY`)。
|
||||
- 上游原代码(`target/i386/whpx/whpx-all.c:3533-3545`)将该错误当作致命错误直接 `goto error` 中止 VM 启动,迫使用户退回 `kernel-irqchip=off`(损失 Hyper-V 内核态 x2APIC / SynIC 加速)。
|
||||
- **最小修复**:
|
||||
- 将 `error_report` + `goto error` 改为 `warn_report` 并将 `processor_features.Bank1.NestedVirtSupport` 清零,继续保留完整 `kernel-irqchip=on` 启动。
|
||||
- **实测状态**:已在 `Reims-Go` 宿主探测逻辑(`internal/host/whpx_probe_windows.go`)复现 `hr=0x80370302`;带该补丁的 `candidate` 运行时需经真机编译冒烟验证后再提上游 PR(**待验证**)。
|
||||
|
||||
---
|
||||
|
||||
## 三、补丁退役检查表
|
||||
|
||||
每当上游合入对应 PR 并产出新 `candidate` 运行时后:
|
||||
1. 移除 `patches/` 下对应 `.patch` 文件,并同步更新 `patches/README.md` 与 `scripts/pack-runtime.ps1`;
|
||||
2. 触发 `.github/workflows/build-runtime.yml` 构建新 `candidate`;
|
||||
3. 在真机运行 `scripts/smoke-runtime.ps1` 并人工确认通过后升级为 `stable`。
|
||||
@@ -1,5 +1,5 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<html dir="ltr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
{
|
||||
"name": "reims-go-frontend",
|
||||
"private": true,
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.10",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc --noEmit && vite build",
|
||||
"test": "node --test scripts/test-i18n.mjs",
|
||||
"build": "tsc --noEmit && vite build && node scripts/check-ui-contract.mjs",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.2.1",
|
||||
"@radix-ui/react-context-menu": "^2.4.1",
|
||||
"@radix-ui/react-dialog": "^1.3.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.2.1",
|
||||
"@radix-ui/react-toast": "^1.3.1",
|
||||
|
||||
@@ -1 +1 @@
|
||||
63074d720d82ba66da97ce3a9813911e
|
||||
58f4fafea894c5f7c1c6ebefde51e110
|
||||
@@ -8,9 +8,15 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@fontsource-variable/inter':
|
||||
specifier: ^5.3.0
|
||||
version: 5.3.0
|
||||
'@radix-ui/react-alert-dialog':
|
||||
specifier: ^1.2.1
|
||||
version: 1.2.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
'@radix-ui/react-context-menu':
|
||||
specifier: ^2.4.1
|
||||
version: 2.4.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
'@radix-ui/react-dialog':
|
||||
specifier: ^1.3.1
|
||||
version: 1.3.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
@@ -305,6 +311,9 @@ packages:
|
||||
'@floating-ui/utils@0.2.12':
|
||||
resolution: {integrity: sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==}
|
||||
|
||||
'@fontsource-variable/inter@5.3.0':
|
||||
resolution: {integrity: sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
|
||||
|
||||
@@ -372,6 +381,19 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-context-menu@2.4.1':
|
||||
resolution: {integrity: sha512-Pddn3Z8lio3/ChxyXaEP3jHTTo1LTHCWwF8+mG1chQlWijP+ttVHBKwezrQTiV6Mj670ojvumqvuGh+mdv33iQ==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
'@types/react-dom': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-context@1.3.0':
|
||||
resolution: {integrity: sha512-v5AYEocMISkbJ+1fTXzZpiFv7NRr3D2WiYbLIKf+FkmJ8VkP6d503eV2n34MFussHXY1pcoq3yfJiQH77dc4Mg==}
|
||||
peerDependencies:
|
||||
@@ -1293,6 +1315,8 @@ snapshots:
|
||||
|
||||
'@floating-ui/utils@0.2.12': {}
|
||||
|
||||
'@fontsource-variable/inter@5.3.0': {}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.6.0
|
||||
@@ -1355,6 +1379,19 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.3.3
|
||||
|
||||
'@radix-ui/react-context-menu@2.4.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.2.0
|
||||
'@radix-ui/react-context': 1.3.0(@types/react@19.3.3)(react@19.3.1)
|
||||
'@radix-ui/react-menu': 2.2.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
'@radix-ui/react-primitive': 2.2.0(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
'@radix-ui/react-use-controllable-state': 1.3.0(@types/react@19.3.3)(react@19.3.1)
|
||||
react: 19.3.1
|
||||
react-dom: 19.3.1(react@19.3.1)
|
||||
optionalDependencies:
|
||||
'@types/react': 19.3.3
|
||||
'@types/react-dom': 19.3.0(@types/react@19.3.3)
|
||||
|
||||
'@radix-ui/react-context@1.3.0(@types/react@19.3.3)(react@19.3.1)':
|
||||
dependencies:
|
||||
react: 19.3.1
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const rootDir = path.resolve(__dirname, '..')
|
||||
const srcDir = path.join(rootDir, 'src')
|
||||
|
||||
const contractSrc = fs.readFileSync(path.join(srcDir, 'styles', 'ui-contract.ts'), 'utf8')
|
||||
const tokensCss = fs.readFileSync(path.join(srcDir, 'styles', 'tokens.css'), 'utf8')
|
||||
|
||||
function extractArray(name) {
|
||||
const re = new RegExp(`export const ${name} = \\[([\\s\\S]*?)\\] as const`)
|
||||
const m = contractSrc.match(re)
|
||||
if (!m) throw new Error(`Could not parse ${name} from ui-contract.ts`)
|
||||
return [...m[1].matchAll(/'([^']+)'/g)].map((x) => x[1])
|
||||
}
|
||||
|
||||
const apiMatch = contractSrc.match(/UI_API_VERSION\s*=\s*'([^']+)'/)
|
||||
const uiApi = apiMatch ? apiMatch[1] : '1.0.0'
|
||||
const parts = extractArray('UI_CONTRACT_PARTS')
|
||||
const stateAttrs = extractArray('UI_CONTRACT_STATE_ATTRS')
|
||||
const slots = extractArray('UI_CONTRACT_SLOTS')
|
||||
const tokens = extractArray('UI_CONTRACT_TOKENS')
|
||||
|
||||
// Collect all React component TSX source text (excluding contract/SDK/theme helpers)
|
||||
// and verify every declared part class is emitted as a distinct class token (§5.1, M17).
|
||||
function readComponentTsx(dir) {
|
||||
let buf = ''
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) buf += readComponentTsx(full)
|
||||
else if (entry.name.endsWith('.tsx')) buf += '\n' + fs.readFileSync(full, 'utf8')
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
const allTsx = readComponentTsx(srcDir)
|
||||
const missingParts = parts.filter((p) => {
|
||||
const re = new RegExp(`(?<![a-zA-Z0-9_-])${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![a-zA-Z0-9_-])`)
|
||||
return !re.test(allTsx)
|
||||
})
|
||||
const missingTokens = tokens.filter((tk) => !tokensCss.includes(`${tk}:`))
|
||||
|
||||
if (missingParts.length > 0) {
|
||||
console.error('[ui-contract] ERROR: contract parts not emitted by any component:', missingParts.join(', '))
|
||||
process.exit(1)
|
||||
}
|
||||
if (missingTokens.length > 0) {
|
||||
console.error('[ui-contract] ERROR: contract tokens missing in tokens.css:', missingTokens.join(', '))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const out = { uiApi, tokens, parts, stateAttrs, slots }
|
||||
const jsonText = JSON.stringify(out, null, 2) + '\n'
|
||||
fs.writeFileSync(path.join(rootDir, 'ui-contract.json'), jsonText, 'utf8')
|
||||
const distDir = path.join(rootDir, 'dist')
|
||||
if (fs.existsSync(distDir)) {
|
||||
fs.writeFileSync(path.join(distDir, 'ui-contract.json'), jsonText, 'utf8')
|
||||
}
|
||||
console.log(`[ui-contract] OK (uiApi=${uiApi}, parts=${parts.length}, tokens=${tokens.length}, slots=${slots.length})`)
|
||||
@@ -0,0 +1,251 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { createRequire } from 'node:module'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const rootDir = path.resolve(__dirname, '..')
|
||||
const srcDir = path.join(rootDir, 'src')
|
||||
const localesDir = path.resolve(rootDir, '..', 'locales', 'en-US')
|
||||
|
||||
// Resolve esbuild from Vite's dependency tree (zero extra npm dependencies per §8.1).
|
||||
const requireFromRoot = createRequire(path.join(rootDir, 'package.json'))
|
||||
const vitePkgPath = requireFromRoot.resolve('vite/package.json')
|
||||
const requireFromVite = createRequire(vitePkgPath)
|
||||
const esbuild = requireFromVite('esbuild')
|
||||
|
||||
async function loadBundledTS(entrySource) {
|
||||
const result = await esbuild.build({
|
||||
stdin: {
|
||||
contents: entrySource,
|
||||
resolveDir: srcDir,
|
||||
sourcefile: 'test-entry.ts',
|
||||
loader: 'ts',
|
||||
},
|
||||
bundle: true,
|
||||
write: false,
|
||||
format: 'esm',
|
||||
platform: 'browser',
|
||||
target: 'es2022',
|
||||
})
|
||||
const code = result.outputFiles[0].text
|
||||
const dataUrl = `data:text/javascript;base64,${Buffer.from(code, 'utf8').toString('base64')}`
|
||||
return import(dataUrl)
|
||||
}
|
||||
|
||||
function walkFiles(dir, exts) {
|
||||
const out = []
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) out.push(...walkFiles(full, exts))
|
||||
else if (exts.some((ext) => entry.name.endsWith(ext))) out.push(full)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
test('Static Guard (CRITICAL-1): lazy i18n domain keys are always backed by domain .gen imports', () => {
|
||||
const lazyDomains = ['wizard', 'settings', 'plugins']
|
||||
const keyToDomain = new Map()
|
||||
for (const dom of ['core', 'vm', ...lazyDomains]) {
|
||||
const raw = JSON.parse(fs.readFileSync(path.join(localesDir, `${dom}.json`), 'utf8'))
|
||||
for (const k of Object.keys(raw)) {
|
||||
if (!k.startsWith('$')) keyToDomain.set(k, dom)
|
||||
}
|
||||
}
|
||||
|
||||
// Known lazy-loaded chunk entry trees (loaded via React.lazy or dynamic import in App.tsx)
|
||||
const lazyEntryBasenames = new Set([
|
||||
'CreateWizard.tsx',
|
||||
'SettingsModal.tsx',
|
||||
'AffinityDialog.tsx',
|
||||
'Setup.tsx',
|
||||
'RuntimeOnline.tsx',
|
||||
'HostView.tsx',
|
||||
'InstallersPage.tsx',
|
||||
'PluginsPage.tsx',
|
||||
'AppSettingsPage.tsx',
|
||||
'AboutPage.tsx',
|
||||
'PluginPanelFrame.tsx',
|
||||
'SchemaForm.tsx',
|
||||
'optimizations.ts',
|
||||
])
|
||||
|
||||
for (const file of walkFiles(srcDir, ['.ts', '.tsx'])) {
|
||||
const rel = path.relative(srcDir, file).replace(/\\/g, '/')
|
||||
if (rel.startsWith('i18n/')) continue
|
||||
const base = path.basename(file)
|
||||
const src = fs.readFileSync(file, 'utf8')
|
||||
|
||||
// Match string literals passed to t(..., 'key'), tr('key'), labelKey: 'key', detailKey: 'key', titleKey: 'key', descKey: 'key'
|
||||
const referencedLazyDomains = new Set()
|
||||
const callMatches = [
|
||||
...src.matchAll(/\b(?:tr|t)\(\s*(?:[a-zA-Z0-9_$.]+\s*,\s*)?'([a-zA-Z0-9_.]+)'/g),
|
||||
...src.matchAll(/\b(?:labelKey|detailKey|titleKey|descKey)\s*:\s*'([a-zA-Z0-9_.]+)'/g),
|
||||
]
|
||||
for (const m of callMatches) {
|
||||
const dom = keyToDomain.get(m[1])
|
||||
if (dom && lazyDomains.includes(dom)) {
|
||||
referencedLazyDomains.add(`${dom}:${m[1]}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (referencedLazyDomains.size === 0) continue
|
||||
|
||||
assert.ok(
|
||||
lazyEntryBasenames.has(base),
|
||||
`Eager module ${rel} references lazy domain keys (${[...referencedLazyDomains].join(', ')})! Either move keys to core/vm or lazy-load the module.`,
|
||||
)
|
||||
|
||||
for (const item of referencedLazyDomains) {
|
||||
const [dom, key] = item.split(':')
|
||||
// Sub-dialogs rendered exclusively inside lazy parent chunks inherit their parent's domain registration
|
||||
if (base === 'AffinityDialog.tsx' && dom === 'settings') continue
|
||||
if (base === 'RuntimeOnline.tsx' && (dom === 'wizard' || dom === 'settings')) continue
|
||||
assert.match(
|
||||
src,
|
||||
new RegExp(`i18n/domains/${dom}\\.gen`),
|
||||
`Module ${rel} uses ${dom} key "${key}" without importing i18n/domains/${dom}.gen`,
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and toast-* class in TSX exists in CSS', () => {
|
||||
const css =
|
||||
fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') +
|
||||
'\n' +
|
||||
fs.readFileSync(path.join(srcDir, 'styles', 'tokens.css'), 'utf8')
|
||||
|
||||
const prefixes = ['stack-', 'notice-', 'error-boundary', 'toast-']
|
||||
const used = new Set()
|
||||
for (const file of walkFiles(srcDir, ['.tsx'])) {
|
||||
const src = fs.readFileSync(file, 'utf8')
|
||||
for (const m of src.matchAll(/className\s*=\s*(?:"([^"]+)"|'([^']+)'|\{`([^`]+)`\})/g)) {
|
||||
const raw = (m[1] || m[2] || m[3] || '').replace(/\$\{[^}]+\}/g, ' ')
|
||||
for (const tok of raw.split(/\s+/)) {
|
||||
if (prefixes.some((p) => tok.startsWith(p))) used.add(tok)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const cls of used) {
|
||||
const escaped = cls.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
assert.match(css, new RegExp(`\\.${escaped}(?![a-zA-Z0-9_-])`), `Missing CSS rule for .${cls}`)
|
||||
}
|
||||
})
|
||||
|
||||
test('Runtime i18n v2: ICU formatting, ghost-locale isolation (H-3), parseAppError (HIGH-2), RTL (L-2), and en-XA', async () => {
|
||||
const mod = await loadBundledTS(`
|
||||
import './i18n/domains/wizard.gen'
|
||||
import './i18n/domains/settings.gen'
|
||||
import './i18n/domains/plugins.gen'
|
||||
export * from './i18n'
|
||||
export * from './lib/format'
|
||||
export * from './lib/themeEngine'
|
||||
`)
|
||||
|
||||
// 1. Built-in bilingual + ICU plural + decimal formatting
|
||||
assert.equal(mod.formatMemory('16G', 'en-US'), '16 GB')
|
||||
assert.equal(mod.formatMemory('1536M', 'de-DE'), '1,5 GB')
|
||||
|
||||
// 2. H-3 & HIGH-9: Functional plugin L10n (has_ui_messages: false) must NOT pollute host UI locales,
|
||||
// while full language pack (has_ui_messages: true) activates properly.
|
||||
mod.setPluginLocales([
|
||||
{
|
||||
locale: 'de-DE',
|
||||
label: 'Deutsch',
|
||||
fallback: 'en-US',
|
||||
has_ui_messages: false,
|
||||
messages: {},
|
||||
plugin_messages: {
|
||||
'acme.de': { 'btn.run': 'Ausführen ({n})' },
|
||||
},
|
||||
},
|
||||
{
|
||||
locale: 'ja-JP',
|
||||
label: '日本語',
|
||||
fallback: 'en-US',
|
||||
has_ui_messages: true,
|
||||
messages: { sidebarSettings: '設定' },
|
||||
plugin_messages: {
|
||||
'acme.de': { 'btn.run': '実行 ({n})' },
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const opts = mod.getLocaleOptions().map((o) => o.value)
|
||||
assert.ok(opts.includes('ja-JP'), 'ja-JP language pack should appear in UI options')
|
||||
assert.ok(!opts.includes('de-DE'), 'de-DE functional plugin L10n must NOT appear as ghost UI locale')
|
||||
assert.equal(mod.resolveActiveLocale('de-DE'), 'en-US')
|
||||
assert.equal(mod.resolveActiveLocale('ja-JP'), 'ja-JP')
|
||||
assert.equal(mod.t('ja-JP', 'sidebarSettings'), '設定')
|
||||
assert.equal(mod.tPlugin('acme.de', 'de-DE', 'btn.run', { n: 3 }), 'Ausführen (3)')
|
||||
assert.equal(mod.getPluginMessageBundle('acme.de', 'ja-JP')['btn.run'], '実行 ({n})')
|
||||
|
||||
// 3. Pseudo-locale en-XA wraps host & plugin strings in ⟦...⟧ and preserves placeholders
|
||||
const pseudoHost = mod.t('en-XA', 'cores', { n: 8 })
|
||||
assert.ok(pseudoHost.startsWith('⟦') && pseudoHost.endsWith('⟧') && pseudoHost.includes('8'), `bad pseudoHost: ${pseudoHost}`)
|
||||
const pseudoPlugin = mod.tPlugin('acme.de', 'en-XA', 'btn.run', { n: 5 }, 'Run ({n})')
|
||||
assert.ok(pseudoPlugin.startsWith('⟦') && pseudoPlugin.includes('5'), `bad pseudoPlugin: ${pseudoPlugin}`)
|
||||
|
||||
// Reset plugin locales
|
||||
mod.setPluginLocales([])
|
||||
|
||||
// 4. HIGH-2: parseAppError handles suffix & prefix [E_CODE], multi-line summaries, codeless [detail], and Error objects
|
||||
const codedSuffix = mod.parseAppError('First summary line\nSecond summary line [E_VM_BUSY]\n[detail] raw trace line 1\nline 2')
|
||||
assert.equal(codedSuffix.code, 'E_VM_BUSY')
|
||||
assert.equal(codedSuffix.summary, 'First summary line\nSecond summary line')
|
||||
assert.equal(codedSuffix.rawDetail, 'raw trace line 1\nline 2')
|
||||
|
||||
const codedPrefix = mod.parseAppError('[E_VM_BUSY] First summary line\nSecond summary line\n[detail] raw trace line 1\nline 2')
|
||||
assert.equal(codedPrefix.code, 'E_VM_BUSY')
|
||||
assert.equal(codedPrefix.summary, 'First summary line\nSecond summary line')
|
||||
assert.equal(codedPrefix.rawDetail, 'raw trace line 1\nline 2')
|
||||
|
||||
const codelessDetail = mod.parseAppError('Human summary without code\n[detail] exit status 1')
|
||||
assert.equal(codelessDetail.code, undefined)
|
||||
assert.equal(codelessDetail.summary, 'Human summary without code')
|
||||
assert.equal(codelessDetail.rawDetail, 'exit status 1')
|
||||
|
||||
const objErr = mod.parseAppError({ message: 'Timeout [E_NET]' })
|
||||
assert.equal(objErr.code, 'E_NET')
|
||||
assert.equal(objErr.summary, 'Timeout')
|
||||
|
||||
// 5. L-2: 8-subtag RTL parity with Go backend
|
||||
for (const rtl of ['ar-SA', 'he-IL', 'iw-IL', 'fa-IR', 'ur-PK', 'ps-AF', 'dv-MV', 'yi']) {
|
||||
assert.equal(mod.isRTLLocale(rtl), true, `expected RTL for ${rtl}`)
|
||||
}
|
||||
assert.equal(mod.isRTLLocale('en-US'), false)
|
||||
assert.equal(mod.isRTLLocale('zh-TW'), false)
|
||||
|
||||
// 6. LOW-5: resolveGuestLang structured preset lookup without punctuation splitting
|
||||
const zhGuest = mod.resolveGuestLang('zh-CN', 'zh-Hans:0')
|
||||
assert.ok(zhGuest.label.length > 0 && zhGuest.detail && zhGuest.detail.length > 0)
|
||||
|
||||
// 7. HIGH-1: Theme seed token derivation enforces WCAG 2.1 AA contrast on bright vs dark accents
|
||||
const hslContrast = (hslStr, surfaceLum) => {
|
||||
const m = hslStr.match(/hsl\(\s*(\d+)\s+(\d+)%\s+(\d+)%\s*\)/)
|
||||
assert.ok(m, `unexpected hsl string: ${hslStr}`)
|
||||
const h = Number(m[1]), s = Number(m[2]) / 100, l = Number(m[3]) / 100
|
||||
const c = (1 - Math.abs(2 * l - 1)) * s
|
||||
const hp = (h % 360) / 60
|
||||
const x = c * (1 - Math.abs((hp % 2) - 1))
|
||||
const [r1, g1, b1] = hp < 1 ? [c, x, 0] : hp < 2 ? [x, c, 0] : hp < 3 ? [0, c, x] : hp < 4 ? [0, x, c] : hp < 5 ? [x, 0, c] : [c, 0, x]
|
||||
const mv = l - c / 2
|
||||
const lin = (v) => (v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4))
|
||||
const lum = 0.2126 * lin(r1 + mv) + 0.7152 * lin(g1 + mv) + 0.0722 * lin(b1 + mv)
|
||||
return (Math.max(lum, surfaceLum) + 0.05) / (Math.min(lum, surfaceLum) + 0.05)
|
||||
}
|
||||
const brightYellow = mod.deriveTokensFromSeeds({ accent: '#ffd60a' }, undefined, 'light')
|
||||
assert.equal(brightYellow['--accent-text'], '#1d1d1f')
|
||||
assert.ok(hslContrast(brightYellow['--accent-soft-text'], 0.92) >= 4.5, `yellow light contrast too low: ${brightYellow['--accent-soft-text']}`)
|
||||
|
||||
const pureBlueDark = mod.deriveTokensFromSeeds({ accent: '#0000ff' }, undefined, 'dark')
|
||||
assert.ok(hslContrast(pureBlueDark['--accent-soft-text'], 0.015) >= 4.5, `blue dark contrast too low: ${pureBlueDark['--accent-soft-text']}`)
|
||||
|
||||
const appleBlue = mod.deriveTokensFromSeeds({ accent: '#0071e3' }, undefined, 'dark')
|
||||
assert.equal(appleBlue['--accent-text'], '#ffffff')
|
||||
assert.ok(hslContrast(appleBlue['--accent-soft-text'], 0.015) >= 4.5, `appleBlue dark contrast too low: ${appleBlue['--accent-soft-text']}`)
|
||||
})
|
||||
@@ -0,0 +1,334 @@
|
||||
import { Copy, Download, ExternalLink, RotateCw, Scale } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { taskDetail } from '../lib/tasks'
|
||||
import { AppUpdateInfo, Locale, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { Segmented } from '../ui/settings'
|
||||
import { api } from '../wails'
|
||||
import { REPO_URL } from './TitleMenus'
|
||||
import type { UpdatePhase } from './UpdateCapsule'
|
||||
|
||||
const QQ_GROUP_ID = '1136042744'
|
||||
|
||||
export type AppUpdateChannel = 'stable' | 'alpha' | 'dev'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
appVersion?: string
|
||||
appUpdateChannel: AppUpdateChannel
|
||||
onAppUpdateChannel: (channel: AppUpdateChannel) => Promise<void> | void
|
||||
/** Latest update check, shared with the sidebar's update button. */
|
||||
appUpdate: AppUpdateInfo | null
|
||||
onAppUpdate: (info: AppUpdateInfo) => void
|
||||
updatePhase: UpdatePhase
|
||||
updateTask: Task | null
|
||||
/** The swap has started and the app is about to restart. */
|
||||
installing: boolean
|
||||
onDownloadUpdate: () => void
|
||||
onCancelUpdate: () => void
|
||||
onInstallUpdate: () => void
|
||||
onCopy?: (text: string) => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
}
|
||||
|
||||
/** About page: version and updates, project links and the community group. */
|
||||
export const AboutPage: React.FC<Props> = ({
|
||||
locale, appVersion, appUpdateChannel, onAppUpdateChannel, appUpdate, onAppUpdate, updatePhase, updateTask, installing,
|
||||
onDownloadUpdate, onCancelUpdate, onInstallUpdate, onCopy, onError,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [checkingUpdate, setCheckingUpdate] = useState(false)
|
||||
const [switchingChannel, setSwitchingChannel] = useState(false)
|
||||
const [updateErr, setUpdateErr] = useState('')
|
||||
const [qqInstalled, setQQInstalled] = useState<boolean | null>(null)
|
||||
const [openingQQ, setOpeningQQ] = useState(false)
|
||||
const [qqLaunchErr, setQQLaunchErr] = useState('')
|
||||
const [licenseOpen, setLicenseOpen] = useState(false)
|
||||
const [licenseTab, setLicenseTab] = useState<'notice' | 'license'>('notice')
|
||||
const [licenses, setLicenses] = useState<{ license: string; notice: string } | null>(null)
|
||||
|
||||
const openLicenses = () => {
|
||||
setLicenseOpen(true)
|
||||
if (!licenses) {
|
||||
api.GetLicenseTexts()
|
||||
.then((res) => setLicenses({ license: res?.license ?? '', notice: res?.notice ?? '' }))
|
||||
.catch((e) => onError(tr('failGeneric'), e))
|
||||
}
|
||||
}
|
||||
|
||||
const runUpdateCheck = async (force: boolean) => {
|
||||
setCheckingUpdate(true)
|
||||
setUpdateErr('')
|
||||
try {
|
||||
onAppUpdate(await api.CheckAppUpdate(force))
|
||||
} catch (e) {
|
||||
setUpdateErr(String(e).replace(/^Error:\s*/, ''))
|
||||
} finally {
|
||||
setCheckingUpdate(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!appUpdate) void runUpdateCheck(false)
|
||||
let cancelled = false
|
||||
api.CanOpenQQGroup()
|
||||
.then((ok) => { if (!cancelled) setQQInstalled(!!ok) })
|
||||
.catch(() => { if (!cancelled) setQQInstalled(false) })
|
||||
return () => { cancelled = true }
|
||||
}, [])
|
||||
|
||||
const openURL = (url: string) => {
|
||||
api.OpenURL(url).catch((e) => onError(tr('failGeneric'), e))
|
||||
}
|
||||
|
||||
const openQQGroup = async () => {
|
||||
setOpeningQQ(true)
|
||||
setQQLaunchErr('')
|
||||
try {
|
||||
await api.OpenQQGroup()
|
||||
} catch (e) {
|
||||
const msg = String(e).replace(/^Error:\s*/, '')
|
||||
if (/qq not installed/i.test(msg)) {
|
||||
setQQInstalled(false)
|
||||
} else {
|
||||
setQQLaunchErr(msg)
|
||||
}
|
||||
} finally {
|
||||
setOpeningQQ(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleChannelChange = async (next: AppUpdateChannel) => {
|
||||
if (next === appUpdateChannel || switchingChannel) return
|
||||
setSwitchingChannel(true)
|
||||
setUpdateErr('')
|
||||
try {
|
||||
await onAppUpdateChannel(next)
|
||||
} catch (e) {
|
||||
setUpdateErr(String(e).replace(/^Error:\s*/, ''))
|
||||
} finally {
|
||||
setSwitchingChannel(false)
|
||||
}
|
||||
}
|
||||
|
||||
const version = appVersion ?? appUpdate?.current ?? ''
|
||||
const pct = updateTask && updateTask.percent >= 0 ? Math.round(updateTask.percent) : null
|
||||
const updateAvailableKey: I18nKey = appUpdate?.channel === 'dev'
|
||||
? 'appUpdateAvailableDev'
|
||||
: appUpdate?.channel === 'alpha'
|
||||
? 'appUpdateAvailableAlpha'
|
||||
: 'appUpdateAvailable'
|
||||
|
||||
let updateSub: React.ReactNode = null
|
||||
if (updatePhase === 'downloading') {
|
||||
updateSub = (
|
||||
<>
|
||||
<div className="row-sub">{tr('updateDownloadingSub', { v: appUpdate?.latest ?? '' })}{updateTask && taskDetail(updateTask) ? ` · ${taskDetail(updateTask)}` : ''}</div>
|
||||
<span className="progress about-update-progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${(pct ?? 0) / 100})` }} />
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
} else if (updatePhase === 'ready') {
|
||||
updateSub = <div className="row-sub">{tr('updateReadySub', { v: appUpdate?.latest ?? '' })}</div>
|
||||
} else if (updatePhase === 'failed') {
|
||||
updateSub = <div className="row-sub warn-text" title={updateTask?.error}>{tr('updateFailedSub')}</div>
|
||||
} else if (appUpdate?.has_update) {
|
||||
updateSub = <div className="row-sub">{tr(updateAvailableKey, { v: appUpdate.latest })}</div>
|
||||
} else if (updateErr) {
|
||||
updateSub = <div className="row-sub" title={updateErr}>{tr('appUpdateLookupFailed')}</div>
|
||||
}
|
||||
|
||||
let updateAction: React.ReactNode
|
||||
if (updatePhase === 'downloading') {
|
||||
updateAction = <Button onClick={onCancelUpdate}>{tr('updateCancel')}</Button>
|
||||
} else if (updatePhase === 'ready') {
|
||||
updateAction = <Button variant="primary" busy={installing} onClick={onInstallUpdate}>{tr('updateRestart')}</Button>
|
||||
} else if (updatePhase === 'failed') {
|
||||
updateAction = <Button variant="primary" icon={<RotateCw size={14} aria-hidden="true" />} onClick={onDownloadUpdate}>{tr('updateRetry')}</Button>
|
||||
} else if (updatePhase === 'available') {
|
||||
updateAction = <Button variant="primary" icon={<Download size={14} aria-hidden="true" />} onClick={onDownloadUpdate}>{tr('updateDownloadInstall')}</Button>
|
||||
} else {
|
||||
updateAction = <Button busy={checkingUpdate} onClick={() => void runUpdateCheck(true)}>{tr('appCheckUpdate')}</Button>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page about-page">
|
||||
<header className="about-hero">
|
||||
<img className="about-hero-mark" src="/logo.svg" alt="" aria-hidden="true" />
|
||||
<div className="about-hero-text">
|
||||
<h1>Reims-Go</h1>
|
||||
<p>{tr('aboutTagline')}</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section className="section">
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('appVersionTitle')} <span className="mono">{version}</span>
|
||||
{appUpdate && !appUpdate.has_update && (
|
||||
<span className="badge badge-ok">{tr('appUpToDate')}</span>
|
||||
)}
|
||||
</div>
|
||||
{updateSub}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{appUpdate?.has_update && appUpdate.page_url && (
|
||||
<Button variant="ghost" icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => openURL(appUpdate.page_url!)}>
|
||||
{tr('updateReleaseNotes')}
|
||||
</Button>
|
||||
)}
|
||||
{updateAction}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('appUpdateChannelTitle')}</div>
|
||||
<div className="row-sub">
|
||||
{appUpdateChannel === 'stable'
|
||||
? tr('appUpdateChannelSubStable')
|
||||
: tr('appUpdateChannelSubKeepOld', {
|
||||
channel: appUpdateChannel === 'dev' ? tr('appUpdateChannelDev') : tr('appUpdateChannelAlpha'),
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Segmented
|
||||
label={tr('appUpdateChannelTitle')}
|
||||
value={appUpdateChannel}
|
||||
onChange={(v) => void handleChannelChange(v)}
|
||||
options={[
|
||||
{ value: 'stable' as AppUpdateChannel, label: tr('appUpdateChannelStable'), disabled: switchingChannel || checkingUpdate || updatePhase === 'downloading' || installing },
|
||||
{ value: 'alpha' as AppUpdateChannel, label: tr('appUpdateChannelAlpha'), disabled: switchingChannel || checkingUpdate || updatePhase === 'downloading' || installing },
|
||||
{ value: 'dev' as AppUpdateChannel, label: tr('appUpdateChannelDev'), disabled: switchingChannel || checkingUpdate || updatePhase === 'downloading' || installing },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('aboutCommunity')}</div>
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('helpProjectPage')}</div>
|
||||
<div className="row-sub">{tr('aboutProjectSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => openURL(REPO_URL)}>
|
||||
{tr('openShort')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('helpReportIssue')}</div>
|
||||
<div className="row-sub">{tr('aboutIssueSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => openURL(`${REPO_URL}/issues`)}>
|
||||
{tr('openShort')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('aboutLicensesTitle')}</div>
|
||||
<div className="row-sub">{tr('aboutLicensesSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button icon={<Scale size={14} aria-hidden="true" />} onClick={openLicenses}>
|
||||
{tr('aboutLicensesView')}
|
||||
</Button>
|
||||
<Button variant="ghost" icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => openURL(`${REPO_URL}/blob/main/NOTICE.md`)}>
|
||||
{tr('openShort')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('aboutQQGroup')} <span className="mono">{QQ_GROUP_ID}</span>
|
||||
{qqInstalled === false && (
|
||||
<span className="badge">{tr('aboutQQNotInstalled')}</span>
|
||||
)}
|
||||
</div>
|
||||
{qqInstalled === false ? (
|
||||
<div className="row-sub">{tr('aboutQQNotInstalledSub')}</div>
|
||||
) : qqLaunchErr ? (
|
||||
<div className="row-sub" title={qqLaunchErr}>{tr('aboutQQLaunchFailed')}</div>
|
||||
) : (
|
||||
<div className="row-sub">{tr('aboutQQGroupSub')}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{qqInstalled && !qqLaunchErr ? (
|
||||
<>
|
||||
{onCopy && (
|
||||
<IconButton
|
||||
small
|
||||
label={tr('aboutCopyQQGroup')}
|
||||
icon={<Copy size={14} aria-hidden="true" />}
|
||||
onClick={() => onCopy(QQ_GROUP_ID)}
|
||||
/>
|
||||
)}
|
||||
<Button busy={openingQQ} icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => void openQQGroup()}>
|
||||
{tr('aboutJoinQQGroup')}
|
||||
</Button>
|
||||
</>
|
||||
) : onCopy ? (
|
||||
<Button icon={<Copy size={14} aria-hidden="true" />} onClick={() => onCopy(QQ_GROUP_ID)}>
|
||||
{tr('aboutCopyQQGroup')}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{licenseOpen && (
|
||||
<Modal
|
||||
title={tr('aboutLicensesTitle')}
|
||||
subtitle={tr('aboutLicensesSub')}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setLicenseOpen(false)}
|
||||
>
|
||||
<div className="dialog-body license-modal-body">
|
||||
<Segmented
|
||||
label={tr('aboutLicensesTitle')}
|
||||
value={licenseTab}
|
||||
onChange={setLicenseTab}
|
||||
options={[
|
||||
{ value: 'notice', label: tr('aboutLicensesTabNotice') },
|
||||
{ value: 'license', label: tr('aboutLicensesTabLicense') },
|
||||
]}
|
||||
/>
|
||||
<pre className="license-pre">
|
||||
{licenses
|
||||
? (licenseTab === 'notice' ? licenses.notice : licenses.license)
|
||||
: '…'}
|
||||
</pre>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Button
|
||||
variant="ghost"
|
||||
icon={<ExternalLink size={14} aria-hidden="true" />}
|
||||
onClick={() => openURL(`${REPO_URL}/blob/main/${licenseTab === 'notice' ? 'NOTICE.md' : 'LICENSE'}`)}
|
||||
>
|
||||
{tr('aboutLicensesOpenGitHub')}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={() => setLicenseOpen(false)}>
|
||||
{tr('close')}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
import { AlertTriangle, Check, Cpu } from 'lucide-react'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, parseAppError, t } from '../i18n'
|
||||
import { HostReport, Locale, LogicalCPUInfo, VMAffinityMode, VMAffinityStatus } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { Segmented, Switch } from '../ui/settings'
|
||||
import { api } from '../wails'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
vmName: string
|
||||
vcpus: number
|
||||
host: HostReport
|
||||
globalAutoPin: boolean
|
||||
onClose: () => void
|
||||
onApplied: (status: VMAffinityStatus) => void
|
||||
}
|
||||
|
||||
function buildTopology(host: HostReport): LogicalCPUInfo[] {
|
||||
if (host.cpu_topology && host.cpu_topology.length > 0) {
|
||||
return host.cpu_topology
|
||||
}
|
||||
const n = Math.min(Math.max(host.logical_cpus || 1, 1), 64)
|
||||
return Array.from({ length: n }, (_, i) => ({
|
||||
index: i,
|
||||
core_index: i,
|
||||
tier: 'standard',
|
||||
smt: false,
|
||||
}))
|
||||
}
|
||||
|
||||
function maskHexFromCPUs(cpus: number[]): string {
|
||||
let mask = 0n
|
||||
for (const idx of cpus) {
|
||||
if (idx >= 0 && idx < 64) {
|
||||
mask |= 1n << BigInt(idx)
|
||||
}
|
||||
}
|
||||
return '0x' + mask.toString(16).toUpperCase()
|
||||
}
|
||||
|
||||
function resolveAutoPreview(topology: LogicalCPUInfo[], host: HostReport, globalAutoPin: boolean, vcpus: number): number[] {
|
||||
const all = topology.map((c) => c.index)
|
||||
if (!globalAutoPin || !host.has_hybrid_cores) return all
|
||||
const pCPUs = topology.filter((c) => c.tier === 'p').map((c) => c.index)
|
||||
if (pCPUs.length >= vcpus + 1 && pCPUs.length > 0) return pCPUs
|
||||
if ((host.lpe_core_count ?? 0) > 0) {
|
||||
const nonLPE = topology.filter((c) => c.tier !== 'lpe').map((c) => c.index)
|
||||
if (nonLPE.length >= vcpus + 1 && nonLPE.length > 0) return nonLPE
|
||||
}
|
||||
return all
|
||||
}
|
||||
|
||||
export function formatAffinitySummary(locale: Locale, status: VMAffinityStatus | null): string {
|
||||
if (!status) return '—'
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const count = status.effective_cpus?.length ?? 0
|
||||
const mask = status.effective_mask_hex || '0x0'
|
||||
switch (status.mode) {
|
||||
case 'all':
|
||||
return tr('affinitySummaryAll', { count })
|
||||
case 'pcores':
|
||||
return tr('affinitySummaryPCores', { count, mask })
|
||||
case 'non_lpe':
|
||||
return tr('affinitySummaryNonLPE', { count, mask })
|
||||
case 'custom':
|
||||
return tr('affinitySummaryCustom', { count, mask })
|
||||
default: {
|
||||
const effLabel = status.effective_mode === 'pcores'
|
||||
? tr('affinityModePCores')
|
||||
: status.effective_mode === 'non_lpe'
|
||||
? tr('affinityModeNonLPE')
|
||||
: tr('affinityModeAll')
|
||||
return tr('affinitySummaryAuto', { eff: effLabel, count })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const AffinityDialog: React.FC<Props> = ({
|
||||
locale, vmName, vcpus, host, globalAutoPin, onClose, onApplied,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const topology = useMemo(() => buildTopology(host), [host])
|
||||
const allIndices = useMemo(() => topology.map((c) => c.index), [topology])
|
||||
const hasSMT = useMemo(() => topology.some((c) => c.smt), [topology])
|
||||
|
||||
const [status, setStatus] = useState<VMAffinityStatus | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [err, setErr] = useState('')
|
||||
|
||||
const [mode, setMode] = useState<VMAffinityMode>('auto')
|
||||
const [selected, setSelected] = useState<number[]>(allIndices)
|
||||
const [disableEcoQoS, setDisableEcoQoS] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
setLoading(true)
|
||||
setErr('')
|
||||
api.GetVMAffinity(vmName)
|
||||
.then((st) => {
|
||||
if (!live) return
|
||||
setStatus(st)
|
||||
setMode(st.mode || 'auto')
|
||||
const initial = st.mode === 'custom' && st.cpus?.length > 0
|
||||
? st.cpus
|
||||
: (st.effective_cpus?.length > 0 ? st.effective_cpus : allIndices)
|
||||
setSelected([...initial].sort((a, b) => a - b))
|
||||
setDisableEcoQoS(st.disable_eco_qos)
|
||||
})
|
||||
.catch((e) => {
|
||||
if (live) setErr(parseAppError(e).summary)
|
||||
})
|
||||
.finally(() => {
|
||||
if (live) setLoading(false)
|
||||
})
|
||||
return () => { live = false }
|
||||
}, [vmName, allIndices])
|
||||
|
||||
const selectedSet = useMemo(() => new Set(selected), [selected])
|
||||
const effectiveVCPUs = status?.vcpus || vcpus
|
||||
const maskHex = useMemo(() => maskHexFromCPUs(selected), [selected])
|
||||
|
||||
const applyPreset = (nextMode: VMAffinityMode) => {
|
||||
setMode(nextMode)
|
||||
setErr('')
|
||||
switch (nextMode) {
|
||||
case 'all':
|
||||
setSelected(allIndices)
|
||||
break
|
||||
case 'pcores': {
|
||||
const list = topology.filter((c) => c.tier === 'p').map((c) => c.index)
|
||||
setSelected(list.length > 0 ? list : allIndices)
|
||||
break
|
||||
}
|
||||
case 'non_lpe': {
|
||||
const list = topology.filter((c) => c.tier !== 'lpe').map((c) => c.index)
|
||||
setSelected(list.length > 0 ? list : allIndices)
|
||||
break
|
||||
}
|
||||
case 'auto':
|
||||
setSelected(resolveAutoPreview(topology, host, globalAutoPin, effectiveVCPUs))
|
||||
break
|
||||
case 'custom':
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const toggleCPU = (idx: number) => {
|
||||
setMode('custom')
|
||||
setErr('')
|
||||
setSelected((prev) => {
|
||||
const s = new Set(prev)
|
||||
if (s.has(idx)) s.delete(idx)
|
||||
else s.add(idx)
|
||||
return Array.from(s).sort((a, b) => a - b)
|
||||
})
|
||||
}
|
||||
|
||||
const pickCustomList = (list: number[]) => {
|
||||
setMode('custom')
|
||||
setErr('')
|
||||
setSelected([...new Set(list)].sort((a, b) => a - b))
|
||||
}
|
||||
|
||||
const physicalOnlyList = useMemo(() => {
|
||||
const seen = new Set<number>()
|
||||
const out: number[] = []
|
||||
for (const c of topology) {
|
||||
if (!seen.has(c.core_index)) {
|
||||
seen.add(c.core_index)
|
||||
out.push(c.index)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}, [topology])
|
||||
|
||||
const modeOptions: { value: VMAffinityMode; label: string }[] = [
|
||||
{ value: 'auto', label: tr('affinityModeAuto') },
|
||||
{ value: 'all', label: tr('affinityModeAll') },
|
||||
...(host.has_hybrid_cores ? [{ value: 'pcores' as const, label: tr('affinityModePCores') }] : []),
|
||||
...((host.lpe_core_count ?? 0) > 0 ? [{ value: 'non_lpe' as const, label: tr('affinityModeNonLPE') }] : []),
|
||||
{ value: 'custom', label: tr('affinityModeCustom') },
|
||||
]
|
||||
|
||||
const modeHintKey: Record<VMAffinityMode, I18nKey> = {
|
||||
auto: 'affinityModeAutoHint',
|
||||
all: 'affinityModeAllHint',
|
||||
pcores: 'affinityModePCoresHint',
|
||||
non_lpe: 'affinityModeNonLPEHint',
|
||||
custom: 'affinityModeCustomHint',
|
||||
}
|
||||
|
||||
const emptyCustom = mode === 'custom' && selected.length === 0
|
||||
const oversubscribed = effectiveVCPUs > 0 && selected.length > 0 && selected.length < effectiveVCPUs
|
||||
const allSelected = selected.length === allIndices.length && allIndices.length > 0
|
||||
|
||||
const handleSave = async () => {
|
||||
if (emptyCustom) {
|
||||
setErr(tr('affinityNeedOne'))
|
||||
return
|
||||
}
|
||||
setSaving(true)
|
||||
setErr('')
|
||||
try {
|
||||
const updated = await api.SetVMAffinity(vmName, {
|
||||
mode,
|
||||
cpus: mode === 'custom' ? selected : [],
|
||||
disable_eco_qos: disableEcoQoS,
|
||||
})
|
||||
onApplied(updated)
|
||||
} catch (e) {
|
||||
setErr(parseAppError(e).summary)
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
const subtitle = status?.running && status.pid
|
||||
? tr('affinitySubtitleRunning', { pid: status.pid, vcpus: effectiveVCPUs })
|
||||
: tr('affinitySubtitleStopped', { vcpus: effectiveVCPUs })
|
||||
|
||||
const tierLabel = (tier: string) => {
|
||||
if (tier === 'p') return 'P'
|
||||
if (tier === 'e') return 'E'
|
||||
if (tier === 'lpe') return 'LP-E'
|
||||
return ''
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={`${tr('affinityTitle')} — ${vmName}`}
|
||||
subtitle={subtitle}
|
||||
closeLabel={tr('close')}
|
||||
dismissable={!saving}
|
||||
onClose={onClose}
|
||||
className="affinity-dialog"
|
||||
>
|
||||
<div className="dialog-body affinity-body">
|
||||
<div className="affinity-mode-bar">
|
||||
<Segmented
|
||||
label={tr('affinityTitle')}
|
||||
value={mode}
|
||||
onChange={(m) => applyPreset(m as VMAffinityMode)}
|
||||
options={modeOptions}
|
||||
/>
|
||||
<p className="affinity-hint">{tr(modeHintKey[mode])}</p>
|
||||
</div>
|
||||
|
||||
<div className="affinity-quick-bar">
|
||||
<button
|
||||
type="button"
|
||||
className={`affinity-chip${allSelected ? ' is-active' : ''}`}
|
||||
disabled={loading || saving}
|
||||
onClick={() => pickCustomList(allSelected ? [allIndices[0]] : allIndices)}
|
||||
>
|
||||
{tr('affinitySelectAll')}
|
||||
</button>
|
||||
{hasSMT && (
|
||||
<button
|
||||
type="button"
|
||||
className="affinity-chip"
|
||||
disabled={loading || saving}
|
||||
onClick={() => pickCustomList(physicalOnlyList)}
|
||||
>
|
||||
{tr('affinityPhysicalOnly')}
|
||||
</button>
|
||||
)}
|
||||
{allIndices.length > 1 && (
|
||||
<button
|
||||
type="button"
|
||||
className="affinity-chip"
|
||||
disabled={loading || saving}
|
||||
onClick={() => pickCustomList(allIndices.filter((i) => i !== 0))}
|
||||
>
|
||||
{tr('affinityExcludeCPU0')}
|
||||
</button>
|
||||
)}
|
||||
{host.has_hybrid_cores && (
|
||||
<button
|
||||
type="button"
|
||||
className="affinity-chip"
|
||||
disabled={loading || saving}
|
||||
onClick={() => pickCustomList(topology.filter((c) => c.tier === 'p').map((c) => c.index))}
|
||||
>
|
||||
{tr('affinityOnlyPCores')}
|
||||
</button>
|
||||
)}
|
||||
{(host.lpe_core_count ?? 0) > 0 && (
|
||||
<button
|
||||
type="button"
|
||||
className="affinity-chip"
|
||||
disabled={loading || saving}
|
||||
onClick={() => pickCustomList(topology.filter((c) => c.tier !== 'lpe').map((c) => c.index))}
|
||||
>
|
||||
{tr('affinityAvoidLPE')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="affinity-grid" role="group" aria-label={tr('affinityTitle')}>
|
||||
{topology.map((cpu) => {
|
||||
const checked = selectedSet.has(cpu.index)
|
||||
const tLabel = tierLabel(cpu.tier)
|
||||
return (
|
||||
<button
|
||||
key={cpu.index}
|
||||
type="button"
|
||||
role="checkbox"
|
||||
aria-checked={checked}
|
||||
disabled={loading || saving}
|
||||
className={`affinity-cpu${checked ? ' is-checked' : ''}${cpu.tier === 'lpe' ? ' is-lpe' : ''}`}
|
||||
onClick={() => toggleCPU(cpu.index)}
|
||||
>
|
||||
<span className="affinity-check" aria-hidden="true">
|
||||
{checked && <Check size={12} strokeWidth={3} />}
|
||||
</span>
|
||||
<span className="affinity-cpu-name tnum">CPU {cpu.index}</span>
|
||||
<span className="affinity-cpu-meta">
|
||||
{cpu.smt && <span className="affinity-core-tag tnum">C{cpu.core_index}</span>}
|
||||
{tLabel && <span className={`affinity-tier tier-${cpu.tier}`}>{tLabel}</span>}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="affinity-summary">
|
||||
<span className="mono tnum">
|
||||
<Cpu size={13} aria-hidden="true" />{' '}
|
||||
{tr('affinitySelectedSummary', { selected: selected.length, total: topology.length, mask: maskHex })}
|
||||
</span>
|
||||
{status?.running && status.live_mask_hex && (
|
||||
<span className="affinity-live mono tnum">
|
||||
{tr('affinityLiveMask', { mask: status.live_mask_hex, count: status.live_cpus?.length ?? 0 })}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{oversubscribed && (
|
||||
<div className="notice" role="status">
|
||||
<span className="notice-main">
|
||||
<AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{tr('affinityOversubWarn', { selected: selected.length, vcpus: effectiveVCPUs })}</span>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="affinity-eco-row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('affinityEcoQoS')}</div>
|
||||
<div className="row-sub">{tr('affinityEcoQoSDesc')}</div>
|
||||
</div>
|
||||
<Switch
|
||||
label={tr('affinityEcoQoS')}
|
||||
checked={disableEcoQoS}
|
||||
disabled={loading || saving}
|
||||
onChange={setDisableEcoQoS}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{err && <div className="notice notice-error" role="alert">{err}</div>}
|
||||
</div>
|
||||
|
||||
<div className="dialog-foot">
|
||||
<Button onClick={onClose} disabled={saving}>{tr('cancel')}</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
busy={saving}
|
||||
disabled={loading || emptyCustom}
|
||||
onClick={() => void handleSave()}
|
||||
>
|
||||
{status?.running ? tr('affinityApplyNow') : tr('affinitySave')}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
import React from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { getLocaleOptions, I18nKey, t } from '../i18n'
|
||||
import { findOptimization, optBadgeClass, optStatusLabel } from '../lib/optimizations'
|
||||
import { AppState, Locale, ResolvedLocalePack } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { PopupSelect, Segmented, Switch } from '../ui/settings'
|
||||
import { api } from '../wails'
|
||||
|
||||
export type ThemeMode = 'light' | 'dark' | 'system'
|
||||
|
||||
interface Props {
|
||||
state: AppState
|
||||
locale: Locale
|
||||
locales?: ResolvedLocalePack[]
|
||||
themeMode: ThemeMode
|
||||
canLight?: boolean
|
||||
canDark?: boolean
|
||||
onThemeMode: (mode: ThemeMode) => void
|
||||
onSetLocale: (l: Locale) => void
|
||||
onRefresh: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
}
|
||||
|
||||
export const AppSettingsPage: React.FC<Props> = ({
|
||||
state, locale, locales, themeMode, canLight = true, canDark = true, onThemeMode, onSetLocale, onRefresh, onError,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const { host, config, optimizations } = state
|
||||
|
||||
const pcoreOpt = findOptimization(optimizations, 'pcore_pin')
|
||||
const missingFontScript = state.missing_font_hint || ''
|
||||
|
||||
const guard = (fn: () => Promise<unknown>) => async () => {
|
||||
try {
|
||||
await fn()
|
||||
onRefresh()
|
||||
} catch (e) {
|
||||
onError(tr('failGeneric'), e)
|
||||
}
|
||||
}
|
||||
|
||||
const pickDataRoot = guard(async () => {
|
||||
const dir = await api.PickDirectory(tr('hostDataRoot'))
|
||||
if (dir) await api.SetDataRoot(dir)
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="page rg-p-settings">
|
||||
<header className="page-head">
|
||||
<div className="page-title"><h1>{tr('sidebarSettings')}</h1></div>
|
||||
</header>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('settingsGeneral')}</div>
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('hostDataRoot')}</div>
|
||||
<div className="row-sub mono">{config.data_root}</div>
|
||||
</div>
|
||||
<div className="row-right"><Button onClick={pickDataRoot}>{tr('choose')}</Button></div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('autoPinPCores')}
|
||||
<span className={`badge ${optBadgeClass(pcoreOpt?.status)}`}>
|
||||
{optStatusLabel(locale, pcoreOpt?.status)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="row-sub">
|
||||
{pcoreOpt?.supported
|
||||
? tr('optPCoreSub', { detail: pcoreOpt.detail ?? `${host.p_core_count}P+${host.e_core_count}E` })
|
||||
: tr('optPCoreUnavailable')}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Switch
|
||||
label={tr('autoPinPCores')}
|
||||
disabled={!pcoreOpt?.supported}
|
||||
checked={!!pcoreOpt?.supported && config.auto_pin_pcores}
|
||||
onChange={(checked) => guard(() => api.SetAutoPinPCores(checked))()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('minimizeToTray')}</div>
|
||||
<div className="row-sub">{tr('minimizeToTraySub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Switch
|
||||
label={tr('minimizeToTray')}
|
||||
checked={config.minimize_to_tray !== false}
|
||||
onChange={(checked) => guard(() => api.SetMinimizeToTray(checked))()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('settingsAppearance')}</div>
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('themeLabel')}</div>
|
||||
{(!canDark || !canLight) && (
|
||||
<div className="row-sub">{tr(!canDark ? 'themePluginDarkDisabled' : 'themePluginLightDisabled')}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Segmented
|
||||
label={tr('themeLabel')}
|
||||
value={themeMode}
|
||||
onChange={onThemeMode}
|
||||
options={[
|
||||
{ value: 'light', label: tr('themeLight'), disabled: !canLight },
|
||||
{ value: 'dark', label: tr('themeDark'), disabled: !canDark },
|
||||
{ value: 'system', label: tr('themeSystem'), disabled: !canLight || !canDark },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('language')}</div>
|
||||
<div className="row-sub">{tr('languageSub')}</div>
|
||||
{missingFontScript && (
|
||||
<div className="row-sub warn-text">{tr('fontMissingFoDHint', { script: missingFontScript })}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<PopupSelect
|
||||
label={tr('language')}
|
||||
value={config.locale || 'auto'}
|
||||
onChange={onSetLocale}
|
||||
options={getLocaleOptions(locales, locale, state.detected_locale)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -24,12 +24,14 @@ export const CloneDialog: React.FC<Props> = ({ locale, sourceName, defaultCloneN
|
||||
<Alert.Description className="dialog-desc">
|
||||
{t(locale, 'cloneDesc')}
|
||||
</Alert.Description>
|
||||
<div className="field" style={{ marginTop: 10 }}>
|
||||
<div className="field field-spaced">
|
||||
<label className="field-label" htmlFor="clone-name">{t(locale, 'cloneNameLabel')}</label>
|
||||
<input
|
||||
id="clone-name"
|
||||
className="input mono"
|
||||
value={cloneName}
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
onChange={(e) => setCloneName(e.target.value)}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter' && trimmed) onConfirm(trimmed) }}
|
||||
autoFocus
|
||||
|
||||
@@ -1,11 +1,42 @@
|
||||
import { ChevronRight, CircleAlert, CircleCheck, Check, Copy } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { formatMemory, gpuLabel, recommendedMemoryGB, shortGPUName } from '../lib/format'
|
||||
import { CachedInstaller, CreateOpts, HostReport, Locale, Release, ValidationIssue } from '../types'
|
||||
import { Check, ChevronRight, CircleAlert, CircleCheck, CloudDownload, Copy, Disc3, HardDrive, LucideIcon, Package } from 'lucide-react'
|
||||
import React, { Suspense, lazy, useEffect, useState } from 'react'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, locText, parseAppError, t } from '../i18n'
|
||||
import {
|
||||
GUEST_LANG_PRESETS,
|
||||
guestLangOptions,
|
||||
MEMORY_MARKS,
|
||||
controllerLabel,
|
||||
defaultGuestLang,
|
||||
findGPU,
|
||||
formatMemory,
|
||||
gpuCompatHint,
|
||||
gpuLabel,
|
||||
gpuOptionValue,
|
||||
guestLangLabel,
|
||||
memorySafeLimitGB,
|
||||
parseMemoryGB,
|
||||
recommendedCPUs,
|
||||
hidpiLooksLike,
|
||||
hostDisplayAdvice,
|
||||
hostDisplayDesc,
|
||||
recommendedDisplayPresets,
|
||||
recommendedMemoryGB,
|
||||
recommendedResolution,
|
||||
shortGPUName,
|
||||
splitLangLabel,
|
||||
sshCommand,
|
||||
} from '../lib/format'
|
||||
import { CachedInstaller, CreateOpts, DriverSummary, HostReport, Locale, Release, Task, ValidationIssue } from '../types'
|
||||
import { findActiveOfflineTask, taskInstallerPhase } from '../lib/tasks'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { NumberField, PopupSelect, RangeField, Segmented, SetGroup, SetRow, Switch } from '../ui/settings'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { backend } from '../wails'
|
||||
import { api } from '../wails'
|
||||
|
||||
const SchemaForm = lazy(() => import('./SchemaForm').then((m) => ({ default: m.SchemaForm })))
|
||||
const BUILTIN_MACOS_DRIVER = 'builtin.driver.reims-macos'
|
||||
|
||||
/** Reopen the wizard where the user left it (e.g. after a failed create). */
|
||||
export interface WizardDraft {
|
||||
@@ -16,6 +47,7 @@ export interface WizardDraft {
|
||||
interface Props {
|
||||
locale: Locale
|
||||
host: HostReport
|
||||
tasks?: Task[]
|
||||
draft?: WizardDraft | null
|
||||
onClose: () => void
|
||||
/** Called with the cleaned payload; the caller runs the create in the background. */
|
||||
@@ -26,14 +58,22 @@ const REVIEW_STEP = 5
|
||||
|
||||
// Which wizard step owns each ValidationIssue.field (internal/driver/reims/reims.go ValidateCreate).
|
||||
const STEP_OF_FIELD: Record<string, number> = {
|
||||
name: 1, installer: 1, disk: 1, macos: 1,
|
||||
installer: 1, disk: 1, macos: 1, guest_lang: 1,
|
||||
cpus: 2, memory: 2,
|
||||
disk_size: 3, disk_controller: 3,
|
||||
graphics: 4, gpu: 4, resolution: 4, displays: 4, ssh_port: 4,
|
||||
}
|
||||
const stepOfIssue = (i: ValidationIssue) => STEP_OF_FIELD[i.field] ?? REVIEW_STEP
|
||||
|
||||
export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, onSubmit }) => {
|
||||
// Step ① as large cards, one per way to get macOS (Parallels / UTM style).
|
||||
const SOURCES: { mode: 'offline' | 'apple' | 'installer' | 'disk'; icon: LucideIcon; title: I18nKey; sub: I18nKey }[] = [
|
||||
{ mode: 'offline', icon: Package, title: 'srcOfflineTitle', sub: 'srcOfflineSub' },
|
||||
{ mode: 'apple', icon: CloudDownload, title: 'srcAppleTitle', sub: 'srcAppleSub' },
|
||||
{ mode: 'installer', icon: Disc3, title: 'srcInstallerTitle', sub: 'srcInstallerSub' },
|
||||
{ mode: 'disk', icon: HardDrive, title: 'srcDiskTitle', sub: 'srcDiskSub' },
|
||||
]
|
||||
|
||||
export const CreateWizard: React.FC<Props> = ({ locale, host, tasks = [], draft, onClose, onSubmit }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [step, setStep] = useState(draft?.step ?? 1)
|
||||
// Once the user has reached the review step, keep validating so step markers stay current.
|
||||
@@ -42,6 +82,18 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
const [err, setErr] = useState('')
|
||||
const [issues, setIssues] = useState<ValidationIssue[]>([])
|
||||
const [cmdPreview, setCmdPreview] = useState('')
|
||||
const [drivers, setDrivers] = useState<DriverSummary[]>([])
|
||||
const [driverID, setDriverID] = useState(BUILTIN_MACOS_DRIVER)
|
||||
const [driverOpts, setDriverOpts] = useState<Record<string, unknown>>({})
|
||||
const [driverCreating, setDriverCreating] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
api.ListDrivers().then((list) => { if (live) setDrivers(list ?? []) }).catch(() => {})
|
||||
return () => { live = false }
|
||||
}, [])
|
||||
const activeDriver = drivers.find((d) => d.id === driverID)
|
||||
const isCustomDriver = driverID !== BUILTIN_MACOS_DRIVER && !!activeDriver
|
||||
|
||||
const [opts, setOpts] = useState<CreateOpts>(draft?.opts ?? {
|
||||
name: 'macos-tahoe',
|
||||
@@ -52,15 +104,17 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
macos: '',
|
||||
offline: true,
|
||||
installer: '',
|
||||
cpus: host.logical_cpus >= 12 ? 8 : 4,
|
||||
cpus: recommendedCPUs(host),
|
||||
memory: `${recommendedMemoryGB(host)}G`,
|
||||
disk_size: '128G',
|
||||
disk: '',
|
||||
disk_mode: 'copy',
|
||||
disk_controller: 'nvme',
|
||||
graphics: 'reims-vgpu',
|
||||
gpu: host.recommended_gpu?.vulkan_icd ?? 'auto',
|
||||
resolution: '1920x1080',
|
||||
graphics: host.recommended_gpu ? 'reims-vgpu' : 'vmware-svga',
|
||||
// Default to "auto" rather than a DriverStore FileRepository ICD path so
|
||||
// Windows GPU driver updates never break existing VM configs.
|
||||
gpu: 'auto',
|
||||
resolution: recommendedResolution(host),
|
||||
displays: 1,
|
||||
borderless: false,
|
||||
capture: false,
|
||||
@@ -68,6 +122,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
network: false,
|
||||
ssh_port: 0,
|
||||
logs: true,
|
||||
guest_lang: defaultGuestLang(locale),
|
||||
start: true,
|
||||
})
|
||||
const set = (patch: Partial<CreateOpts>) => setOpts((o) => ({ ...o, ...patch }))
|
||||
@@ -102,8 +157,8 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
useEffect(() => {
|
||||
if (opts.source_mode !== 'offline' || releases) return
|
||||
let live = true
|
||||
backend.listInstallers().then((l) => { if (live) setCached(l ?? []) }).catch(() => {})
|
||||
backend.listOfflineReleases()
|
||||
api.ListInstallers().then((l) => { if (live) setCached(l ?? []) }).catch(() => {})
|
||||
api.ListOfflineReleases()
|
||||
.then((list) => {
|
||||
if (!live) return
|
||||
setReleases(list ?? [])
|
||||
@@ -113,9 +168,12 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
return () => { live = false }
|
||||
}, [opts.source_mode])
|
||||
const isCached = (v: string) => cached.some((c) => c.kind === 'offline' && !c.partial && c.version === v)
|
||||
const activeRelease = (v: string) => findActiveOfflineTask(tasks, v)
|
||||
const chosenRelease = releases?.find((r) => r.version === opts.macos)
|
||||
// reims-util pre-allocates the whole image as it starts (19.7 GB for an 18.4 GB release, measured).
|
||||
const needGB = chosenRelease && !isCached(chosenRelease.version) ? Math.ceil((chosenRelease.size * 1.1) / 1e9) : 0
|
||||
const needGB = chosenRelease && !isCached(chosenRelease.version) && !activeRelease(chosenRelease.version)
|
||||
? Math.ceil((chosenRelease.size * 1.1) / 1e9)
|
||||
: 0
|
||||
|
||||
useEffect(() => {
|
||||
if (!reviewed && step !== REVIEW_STEP) return
|
||||
@@ -123,26 +181,26 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
setChecking(true)
|
||||
const timer = setTimeout(() => {
|
||||
const payload = buildPayload()
|
||||
Promise.all([backend.validateCreate(payload), backend.previewCreate(payload)])
|
||||
Promise.all([api.ValidateCreate(payload), api.PreviewCreate(payload)])
|
||||
.then(([iss, cmd]) => {
|
||||
if (!live) return
|
||||
setIssues(iss ?? [])
|
||||
setCmdPreview(cmd)
|
||||
setErr('')
|
||||
})
|
||||
.catch((e) => { if (live) setErr(String(e).replace(/^Error:\s*/, '')) })
|
||||
.catch((e) => { if (live) setErr(parseAppError(e).summary) })
|
||||
.finally(() => { if (live) setChecking(false) })
|
||||
}, 200)
|
||||
return () => { live = false; clearTimeout(timer) }
|
||||
}, [step, reviewed, opts])
|
||||
|
||||
const pickDir = async () => {
|
||||
const dir = await backend.pickDirectory(tr('vmDir'))
|
||||
const dir = await api.PickDirectory(tr('vmDir'))
|
||||
if (dir) set({ dir })
|
||||
}
|
||||
|
||||
const pickFile = async (field: 'installer' | 'disk', pattern: string) => {
|
||||
const f = await backend.pickFile(tr(field === 'installer' ? 'sourceInstaller' : 'sourceDisk'), pattern)
|
||||
const f = await api.PickFile(tr(field === 'installer' ? 'sourceInstaller' : 'sourceDisk'), pattern)
|
||||
if (f) set({ [field]: f })
|
||||
}
|
||||
|
||||
@@ -150,20 +208,19 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
const issueSteps = new Set(reviewed ? issues.map(stepOfIssue) : [])
|
||||
|
||||
const realGPUs = (host.gpus ?? []).filter((g) => g.kind !== 'virtual')
|
||||
const selectedGPU = findGPU(host, opts.gpu)
|
||||
const selectedGPUHint = gpuCompatHint(locale, selectedGPU)
|
||||
const threads = Math.max(host.logical_cpus || 0, 1)
|
||||
const cpuRec = recommendedCPUs(host)
|
||||
const memRec = recommendedMemoryGB(host)
|
||||
const memSafe = memorySafeLimitGB(host)
|
||||
const memMax = Math.max(Math.floor((host.total_ram_gb || 16) * 0.85), memRec, 4)
|
||||
const memGB = Math.round(parseMemoryGB(opts.memory) ?? memRec)
|
||||
const steps: I18nKey[] = ['step1', 'step2', 'step3', 'step4', 'step5']
|
||||
|
||||
const presets = <T extends string | number>(values: T[], current: T | undefined, label: (v: T) => string, pick: (v: T) => void) => (
|
||||
<div className="presets">
|
||||
{values.map((v) => (
|
||||
<button key={v} type="button" className="preset" aria-pressed={current === v} onClick={() => pick(v)}>
|
||||
{label(v)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<Modal title={tr('wizardTitle')} closeLabel={tr('close')} onClose={onClose}>
|
||||
<Modal className="wizard-dialog" title={tr('wizardTitle')} closeLabel={tr('close')} onClose={onClose}>
|
||||
<nav className="wizard-steps" aria-label={tr('wizardTitle')}>
|
||||
{steps.map((key, idx) => {
|
||||
const n = idx + 1
|
||||
@@ -187,246 +244,383 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
<div className="dialog-body">
|
||||
{err && <div className="notice notice-error">{err}</div>}
|
||||
|
||||
<div key={step} className="step-anim">
|
||||
{step === 1 && (
|
||||
<>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-name">{tr('vmName')}</label>
|
||||
<input id="vm-name" className="input" value={opts.name} onChange={(e) => set({ name: e.target.value })} />
|
||||
</div>
|
||||
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-dir">{tr('vmDir')}</label>
|
||||
<div className="input-group">
|
||||
<input id="vm-dir" className="input mono" value={opts.dir ?? ''} onChange={(e) => set({ dir: e.target.value })} />
|
||||
<Button onClick={pickDir}>{tr('choose')}</Button>
|
||||
</div>
|
||||
<span className="hint">{tr('vmDirHint')}</span>
|
||||
</div>
|
||||
|
||||
<fieldset className="field choices fieldset">
|
||||
<legend className="field-label">{tr('step1')}</legend>
|
||||
{(['offline', 'apple', 'installer', 'disk'] as const).map((mode) => (
|
||||
<label key={mode} className="choice">
|
||||
<input
|
||||
type="radio"
|
||||
name="source"
|
||||
checked={opts.source_mode === mode}
|
||||
onChange={() => set({
|
||||
source_mode: mode,
|
||||
network: mode !== 'offline',
|
||||
...(mode === 'apple' ? { macos: 'tahoe' } : {}),
|
||||
...(mode === 'offline' ? { macos: releases?.[0]?.version ?? '' } : {}),
|
||||
})}
|
||||
/>
|
||||
{tr(mode === 'offline' ? 'sourceOffline' : mode === 'apple' ? 'sourceApple' : mode === 'installer' ? 'sourceInstaller' : 'sourceDisk')}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
|
||||
{opts.source_mode === 'apple' && (
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-macos">{tr('macosVersion')}</label>
|
||||
<select id="vm-macos" className="select" value={opts.macos} onChange={(e) => set({ macos: e.target.value })}>
|
||||
<option value="tahoe">{tr('macosTahoe')}</option>
|
||||
</select>
|
||||
</div>
|
||||
{drivers.length > 1 && (
|
||||
<SetGroup title={tr('wizardDriverGroup')}>
|
||||
<SetRow
|
||||
title={tr('wizardDriverType')}
|
||||
control={
|
||||
<PopupSelect
|
||||
label={tr('wizardDriverType')}
|
||||
value={driverID}
|
||||
options={drivers.map((d) => ({
|
||||
value: d.id,
|
||||
label: locText(d.name, locale, d.id),
|
||||
}))}
|
||||
onChange={(id) => { setDriverID(id); setErr('') }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SetGroup>
|
||||
)}
|
||||
|
||||
{opts.source_mode === 'offline' && (
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-release">{tr('macosVersion')}</label>
|
||||
{releasesErr ? (
|
||||
<div className="notice notice-error">{tr('offlineListFailed')}:{releasesErr}</div>
|
||||
) : !releases ? (
|
||||
<span className="hint">{tr('offlineLoading')}</span>
|
||||
) : (
|
||||
<select id="vm-release" className="select" value={opts.macos} onChange={(e) => set({ macos: e.target.value })}>
|
||||
{releases.map((r) => (
|
||||
<option key={r.product} value={r.version}>
|
||||
{r.title} {r.version} ({r.build}) · {(r.size / 1e9).toFixed(1)} GB{isCached(r.version) ? ` · ${tr('offlineCached')}` : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
<span className="hint">{tr('offlineHint')}</span>
|
||||
{needGB > 0 && host.free_disk_gb > 0 && host.free_disk_gb < needGB + 10 && (
|
||||
<span className="hint warn">{tr('offlineSpaceWarn', { free: host.free_disk_gb.toFixed(0), need: needGB })}</span>
|
||||
{isCustomDriver ? (
|
||||
<div className="stack-3">
|
||||
<SetGroup title={tr('wizardBasics')}>
|
||||
<SetRow
|
||||
title={tr('vmName')}
|
||||
control={<input className="input" value={opts.name} onChange={(e) => set({ name: e.target.value })} />}
|
||||
/>
|
||||
</SetGroup>
|
||||
{activeDriver.create_schema && (
|
||||
<Suspense fallback={null}>
|
||||
<SchemaForm
|
||||
locale={locale}
|
||||
schema={activeDriver.create_schema}
|
||||
values={driverOpts}
|
||||
onChange={setDriverOpts}
|
||||
/>
|
||||
</Suspense>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
) : (
|
||||
<>
|
||||
<div className="source-cards" role="radiogroup" aria-label={tr('step1')}>
|
||||
{SOURCES.map((s) => {
|
||||
const Icon = s.icon
|
||||
const on = opts.source_mode === s.mode
|
||||
return (
|
||||
<label key={s.mode} className="source-card" data-selected={on || undefined}>
|
||||
<input
|
||||
type="radio"
|
||||
name="source"
|
||||
checked={on}
|
||||
onChange={() => set({
|
||||
source_mode: s.mode,
|
||||
network: s.mode !== 'offline',
|
||||
...(s.mode === 'apple' ? { macos: 'tahoe' } : {}),
|
||||
...(s.mode === 'offline' ? { macos: releases?.[0]?.version ?? '' } : {}),
|
||||
})}
|
||||
/>
|
||||
<span className={`source-icon source-icon-${s.mode}`} aria-hidden="true"><Icon size={20} /></span>
|
||||
<span className="source-title">
|
||||
{tr(s.title)}
|
||||
{s.mode === 'offline' && <span className="badge badge-accent">{tr('recommendedBadge')}</span>}
|
||||
</span>
|
||||
<span className="source-sub">{tr(s.sub)}</span>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
{(opts.source_mode === 'installer' || opts.source_mode === 'disk') && (
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-src">
|
||||
{tr(opts.source_mode === 'installer' ? 'sourceInstaller' : 'sourceDisk')}
|
||||
</label>
|
||||
<div className="input-group">
|
||||
<input
|
||||
id="vm-src"
|
||||
className="input mono"
|
||||
value={(opts.source_mode === 'installer' ? opts.installer : opts.disk) ?? ''}
|
||||
onChange={(e) => set(opts.source_mode === 'installer' ? { installer: e.target.value } : { disk: e.target.value })}
|
||||
<SetGroup>
|
||||
{opts.source_mode === 'apple' && (
|
||||
<SetRow
|
||||
title={tr('macosVersion')}
|
||||
control={<PopupSelect id="vm-macos" label={tr('macosVersion')} value={opts.macos} onChange={(macos) => set({ macos })} options={[{ value: 'tahoe', label: 'macOS Tahoe' }]} />}
|
||||
/>
|
||||
)}
|
||||
{opts.source_mode === 'offline' && (
|
||||
<SetRow
|
||||
title={tr('macosVersion')}
|
||||
desc={releasesErr
|
||||
? <span className="warn-text">{tr('offlineListFailedDetail', { err: releasesErr })}</span>
|
||||
: needGB > 0 && host.free_disk_gb > 0 && host.free_disk_gb < needGB + 10
|
||||
? <span className="warn-text">{tr('offlineSpaceWarn', { free: host.free_disk_gb.toFixed(0), need: needGB })}</span>
|
||||
: tr('offlineHint')}
|
||||
control={!releases
|
||||
? <span className="muted">{releasesErr ? '—' : tr('offlineLoading')}</span>
|
||||
: (
|
||||
<PopupSelect
|
||||
id="vm-release"
|
||||
label={tr('macosVersion')}
|
||||
value={opts.macos}
|
||||
onChange={(macos) => set({ macos })}
|
||||
options={releases.map((r) => {
|
||||
const active = activeRelease(r.version)
|
||||
const statusTag = isCached(r.version)
|
||||
? tr('offlineCached')
|
||||
: active
|
||||
? tr(taskInstallerPhase(active.primary) === 'queued' ? 'offlineQueued' : 'offlineDownloading')
|
||||
: ''
|
||||
return {
|
||||
value: r.version,
|
||||
label: `macOS ${r.version}`,
|
||||
detail: `${(r.size / 1e9).toFixed(1)} GB${statusTag ? ` · ${statusTag}` : ''}`,
|
||||
}
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
{(opts.source_mode === 'installer' || opts.source_mode === 'disk') && (() => {
|
||||
const isInstaller = opts.source_mode === 'installer'
|
||||
const file = (isInstaller ? opts.installer : opts.disk) ?? ''
|
||||
return (
|
||||
<SetRow
|
||||
title={tr(isInstaller ? 'srcInstallerTitle' : 'srcDiskTitle')}
|
||||
desc={file ? <span className="mono path-text" title={file}>{file}</span> : tr('wizNoFile')}
|
||||
control={
|
||||
<Button onClick={() => (isInstaller
|
||||
? pickFile('installer', '*.img;*.dmg')
|
||||
: pickFile('disk', '*.qcow2;*.img;*.vmdk;*.raw'))}
|
||||
>
|
||||
{tr('wizChooseFile')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => (opts.source_mode === 'installer'
|
||||
? pickFile('installer', '*.img;*.dmg')
|
||||
: pickFile('disk', '*.qcow2;*.img;*.vmdk;*.raw'))}
|
||||
>
|
||||
{tr('choose')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
<SetRow
|
||||
title={tr('guestLangShort')}
|
||||
desc={tr('guestLangHint')}
|
||||
control={
|
||||
<PopupSelect
|
||||
id="vm-guest-lang"
|
||||
label={tr('guestLangShort')}
|
||||
value={opts.guest_lang || defaultGuestLang(locale)}
|
||||
onChange={(guest_lang) => set({ guest_lang })}
|
||||
options={guestLangOptions(locale)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SetGroup>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{step === 2 && (
|
||||
<>
|
||||
<div className="field">
|
||||
<span className="field-label">{tr('factCPU')} · {tr('hostThreads', { n: host.logical_cpus })}</span>
|
||||
{presets(
|
||||
[4, 6, 8, 12].filter((n) => n <= Math.max(host.logical_cpus, 4)),
|
||||
opts.cpus,
|
||||
(n) => tr('cores', { n }),
|
||||
(cpus) => set({ cpus }),
|
||||
)}
|
||||
<span className="hint">{tr('cpuHint')}</span>
|
||||
</div>
|
||||
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-mem">{tr('factMemory')} · {tr('hostMemory', { n: host.total_ram_gb.toFixed(0) })}</label>
|
||||
{presets(['4G', '8G', '12G', '16G', '24G'], opts.memory, (m) => m, (memory) => set({ memory }))}
|
||||
<input id="vm-mem" className="input" value={opts.memory} onChange={(e) => set({ memory: e.target.value })} />
|
||||
<span className="hint">
|
||||
{host.commit_avail_gb > 0
|
||||
? tr('memCommitHint', { avail: host.commit_avail_gb.toFixed(1), rec: recommendedMemoryGB(host) })
|
||||
: tr('memHint')}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
<SetGroup>
|
||||
<SetRow
|
||||
title={tr('vcpus')}
|
||||
desc={(opts.cpus ?? 0) > threads - 2 && threads > 2
|
||||
? <span className="warn-text">{tr('cpuOverHint')}</span>
|
||||
: tr('cpuRecHint', { rec: cpuRec, n: threads })}
|
||||
block={
|
||||
<RangeField
|
||||
label={tr('vcpus')}
|
||||
value={opts.cpus ?? cpuRec}
|
||||
min={1}
|
||||
max={threads}
|
||||
unit={tr('coresUnit')}
|
||||
onChange={(cpus) => set({ cpus })}
|
||||
recommend={[Math.min(4, cpuRec), cpuRec]}
|
||||
warnFrom={threads > 2 ? threads - 1 : undefined}
|
||||
marks={[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64].concat(threads).map((n) => ({ value: n, label: String(n) }))}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('guestMemory')}
|
||||
desc={memGB > memSafe
|
||||
? <span className="warn-text">{tr('memOverHint')}</span>
|
||||
: host.commit_avail_gb > 0
|
||||
? tr('memCommitHint', { avail: host.commit_avail_gb.toFixed(1), rec: memRec })
|
||||
: tr('memRecHint', { rec: memRec, n: host.total_ram_gb.toFixed(0) })}
|
||||
block={
|
||||
<RangeField
|
||||
label={tr('guestMemory')}
|
||||
value={memGB}
|
||||
min={2}
|
||||
max={memMax}
|
||||
unit="GB"
|
||||
onChange={(gb) => set({ memory: `${gb}G` })}
|
||||
recommend={[Math.min(4, memRec), memRec]}
|
||||
warnFrom={memSafe + 1}
|
||||
marks={MEMORY_MARKS.concat(memMax).map((n) => ({ value: n, label: String(n) }))}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SetGroup>
|
||||
)}
|
||||
|
||||
{step === 3 && (
|
||||
<>
|
||||
<SetGroup>
|
||||
{opts.source_mode !== 'disk' ? (
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-disk">{tr('diskSize')}</label>
|
||||
{presets(['64G', '128G', '256G', '512G'], opts.disk_size, (s) => s, (disk_size) => set({ disk_size }))}
|
||||
<input id="vm-disk" className="input" value={opts.disk_size ?? ''} onChange={(e) => set({ disk_size: e.target.value })} />
|
||||
<span className="hint">{tr('diskSizeHint')}</span>
|
||||
</div>
|
||||
<SetRow
|
||||
title={tr('diskSize')}
|
||||
desc={tr('diskSizeHint')}
|
||||
control={
|
||||
<Segmented
|
||||
label={tr('diskSize')}
|
||||
value={opts.disk_size}
|
||||
onChange={(disk_size) => set({ disk_size })}
|
||||
options={Array.from(new Set(['64G', '128G', '256G', '512G', opts.disk_size ?? '128G'])).map((v) => ({ value: v, label: formatMemory(v) }))}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-diskmode">{tr('diskMode')}</label>
|
||||
<select
|
||||
id="vm-diskmode"
|
||||
className="select"
|
||||
value={opts.disk_mode}
|
||||
onChange={(e) => set({ disk_mode: e.target.value as 'copy' | 'in-place' })}
|
||||
>
|
||||
<option value="copy">{tr('diskModeCopy')}</option>
|
||||
<option value="in-place">{tr('diskModeInPlace')}</option>
|
||||
</select>
|
||||
</div>
|
||||
<SetRow
|
||||
title={tr('diskMode')}
|
||||
control={
|
||||
<Segmented
|
||||
label={tr('diskMode')}
|
||||
value={opts.disk_mode}
|
||||
onChange={(disk_mode) => set({ disk_mode })}
|
||||
options={[
|
||||
{ value: 'copy' as const, label: tr('diskModeCopy') },
|
||||
{ value: 'in-place' as const, label: tr('diskModeInPlace') },
|
||||
]}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-diskctl">{tr('diskController')}</label>
|
||||
<select
|
||||
id="vm-diskctl"
|
||||
className="select"
|
||||
value={opts.disk_controller ?? 'nvme'}
|
||||
onChange={(e) => set({ disk_controller: e.target.value as 'nvme' | 'ahci' | 'virtio' })}
|
||||
>
|
||||
<option value="nvme">NVMe ({locale === 'zh-CN' ? '推荐' : 'Recommended'})</option>
|
||||
<option value="ahci">SATA (AHCI)</option>
|
||||
{opts.source_mode === 'disk' && <option value="virtio">VirtIO</option>}
|
||||
</select>
|
||||
<span className="hint">{tr('diskControllerNvmeHint')}</span>
|
||||
</div>
|
||||
</>
|
||||
<SetRow
|
||||
title={tr('diskController')}
|
||||
desc={tr('diskControllerNvmeHint')}
|
||||
control={
|
||||
<Segmented
|
||||
label={tr('diskController')}
|
||||
value={opts.disk_controller ?? 'nvme'}
|
||||
onChange={(disk_controller) => set({ disk_controller })}
|
||||
options={[
|
||||
{ value: 'nvme' as const, label: 'NVMe' },
|
||||
{ value: 'ahci' as const, label: 'SATA' },
|
||||
...(opts.source_mode === 'disk' ? [{ value: 'virtio' as const, label: 'VirtIO' }] : []),
|
||||
]}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SetGroup>
|
||||
)}
|
||||
|
||||
{step === 4 && (
|
||||
<>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-gfx">{tr('graphicsBackend')}</label>
|
||||
<select
|
||||
id="vm-gfx"
|
||||
className="select"
|
||||
value={opts.graphics}
|
||||
onChange={(e) => set({ graphics: e.target.value as 'reims-vgpu' | 'vmware-svga' })}
|
||||
>
|
||||
<option value="reims-vgpu">{tr('graphicsReims')}</option>
|
||||
<option value="vmware-svga">{tr('graphicsSvga')}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{opts.graphics === 'reims-vgpu' && (
|
||||
<>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-gpu">{tr('gpuSelect')}</label>
|
||||
<select id="vm-gpu" className="select" value={opts.gpu} onChange={(e) => set({ gpu: e.target.value })}>
|
||||
<option value="auto">{tr('gpuAutoOption')}</option>
|
||||
{realGPUs.map((g) => (
|
||||
<option key={g.vulkan_icd} value={g.vulkan_icd}>{shortGPUName(g.name)}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="field-row">
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-res">{tr('resolution')}</label>
|
||||
<select id="vm-res" className="select" value={opts.resolution} onChange={(e) => set({ resolution: e.target.value })}>
|
||||
<option value="1920x1080">1920 × 1080</option>
|
||||
<option value="2560x1440">2560 × 1440</option>
|
||||
<option value="2880x1800">2880 × 1800 HiDPI</option>
|
||||
<option value="3840x2160">3840 × 2160 HiDPI</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-displays">{tr('displays')}</label>
|
||||
<select id="vm-displays" className="select" value={opts.displays} onChange={(e) => set({ displays: Number(e.target.value) })}>
|
||||
{[1, 2, 3, 4].map((d) => <option key={d} value={d}>{d}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="vm-ssh">{tr('sshPort')}</label>
|
||||
<input
|
||||
id="vm-ssh"
|
||||
className="input"
|
||||
type="number"
|
||||
min={0}
|
||||
max={65535}
|
||||
value={opts.ssh_port ?? 0}
|
||||
onChange={(e) => set({ ssh_port: Number(e.target.value) })}
|
||||
/>
|
||||
<span className="hint">{tr('sshPortHint')}</span>
|
||||
</div>
|
||||
|
||||
<div className="choices">
|
||||
{([
|
||||
['audio', 'enableAudio'],
|
||||
['network', 'enableNetwork'],
|
||||
['capture', 'captureInput'],
|
||||
['logs', 'enableLogs'],
|
||||
['start', 'startAfterCreate'],
|
||||
] as const).map(([key, label]) => (
|
||||
<label key={key} className="choice">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={!!opts[key]}
|
||||
onChange={(e) => set({ [key]: e.target.checked })}
|
||||
<SetGroup title={tr('groupGraphics')}>
|
||||
<SetRow
|
||||
title={tr('graphicsBackend')}
|
||||
desc={opts.graphics === 'vmware-svga' ? tr('graphicsSvgaDesc') : tr('graphicsReimsDesc')}
|
||||
control={
|
||||
<Segmented
|
||||
label={tr('graphicsBackend')}
|
||||
value={opts.graphics}
|
||||
onChange={(graphics) => set({ graphics })}
|
||||
options={[
|
||||
{ value: 'reims-vgpu' as const, label: tr('graphicsReimsShort') },
|
||||
{ value: 'vmware-svga' as const, label: tr('graphicsSvgaShort') },
|
||||
]}
|
||||
/>
|
||||
{tr(label)}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<span className="hint">{tr('captureInputHint')}</span>
|
||||
{opts.source_mode === 'offline' && <span className="hint">{tr('networkOfflineHint')}</span>}
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('gpuSelect')}
|
||||
disabled={opts.graphics !== 'reims-vgpu'}
|
||||
reason={tr('gpuSvgaReason')}
|
||||
desc={
|
||||
realGPUs.length === 0 ? (
|
||||
<span className="warn-text">{tr('gpuUnavailableHint')}</span>
|
||||
) : selectedGPUHint ? (
|
||||
<span className="warn-text">
|
||||
{selectedGPUHint}{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="link-btn"
|
||||
onClick={() => set({ graphics: 'vmware-svga' })}
|
||||
>
|
||||
{tr('gpuSwitchSvga')}
|
||||
</button>
|
||||
</span>
|
||||
) : undefined
|
||||
}
|
||||
control={
|
||||
<PopupSelect
|
||||
id="vm-gpu"
|
||||
label={tr('gpuSelect')}
|
||||
value={opts.gpu}
|
||||
onChange={(gpu) => set({ gpu })}
|
||||
options={[
|
||||
{ value: 'auto', label: tr('gpuAutoTitle'), detail: host.recommended_gpu ? shortGPUName(host.recommended_gpu.name) : undefined },
|
||||
...realGPUs.map((g) => ({
|
||||
value: gpuOptionValue(g, realGPUs),
|
||||
label: shortGPUName(g.name),
|
||||
detail:
|
||||
g.compat === 'unsupported'
|
||||
? tr('gpuCompatUnsupported')
|
||||
: g.compat === 'warn'
|
||||
? tr('gpuCompatWarn')
|
||||
: g.vulkan_version
|
||||
? `Vulkan ${g.vulkan_version}`
|
||||
: undefined,
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('resolution')}
|
||||
disabled={opts.graphics !== 'reims-vgpu'}
|
||||
reason={tr('gpuSvgaReason')}
|
||||
desc={[hostDisplayDesc(host, tr), hostDisplayAdvice(host, tr)].filter(Boolean).join(' · ') || undefined}
|
||||
control={
|
||||
<PopupSelect
|
||||
id="vm-res"
|
||||
label={tr('resolution')}
|
||||
value={opts.resolution}
|
||||
onChange={(resolution) => set({ resolution })}
|
||||
options={recommendedDisplayPresets(host).map((p) => ({
|
||||
value: p.resolution,
|
||||
label: p.label,
|
||||
detail: [p.hidpi ? `${tr('hidpiPresetBadge')} · ${hidpiLooksLike(p.resolution, tr) ?? ''}` : '', p.recommended ? tr('recommendedBadge') : ''].filter(Boolean).join(' · ') || undefined,
|
||||
}))}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('displays')}
|
||||
disabled={opts.graphics !== 'reims-vgpu'}
|
||||
reason={tr('gpuSvgaReason')}
|
||||
control={
|
||||
<Segmented
|
||||
label={tr('displays')}
|
||||
value={opts.displays}
|
||||
onChange={(displays) => set({ displays })}
|
||||
options={[1, 2, 3, 4].map((d) => ({ value: d, label: String(d) }))}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SetGroup>
|
||||
|
||||
<SetGroup title={tr('wizOptions')}>
|
||||
<SetRow
|
||||
title={tr('networkTitle')}
|
||||
desc={opts.source_mode === 'offline' ? tr('networkOfflineHint') : tr('networkDesc')}
|
||||
control={<Switch label={tr('networkTitle')} checked={!!opts.network} onChange={(network) => set({ network })} />}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('sshForward')}
|
||||
desc={(opts.ssh_port ?? 0) > 0 ? <code className="inline-code">{sshCommand(opts.ssh_port ?? 0)}</code> : tr('sshOffDesc')}
|
||||
disabled={!opts.network}
|
||||
reason={tr('sshNeedsNetwork')}
|
||||
control={
|
||||
<div className="hstack">
|
||||
{(opts.ssh_port ?? 0) > 0 && (
|
||||
<NumberField label={tr('sshPort')} value={opts.ssh_port ?? 0} min={1} max={65535} onChange={(ssh_port) => set({ ssh_port })} />
|
||||
)}
|
||||
<Switch label={tr('sshForward')} checked={(opts.ssh_port ?? 0) > 0} onChange={(on) => set({ ssh_port: on ? 2222 : 0 })} />
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('enableAudio')}
|
||||
control={<Switch label={tr('enableAudio')} checked={!!opts.audio} onChange={(audio) => set({ audio })} />}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('captureInput')}
|
||||
desc={tr('captureInputHint')}
|
||||
control={<Switch label={tr('captureInput')} checked={!!opts.capture} onChange={(capture) => set({ capture })} />}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('fullscreenLaunch')}
|
||||
desc={tr('fullscreenLaunchHint')}
|
||||
control={<Switch label={tr('fullscreenLaunch')} checked={!!opts.borderless} onChange={(borderless) => set({ borderless })} />}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('enableLogs')}
|
||||
control={<Switch label={tr('enableLogs')} checked={!!opts.logs} onChange={(logs) => set({ logs })} />}
|
||||
/>
|
||||
</SetGroup>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -439,13 +633,43 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
checking={checking}
|
||||
command={cmdPreview}
|
||||
onEdit={setStep}
|
||||
onName={(name) => set({ name })}
|
||||
onPickDir={pickDir}
|
||||
onDir={(dir) => set({ dir })}
|
||||
onStartAfter={(start) => set({ start })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="dialog-foot">
|
||||
<Button variant="ghost" disabled={step === 1} onClick={() => setStep(step - 1)}>{tr('back')}</Button>
|
||||
{step < REVIEW_STEP ? (
|
||||
<Button variant="ghost" disabled={step === 1 || isCustomDriver} onClick={() => setStep(step - 1)}>{tr('back')}</Button>
|
||||
{isCustomDriver ? (
|
||||
<Button
|
||||
variant="primary"
|
||||
busy={driverCreating}
|
||||
disabled={!opts.name.trim() || driverCreating}
|
||||
onClick={async () => {
|
||||
setDriverCreating(true)
|
||||
setErr('')
|
||||
try {
|
||||
await api.CreateVMWithDriver({
|
||||
driver_id: driverID,
|
||||
name: opts.name.trim(),
|
||||
dir: opts.dir,
|
||||
options: driverOpts,
|
||||
})
|
||||
onClose()
|
||||
} catch (e) {
|
||||
setErr(parseAppError(e).summary)
|
||||
} finally {
|
||||
setDriverCreating(false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{tr('createNow')}
|
||||
</Button>
|
||||
) : step < REVIEW_STEP ? (
|
||||
<Button variant="primary" onClick={() => setStep(step + 1)}>{tr('next')}</Button>
|
||||
) : (
|
||||
<Button
|
||||
@@ -470,6 +694,10 @@ interface ReviewProps {
|
||||
checking: boolean
|
||||
command: string
|
||||
onEdit: (step: number) => void
|
||||
onName: (name: string) => void
|
||||
onDir: (dir: string) => void
|
||||
onPickDir: () => void
|
||||
onStartAfter: (start: boolean) => void
|
||||
}
|
||||
|
||||
type Row = { label: string; value: string; mono?: boolean }
|
||||
@@ -477,7 +705,7 @@ type Row = { label: string; value: string; mono?: boolean }
|
||||
const fileName = (p?: string) => (p ?? '').split(/[\\/]/).pop() || (p ?? '')
|
||||
|
||||
/** Step ⑤: what will be created, grouped by the step that set it, with the CLI equivalent folded away. */
|
||||
const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, command, onEdit }) => {
|
||||
const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, command, onEdit, onName, onDir, onPickDir, onStartAfter }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [copied, setCopied] = useState(false)
|
||||
const onOff = (b?: boolean) => tr(b ? 'summaryOn' : 'off')
|
||||
@@ -503,9 +731,8 @@ const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, c
|
||||
step: 1,
|
||||
title: 'step1',
|
||||
rows: [
|
||||
{ label: tr('vmName'), value: opts.name },
|
||||
{ label: tr('summarySource'), value: source },
|
||||
{ label: tr('vmDir'), value: opts.dir || tr('summaryDefaultDir'), mono: !!opts.dir },
|
||||
{ label: tr('guestLangShort'), value: guestLangLabel(locale, opts.guest_lang) },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -523,7 +750,7 @@ const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, c
|
||||
...(opts.source_mode !== 'disk'
|
||||
? [{ label: tr('diskSize'), value: tr('summaryDiskGrow', { size: formatMemory(opts.disk_size ?? '') }) }]
|
||||
: [{ label: tr('diskMode'), value: tr(opts.disk_mode === 'in-place' ? 'diskModeInPlace' : 'diskModeCopy') }]),
|
||||
{ label: tr('diskController'), value: (opts.disk_controller ?? 'nvme').toUpperCase() === 'AHCI' ? 'SATA' : (opts.disk_controller ?? 'nvme').toUpperCase() },
|
||||
{ label: tr('diskController'), value: controllerLabel(opts.disk_controller ?? 'nvme') },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -536,12 +763,12 @@ const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, c
|
||||
{ label: tr('captureInput'), value: onOff(opts.capture) },
|
||||
{ label: tr('summarySSH'), value: opts.ssh_port ? tr('summarySSHPort', { n: opts.ssh_port }) : tr('off') },
|
||||
{ label: tr('summaryLogs'), value: onOff(opts.logs) },
|
||||
{ label: tr('summaryStartAfter'), value: onOff(opts.start) },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const general = issues.filter((i) => stepOfIssue(i) === REVIEW_STEP)
|
||||
const nameIssue = issues.find((i) => i.field === 'name')?.message
|
||||
const general = issues.filter((i) => stepOfIssue(i) === REVIEW_STEP && i.field !== 'name')
|
||||
|
||||
const copy = async () => {
|
||||
try {
|
||||
@@ -553,6 +780,28 @@ const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, c
|
||||
|
||||
return (
|
||||
<>
|
||||
<SetGroup>
|
||||
<SetRow
|
||||
title={tr('vmName')}
|
||||
error={nameIssue}
|
||||
control={<input className="input name-input" aria-label={tr('vmName')} value={opts.name} onChange={(e) => onName(e.target.value)} spellCheck={false} />}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('vmDir')}
|
||||
desc={opts.dir ? <span className="mono path-text" title={opts.dir}>{opts.dir}</span> : tr('summaryDefaultDir')}
|
||||
control={
|
||||
<div className="hstack">
|
||||
{opts.dir && <Button variant="ghost" onClick={() => onDir('')}>{tr('useDefault')}</Button>}
|
||||
<Button onClick={onPickDir}>{tr('wizChooseFile')}</Button>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
title={tr('startAfterCreate')}
|
||||
control={<Switch label={tr('startAfterCreate')} checked={!!opts.start} onChange={onStartAfter} />}
|
||||
/>
|
||||
</SetGroup>
|
||||
|
||||
{checking && issues.length === 0 ? (
|
||||
<div className="review-status">{tr('validationChecking')}</div>
|
||||
) : issues.length > 0 ? (
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import React from 'react'
|
||||
import { resolveActiveLocale, t } from '../i18n'
|
||||
import { events } from '../wails'
|
||||
|
||||
interface State {
|
||||
error: Error | null
|
||||
stack: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Top-level React error boundary: prevents any uncaught render/lifecycle error
|
||||
* from unmounting the entire tree into an unrecoverable blank white screen,
|
||||
* reports the stack trace to the Go backend log, and offers a one-click reload.
|
||||
*/
|
||||
export class ErrorBoundary extends React.Component<{ children: React.ReactNode }, State> {
|
||||
state: State = { error: null, stack: '' }
|
||||
|
||||
static getDerivedStateFromError(error: Error): Partial<State> {
|
||||
return { error }
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, info: React.ErrorInfo): void {
|
||||
const stack = [error.stack, info.componentStack].filter(Boolean).join('\n').trim()
|
||||
this.setState({ stack })
|
||||
events.emitUIError(`ReactErrorBoundary: ${error.message}\n${stack.slice(0, 1500)}`)
|
||||
}
|
||||
|
||||
render(): React.ReactNode {
|
||||
const { error, stack } = this.state
|
||||
if (!error) return this.props.children
|
||||
|
||||
const docLocale = typeof document !== 'undefined' ? document.documentElement.dataset.locale : undefined
|
||||
const loc = resolveActiveLocale(docLocale || undefined)
|
||||
return (
|
||||
<div className="error-boundary">
|
||||
<div className="error-boundary-card" role="alert">
|
||||
<h2 className="error-boundary-title">
|
||||
{t(loc, 'errorBoundaryTitle')}
|
||||
</h2>
|
||||
<pre className="error-boundary-pre selectable">
|
||||
{error.message || String(error)}
|
||||
{stack ? `\n\n${stack}` : ''}
|
||||
</pre>
|
||||
<div className="error-boundary-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={() => window.location.reload()}
|
||||
>
|
||||
{t(loc, 'errorBoundaryReload')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,41 @@
|
||||
import { Cpu, Download, HardDrive, MemoryStick, RefreshCw, ShieldCheck } from 'lucide-react'
|
||||
import { Cpu, HardDrive, MemoryStick, Plus, RefreshCw, ShieldCheck, Trash } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { findOptimization, kernelIrqchipHint, optBadgeClass, optStatusLabel } from '../lib/optimizations'
|
||||
import { AppState, AppUpdateInfo, Locale, Task } from '../types'
|
||||
import { formatBytes, gpuCompatHint, gpuKey, gpuMetaLine, sameGPU } from '../lib/format'
|
||||
import { AppState, Locale, StorageBreakdown, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { backend } from '../wails'
|
||||
import { api } from '../wails'
|
||||
import { RuntimeOnline } from './RuntimeOnline'
|
||||
|
||||
interface Props {
|
||||
state: AppState
|
||||
locale: Locale
|
||||
onRefresh: () => void
|
||||
onNewVM?: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onSetLocale: (l: Locale) => void
|
||||
onToast?: (title: string) => void
|
||||
runtimeTask: Task | null
|
||||
onChannel: (candidate: boolean) => void
|
||||
onChannel: (alpha: boolean) => void
|
||||
onInstallRuntime: (commit: string) => void
|
||||
onCancelTask: (id: string) => void
|
||||
}
|
||||
|
||||
export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, onSetLocale, runtimeTask, onChannel, onInstallRuntime, onCancelTask }) => {
|
||||
export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onNewVM, onError, onToast, runtimeTask, onChannel, onInstallRuntime, onCancelTask }) => {
|
||||
const [importing, setImporting] = useState(false)
|
||||
const [enabling, setEnabling] = useState(false)
|
||||
const [appUpdate, setAppUpdate] = useState<AppUpdateInfo | null>(null)
|
||||
const [checkingUpdate, setCheckingUpdate] = useState(false)
|
||||
const [updateErr, setUpdateErr] = useState('')
|
||||
const { host, config, runtimes, optimizations } = state
|
||||
const [confirmDelete, setConfirmDelete] = useState('')
|
||||
const [removing, setRemoving] = useState('')
|
||||
const [storage, setStorage] = useState<StorageBreakdown | null>(null)
|
||||
const { host, config, runtimes } = state
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
|
||||
const runUpdateCheck = async (force: boolean) => {
|
||||
setCheckingUpdate(true)
|
||||
setUpdateErr('')
|
||||
try {
|
||||
const info = await backend.checkAppUpdate(force)
|
||||
setAppUpdate(info)
|
||||
} catch (e) {
|
||||
setUpdateErr(String(e).replace(/^Error:\s*/, ''))
|
||||
} finally {
|
||||
setCheckingUpdate(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void runUpdateCheck(false)
|
||||
}, [])
|
||||
const pcoreOpt = findOptimization(optimizations, 'pcore_pin')
|
||||
const irqOpt = findOptimization(optimizations, 'kernel_irqchip')
|
||||
const rebootOpt = findOptimization(optimizations, 'cold_reboot')
|
||||
const gpuOpt = findOptimization(optimizations, 'discrete_gpu')
|
||||
let live = true
|
||||
api.GetStorageBreakdown().then((s) => { if (live) setStorage(s) }).catch(() => {})
|
||||
return () => { live = false }
|
||||
}, [state.config.data_root, state.vms?.length, state.runtimes?.length])
|
||||
|
||||
const whpx = {
|
||||
ready: { short: tr('whpxReady'), hint: '', tone: 'ok' },
|
||||
@@ -67,24 +55,33 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, o
|
||||
|
||||
const enableWHPX = async () => {
|
||||
setEnabling(true)
|
||||
await guard(() => backend.enableWHPX())()
|
||||
await guard(() => api.EnableWHPX())()
|
||||
setEnabling(false)
|
||||
}
|
||||
|
||||
const pickDataRoot = guard(async () => {
|
||||
const dir = await backend.pickDirectory(tr('hostDataRoot'))
|
||||
if (dir) await backend.setDataRoot(dir)
|
||||
})
|
||||
|
||||
const importRuntime = async () => {
|
||||
setImporting(true)
|
||||
await guard(async () => {
|
||||
const file = await backend.pickFile(tr('importRuntime'), '*.tar.zst;*.zip')
|
||||
if (file) await backend.installRuntimeArchive(file)
|
||||
const file = await api.PickFile(tr('importRuntime'), '*.tar.zst;*.zip')
|
||||
if (file) await api.InstallRuntimeArchive(file)
|
||||
})()
|
||||
setImporting(false)
|
||||
}
|
||||
|
||||
const removeRuntime = async (commit: string) => {
|
||||
setRemoving(commit)
|
||||
try {
|
||||
await api.RemoveRuntime(commit)
|
||||
setConfirmDelete('')
|
||||
onToast?.(tr('runtimeDeleted', { commit }))
|
||||
onRefresh()
|
||||
} catch (e) {
|
||||
onError(tr('failDelete'), e)
|
||||
} finally {
|
||||
setRemoving('')
|
||||
}
|
||||
}
|
||||
|
||||
const gpuKind = (k: string) =>
|
||||
tr(k === 'discrete' ? 'gpuDiscrete' : k === 'integrated' ? 'gpuIntegrated' : k === 'virtual' ? 'gpuVirtual' : 'gpuUnknown')
|
||||
|
||||
@@ -99,9 +96,22 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, o
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{(state.vms?.length ?? 0) === 0 && host.whpx === 'ready' && !!state.active_runtime && onNewVM && (
|
||||
<section className="welcome-card">
|
||||
<h1>{tr('welcomeTitle')}</h1>
|
||||
<p>{tr('welcomeSub')}</p>
|
||||
<Button variant="primary" icon={<Plus size={14} aria-hidden="true" />} onClick={onNewVM}>
|
||||
{tr('newVM')}
|
||||
</Button>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<div className="tiles">
|
||||
<div className="tile">
|
||||
<div className="tile-head"><ShieldCheck size={14} /> {tr('whpxTitle')}</div>
|
||||
<div className="tile-head">
|
||||
<span className={`tile-icon ${whpx.tone}`} aria-hidden="true"><ShieldCheck size={13} /></span>
|
||||
{tr('whpxTitle')}
|
||||
</div>
|
||||
<div className={`tile-value ${whpx.tone}`}>{whpx.short}</div>
|
||||
{host.whpx === 'missing' ? (
|
||||
<Button variant="primary" className="tile-action" busy={enabling} onClick={enableWHPX}>{tr('enableWHPX')}</Button>
|
||||
@@ -110,20 +120,67 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, o
|
||||
) : null}
|
||||
</div>
|
||||
<div className="tile">
|
||||
<div className="tile-head"><Cpu size={14} /> {tr('hostCPU')}</div>
|
||||
<div className="tile-head">
|
||||
<span className="tile-icon accent" aria-hidden="true"><Cpu size={13} /></span>
|
||||
{tr('hostCPU')}
|
||||
</div>
|
||||
<div className="tile-value">{tr('hostCoresThreads', { c: host.physical_cores, t: host.logical_cpus })}</div>
|
||||
{host.p_core_count > 0 && host.e_core_count > 0 && (
|
||||
<div className="tile-sub">{host.p_core_count}P + {host.e_core_count}E</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="tile">
|
||||
<div className="tile-head"><MemoryStick size={14} /> {tr('hostRAM')}</div>
|
||||
<div className="tile-head">
|
||||
<span className="tile-icon accent" aria-hidden="true"><MemoryStick size={13} /></span>
|
||||
{tr('hostRAM')}
|
||||
</div>
|
||||
<div className="tile-value">{tr('hostRAMAvail', { n: host.avail_ram_gb.toFixed(1) })}</div>
|
||||
<div className="tile-sub">{tr('hostRAMTotal', { n: host.total_ram_gb.toFixed(1) })}</div>
|
||||
</div>
|
||||
<div className="tile">
|
||||
<div className="tile-head"><HardDrive size={14} /> {tr('hostDisk')}</div>
|
||||
<div className="tile-head">
|
||||
<span className="tile-icon" aria-hidden="true"><HardDrive size={13} /></span>
|
||||
{tr('hostDisk')}
|
||||
</div>
|
||||
<div className="tile-value">{host.free_disk_gb.toFixed(0)} GB</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{storage && storage.total_bytes > 0 && (() => {
|
||||
const tot = Math.max(storage.total_bytes, 1)
|
||||
const vmsPct = (storage.vms_bytes / tot) * 100
|
||||
const instPct = (storage.installers_bytes / tot) * 100
|
||||
const rtPct = (storage.runtimes_bytes / tot) * 100
|
||||
return (
|
||||
<section className="card">
|
||||
<div className="card-title">
|
||||
<span>{tr('storageBreakdownTitle')}</span>
|
||||
<span className="spacer" />
|
||||
<span className="muted tnum" style={{ fontSize: 'var(--fs-12)', fontWeight: 'var(--fw-medium)' }}>{formatBytes(storage.total_bytes, locale)}</span>
|
||||
</div>
|
||||
<div className="storage-bar" aria-hidden="true">
|
||||
{vmsPct > 0 && <div className="storage-seg-vms" style={{ width: `${vmsPct}%` }} />}
|
||||
{instPct > 0 && <div className="storage-seg-inst" style={{ width: `${instPct}%` }} />}
|
||||
{rtPct > 0 && <div className="storage-seg-rt" style={{ width: `${rtPct}%` }} />}
|
||||
</div>
|
||||
<div className="storage-legend">
|
||||
<span className="storage-legend-item">
|
||||
<span className="storage-dot storage-seg-vms" aria-hidden="true" />
|
||||
{tr('storageVMs')} · {formatBytes(storage.vms_bytes, locale)}
|
||||
</span>
|
||||
<span className="storage-legend-item">
|
||||
<span className="storage-dot storage-seg-inst" aria-hidden="true" />
|
||||
{tr('storageInstallers')} · {formatBytes(storage.installers_bytes, locale)}
|
||||
</span>
|
||||
<span className="storage-legend-item">
|
||||
<span className="storage-dot storage-seg-rt" aria-hidden="true" />
|
||||
{tr('storageRuntimes')} · {formatBytes(storage.runtimes_bytes, locale)}
|
||||
</span>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
})()}
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">
|
||||
{tr('hostRuntime')}
|
||||
@@ -134,7 +191,7 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, o
|
||||
<div className="list">
|
||||
<RuntimeOnline
|
||||
locale={locale}
|
||||
channel={config.runtime_channel === 'candidate' ? 'candidate' : 'stable'}
|
||||
channel={config.runtime_channel === 'alpha' ? 'alpha' : 'stable'}
|
||||
installed={runtimes ?? []}
|
||||
task={runtimeTask}
|
||||
onChannel={onChannel}
|
||||
@@ -148,153 +205,82 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, o
|
||||
<div className="row-sub">{rt.manifest.qemu_version.replace(/^QEMU emulator version\s*/i, 'QEMU ')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button onClick={guard(() => backend.useRuntime(rt.commit))}>{tr('activate')}</Button>
|
||||
{confirmDelete === rt.commit ? (
|
||||
<>
|
||||
<Button variant="ghost" disabled={removing === rt.commit} onClick={() => setConfirmDelete('')}>
|
||||
{tr('cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" busy={removing === rt.commit} onClick={() => removeRuntime(rt.commit)}>
|
||||
{tr('runtimeDeleteConfirm')}
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button disabled={removing === rt.commit} onClick={guard(() => api.UseRuntime(rt.commit))}>
|
||||
{tr('activate')}
|
||||
</Button>
|
||||
<IconButton
|
||||
label={tr('runtimeDelete')}
|
||||
icon={<Trash size={15} />}
|
||||
disabled={removing !== ''}
|
||||
onClick={() => setConfirmDelete(rt.commit)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('settings')}</div>
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('hostDataRoot')}</div>
|
||||
<div className="row-sub mono">{config.data_root}</div>
|
||||
</div>
|
||||
<div className="row-right"><Button onClick={pickDataRoot}>{tr('choose')}</Button></div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('autoPinPCores')}
|
||||
<span className={`badge ${optBadgeClass(pcoreOpt?.status)}`}>
|
||||
{optStatusLabel(locale, pcoreOpt?.status)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="row-sub">
|
||||
{pcoreOpt?.supported
|
||||
? tr('optPCoreSub', { detail: pcoreOpt.detail ?? `${host.p_core_count}P+${host.e_core_count}E` })
|
||||
: tr('optPCoreUnavailable')}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<label className="switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={tr('autoPinPCores')}
|
||||
disabled={!pcoreOpt?.supported}
|
||||
checked={!!pcoreOpt?.supported && config.auto_pin_pcores}
|
||||
onChange={(e) => guard(() => backend.setAutoPinPCores(e.target.checked))()}
|
||||
/>
|
||||
<span className="slider" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main"><div className="row-title">{tr('language')}</div></div>
|
||||
<div className="row-right">
|
||||
<div className="segmented" role="group" aria-label={tr('language')}>
|
||||
<button type="button" aria-pressed={locale === 'zh-CN'} onClick={() => onSetLocale('zh-CN')}>中文</button>
|
||||
<button type="button" aria-pressed={locale === 'en-US'} onClick={() => onSetLocale('en-US')}>English</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('appVersionTitle')} <span className="mono">{state.app_version ?? appUpdate?.current ?? 'v0.2.1'}</span>
|
||||
{appUpdate && !appUpdate.has_update && (
|
||||
<span className="badge badge-ok">{tr('appUpToDate')}</span>
|
||||
)}
|
||||
</div>
|
||||
{appUpdate?.has_update ? (
|
||||
<div className="row-sub">{tr('appUpdateAvailable', { v: appUpdate.latest })}</div>
|
||||
) : updateErr ? (
|
||||
<div className="row-sub" title={updateErr}>{tr('appUpdateLookupFailed')}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{appUpdate?.has_update && (appUpdate.page_url || appUpdate.download_url) ? (
|
||||
<Button
|
||||
variant="primary"
|
||||
icon={<Download size={14} />}
|
||||
onClick={() => guard(() => backend.openURL(appUpdate.page_url || appUpdate.download_url || ''))()}
|
||||
>
|
||||
{tr('appDownloadUpdate')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button busy={checkingUpdate} onClick={() => void runUpdateCheck(true)}>
|
||||
{tr('appCheckUpdate')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('hostOptimizations')}</div>
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('optKernelIrqchipTitle')}
|
||||
<span className={`badge ${optBadgeClass(irqOpt?.status)}`}>{optStatusLabel(locale, irqOpt?.status)}</span>
|
||||
</div>
|
||||
<div className="row-sub">{kernelIrqchipHint(locale, irqOpt)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('optColdRebootTitle')}
|
||||
<span className={`badge ${optBadgeClass(rebootOpt?.status)}`}>{optStatusLabel(locale, rebootOpt?.status)}</span>
|
||||
</div>
|
||||
<div className="row-sub">
|
||||
{tr(rebootOpt?.supported ? 'optColdRebootAuto' : 'optColdRebootUnavailable')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('optDiscreteGpuTitle')}
|
||||
<span className={`badge ${optBadgeClass(gpuOpt?.status)}`}>{optStatusLabel(locale, gpuOpt?.status)}</span>
|
||||
</div>
|
||||
<div className="row-sub">
|
||||
{gpuOpt?.status === 'recommended'
|
||||
? tr('optDiscreteGpuRec', { name: gpuOpt.detail ?? '' })
|
||||
: gpuOpt?.status === 'available'
|
||||
? tr('optDiscreteGpuIntegrated', { name: gpuOpt.detail ?? '' })
|
||||
: tr('optDiscreteGpuUnavailable')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('hostGPUs')}</div>
|
||||
<div className="list">
|
||||
{realGPUs.length === 0 ? (
|
||||
<div className="row"><span className="row-sub">—</span></div>
|
||||
) : (
|
||||
realGPUs.map((g) => (
|
||||
<div className="row" key={g.vulkan_icd}>
|
||||
<div className="row-main">
|
||||
<div className="row-title" title={g.vulkan_icd}>
|
||||
{g.name}
|
||||
<span className={`badge ${g.kind === 'discrete' ? 'badge-accent' : ''}`}>{gpuKind(g.kind)}</span>
|
||||
{host.recommended_gpu?.vulkan_icd === g.vulkan_icd && <span className="badge badge-ok">{tr('gpuRecommended')}</span>}
|
||||
realGPUs.map((g, idx) => {
|
||||
const meta = gpuMetaLine(g)
|
||||
const hint = gpuCompatHint(locale, g)
|
||||
const isRec = sameGPU(host.recommended_gpu, g)
|
||||
return (
|
||||
<div className="row" key={gpuKey(g, idx)}>
|
||||
<div className="row-main">
|
||||
<div className="row-title" title={g.vulkan_icd}>
|
||||
{g.name}
|
||||
<span className={`badge ${g.kind === 'discrete' ? 'badge-accent' : ''}`}>{gpuKind(g.kind)}</span>
|
||||
{g.compat === 'unsupported' && <span className="badge badge-warn">{tr('gpuCompatUnsupported')}</span>}
|
||||
{g.compat === 'warn' && <span className="badge badge-warn">{tr('gpuCompatWarn')}</span>}
|
||||
{isRec && g.compat !== 'warn' && g.compat !== 'unsupported' && <span className="badge badge-ok">{tr('gpuRecommended')}</span>}
|
||||
</div>
|
||||
{meta && <div className="row-sub">{meta}</div>}
|
||||
{hint && <div className="row-sub warn-text">{hint}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
{(host.displays?.length ?? 0) > 0 && (
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('hostDisplays')}</div>
|
||||
<div className="list">
|
||||
{(host.displays ?? []).map((d, idx) => (
|
||||
<div className="row" key={d.name || idx}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{d.width} × {d.height}
|
||||
{d.refresh_hz ? ` @ ${d.refresh_hz}Hz` : ''}
|
||||
<span className="badge">{d.scale_pct || 100}%</span>
|
||||
{d.primary && <span className="badge badge-ok">{tr('hostDisplayPrimary')}</span>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,27 @@
|
||||
import { Download, LoaderCircle, Pause, Plus, RefreshCw, Trash } from 'lucide-react'
|
||||
import { AlertTriangle, Check, ChevronDown, Clock, Download, LoaderCircle, Pause, Plus, RefreshCw, Trash, X } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { taskDetail } from '../lib/tasks'
|
||||
import { macOSMajor } from '../lib/macosRelease'
|
||||
import {
|
||||
ActiveInstallerMatch,
|
||||
findActiveCachedTask,
|
||||
findActiveOfflineTask,
|
||||
groupUnmatchedInstallerTasks,
|
||||
isActiveInstallerTask,
|
||||
isInstallerTask,
|
||||
taskDetail,
|
||||
taskInstallerKey,
|
||||
taskInstallerKind,
|
||||
taskInstallerPhase,
|
||||
taskInstallerVersion,
|
||||
taskStopAction,
|
||||
} from '../lib/tasks'
|
||||
import { CachedInstaller, HostReport, Locale, Release, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { backend } from '../wails'
|
||||
import { api } from '../wails'
|
||||
import { VersionArt } from './VersionArt'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
@@ -21,6 +38,39 @@ const gb = (b: number) => (b >= 1e9 ? `${(b / 1e9).toFixed(1)} GB` : `${Math.max
|
||||
// 18.4 GB release, measured 2026-11-28): reserve 10% over the release size.
|
||||
const needBytes = (r: Release) => r.size * 1.1
|
||||
|
||||
type ReleaseGroup = { key: string; title: string; major: number | null; releases: Release[] }
|
||||
|
||||
type DownloadedRow = {
|
||||
key: string
|
||||
title: string
|
||||
version: string
|
||||
kind: CachedInstaller['kind']
|
||||
cached?: CachedInstaller
|
||||
active: ActiveInstallerMatch | null
|
||||
}
|
||||
|
||||
/** Newest point release first, one card per macOS major version. */
|
||||
function groupReleases(releases: Release[]): ReleaseGroup[] {
|
||||
const groups = new Map<string, ReleaseGroup>()
|
||||
for (const release of releases) {
|
||||
const major = macOSMajor(release.version, release.title)
|
||||
const key = major === null ? release.title : String(major)
|
||||
const group = groups.get(key) ?? { key, title: release.title, major, releases: [] }
|
||||
group.releases.push(release)
|
||||
groups.set(key, group)
|
||||
}
|
||||
return [...groups.values()]
|
||||
.map((group) => ({ ...group, releases: group.releases.sort((a, b) => b.version.localeCompare(a.version, undefined, { numeric: true })) }))
|
||||
.sort((a, b) => (b.major ?? -1) - (a.major ?? -1) || a.title.localeCompare(b.title))
|
||||
}
|
||||
|
||||
function formatOnlineTitle(version: string): string {
|
||||
const v = version.trim()
|
||||
if (!v || v.toLowerCase() === 'latest') return 'macOS'
|
||||
const words = v.split(/[-_\s]+/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1))
|
||||
return `macOS ${words.join(' ')}`
|
||||
}
|
||||
|
||||
/** Offline installers (roadmap M2.2): what is downloaded, and Apple's releases to download. */
|
||||
export const InstallersPage: React.FC<Props> = ({ locale, host, tasks, onCreateWithInstaller, onError, onToast }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
@@ -29,33 +79,45 @@ export const InstallersPage: React.FC<Props> = ({ locale, host, tasks, onCreateW
|
||||
const [releasesErr, setReleasesErr] = useState('')
|
||||
const [confirmDelete, setConfirmDelete] = useState('')
|
||||
|
||||
const downloads = tasks.filter((x) => x.kind === 'installer-download')
|
||||
const running = (version: string) => downloads.find((x) => x.status === 'running' && x.subject === version)
|
||||
const finishedCount = downloads.filter((x) => x.status !== 'running').length
|
||||
const installerTasks = tasks.filter(isInstallerTask)
|
||||
const activeInstallerTasks = installerTasks.filter(isActiveInstallerTask)
|
||||
const installerTasksSig = installerTasks
|
||||
.map((x) => `${x.id}:${x.status}:${x.installer_phase ?? ''}`)
|
||||
.sort()
|
||||
.join('|')
|
||||
|
||||
const loadCached = () => backend.listInstallers().then((l) => setCached(l ?? [])).catch((e) => onError(tr('failGeneric'), e))
|
||||
const loadCached = () => api.ListInstallers().then((l) => setCached(l ?? [])).catch((e) => onError(tr('failGeneric'), e))
|
||||
const loadReleases = () => {
|
||||
setReleases(null)
|
||||
setReleasesErr('')
|
||||
backend.listOfflineReleases()
|
||||
api.ListOfflineReleases()
|
||||
.then((l) => setReleases(l ?? []))
|
||||
.catch((e) => setReleasesErr(String(e).replace(/^Error:\s*/, '')))
|
||||
}
|
||||
useEffect(() => { loadReleases() }, [])
|
||||
// Refresh the downloaded list whenever a download starts or ends.
|
||||
useEffect(() => { loadCached() }, [finishedCount, downloads.length])
|
||||
// Refresh the downloaded list whenever an installer download starts, shifts phase, or ends.
|
||||
useEffect(() => {
|
||||
setConfirmDelete('')
|
||||
loadCached()
|
||||
}, [installerTasksSig])
|
||||
|
||||
const isDownloaded = (v: string) => (cached ?? []).some((c) => c.kind === 'offline' && !c.partial && c.version === v)
|
||||
const downloaded = (version: string) => (cached ?? []).find((c) => c.kind === 'offline' && !c.partial && c.version === version)
|
||||
const partial = (version: string) => (cached ?? []).some((c) => c.kind === 'offline' && c.partial && c.version === version)
|
||||
const activeForRelease = (version: string) => findActiveOfflineTask(activeInstallerTasks, version)
|
||||
|
||||
const download = (version: string) => {
|
||||
backend.downloadInstaller(version).catch((e) => onError(tr('failDownload'), e))
|
||||
api.DownloadInstaller(version).catch((e) => onError(tr('failDownload'), e))
|
||||
}
|
||||
|
||||
const cancelTask = (task: Task) => {
|
||||
api.CancelTask(task.id).catch((e) => onError(tr('failGeneric'), e))
|
||||
}
|
||||
|
||||
const remove = async (name: string) => {
|
||||
if (confirmDelete !== name) { setConfirmDelete(name); return }
|
||||
setConfirmDelete('')
|
||||
try {
|
||||
await backend.deleteInstaller(name)
|
||||
await api.DeleteInstaller(name)
|
||||
onToast(tr('toastDeleted', { name }))
|
||||
loadCached()
|
||||
} catch (e) {
|
||||
@@ -63,110 +125,293 @@ export const InstallersPage: React.FC<Props> = ({ locale, host, tasks, onCreateW
|
||||
}
|
||||
}
|
||||
|
||||
const progress = (task: Task) => (
|
||||
<span className="task-inline row-sub">
|
||||
<LoaderCircle size={14} className="spin" />
|
||||
{task.percent >= 0 && <span className="progress"><div style={{ width: `${task.percent}%` }} /></span>}
|
||||
<span>{task.percent >= 0 ? `${Math.floor(task.percent)}%` : ''} {taskDetail(task)}</span>
|
||||
</span>
|
||||
const progress = (task: Task) => {
|
||||
if (taskInstallerPhase(task) === 'queued') {
|
||||
return (
|
||||
<span className="task-inline row-sub">
|
||||
<Clock size={14} aria-hidden="true" />
|
||||
<span>{tr('installersQueuedDesc')}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<span className="task-inline row-sub">
|
||||
<LoaderCircle size={14} className="spin" aria-hidden="true" />
|
||||
{task.percent >= 0 && (
|
||||
<span className="progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${Math.max(0, Math.min(1, task.percent / 100))})` }} />
|
||||
</span>
|
||||
)}
|
||||
<span>{task.percent >= 0 ? `${Math.floor(task.percent)}%` : ''} {taskDetail(task)}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
const skeleton = (rows: number, label?: string) => (
|
||||
<div className="skeleton-list" role="status" aria-label={label}>
|
||||
{Array.from({ length: rows }).map((_, i) => (
|
||||
<div className="skeleton-row" key={i} aria-hidden="true">
|
||||
<div className="skeleton-stack">
|
||||
<div className="skeleton-bar w-title" />
|
||||
<div className="skeleton-bar w-sub" />
|
||||
</div>
|
||||
<div className="skeleton-bar w-btn" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
const spaceShort = (r: Release) => !downloaded(r.version) && !activeForRelease(r.version) && host.free_disk_gb > 0 && host.free_disk_gb * 1e9 < needBytes(r)
|
||||
|
||||
const releaseAction = (r: Release) => {
|
||||
const active = activeForRelease(r.version)
|
||||
if (active) {
|
||||
const task = active.primary
|
||||
const queued = taskInstallerPhase(task) === 'queued'
|
||||
if (queued) {
|
||||
return <span className="badge" role="status">{tr('installersQueued')}</span>
|
||||
}
|
||||
return (
|
||||
<span className="badge badge-accent installer-active-status" role="status">
|
||||
<LoaderCircle size={12} className="spin" aria-hidden="true" />
|
||||
<span>
|
||||
{task.percent >= 0
|
||||
? tr('installersDownloadingPct', { p: Math.floor(task.percent) })
|
||||
: tr('installersDownloading')}
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
const item = downloaded(r.version)
|
||||
if (item) {
|
||||
return (
|
||||
<Button variant="primary" icon={<Plus size={14} />} onClick={() => onCreateWithInstaller(item)}>
|
||||
{tr('installersCreateVM')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Button icon={<Download size={14} />} disabled={spaceShort(r)} onClick={() => download(r.version)}>
|
||||
{partial(r.version) ? tr('installersResume') : tr('installersDownload')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
const releaseMeta = (r: Release) => (
|
||||
<div className="row-sub">
|
||||
{r.posted} · {gb(r.size)}
|
||||
{spaceShort(r) && <span className="warn-text"> · {tr('installersNoSpace', { need: Math.ceil(needBytes(r) / 1e9), free: host.free_disk_gb.toFixed(0) })}</span>}
|
||||
</div>
|
||||
)
|
||||
|
||||
const matchedTaskIDs = new Set<string>()
|
||||
const cachedRows: DownloadedRow[] = (cached ?? []).map((c) => {
|
||||
const active = findActiveCachedTask(activeInstallerTasks, c)
|
||||
if (active) {
|
||||
for (const id of active.matchedIDs) matchedTaskIDs.add(id)
|
||||
}
|
||||
return {
|
||||
key: c.name,
|
||||
title: c.title ?? c.name,
|
||||
version: c.version ?? '',
|
||||
kind: c.kind,
|
||||
cached: c,
|
||||
active,
|
||||
}
|
||||
})
|
||||
|
||||
const virtualRows: DownloadedRow[] = groupUnmatchedInstallerTasks(activeInstallerTasks, matchedTaskIDs).map((active) => {
|
||||
const task = active.primary
|
||||
const kind = taskInstallerKind(task) || 'offline'
|
||||
const version = taskInstallerVersion(task)
|
||||
if (kind === 'offline') {
|
||||
const rel = (releases ?? []).find((r) => r.version.toLowerCase() === version.toLowerCase())
|
||||
return {
|
||||
key: `active-${taskInstallerKey(task) || task.id}`,
|
||||
title: rel?.title ?? 'macOS',
|
||||
version: rel?.version ?? version,
|
||||
kind: 'offline',
|
||||
active,
|
||||
}
|
||||
}
|
||||
return {
|
||||
key: `active-${taskInstallerKey(task) || task.id}`,
|
||||
title: formatOnlineTitle(version),
|
||||
version: '',
|
||||
kind: 'online',
|
||||
active,
|
||||
}
|
||||
})
|
||||
|
||||
const rowPriority = (row: DownloadedRow) => {
|
||||
if (!row.active) return 2
|
||||
return taskInstallerPhase(row.active.primary) === 'queued' ? 1 : 0
|
||||
}
|
||||
const downloadedRows = [...virtualRows, ...cachedRows].sort((a, b) => rowPriority(a) - rowPriority(b))
|
||||
|
||||
const groups = groupReleases(releases ?? [])
|
||||
const showDownloaded = cached === null || downloadedRows.length > 0
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<div className="page installers-page">
|
||||
<header className="page-head">
|
||||
<div className="page-title"><h1>{tr('installersTitle')}</h1></div>
|
||||
<div className="page-title installers-page-title">
|
||||
<h1>{tr('installersTitle')}</h1>
|
||||
<span>{tr('installersHint')}</span>
|
||||
</div>
|
||||
<div className="actions">
|
||||
<IconButton label={tr('refresh')} icon={<RefreshCw size={16} />} onClick={() => { loadCached(); loadReleases() }} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('installersDownloaded')}</div>
|
||||
<div className="list">
|
||||
{cached === null ? (
|
||||
<div className="row"><span className="row-sub">…</span></div>
|
||||
) : cached.length === 0 ? (
|
||||
<div className="row"><span className="row-sub">{tr('installersEmpty')}</span></div>
|
||||
) : cached.map((c) => {
|
||||
const task = c.version ? running(c.version) : undefined
|
||||
return (
|
||||
<div className="row" key={c.name}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{c.title ?? c.name} {c.version}
|
||||
{c.build && <span className="muted">({c.build})</span>}
|
||||
{c.kind === 'offline' && !c.partial && <span className="badge badge-ok">{tr('installersKindOffline')}</span>}
|
||||
{c.kind === 'online' && !c.partial && <span className="badge">{tr('installersKindOnline')}</span>}
|
||||
{c.partial && !task && <span className="badge badge-warn">{tr('installersPartial')}</span>}
|
||||
{showDownloaded && (
|
||||
<section className="section">
|
||||
<div className="section-title">
|
||||
<span>{tr('installersDownloaded')}</span>
|
||||
{downloadedRows.length > 0 && <span className="section-count">{downloadedRows.length}</span>}
|
||||
</div>
|
||||
{cached === null && downloadedRows.length === 0 ? (
|
||||
skeleton(1, tr('installersDownloaded'))
|
||||
) : (
|
||||
<div className="list installer-list">
|
||||
{downloadedRows.map((row) => {
|
||||
const c = row.cached
|
||||
const active = row.active
|
||||
const task = active?.primary
|
||||
const queued = !!task && taskInstallerPhase(task) === 'queued'
|
||||
const vmName = task
|
||||
? (task.vm || (task.kind === 'vm-create' || task.kind === 'recovery-download' ? task.subject : ''))
|
||||
: ''
|
||||
const waitingVMs = active?.waitingVMs ?? []
|
||||
const stop = task ? taskStopAction(locale, task) : null
|
||||
return (
|
||||
<div className="row installer-row" key={row.key} title={c?.name ?? row.title}>
|
||||
<span className="installer-art">
|
||||
<VersionArt shape="tile" major={macOSMajor(row.version, row.title)} name={row.title} />
|
||||
</span>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span>{row.title}{row.version ? ` ${row.version}` : ''}</span>
|
||||
{!task && c?.kind === 'offline' && !c.partial && <span className="badge badge-ok">{tr('installersKindOffline')}</span>}
|
||||
{(!task && c?.kind === 'online' && !c.partial) || (task && row.kind === 'online')
|
||||
? <span className="badge">{tr('installersKindOnline')}</span>
|
||||
: null}
|
||||
{c?.partial && !task && <span className="badge badge-warn">{tr('installersPartial')}</span>}
|
||||
{task && vmName && (
|
||||
<span className={`badge ${queued ? '' : 'badge-accent'}`}>
|
||||
{tr(queued ? 'installersQueuedForVM' : 'installersDownloadingForVM', { vm: vmName })}
|
||||
</span>
|
||||
)}
|
||||
{task && !vmName && waitingVMs.length > 0 && (
|
||||
<span className="badge badge-accent">
|
||||
{tr('installersWaitingVM', { vm: waitingVMs.join(', ') })}
|
||||
</span>
|
||||
)}
|
||||
{task && !vmName && queued && (
|
||||
<span className="badge">{tr('installersQueued')}</span>
|
||||
)}
|
||||
</div>
|
||||
{task ? progress(task) : c ? (
|
||||
<div className="row-sub">{gb(c.bytes)}{c.build ? ` · ${c.build}` : ''}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{task && stop ? (
|
||||
<IconButton
|
||||
label={stop.label}
|
||||
icon={stop.kind === 'cancel' ? <X size={16} /> : <Pause size={16} />}
|
||||
onClick={() => cancelTask(task)}
|
||||
/>
|
||||
) : c ? (
|
||||
<>
|
||||
{!c.partial && (c.kind === 'offline' || c.kind === 'online') && (
|
||||
<Button variant={c.kind === 'offline' ? 'primary' : 'secondary'} icon={<Plus size={14} />} onClick={() => onCreateWithInstaller(c)}>
|
||||
{tr('installersCreateVM')}
|
||||
</Button>
|
||||
)}
|
||||
{c.partial && c.kind === 'offline' && c.version && (
|
||||
<Button icon={<Download size={14} />} onClick={() => download(c.version!)}>{tr('installersResume')}</Button>
|
||||
)}
|
||||
{confirmDelete === c.name ? (
|
||||
<Button variant="danger" onClick={() => remove(c.name)}>{tr('installersDeleteConfirm')}</Button>
|
||||
) : (
|
||||
<IconButton label={tr('installersDelete')} icon={<Trash size={15} />} onClick={() => remove(c.name)} />
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{task ? progress(task) : <div className="row-sub mono">{c.name} · {gb(c.bytes)}</div>}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{task ? (
|
||||
<IconButton label={tr('pauseDownload')} icon={<Pause size={16} />} onClick={() => backend.cancelTask(task.id)} />
|
||||
) : (
|
||||
<>
|
||||
{!c.partial && (c.kind === 'offline' || c.kind === 'online') && (
|
||||
<Button variant={c.kind === 'offline' ? 'primary' : 'secondary'} icon={<Plus size={14} />} onClick={() => onCreateWithInstaller(c)}>
|
||||
{tr('installersCreateVM')}
|
||||
</Button>
|
||||
)}
|
||||
{c.partial && c.kind === 'offline' && c.version && (
|
||||
<Button icon={<Download size={14} />} onClick={() => download(c.version!)}>{tr('installersResume')}</Button>
|
||||
)}
|
||||
{confirmDelete === c.name ? (
|
||||
<Button variant="danger" onClick={() => remove(c.name)}>{tr('installersDeleteConfirm')}</Button>
|
||||
) : (
|
||||
<IconButton label={tr('installersDelete')} icon={<Trash size={15} />} onClick={() => remove(c.name)} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('installersAvailable')}</div>
|
||||
<div className="list">
|
||||
{releasesErr ? (
|
||||
<div className="row"><span className="row-sub">{tr('offlineListFailed')}:{releasesErr}</span></div>
|
||||
) : releases === null ? (
|
||||
<div className="row"><span className="row-sub">{tr('offlineLoading')}</span></div>
|
||||
) : releases.map((r) => {
|
||||
const task = running(r.version)
|
||||
const done = isDownloaded(r.version)
|
||||
const short = !done && !task && host.free_disk_gb > 0 && host.free_disk_gb * 1e9 < needBytes(r)
|
||||
return (
|
||||
<div className="row" key={r.product}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{r.title} {r.version}
|
||||
<span className="muted">({r.build})</span>
|
||||
</div>
|
||||
{task ? progress(task) : (
|
||||
<div className="row-sub">
|
||||
{r.posted} · {gb(r.size)}
|
||||
{short && <span className="warn-text"> · {tr('installersNoSpace', { need: Math.ceil(needBytes(r) / 1e9), free: host.free_disk_gb.toFixed(0) })}</span>}
|
||||
{releasesErr ? (
|
||||
<div className="notice notice-error" role="alert">
|
||||
<span className="notice-main">
|
||||
<AlertTriangle size={15} className="notice-icon" aria-hidden="true" />
|
||||
<span>{tr('offlineListFailedDetail', { err: releasesErr })}</span>
|
||||
</span>
|
||||
<Button onClick={loadReleases}>{tr('installersRetry')}</Button>
|
||||
</div>
|
||||
) : releases === null ? (
|
||||
<>
|
||||
{skeleton(2, tr('offlineLoading'))}
|
||||
<span className="hint">{tr('offlineLoading')}</span>
|
||||
</>
|
||||
) : (
|
||||
<div className="release-list">
|
||||
{groups.map((group, groupIndex) => {
|
||||
const [latest, ...older] = group.releases
|
||||
return (
|
||||
<article className="release-card" key={group.key}>
|
||||
<div className="release-latest">
|
||||
<span className="release-art">
|
||||
<VersionArt shape="tile" major={group.major} name={group.title} />
|
||||
</span>
|
||||
<div className="release-copy">
|
||||
<div className="row-title release-title">
|
||||
<span>{latest.title}</span>
|
||||
<strong>{latest.version}</strong>
|
||||
{groupIndex === 0 && <span className="badge badge-accent">{tr('installersLatest')}</span>}
|
||||
{downloaded(latest.version) && <Check size={15} className="ok-text" aria-label={tr('offlineCached')} />}
|
||||
</div>
|
||||
{releaseMeta(latest)}
|
||||
</div>
|
||||
<div className="row-right">{releaseAction(latest)}</div>
|
||||
</div>
|
||||
{older.length > 0 && (
|
||||
<details className="release-history">
|
||||
<summary>
|
||||
<span>{tr('installersOlder', { count: older.length })}</span>
|
||||
<ChevronDown size={14} aria-hidden="true" />
|
||||
</summary>
|
||||
<div className="release-history-list">
|
||||
{older.map((r) => (
|
||||
<div className="release-history-row" key={r.product}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span>{r.version}</span>
|
||||
<span className="muted">{r.build}</span>
|
||||
{downloaded(r.version) && <span className="badge badge-ok">{tr('offlineCached')}</span>}
|
||||
</div>
|
||||
{releaseMeta(r)}
|
||||
</div>
|
||||
<div className="row-right">{releaseAction(r)}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{task ? (
|
||||
<IconButton label={tr('pauseDownload')} icon={<Pause size={16} />} onClick={() => backend.cancelTask(task.id)} />
|
||||
) : done ? (
|
||||
<span className="badge badge-ok">{tr('offlineCached')}</span>
|
||||
) : (
|
||||
<Button icon={<Download size={14} />} disabled={short} onClick={() => download(r.version)}>{tr('installersDownload')}</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<span className="hint">{tr('installersHint')}</span>
|
||||
</article>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ArrowDown, ChevronDown, ChevronUp, Eraser, LoaderCircle, Pause, RefreshCw } from 'lucide-react'
|
||||
import React, { useLayoutEffect, useRef, useState } from 'react'
|
||||
import { AlertTriangle, ArrowDown, ChevronDown, ChevronUp, Copy, Eraser, LoaderCircle, Pause, RefreshCw, X } from 'lucide-react'
|
||||
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { LogLine } from '../lib/logs'
|
||||
import { taskDetail, taskTitle } from '../lib/tasks'
|
||||
import { Locale, Task } from '../types'
|
||||
import { taskDetail, taskInstallerPhase, taskStopAction, taskTitle } from '../lib/tasks'
|
||||
import { HostReport, Locale, Task } from '../types'
|
||||
import { Button, IconButton, Tip } from '../ui/controls'
|
||||
|
||||
export type LogTab = 'app' | 'serial' | 'qemu'
|
||||
@@ -25,6 +25,12 @@ interface Props {
|
||||
task: Task | null
|
||||
runningTasks: number
|
||||
onCancelTask: (id: string) => void
|
||||
host?: HostReport
|
||||
runningVMs?: number
|
||||
onCopy?: (text: string) => void
|
||||
/** False when WHPX or the runtime needs attention; the bar then leads with a link to the host page. */
|
||||
hostReady?: boolean
|
||||
onOpenHost?: () => void
|
||||
}
|
||||
|
||||
/** Sticks to the bottom until the user scrolls up; offers "jump to latest" then. */
|
||||
@@ -50,55 +56,276 @@ function useStickToBottom(dep: unknown, active: boolean) {
|
||||
return { ref, stuck, onScroll, jump }
|
||||
}
|
||||
|
||||
const LogRow = React.memo(({ line }: { line: LogLine }) => (
|
||||
<div className={`log-line ${line.level}`}>
|
||||
<span className="log-ts">{line.ts}</span>
|
||||
<span className="log-src">{line.source}</span>
|
||||
<span className="log-msg">{line.line}</span>
|
||||
</div>
|
||||
))
|
||||
LogRow.displayName = 'LogRow'
|
||||
|
||||
const LOG_HEIGHT_KEY = 'reims-go-log-height'
|
||||
const DEFAULT_LOG_HEIGHT = 240
|
||||
const MIN_LOG_HEIGHT = 120
|
||||
const MAX_LOG_HEIGHT = 520
|
||||
|
||||
export const LogPanel: React.FC<Props> = ({
|
||||
locale, open, onToggle, tab, onTab, lines, unseenErrors, onClear, serialText, qemuText, showSerial, onRefreshSerial, onRefreshQemu,
|
||||
task, runningTasks, onCancelTask,
|
||||
task, runningTasks, onCancelTask, host, runningVMs = 0, onCopy, hostReady = true, onOpenHost,
|
||||
}) => {
|
||||
const tr = (k: Parameters<typeof t>[1]) => t(locale, k)
|
||||
const content = tab === 'app' ? lines : tab === 'serial' ? serialText : qemuText
|
||||
const tr = (k: Parameters<typeof t>[1], v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [query, setQuery] = useState('')
|
||||
const [errorsOnly, setErrorsOnly] = useState(false)
|
||||
|
||||
const q = query.trim().toLowerCase()
|
||||
const filteredLines = useMemo(() => {
|
||||
return lines.filter((l) => {
|
||||
if (errorsOnly && l.level !== 'error' && l.level !== 'warn') return false
|
||||
if (q && !l.line.toLowerCase().includes(q) && !l.source.toLowerCase().includes(q)) return false
|
||||
return true
|
||||
})
|
||||
}, [lines, errorsOnly, q])
|
||||
// Same element list while the lines are unchanged, so an App re-render for
|
||||
// something else doesn't rebuild up to MAX_LOG_LINES rows; a new line renders
|
||||
// just its own row (LogRow is memoised on the line object).
|
||||
const rows = useMemo(() => filteredLines.map((l) => <LogRow key={l.id} line={l} />), [filteredLines])
|
||||
|
||||
const filteredText = useMemo(() => {
|
||||
const raw = tab === 'serial' ? serialText : qemuText
|
||||
if (!q || !raw) return raw
|
||||
return raw.split('\n').filter((line) => line.toLowerCase().includes(q)).join('\n')
|
||||
}, [tab, serialText, qemuText, q])
|
||||
|
||||
const copyVisible = () => {
|
||||
if (!onCopy) return
|
||||
if (tab === 'app') {
|
||||
const txt = filteredLines.map((l) => `${l.ts} [${l.source}] ${l.line}`).join('\n')
|
||||
if (txt) onCopy(txt)
|
||||
} else if (filteredText) {
|
||||
onCopy(filteredText)
|
||||
}
|
||||
}
|
||||
|
||||
const content = tab === 'app' ? filteredLines : filteredText
|
||||
const { ref, stuck, onScroll, jump } = useStickToBottom(content, open)
|
||||
|
||||
const memPct = host
|
||||
? Math.max(0, Math.min(100, host.memory_load_pct > 0
|
||||
? host.memory_load_pct
|
||||
: host.total_ram_gb > 0
|
||||
? Math.round(((host.total_ram_gb - host.avail_ram_gb) / host.total_ram_gb) * 100)
|
||||
: 0))
|
||||
: 0
|
||||
const usedMemGB = host && host.total_ram_gb > 0 ? Math.max(0, host.total_ram_gb - host.avail_ram_gb) : 0
|
||||
const memTone = memPct >= 90 ? ' high' : memPct >= 80 ? ' warn' : ''
|
||||
const lowDisk = !!host && host.free_disk_gb > 0 && host.free_disk_gb < 30
|
||||
// "D:\Data\reims-go" → "D:": the drive VM disks and snapshots grow on.
|
||||
const dataDrive = /^([A-Za-z]:)/.exec(host?.data_root ?? '')?.[1]?.toUpperCase() ?? ''
|
||||
|
||||
const [height, setHeight] = useState<number>(() => {
|
||||
try {
|
||||
const saved = Number(localStorage.getItem(LOG_HEIGHT_KEY))
|
||||
if (Number.isFinite(saved) && saved >= MIN_LOG_HEIGHT && saved <= MAX_LOG_HEIGHT) return saved
|
||||
} catch {}
|
||||
return DEFAULT_LOG_HEIGHT
|
||||
})
|
||||
const [dragging, setDragging] = useState(false)
|
||||
const dragRef = useRef<{ startY: number; startH: number } | null>(null)
|
||||
|
||||
const onResizeDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
e.preventDefault()
|
||||
e.currentTarget.setPointerCapture(e.pointerId)
|
||||
dragRef.current = { startY: e.clientY, startH: height }
|
||||
setDragging(true)
|
||||
}
|
||||
const onResizeMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!dragRef.current) return
|
||||
const next = Math.min(MAX_LOG_HEIGHT, Math.max(MIN_LOG_HEIGHT, Math.round(dragRef.current.startH + (dragRef.current.startY - e.clientY))))
|
||||
setHeight(next)
|
||||
}
|
||||
const onResizeUp = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!dragRef.current) return
|
||||
dragRef.current = null
|
||||
setDragging(false)
|
||||
if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId)
|
||||
try { localStorage.setItem(LOG_HEIGHT_KEY, String(height)) } catch {}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="logs">
|
||||
<div className="logbar">
|
||||
{task && (
|
||||
<div className="logs rg-p-logpanel">
|
||||
{open && (
|
||||
<div
|
||||
className="log-resize-handle"
|
||||
role="separator"
|
||||
tabIndex={0}
|
||||
aria-orientation="horizontal"
|
||||
aria-label={tr('resizeLogPanel')}
|
||||
aria-valuemin={MIN_LOG_HEIGHT}
|
||||
aria-valuemax={MAX_LOG_HEIGHT}
|
||||
aria-valuenow={height}
|
||||
data-dragging={dragging}
|
||||
onPointerDown={onResizeDown}
|
||||
onPointerMove={onResizeMove}
|
||||
onPointerUp={onResizeUp}
|
||||
onPointerCancel={onResizeUp}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return
|
||||
e.preventDefault()
|
||||
const delta = e.key === 'ArrowUp' ? 24 : -24
|
||||
const next = Math.min(MAX_LOG_HEIGHT, Math.max(MIN_LOG_HEIGHT, height + delta))
|
||||
setHeight(next)
|
||||
try { localStorage.setItem(LOG_HEIGHT_KEY, String(next)) } catch {}
|
||||
}}
|
||||
onDoubleClick={() => {
|
||||
setHeight(DEFAULT_LOG_HEIGHT)
|
||||
try { localStorage.setItem(LOG_HEIGHT_KEY, String(DEFAULT_LOG_HEIGHT)) } catch {}
|
||||
}}
|
||||
>
|
||||
<span className="log-resize-pill" aria-hidden="true" />
|
||||
</div>
|
||||
)}
|
||||
<div className="logbar rg-p-statusbar">
|
||||
{task ? (
|
||||
<>
|
||||
<Tip label={[task.step, taskDetail(task)].filter(Boolean).join(' · ') || taskTitle(locale, task)} side="top">
|
||||
<Tip
|
||||
label={[
|
||||
taskInstallerPhase(task) === 'queued' ? tr('installersQueuedDesc') : task.step,
|
||||
taskDetail(task),
|
||||
].filter(Boolean).join(' · ') || taskTitle(locale, task)}
|
||||
side="top"
|
||||
>
|
||||
<span className="task" tabIndex={0}>
|
||||
<LoaderCircle size={14} className="spin" />
|
||||
<LoaderCircle size={14} className="spin" aria-hidden="true" />
|
||||
<span className="task-label">
|
||||
{runningTasks > 1 ? t(locale, 'tasksRunning', { n: runningTasks }) : taskTitle(locale, task)}
|
||||
</span>
|
||||
{task.percent >= 0 && (
|
||||
<>
|
||||
<span className="progress" aria-hidden="true"><div style={{ width: `${task.percent}%` }} /></span>
|
||||
<span>{Math.floor(task.percent)}%</span>
|
||||
<span className="progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${Math.max(0, Math.min(1, task.percent / 100))})` }} />
|
||||
</span>
|
||||
<span className="task-pct">{Math.floor(task.percent)}%</span>
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
</Tip>
|
||||
{task.cancelable && (
|
||||
<IconButton small tipSide="top" label={tr('pauseDownload')} icon={<Pause size={14} />} onClick={() => onCancelTask(task.id)} />
|
||||
)}
|
||||
{task.cancelable && (() => {
|
||||
const stop = taskStopAction(locale, task)
|
||||
return (
|
||||
<IconButton
|
||||
small
|
||||
tipSide="top"
|
||||
label={stop.label}
|
||||
icon={stop.kind === 'cancel' ? <X size={14} /> : <Pause size={14} />}
|
||||
onClick={() => onCancelTask(task.id)}
|
||||
/>
|
||||
)
|
||||
})()}
|
||||
</>
|
||||
)}
|
||||
<span className="spacer" />
|
||||
{open && (
|
||||
<div className="tabs" role="tablist">
|
||||
<button type="button" role="tab" className="tab" aria-selected={tab === 'app'} onClick={() => onTab('app')}>
|
||||
{tr('logActivity')}
|
||||
</button>
|
||||
{showSerial && (
|
||||
<>
|
||||
<button type="button" role="tab" className="tab" aria-selected={tab === 'serial'} onClick={() => onTab('serial')}>
|
||||
{tr('logSerial')}
|
||||
) : host ? (
|
||||
// Host at a glance: a problem first (only when there is one), then
|
||||
// memory, the data drive and running VMs. "Label value" pairs with
|
||||
// thin rules between them; exact figures live in the tooltips.
|
||||
<div className="status-telemetry">
|
||||
{!hostReady && onOpenHost && (
|
||||
<Tip side="top" label={tr('footerHostIssueTip')}>
|
||||
<button type="button" className="status-metric status-issue" onClick={onOpenHost}>
|
||||
<AlertTriangle size={12} aria-hidden="true" />
|
||||
<span>{tr('footerHostIssue')}</span>
|
||||
</button>
|
||||
<button type="button" role="tab" className="tab" aria-selected={tab === 'qemu'} onClick={() => onTab('qemu')}>
|
||||
{tr('logQemu')}
|
||||
</button>
|
||||
</>
|
||||
</Tip>
|
||||
)}
|
||||
{host.total_ram_gb > 0 && (
|
||||
<Tip
|
||||
side="top"
|
||||
label={tr('footerMemTip', {
|
||||
used: usedMemGB.toFixed(1),
|
||||
total: host.total_ram_gb.toFixed(1),
|
||||
avail: host.avail_ram_gb.toFixed(1),
|
||||
})}
|
||||
>
|
||||
<span className={`status-metric${memTone}`} tabIndex={0}>
|
||||
<span className="status-label">{tr('footerMemLabel')}</span>
|
||||
<span className="status-value">{tr('footerMemValue', { used: usedMemGB.toFixed(1), total: host.total_ram_gb.toFixed(0) })}</span>
|
||||
<span className="status-mini-bar" aria-hidden="true">
|
||||
<span className={`status-mini-fill${memTone}`} style={{ transform: `scaleX(${memPct / 100})` }} />
|
||||
</span>
|
||||
</span>
|
||||
</Tip>
|
||||
)}
|
||||
{host.free_disk_gb > 0 && (
|
||||
<Tip side="top" label={tr('footerDiskTip', { dir: host.data_root })}>
|
||||
<span className={`status-metric${lowDisk ? ' warn' : ''}`} tabIndex={0}>
|
||||
<span className="status-label">{dataDrive || tr('footerDiskLabel')}</span>
|
||||
<span className="status-value">{tr('footerDiskValue', { gb: host.free_disk_gb.toFixed(0) })}</span>
|
||||
</span>
|
||||
</Tip>
|
||||
)}
|
||||
{runningVMs > 0 && (
|
||||
<span className="status-metric ok">
|
||||
<span className="status status-running" aria-hidden="true" />
|
||||
<span className="status-value">{tr('footerRunningVMs', { n: runningVMs })}</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
<span className="spacer" />
|
||||
{open && (
|
||||
<>
|
||||
<input
|
||||
type="search"
|
||||
className="log-filter-input"
|
||||
value={query}
|
||||
placeholder={tr('logSearchPlaceholder')}
|
||||
aria-label={tr('logSearchPlaceholder')}
|
||||
spellCheck={false}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
/>
|
||||
{tab === 'app' && (
|
||||
<button
|
||||
type="button"
|
||||
className="log-filter-pill"
|
||||
aria-pressed={errorsOnly}
|
||||
onClick={() => setErrorsOnly((v) => !v)}
|
||||
>
|
||||
{tr('logErrorsOnly')}
|
||||
</button>
|
||||
)}
|
||||
<div
|
||||
className="tabs"
|
||||
role="tablist"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return
|
||||
e.preventDefault()
|
||||
const order: LogTab[] = showSerial ? ['app', 'serial', 'qemu'] : ['app']
|
||||
const cur = Math.max(0, order.indexOf(tab))
|
||||
const isRTL = getComputedStyle(e.currentTarget).direction === 'rtl'
|
||||
const delta = (e.key === 'ArrowRight') !== isRTL ? 1 : -1
|
||||
const next = order[(cur + delta + order.length) % order.length]
|
||||
onTab(next)
|
||||
const btns = e.currentTarget.querySelectorAll<HTMLButtonElement>('[role="tab"]')
|
||||
btns[order.indexOf(next)]?.focus()
|
||||
}}
|
||||
>
|
||||
<button type="button" role="tab" className="tab" tabIndex={tab === 'app' ? 0 : -1} aria-selected={tab === 'app'} onClick={() => onTab('app')}>
|
||||
{tr('logActivity')}
|
||||
</button>
|
||||
{showSerial && (
|
||||
<>
|
||||
<button type="button" role="tab" className="tab" tabIndex={tab === 'serial' ? 0 : -1} aria-selected={tab === 'serial'} onClick={() => onTab('serial')}>
|
||||
{tr('logSerial')}
|
||||
</button>
|
||||
<button type="button" role="tab" className="tab" tabIndex={tab === 'qemu' ? 0 : -1} aria-selected={tab === 'qemu'} onClick={() => onTab('qemu')}>
|
||||
{tr('logQemu')}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{open && onCopy && (
|
||||
<IconButton small tipSide="top" label={tr('logCopy')} icon={<Copy size={14} />} onClick={copyVisible} />
|
||||
)}
|
||||
{open && tab === 'app' && lines.length > 0 && (
|
||||
<IconButton small tipSide="top" label={tr('clear')} icon={<Eraser size={14} />} onClick={onClear} />
|
||||
@@ -109,34 +336,30 @@ export const LogPanel: React.FC<Props> = ({
|
||||
{open && tab === 'qemu' && (
|
||||
<IconButton small tipSide="top" label={tr('refresh')} icon={<RefreshCw size={14} />} onClick={onRefreshQemu} />
|
||||
)}
|
||||
<span className="rg-slot-inline" data-rg-slot="statusbar.right" />
|
||||
{!open && unseenErrors > 0 && <span className="badge badge-error" aria-hidden="true">{unseenErrors}</span>}
|
||||
<IconButton
|
||||
small
|
||||
tipSide="top"
|
||||
label={open ? tr('collapseLogs') : tr('expandLogs')}
|
||||
shortcut="Ctrl+L"
|
||||
icon={open ? <ChevronDown size={16} /> : <ChevronUp size={16} />}
|
||||
onClick={onToggle}
|
||||
aria-expanded={open}
|
||||
/>
|
||||
<Tip label={open ? tr('collapseLogs') : tr('expandLogs')} shortcut="Ctrl+L" side="top">
|
||||
<button
|
||||
type="button"
|
||||
className="log-toggle-btn"
|
||||
onClick={onToggle}
|
||||
aria-expanded={open}
|
||||
aria-label={open ? tr('collapseLogs') : tr('expandLogs')}
|
||||
>
|
||||
<span>{tr('logButton')}</span>
|
||||
{open ? <ChevronDown size={14} aria-hidden="true" /> : <ChevronUp size={14} aria-hidden="true" />}
|
||||
</button>
|
||||
</Tip>
|
||||
</div>
|
||||
|
||||
{open && (
|
||||
<div className="logs-body-wrap">
|
||||
<div className="logs-body" ref={ref} onScroll={onScroll} role="log" aria-live="off">
|
||||
<div className="logs-body" style={{ height }} ref={ref} onScroll={onScroll} role="log" aria-live="off">
|
||||
{tab === 'app'
|
||||
? (lines.length === 0
|
||||
? (filteredLines.length === 0
|
||||
? <span className="muted">{tr('logsEmpty')}</span>
|
||||
: lines.map((l) => (
|
||||
<div key={l.id} className={`log-line ${l.level}`}>
|
||||
<span className="log-ts">{l.ts}</span>
|
||||
<span className="log-src">{l.source}</span>
|
||||
<span className="log-msg">{l.line}</span>
|
||||
</div>
|
||||
)))
|
||||
: tab === 'serial'
|
||||
? (serialText || <span className="muted">{tr('logsEmpty')}</span>)
|
||||
: (qemuText || <span className="muted">{tr('logsEmpty')}</span>)}
|
||||
: rows)
|
||||
: (filteredText || <span className="muted">{tr('logsEmpty')}</span>)}
|
||||
</div>
|
||||
{!stuck && (
|
||||
<Button className="jump-latest" icon={<ArrowDown size={14} />} onClick={jump}>
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { getPluginMessageBundle, localeDir, parseAppError, t } from '../i18n'
|
||||
import { Locale, PanelContribution } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { api } from '../wails'
|
||||
import { locText } from './SchemaForm'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
panel: PanelContribution
|
||||
assetToken: string
|
||||
appearance: 'light' | 'dark'
|
||||
}
|
||||
|
||||
/**
|
||||
* Sandboxed L4 iframe panel with strict bridge verification (§4.2, §7.3):
|
||||
* - `sandbox="allow-scripts"` (no allow-same-origin, no top-navigation)
|
||||
* - Only responds to postMessage where `event.source === iframe.contentWindow`
|
||||
* - Routes all Host API calls through Go `PanelBridgeCall` for permission & rate checks
|
||||
* - Syncs theme tokens into iframe and provides error placeholder + retry.
|
||||
*/
|
||||
const RE_SAFE_TOKEN = /^[a-f0-9]+$/
|
||||
const RE_SAFE_PLUGIN_ID = /^[a-z0-9][a-z0-9._-]*$/
|
||||
const RE_SAFE_ENTRY_SEG = /^[a-zA-Z0-9._@ -]+$/
|
||||
|
||||
function buildSafePanelSrc(assetToken: string, pluginId: string | undefined, entry: string | undefined): string | null {
|
||||
if (!assetToken || !RE_SAFE_TOKEN.test(assetToken)) return null
|
||||
if (!pluginId || !RE_SAFE_PLUGIN_ID.test(pluginId) || pluginId.includes('..')) return null
|
||||
const raw = (entry || 'index.html').trim().replace(/^\/+/, '')
|
||||
if (!raw || raw.includes('\\') || raw.includes('?') || raw.includes('#') || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(raw)) {
|
||||
return null
|
||||
}
|
||||
const segs = raw.split('/')
|
||||
for (const seg of segs) {
|
||||
if (!seg || seg === '.' || seg === '..' || !RE_SAFE_ENTRY_SEG.test(seg)) return null
|
||||
}
|
||||
return `/plugin-assets/${encodeURIComponent(assetToken)}/${encodeURIComponent(pluginId)}/${segs.map(encodeURIComponent).join('/')}`
|
||||
}
|
||||
|
||||
export const PluginPanelFrame: React.FC<Props> = ({ locale, panel, assetToken, appearance }) => {
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null)
|
||||
const localeRef = useRef<Locale>(locale)
|
||||
localeRef.current = locale
|
||||
const [failed, setFailed] = useState(false)
|
||||
const [nonce, setNonce] = useState(0)
|
||||
|
||||
const src = buildSafePanelSrc(assetToken, panel.pluginId, panel.entry)
|
||||
|
||||
const syncTheme = () => {
|
||||
const win = iframeRef.current?.contentWindow
|
||||
if (!win) return
|
||||
const cs = getComputedStyle(document.documentElement)
|
||||
const tokens: Record<string, string> = {}
|
||||
for (const k of ['--surface-0', '--surface-1', '--text', '--text-2', '--border', '--accent', '--font-sans']) {
|
||||
tokens[k] = cs.getPropertyValue(k).trim()
|
||||
}
|
||||
const dir = localeDir(locale)
|
||||
const messages = getPluginMessageBundle(panel.pluginId ?? '', locale)
|
||||
win.postMessage({ type: 'reims:theme', appearance, locale, dir, tokens, messages }, '*')
|
||||
win.postMessage({ type: 'reims:i18n', locale, dir, messages }, '*')
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
syncTheme()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [appearance, locale])
|
||||
|
||||
useEffect(() => {
|
||||
if (!src) return
|
||||
let cancelled = false
|
||||
|
||||
const onMessage = async (e: MessageEvent) => {
|
||||
const win = iframeRef.current?.contentWindow
|
||||
// Strict origin + window identity check for sandbox="allow-scripts" opaque origin (§7.3).
|
||||
if (!win || e.source !== win || e.origin !== 'null') return
|
||||
const msg = e.data
|
||||
if (!msg || typeof msg !== 'object' || msg.type !== 'reims:rpc' || typeof msg.id !== 'string' || typeof msg.method !== 'string') return
|
||||
const rawParams = msg.params
|
||||
const params: Record<string, unknown> =
|
||||
rawParams && typeof rawParams === 'object' && !Array.isArray(rawParams)
|
||||
? (rawParams as Record<string, unknown>)
|
||||
: {}
|
||||
try {
|
||||
if (msg.method === 'i18n.getBundle') {
|
||||
const curLocale = localeRef.current
|
||||
const bundle = {
|
||||
locale: curLocale,
|
||||
dir: localeDir(curLocale),
|
||||
messages: getPluginMessageBundle(panel.pluginId ?? '', curLocale),
|
||||
}
|
||||
win.postMessage({ type: 'reims:rpc-result', id: msg.id, ok: true, result: bundle }, '*')
|
||||
return
|
||||
}
|
||||
const result = await api.PanelBridgeCall(panel.pluginId ?? '', msg.method, params)
|
||||
if (cancelled || iframeRef.current?.contentWindow !== win) return
|
||||
win.postMessage({ type: 'reims:rpc-result', id: msg.id, ok: true, result }, '*')
|
||||
} catch (err) {
|
||||
if (cancelled || iframeRef.current?.contentWindow !== win) return
|
||||
win.postMessage({ type: 'reims:rpc-result', id: msg.id, ok: false, error: parseAppError(err).summary || 'RPC failed' }, '*')
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('message', onMessage)
|
||||
return () => {
|
||||
cancelled = true
|
||||
window.removeEventListener('message', onMessage)
|
||||
}
|
||||
}, [panel.pluginId, nonce, src])
|
||||
|
||||
if (failed || !src) {
|
||||
return (
|
||||
<div className="plugin-panel-error">
|
||||
<span>{t(locale, 'panelLoadFailed')}</span>
|
||||
{src && (
|
||||
<Button onClick={() => { setFailed(false); setNonce((n) => n + 1) }}>
|
||||
{t(locale, 'installersRetry')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="plugin-panel-wrap">
|
||||
<div className="plugin-panel-head">{locText(panel.title, locale, panel.id)}</div>
|
||||
<iframe
|
||||
key={nonce}
|
||||
ref={iframeRef}
|
||||
className="plugin-panel-frame"
|
||||
title={locText(panel.title, locale, panel.id)}
|
||||
src={src}
|
||||
sandbox="allow-scripts"
|
||||
referrerPolicy="no-referrer"
|
||||
style={{ height: Math.max(120, Math.min(480, panel.height || 220)) }}
|
||||
onLoad={syncTheme}
|
||||
onError={() => setFailed(true)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
import { Download, LoaderCircle, Pause } from 'lucide-react'
|
||||
import { Download, LoaderCircle, Pause, RefreshCw } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { taskDetail } from '../lib/tasks'
|
||||
import { InstalledRuntime, Locale, RemoteRuntime, Task } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { backend } from '../wails'
|
||||
import { Switch } from '../ui/settings'
|
||||
import { api } from '../wails'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
channel: 'stable' | 'candidate'
|
||||
channel: 'stable' | 'alpha'
|
||||
installed: InstalledRuntime[]
|
||||
task: Task | null
|
||||
onChannel: (candidate: boolean) => void
|
||||
onChannel: (alpha: boolean) => void
|
||||
onInstall: (commit: string) => void
|
||||
onCancel: (taskId: string) => void
|
||||
}
|
||||
@@ -23,26 +25,32 @@ const shortQemu = (v: string) => v.replace(/^QEMU emulator version\s*/i, 'QEMU '
|
||||
|
||||
/**
|
||||
* The runtime rows: the active runtime and whether it is current (or, with
|
||||
* none installed, the newest release to install), then the candidate switch.
|
||||
* none installed, the newest release to install), then the alpha switch.
|
||||
*/
|
||||
export const RuntimeOnline: React.FC<Props> = ({ locale, channel, installed, task, onChannel, onInstall, onCancel }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [remote, setRemote] = useState<RemoteRuntime[] | null>(null)
|
||||
const [error, setError] = useState('')
|
||||
const [reload, setReload] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
setRemote(null)
|
||||
setError('')
|
||||
backend.listRemoteRuntimes()
|
||||
api.ListRemoteRuntimes()
|
||||
.then((list) => { if (live) setRemote(list ?? []) })
|
||||
.catch((e) => { if (live) setError(String(e).replace(/^Error:\s*/, '')) })
|
||||
return () => { live = false }
|
||||
}, [channel, task?.status === 'done'])
|
||||
}, [channel, task?.status === 'done', reload])
|
||||
|
||||
const active = installed.find((i) => i.active) ?? installed[0]
|
||||
const latest = remote?.[0]
|
||||
const isInstalled = (c: string) => installed.some((i) => i.commit.startsWith(c) || c.startsWith(i.commit))
|
||||
const sameRuntimeId = (a: string, b: string) => {
|
||||
const [baseA, revA = ''] = a.split('-', 2)
|
||||
const [baseB, revB = ''] = b.split('-', 2)
|
||||
return revA === revB && (baseA.startsWith(baseB) || baseB.startsWith(baseA))
|
||||
}
|
||||
const isInstalled = (c: string) => installed.some((i) => sameRuntimeId(i.commit, c))
|
||||
const running = task?.status === 'running'
|
||||
const updatable = !!latest && !isInstalled(latest.commit)
|
||||
|
||||
@@ -50,15 +58,21 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, installed, tas
|
||||
if (running && task) {
|
||||
sub = (
|
||||
<div className="row-sub task-inline">
|
||||
<LoaderCircle size={14} className="spin" />
|
||||
{task.percent >= 0 && <span className="progress"><div style={{ width: `${task.percent}%` }} /></span>}
|
||||
<LoaderCircle size={14} className="spin" aria-hidden="true" />
|
||||
{task.percent >= 0 && (
|
||||
<span className="progress" aria-hidden="true">
|
||||
<span className="progress-fill" style={{ transform: `scaleX(${Math.max(0, Math.min(1, task.percent / 100))})` }} />
|
||||
</span>
|
||||
)}
|
||||
<span>{task.percent >= 0 ? `${Math.floor(task.percent)}%` : ''} {taskDetail(task)}</span>
|
||||
</div>
|
||||
)
|
||||
} else if (active && !updatable) {
|
||||
sub = <div className="row-sub">{shortQemu(active.manifest.qemu_version)}</div>
|
||||
} else if (error) {
|
||||
sub = <div className="row-sub" title={error}>{tr('runtimeLookupFailed')}</div>
|
||||
const isRateLimit = /rate limit|HTTP 403|HTTP 429/i.test(error)
|
||||
const msg = isRateLimit ? tr('runtimeLookupRateLimit') : `${tr('runtimeLookupFailed')}: ${error}`
|
||||
sub = <div className="row-sub" title={error}>{msg}</div>
|
||||
} else if (!remote) {
|
||||
sub = <div className="row-sub">…</div>
|
||||
} else if (!latest) {
|
||||
@@ -67,7 +81,8 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, installed, tas
|
||||
sub = (
|
||||
<div className="row-sub">
|
||||
{active ? tr('runtimeNewer', { v: latest.commit }) : tr('runtimeLatest', { v: latest.commit })}
|
||||
{' · '}{tr(`runtimeChannel_${latest.channel}` as I18nKey)} · {gb(latest.archive_size)}
|
||||
{' · '}{tr(`runtimeChannel_${latest.channel}` as I18nKey)}
|
||||
{latest.archive_size > 0 ? ` · ${gb(latest.archive_size)}` : ''}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -84,6 +99,10 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, installed, tas
|
||||
<div className="row-right">
|
||||
{running && task?.cancelable ? (
|
||||
<IconButton label={tr('pauseDownload')} icon={<Pause size={16} />} onClick={() => onCancel(task.id)} />
|
||||
) : !running && error ? (
|
||||
<Button icon={<RefreshCw size={14} />} onClick={() => setReload((n) => n + 1)}>
|
||||
{tr('runtimeRetry')}
|
||||
</Button>
|
||||
) : !running && updatable ? (
|
||||
<Button variant="primary" icon={<Download size={14} />} onClick={() => onInstall(latest!.commit)}>
|
||||
{tr(active ? 'runtimeUpdate' : 'runtimeInstall')}
|
||||
@@ -95,19 +114,11 @@ export const RuntimeOnline: React.FC<Props> = ({ locale, channel, installed, tas
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('runtimeCandidate')}</div>
|
||||
<div className="row-sub">{tr('runtimeCandidateHint')}</div>
|
||||
<div className="row-title">{tr('runtimeAlpha')}</div>
|
||||
<div className="row-sub">{tr('runtimeAlphaHint')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<label className="switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={tr('runtimeCandidate')}
|
||||
checked={channel === 'candidate'}
|
||||
onChange={(e) => onChannel(e.target.checked)}
|
||||
/>
|
||||
<span className="slider" />
|
||||
</label>
|
||||
<Switch label={tr('runtimeAlpha')} checked={channel === 'alpha'} onChange={onChannel} />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
import React from 'react'
|
||||
import '../i18n/domains/plugins.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { locText, t } from '../i18n'
|
||||
import { Locale, SettingProperty, SettingsSchema } from '../types'
|
||||
import { NumberField, PopupSelect, Segmented, SetGroup, SetRow, Switch } from '../ui/settings'
|
||||
|
||||
export { locText }
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
schema: SettingsSchema
|
||||
values: Record<string, unknown>
|
||||
scopeFilter?: 'app' | 'vm'
|
||||
groupFilter?: string
|
||||
onChange: (next: Record<string, unknown>) => void
|
||||
hideGroupHeader?: boolean
|
||||
}
|
||||
|
||||
const SECRET_MASK = '••••••••'
|
||||
const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype'])
|
||||
|
||||
/** Lazy-loaded JSON Schema form renderer supporting x-secret, x-effect, x-scope (§6.2, §8.1, §10). */
|
||||
export const SchemaForm: React.FC<Props> = ({
|
||||
locale, schema, values, scopeFilter, groupFilter, onChange, hideGroupHeader,
|
||||
}) => {
|
||||
const propsMap = schema.properties ?? {}
|
||||
const keys = (schema['x-order'] && schema['x-order'].length > 0
|
||||
? schema['x-order'].filter((k) => !FORBIDDEN_KEYS.has(k) && Object.prototype.hasOwnProperty.call(propsMap, k))
|
||||
: Object.keys(propsMap).filter((k) => !FORBIDDEN_KEYS.has(k))
|
||||
).filter((k) => {
|
||||
const prop = propsMap[k]
|
||||
const effScope = prop['x-scope'] || schema['x-scope'] || 'app'
|
||||
const effGroup = prop['x-group'] || schema['x-group'] || ''
|
||||
if (scopeFilter && effScope !== scopeFilter) return false
|
||||
if (groupFilter && effGroup !== groupFilter) return false
|
||||
return true
|
||||
})
|
||||
|
||||
if (keys.length === 0) return null
|
||||
|
||||
const setKey = (k: string, v: unknown) => {
|
||||
const next: Record<string, unknown> = {}
|
||||
for (const [ek, ev] of Object.entries(values)) {
|
||||
if (propsMap[ek]?.['x-secret'] && ev === SECRET_MASK) continue
|
||||
next[ek] = ev
|
||||
}
|
||||
next[k] = v
|
||||
onChange(next)
|
||||
}
|
||||
|
||||
const effectBadge = (prop: SettingProperty) => {
|
||||
const eff = prop['x-effect']
|
||||
if (!eff) return null
|
||||
const label = t(locale, eff === 'immediate' ? 'effectImmediate' : 'effectNextStart')
|
||||
return <span className={`badge ${eff === 'immediate' ? 'badge-ok' : ''}`}>{label}</span>
|
||||
}
|
||||
|
||||
const renderControl = (k: string, prop: SettingProperty) => {
|
||||
const cur = values[k] ?? prop.default
|
||||
const label = locText(prop.title, locale, k)
|
||||
|
||||
if (prop.type === 'boolean') {
|
||||
return (
|
||||
<Switch
|
||||
label={label}
|
||||
checked={Boolean(cur)}
|
||||
onChange={(checked) => setKey(k, checked)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (prop.enum && prop.enum.length > 0) {
|
||||
const options = prop.enum.map((val, idx) => ({
|
||||
value: val,
|
||||
label: locText(prop['x-enumLabels']?.[idx], locale, val),
|
||||
}))
|
||||
if (options.length <= 3) {
|
||||
return (
|
||||
<Segmented
|
||||
label={label}
|
||||
value={String(cur ?? prop.enum[0])}
|
||||
options={options}
|
||||
onChange={(val) => setKey(k, val)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<PopupSelect
|
||||
label={label}
|
||||
value={String(cur ?? prop.enum[0])}
|
||||
options={options}
|
||||
onChange={(val) => setKey(k, val)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (prop.type === 'integer' || prop.type === 'number') {
|
||||
const numVal = Number(cur ?? 0)
|
||||
return (
|
||||
<NumberField
|
||||
label={label}
|
||||
value={Number.isFinite(numVal) ? numVal : 0}
|
||||
min={prop.minimum ?? 0}
|
||||
max={prop.maximum ?? 65535}
|
||||
step={prop.type === 'number' ? 0.1 : 1}
|
||||
onChange={(n) => setKey(k, n)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (prop['x-secret']) {
|
||||
const isMasked = cur === SECRET_MASK
|
||||
return (
|
||||
<input
|
||||
type="password"
|
||||
className="input"
|
||||
aria-label={label}
|
||||
autoComplete="new-password"
|
||||
placeholder={isMasked ? SECRET_MASK : undefined}
|
||||
value={isMasked ? '' : String(cur ?? '')}
|
||||
onChange={(e) => setKey(k, e.target.value)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<input
|
||||
type="text"
|
||||
className="input"
|
||||
aria-label={label}
|
||||
value={String(cur ?? '')}
|
||||
onChange={(e) => setKey(k, e.target.value)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const rows = keys.map((k) => {
|
||||
const prop = propsMap[k]
|
||||
const title = locText(prop.title, locale, k)
|
||||
const desc = locText(prop.description, locale)
|
||||
const badge = effectBadge(prop)
|
||||
return (
|
||||
<SetRow
|
||||
key={k}
|
||||
title={title}
|
||||
desc={badge || desc ? <span className="hstack">{badge}{desc ? <span>{desc}</span> : null}</span> : undefined}
|
||||
control={renderControl(k, prop)}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
if (hideGroupHeader) return <>{rows}</>
|
||||
return (
|
||||
<SetGroup title={locText(schema.title, locale, t(locale, 'pluginSettings'))}>
|
||||
{rows}
|
||||
</SetGroup>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import * as Alert from '@radix-ui/react-alert-dialog'
|
||||
import React, { useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { Locale } from '../types'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
vmName: string
|
||||
guestToolsConnected: boolean
|
||||
onCancel: () => void
|
||||
onConfirm: (text: string) => void
|
||||
}
|
||||
|
||||
export const SendTextDialog: React.FC<Props> = ({ locale, vmName, guestToolsConnected, onCancel, onConfirm }) => {
|
||||
const [text, setText] = useState('')
|
||||
const canSend = text.length > 0
|
||||
|
||||
return (
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{t(locale, 'sendTextTitle', { name: vmName })}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">
|
||||
{t(locale, guestToolsConnected ? 'sendTextDesc' : 'sendTextDescNoGT')}
|
||||
</Alert.Description>
|
||||
<div className="field field-spaced">
|
||||
<textarea
|
||||
className="input textarea"
|
||||
rows={4}
|
||||
placeholder={t(locale, 'sendTextPlaceholder')}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey) && canSend) {
|
||||
e.preventDefault()
|
||||
onConfirm(text)
|
||||
}
|
||||
}}
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild>
|
||||
<button type="button" className="btn">{t(locale, 'cancel')}</button>
|
||||
</Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-primary" disabled={!canSend} onClick={() => onConfirm(text)}>
|
||||
{t(locale, 'sendTextConfirm')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
)
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
import { FolderOpen, HardDrive } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { AppState, DataRootCheck, DataRootChoice, Locale, Task } from '../types'
|
||||
import '../i18n/domains/wizard.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { getLocaleOptions, I18nKey, joinNotices, t } from '../i18n'
|
||||
import { AppState, DataRootCheck, DataRootChoice, Locale, ResolvedLocalePack, Task } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { recommendedMemoryGB, shortGPUName } from '../lib/format'
|
||||
import { backend } from '../wails'
|
||||
import { PopupSelect } from '../ui/settings'
|
||||
import { gpuCompatHint, recommendedMemoryGB, shortGPUName } from '../lib/format'
|
||||
import { api } from '../wails'
|
||||
import { RuntimeOnline } from './RuntimeOnline'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
locales?: ResolvedLocalePack[]
|
||||
state: AppState
|
||||
stage: 'folder' | 'runtime'
|
||||
runtimeTask: Task | null
|
||||
@@ -16,7 +20,7 @@ interface Props {
|
||||
onFolderDone: () => void
|
||||
onFinish: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onChannel: (candidate: boolean) => void
|
||||
onChannel: (alpha: boolean) => void
|
||||
onInstallRuntime: (commit: string) => void
|
||||
onCancelTask: (id: string) => void
|
||||
onImportRuntime: () => void
|
||||
@@ -38,7 +42,7 @@ export const Setup: React.FC<Props> = (p) => {
|
||||
|
||||
type StepProps = Props & { tr: (k: I18nKey, v?: Record<string, string | number>) => string }
|
||||
|
||||
const FolderStep: React.FC<StepProps> = ({ locale, tr, onLocale, onFolderDone, onError }) => {
|
||||
const FolderStep: React.FC<StepProps> = ({ locale, locales, state, tr, onLocale, onFolderDone, onError }) => {
|
||||
const [choices, setChoices] = useState<DataRootChoice[]>([])
|
||||
const [custom, setCustom] = useState('')
|
||||
const [customMode, setCustomMode] = useState(false)
|
||||
@@ -47,7 +51,7 @@ const FolderStep: React.FC<StepProps> = ({ locale, tr, onLocale, onFolderDone, o
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
backend.suggestDataRoots().then((list) => {
|
||||
api.SuggestDataRoots().then((list) => {
|
||||
const l = list ?? []
|
||||
setChoices(l)
|
||||
const rec = l.find((c) => c.recommended) ?? l[0]
|
||||
@@ -58,19 +62,19 @@ const FolderStep: React.FC<StepProps> = ({ locale, tr, onLocale, onFolderDone, o
|
||||
useEffect(() => {
|
||||
if (!selected) { setCheck(null); return }
|
||||
let live = true
|
||||
backend.checkDataRoot(selected).then((c) => { if (live) setCheck(c) }).catch(() => {})
|
||||
api.CheckDataRoot(selected).then((c) => { if (live) setCheck(c) }).catch(() => {})
|
||||
return () => { live = false }
|
||||
}, [selected])
|
||||
|
||||
const browse = async () => {
|
||||
const dir = await backend.pickDirectory(tr('setupTitle')).catch(() => '')
|
||||
const dir = await api.PickDirectory(tr('setupTitle')).catch(() => '')
|
||||
if (dir) { setCustom(dir); setCustomMode(true); setSelected(dir) }
|
||||
}
|
||||
|
||||
const next = async () => {
|
||||
setBusy(true)
|
||||
try {
|
||||
await backend.completeSetup(selected)
|
||||
await api.CompleteSetup(selected)
|
||||
onFolderDone()
|
||||
} catch (e) {
|
||||
onError(tr('failGeneric'), e)
|
||||
@@ -120,6 +124,8 @@ const FolderStep: React.FC<StepProps> = ({ locale, tr, onLocale, onFolderDone, o
|
||||
aria-label={tr('setupOther')}
|
||||
value={custom}
|
||||
placeholder="D:\VMs\reims-go"
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
autoFocus
|
||||
onFocus={() => custom && setSelected(custom)}
|
||||
onChange={(e) => { setCustom(e.target.value); setSelected(e.target.value.trim()) }}
|
||||
@@ -131,17 +137,19 @@ const FolderStep: React.FC<StepProps> = ({ locale, tr, onLocale, onFolderDone, o
|
||||
)}
|
||||
</div>
|
||||
{notices.length > 0 && (
|
||||
<div className={check?.error ? 'notice notice-error' : 'hint warn'}>{notices.join(';')}</div>
|
||||
<div className={check?.error ? 'notice notice-error' : 'hint warn'}>{joinNotices(locale, notices)}</div>
|
||||
)}
|
||||
{!check?.error && check?.has_config && <div className="hint">{tr('setupReuse')}</div>}
|
||||
{customMode && check && check.path === custom && !check.error && (
|
||||
<div className="hint">{tr('setupFree', { n: check.free_gb.toFixed(0) })}</div>
|
||||
)}
|
||||
<div className="setup-foot">
|
||||
<div className="segmented" role="group" aria-label={tr('language')}>
|
||||
<button type="button" aria-pressed={locale === 'zh-CN'} onClick={() => onLocale('zh-CN')}>中文</button>
|
||||
<button type="button" aria-pressed={locale === 'en-US'} onClick={() => onLocale('en-US')}>English</button>
|
||||
</div>
|
||||
<PopupSelect
|
||||
label={tr('language')}
|
||||
value={state.config.locale || 'auto'}
|
||||
onChange={onLocale}
|
||||
options={getLocaleOptions(locales, locale, state.detected_locale)}
|
||||
/>
|
||||
<Button variant="primary" busy={busy} disabled={!selected || !!check?.error} onClick={next}>{tr('setupContinue')}</Button>
|
||||
</div>
|
||||
</>
|
||||
@@ -154,10 +162,12 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
const [enabling, setEnabling] = useState(false)
|
||||
const enableWHPX = async () => {
|
||||
setEnabling(true)
|
||||
try { await backend.enableWHPX() } catch (e) { onError(tr('failGeneric'), e) } finally { setEnabling(false) }
|
||||
try { await api.EnableWHPX() } catch (e) { onError(tr('failGeneric'), e) } finally { setEnabling(false) }
|
||||
}
|
||||
const whpxOK = host.whpx === 'ready'
|
||||
const gpu = host.recommended_gpu ?? (host.gpus ?? []).find((g) => g.kind !== 'virtual')
|
||||
const gpuHint = gpuCompatHint(locale, gpu)
|
||||
const gpuOK = !!gpu && gpu.compat !== 'warn' && gpu.compat !== 'unsupported'
|
||||
const recMem = recommendedMemoryGB(host)
|
||||
return (
|
||||
<>
|
||||
@@ -191,9 +201,20 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('setupGPU')}</div>
|
||||
<div className="row-sub">{gpu ? shortGPUName(gpu.name) : tr('setupNoGPU')}</div>
|
||||
{gpuHint && <div className="row-sub warn-text">{gpuHint}</div>}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<span className={`badge ${gpu ? 'badge-ok' : 'badge-warn'}`}>{tr(gpu ? 'whpxReady' : 'hostNeedsAction')}</span>
|
||||
<span className={`badge ${gpuOK ? 'badge-ok' : 'badge-warn'}`}>
|
||||
{tr(
|
||||
gpuOK
|
||||
? 'whpxReady'
|
||||
: gpu?.compat === 'unsupported'
|
||||
? 'gpuCompatUnsupported'
|
||||
: gpu?.compat === 'warn'
|
||||
? 'gpuCompatWarn'
|
||||
: 'hostNeedsAction',
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
@@ -214,7 +235,7 @@ const RuntimeStep: React.FC<StepProps> = ({ locale, tr, state, runtimeTask, onCh
|
||||
<div className="list">
|
||||
<RuntimeOnline
|
||||
locale={locale}
|
||||
channel={state.config.runtime_channel === 'candidate' ? 'candidate' : 'stable'}
|
||||
channel={state.config.runtime_channel === 'alpha' ? 'alpha' : 'stable'}
|
||||
installed={state.runtimes ?? []}
|
||||
task={runtimeTask}
|
||||
onChannel={onChannel}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import { Cpu, Download, Monitor, Plus } from 'lucide-react'
|
||||
import * as Ctx from '@radix-ui/react-context-menu'
|
||||
import { AppWindow, Camera, CopyPlus, Cpu, Download, FolderOpen, Info, Play, Plus, Power, Puzzle, RotateCw, Settings, Square, Trash } from 'lucide-react'
|
||||
import React, { useRef } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale, VMListItem } from '../types'
|
||||
import { IconButton, StatusShape, Tip, statusKind } from '../ui/controls'
|
||||
import { VersionArt } from './VersionArt'
|
||||
import { VMAction } from './VMPage'
|
||||
|
||||
export const HOST_ID = '__host__'
|
||||
export const INSTALLERS_ID = '__installers__'
|
||||
export const PLUGINS_ID = '__plugins__'
|
||||
export const SETTINGS_ID = '__settings__'
|
||||
export const ABOUT_ID = '__about__'
|
||||
|
||||
/** Pages that are not VMs; everything else selectable in the sidebar is a VM name. */
|
||||
export const PAGE_IDS: readonly string[] = [HOST_ID, INSTALLERS_ID, PLUGINS_ID, SETTINGS_ID, ABOUT_ID]
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
@@ -14,14 +23,31 @@ interface Props {
|
||||
selected: string
|
||||
hostReady: boolean
|
||||
onSelect: (id: string) => void
|
||||
/** VM name → display name (its note); empty or missing shows the name. */
|
||||
displayNames?: Record<string, string>
|
||||
/** VM name → macOS major version for its icon; null shows the name's initial. */
|
||||
macosMajors?: Record<string, number | null>
|
||||
/** Double-click on a VM: its main action (start, or show its window). */
|
||||
onActivate?: (name: string) => void
|
||||
onNew: () => void
|
||||
onVMContextAction?: (name: string, action: VMAction | 'settings') => void
|
||||
/** An installer download is running (busy dot on the Installers entry). */
|
||||
downloading?: boolean
|
||||
/** Safe mode is active (third-party plugins skipped). */
|
||||
safeMode?: boolean
|
||||
/** Update capsule card shown under the brand (null when nothing to show). */
|
||||
updateCard?: React.ReactNode
|
||||
/** A newer release exists: dot on the About entry. */
|
||||
updateDot?: boolean
|
||||
}
|
||||
|
||||
export const Sidebar: React.FC<Props> = ({ locale, vms, transitions, selected, hostReady, onSelect, onNew, downloading }) => {
|
||||
export const Sidebar: React.FC<Props> = ({
|
||||
locale, vms, transitions, selected, hostReady, onSelect, displayNames = {}, macosMajors = {}, onActivate, onNew, onVMContextAction, downloading, safeMode, updateCard, updateDot,
|
||||
}) => {
|
||||
const tr = (k: I18nKey) => t(locale, k)
|
||||
const listRef = useRef<HTMLDivElement>(null)
|
||||
const ids = [...vms.map((v) => v.name), INSTALLERS_ID, HOST_ID]
|
||||
const ctxOpenedByPointerRef = useRef(false)
|
||||
const ids = [...vms.map((v) => v.name), INSTALLERS_ID, PLUGINS_ID, HOST_ID, SETTINGS_ID, ABOUT_ID]
|
||||
|
||||
// Listbox keyboard model: ↑/↓/Home/End move selection and focus together.
|
||||
const onKeyDown = (e: React.KeyboardEvent) => {
|
||||
@@ -37,13 +63,16 @@ export const Sidebar: React.FC<Props> = ({ locale, vms, transitions, selected, h
|
||||
listRef.current?.querySelector<HTMLElement>(`[data-id="${CSS.escape(ids[next])}"]`)?.focus()
|
||||
}
|
||||
|
||||
const item = (
|
||||
const hasSelectedInList = ids.includes(selected)
|
||||
const navBtn = (
|
||||
id: string,
|
||||
label: string,
|
||||
icon: React.ReactNode,
|
||||
badgeClass: string,
|
||||
stateLabel: string,
|
||||
kind: ReturnType<typeof statusKind> | null,
|
||||
onDoubleClick?: () => void,
|
||||
dot?: boolean,
|
||||
) => (
|
||||
<button
|
||||
key={id}
|
||||
@@ -52,12 +81,14 @@ export const Sidebar: React.FC<Props> = ({ locale, vms, transitions, selected, h
|
||||
data-id={id}
|
||||
className="nav-item"
|
||||
aria-selected={selected === id}
|
||||
aria-label={stateLabel ? `${label},${stateLabel}` : label}
|
||||
tabIndex={selected === id ? 0 : -1}
|
||||
aria-label={stateLabel ? t(locale, 'sidebarItemAria', { label, state: stateLabel }) : label}
|
||||
tabIndex={selected === id || (!hasSelectedInList && id === ids[0]) ? 0 : -1}
|
||||
onClick={() => onSelect(id)}
|
||||
onDoubleClick={onDoubleClick}
|
||||
>
|
||||
<span className={`nav-icon-badge ${badgeClass}`} aria-hidden="true">{icon}</span>
|
||||
<span className="nav-label">{label}</span>
|
||||
{dot && <span className="nav-dot" aria-hidden="true" />}
|
||||
{kind && (
|
||||
<Tip label={stateLabel} side="right">
|
||||
<span className="hstack"><StatusShape kind={kind} /></span>
|
||||
@@ -68,35 +99,154 @@ export const Sidebar: React.FC<Props> = ({ locale, vms, transitions, selected, h
|
||||
|
||||
return (
|
||||
<div className="sidebar-wrap">
|
||||
<aside className="sidebar">
|
||||
<div className="sidebar-head">
|
||||
<span>{t(locale, 'sidebarVMs')}</span>
|
||||
<IconButton small label={t(locale, 'newVM')} shortcut="Ctrl+N" icon={<Plus size={15} />} onClick={onNew} tipSide="right" />
|
||||
<aside className="sidebar rg-p-sidebar">
|
||||
<div className="sidebar-brand">
|
||||
<img className="sidebar-brand-mark" src="/logo.svg" alt="" aria-hidden="true" />
|
||||
<span className="sidebar-brand-name">Reims-Go</span>
|
||||
</div>
|
||||
<div className="nav" role="listbox" aria-label={t(locale, 'sidebarVMs')} ref={listRef} onKeyDown={onKeyDown}>
|
||||
{vms.length === 0 && <div className="nav-empty">{t(locale, 'emptyVMs')}</div>}
|
||||
{updateCard}
|
||||
<div className="sidebar-head rg-p-sidebar-head">
|
||||
<span>{tr('sidebarVMs')}</span>
|
||||
<IconButton small label={tr('newVM')} shortcut="Ctrl+N" icon={<Plus size={15} />} onClick={onNew} tipSide="right" />
|
||||
</div>
|
||||
<div className="nav rg-p-nav" role="listbox" aria-label={tr('sidebarVMs')} ref={listRef} onKeyDown={onKeyDown}>
|
||||
<div className="nav-group nav-vms" role="group" aria-label={tr('sidebarVMs')}>
|
||||
{vms.length === 0 && <div className="nav-empty rg-p-empty" data-rg-slot="empty.state">{tr('emptyVMs')}</div>}
|
||||
{vms.map((vm) => {
|
||||
const st = transitions[vm.name] ?? vm.state
|
||||
return item(vm.name, vm.name, <Monitor size={13} />, 'nav-icon-vm', t(locale, `state_${st}` as I18nKey), statusKind(st))
|
||||
const running = st === 'running'
|
||||
const stopped = st === 'stopped'
|
||||
const transitioning = st === 'starting' || st === 'stopping'
|
||||
const label = displayNames[vm.name] || vm.name
|
||||
const trigger = navBtn(
|
||||
vm.name,
|
||||
label,
|
||||
<VersionArt shape="tile" major={macosMajors[vm.name] ?? null} name={label} />,
|
||||
'nav-icon-art',
|
||||
t(locale, `state_${st}` as I18nKey),
|
||||
statusKind(st),
|
||||
onActivate ? () => onActivate(vm.name) : undefined,
|
||||
)
|
||||
if (!onVMContextAction) return trigger
|
||||
return (
|
||||
<Ctx.Root key={vm.name}>
|
||||
<Ctx.Trigger
|
||||
asChild
|
||||
onContextMenu={(e) => {
|
||||
ctxOpenedByPointerRef.current = e.button === 2 && (e.clientX !== 0 || e.clientY !== 0)
|
||||
}}
|
||||
>
|
||||
{trigger}
|
||||
</Ctx.Trigger>
|
||||
<Ctx.Portal>
|
||||
<Ctx.Content
|
||||
className="menu"
|
||||
onCloseAutoFocus={(e) => {
|
||||
if (
|
||||
ctxOpenedByPointerRef.current
|
||||
|| document.querySelector('[role="dialog"], [role="alertdialog"]')
|
||||
) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
>
|
||||
{stopped && (
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'start')}>
|
||||
<Play size={14} /> {tr('start')}
|
||||
</Ctx.Item>
|
||||
)}
|
||||
{running && (
|
||||
<>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'focus')}>
|
||||
<AppWindow size={14} /> {tr('showWindow')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'screenshot')}>
|
||||
<Camera size={14} /> {tr('copyScreenshot')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'stop')}>
|
||||
<Square size={14} /> {tr('stop')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'restart')}>
|
||||
<RotateCw size={14} /> {tr('restart')}
|
||||
</Ctx.Item>
|
||||
</>
|
||||
)}
|
||||
{(running || transitioning) && (
|
||||
<Ctx.Item className="menu-item danger" onSelect={() => onVMContextAction(vm.name, 'forceStop')}>
|
||||
<Power size={14} /> {tr('forceStop')}
|
||||
</Ctx.Item>
|
||||
)}
|
||||
<Ctx.Separator className="menu-sep" />
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'settings')}>
|
||||
<Settings size={14} /> {tr('settingsEllipsis')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'openSharedFolder')}>
|
||||
<FolderOpen size={14} /> {tr('openSharedFolder')}
|
||||
</Ctx.Item>
|
||||
{stopped && (
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'cloneVM')}>
|
||||
<CopyPlus size={14} /> {tr('cloneVM')}
|
||||
</Ctx.Item>
|
||||
)}
|
||||
<Ctx.Item className="menu-item" onSelect={() => onVMContextAction(vm.name, 'openFolder')}>
|
||||
<FolderOpen size={14} /> {tr('openFolder')}
|
||||
</Ctx.Item>
|
||||
<Ctx.Separator className="menu-sep" />
|
||||
<Ctx.Item className="menu-item danger" disabled={running || transitioning} onSelect={() => onVMContextAction(vm.name, 'delete')}>
|
||||
<Trash size={14} /> {tr('delete')}
|
||||
</Ctx.Item>
|
||||
</Ctx.Content>
|
||||
</Ctx.Portal>
|
||||
</Ctx.Root>
|
||||
)
|
||||
})}
|
||||
<div className="sidebar-sep" role="presentation" />
|
||||
{item(
|
||||
</div>
|
||||
<div className="nav-group nav-system" role="group" aria-label={tr('sidebarSystem')}>
|
||||
{navBtn(
|
||||
INSTALLERS_ID,
|
||||
t(locale, 'sidebarInstallers'),
|
||||
tr('sidebarInstallers'),
|
||||
<Download size={13} />,
|
||||
'nav-icon-installers',
|
||||
downloading ? t(locale, 'state_starting') : '',
|
||||
downloading ? tr('installersDownloading') : '',
|
||||
downloading ? 'busy' : null,
|
||||
)}
|
||||
{item(
|
||||
{navBtn(
|
||||
PLUGINS_ID,
|
||||
tr('sidebarPlugins'),
|
||||
<Puzzle size={13} />,
|
||||
'nav-icon-plugins',
|
||||
safeMode ? tr('pluginSafeModeShort') : '',
|
||||
safeMode ? 'warn' : null,
|
||||
)}
|
||||
{navBtn(
|
||||
HOST_ID,
|
||||
t(locale, 'sidebarHost'),
|
||||
tr('sidebarHost'),
|
||||
<Cpu size={13} />,
|
||||
'nav-icon-host',
|
||||
t(locale, hostReady ? 'hostReady' : 'hostNeedsAction'),
|
||||
tr(hostReady ? 'hostReady' : 'hostNeedsAction'),
|
||||
hostReady ? 'running' : 'warn',
|
||||
)}
|
||||
{navBtn(
|
||||
SETTINGS_ID,
|
||||
tr('sidebarSettings'),
|
||||
<Settings size={13} />,
|
||||
'nav-icon-settings',
|
||||
'',
|
||||
null,
|
||||
)}
|
||||
{navBtn(
|
||||
ABOUT_ID,
|
||||
tr('settingsAbout'),
|
||||
<Info size={13} />,
|
||||
'nav-icon-about',
|
||||
'',
|
||||
null,
|
||||
undefined,
|
||||
updateDot,
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rg-slot-anchor" data-rg-slot="sidebar.footer" />
|
||||
</aside>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
import * as Menu from '@radix-ui/react-dropdown-menu'
|
||||
import { Check, PanelLeft } from 'lucide-react'
|
||||
import React, { useRef, useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale } from '../types'
|
||||
import { Tip } from '../ui/controls'
|
||||
import type { ThemeMode } from './AppSettingsPage'
|
||||
import { ABOUT_ID, HOST_ID, INSTALLERS_ID, PLUGINS_ID, SETTINGS_ID } from './Sidebar'
|
||||
import { VMAction } from './VMPage'
|
||||
|
||||
export const REPO_URL = 'https://github.com/Nwflower/Reims-Go'
|
||||
|
||||
const MENU_IDS = ['vm', 'view', 'help'] as const
|
||||
type MenuId = (typeof MENU_IDS)[number]
|
||||
|
||||
const HOVER_CLICK_GUARD_MS = 300
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
sidebarOpen: boolean
|
||||
onToggleSidebar: () => void
|
||||
logsOpen: boolean
|
||||
onToggleLogs: () => void
|
||||
themeMode: ThemeMode
|
||||
canLight?: boolean
|
||||
canDark?: boolean
|
||||
onThemeMode: (mode: ThemeMode) => void
|
||||
/** The selected VM and its current state, or null on the system pages. */
|
||||
vm: { name: string; state: string; busy: boolean } | null
|
||||
onNewVM: () => void
|
||||
onVMAction: (action: VMAction) => void
|
||||
onVMSettings: () => void
|
||||
onVMDelete: () => void
|
||||
onNavigate: (id: string) => void
|
||||
onOpenURL: (url: string) => void
|
||||
appVersion: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The title bar's left side: a sidebar toggle and a small menu bar (VM / View /
|
||||
* Help) that lists every command with its shortcut, so the keyboard paths are
|
||||
* discoverable and still reachable with the sidebar hidden. Once one menu is
|
||||
* open, hovering the next title switches to it, as in a native menu bar.
|
||||
*/
|
||||
export const TitleMenus: React.FC<Props> = ({
|
||||
locale, sidebarOpen, onToggleSidebar, logsOpen, onToggleLogs, themeMode, canLight = true, canDark = true, onThemeMode,
|
||||
vm, onNewVM, onVMAction, onVMSettings, onVMDelete, onNavigate, onOpenURL, appVersion,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [menuState, setMenuState] = useState<{ id: MenuId | null; switched: boolean }>({ id: null, switched: false })
|
||||
const openRef = useRef<MenuId | null>(null)
|
||||
const navRef = useRef<HTMLElement>(null)
|
||||
const hoverOpenedRef = useRef<{ id: MenuId; at: number } | null>(null)
|
||||
const openedByPointerRef = useRef(false)
|
||||
const pointerClosedRef = useRef(false)
|
||||
|
||||
const setActiveMenu = (next: MenuId | null, switched: boolean) => {
|
||||
openRef.current = next
|
||||
setMenuState({ id: next, switched })
|
||||
}
|
||||
|
||||
const running = vm?.state === 'running'
|
||||
const stopped = vm?.state === 'stopped'
|
||||
const transitioning = vm?.state === 'starting' || vm?.state === 'stopping'
|
||||
const vmBusy = !vm || vm.busy
|
||||
|
||||
const item = (label: string, onSelect: () => void, opts: { shortcut?: string; disabled?: boolean; danger?: boolean } = {}) => (
|
||||
<Menu.Item className={`menu-item${opts.danger ? ' danger' : ''}`} disabled={opts.disabled} onSelect={onSelect}>
|
||||
<span className="menu-label">{label}</span>
|
||||
{opts.shortcut && <kbd className="menu-shortcut">{opts.shortcut}</kbd>}
|
||||
</Menu.Item>
|
||||
)
|
||||
const check = (label: string, checked: boolean, onSelect: () => void, shortcut?: string) => (
|
||||
<Menu.CheckboxItem className="menu-item menu-item-check" checked={checked} onSelect={onSelect}>
|
||||
<Menu.ItemIndicator className="menu-check"><Check size={13} /></Menu.ItemIndicator>
|
||||
<span className="menu-label">{label}</span>
|
||||
{shortcut && <kbd className="menu-shortcut">{shortcut}</kbd>}
|
||||
</Menu.CheckboxItem>
|
||||
)
|
||||
|
||||
// `indented`: the menu has check marks, so every row shares their indent.
|
||||
const menu = (id: MenuId, label: string, content: React.ReactNode, indented = false) => (
|
||||
<Menu.Root
|
||||
modal={false}
|
||||
open={menuState.id === id}
|
||||
onOpenChange={(o) => {
|
||||
if (o) {
|
||||
hoverOpenedRef.current = null
|
||||
pointerClosedRef.current = false
|
||||
setActiveMenu(id, openRef.current !== null && openRef.current !== id)
|
||||
} else if (openRef.current === id) {
|
||||
hoverOpenedRef.current = null
|
||||
setActiveMenu(null, false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Menu.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="titlebar-menu"
|
||||
onPointerEnter={(e) => {
|
||||
if (e.pointerType !== 'mouse') return
|
||||
if (openRef.current && openRef.current !== id) {
|
||||
openedByPointerRef.current = true
|
||||
pointerClosedRef.current = false
|
||||
hoverOpenedRef.current = { id, at: performance.now() }
|
||||
setActiveMenu(id, true)
|
||||
}
|
||||
}}
|
||||
onPointerDown={(e) => {
|
||||
if (e.button === 0 && !e.ctrlKey) {
|
||||
openedByPointerRef.current = true
|
||||
}
|
||||
const h = hoverOpenedRef.current
|
||||
if (
|
||||
e.pointerType === 'mouse'
|
||||
&& e.button === 0
|
||||
&& !e.ctrlKey
|
||||
&& openRef.current === id
|
||||
&& h
|
||||
&& h.id === id
|
||||
&& performance.now() - h.at < HOVER_CLICK_GUARD_MS
|
||||
) {
|
||||
hoverOpenedRef.current = null
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
|
||||
openedByPointerRef.current = false
|
||||
}
|
||||
}}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Content
|
||||
className={`menu titlebar-menu-content${indented ? ' menu-indented' : ''}`}
|
||||
data-menubar-switch={menuState.id === id && menuState.switched ? 'true' : undefined}
|
||||
align="start"
|
||||
sideOffset={4}
|
||||
collisionPadding={8}
|
||||
onPointerDownCapture={(e) => {
|
||||
if (!(e.target as HTMLElement | null)?.closest('[data-disabled]')) {
|
||||
pointerClosedRef.current = true
|
||||
}
|
||||
}}
|
||||
onKeyDownCapture={() => {
|
||||
pointerClosedRef.current = false
|
||||
}}
|
||||
onPointerDownOutside={(e) => {
|
||||
const target = e.target as Node | null
|
||||
if (target && navRef.current?.contains(target)) {
|
||||
e.preventDefault()
|
||||
return
|
||||
}
|
||||
pointerClosedRef.current = true
|
||||
}}
|
||||
onCloseAutoFocus={(e) => {
|
||||
// Prevent Radix's deferred setTimeout(0) focus restoration from pulling focus
|
||||
// back to the old trigger when switching to a sibling menu (which triggers
|
||||
// onFocusOutside on the newly opened menu), when closed via pointer, or when
|
||||
// an item opens a modal dialog.
|
||||
if (
|
||||
openRef.current !== null
|
||||
|| openedByPointerRef.current
|
||||
|| pointerClosedRef.current
|
||||
|| document.querySelector('[role="dialog"], [role="alertdialog"]')
|
||||
) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return
|
||||
e.preventDefault()
|
||||
const isRTL = navRef.current ? getComputedStyle(navRef.current).direction === 'rtl' : false
|
||||
const delta = (e.key === 'ArrowRight') !== isRTL ? 1 : -1
|
||||
const idx = MENU_IDS.indexOf(id)
|
||||
const nextId = MENU_IDS[(idx + delta + MENU_IDS.length) % MENU_IDS.length]
|
||||
hoverOpenedRef.current = null
|
||||
openedByPointerRef.current = false
|
||||
pointerClosedRef.current = false
|
||||
setActiveMenu(nextId, true)
|
||||
}}
|
||||
>
|
||||
{content}
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu.Root>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="titlebar-left" onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<Tip label={tr(sidebarOpen ? 'hideSidebar' : 'showSidebar')} shortcut="Ctrl+B" disabled={menuState.id !== null}>
|
||||
<button
|
||||
type="button"
|
||||
className="titlebar-icon"
|
||||
aria-label={tr(sidebarOpen ? 'hideSidebar' : 'showSidebar')}
|
||||
aria-pressed={sidebarOpen}
|
||||
onClick={onToggleSidebar}
|
||||
>
|
||||
<PanelLeft size={16} aria-hidden="true" />
|
||||
</button>
|
||||
</Tip>
|
||||
<nav ref={navRef} className="titlebar-menus" aria-label={tr('menuBar')}>
|
||||
{menu('vm', tr('menuVM'), (
|
||||
<>
|
||||
{item(tr('newVMEllipsis'), onNewVM, { shortcut: 'Ctrl+N' })}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{running
|
||||
? item(tr('showWindow'), () => onVMAction('focus'), { shortcut: 'Ctrl+Enter', disabled: vmBusy })
|
||||
: item(tr('start'), () => onVMAction('start'), { shortcut: 'Ctrl+Enter', disabled: vmBusy || !stopped })}
|
||||
{item(tr('stop'), () => onVMAction('stop'), { disabled: vmBusy || !running })}
|
||||
{item(tr('restart'), () => onVMAction('restart'), { disabled: vmBusy || !running })}
|
||||
{item(tr('copyScreenshot'), () => onVMAction('screenshot'), { disabled: vmBusy || !running })}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{item(tr('settingsEllipsis'), onVMSettings, { shortcut: 'Ctrl+,', disabled: !vm })}
|
||||
{item(tr('openFolder'), () => onVMAction('openFolder'), { disabled: !vm })}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{item(tr('forceStop'), () => onVMAction('forceStop'), { danger: true, disabled: !vm || !(running || transitioning) })}
|
||||
{item(tr('deleteEllipsis'), onVMDelete, { danger: true, disabled: vmBusy || running || transitioning })}
|
||||
</>
|
||||
))}
|
||||
{menu('view', tr('menuView'), (
|
||||
<>
|
||||
{check(tr('sidebarLabel'), sidebarOpen, onToggleSidebar, 'Ctrl+B')}
|
||||
{check(tr('logButton'), logsOpen, onToggleLogs, 'Ctrl+L')}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
<Menu.Label className="menu-group-label">{tr('appearance')}</Menu.Label>
|
||||
<Menu.RadioGroup value={themeMode} onValueChange={(v) => onThemeMode(v as ThemeMode)}>
|
||||
{(['light', 'dark', 'system'] as const).map((m) => (
|
||||
<Menu.RadioItem
|
||||
key={m}
|
||||
className="menu-item menu-item-check"
|
||||
value={m}
|
||||
disabled={(m === 'light' && !canLight) || (m === 'dark' && !canDark) || (m === 'system' && (!canLight || !canDark))}
|
||||
>
|
||||
<Menu.ItemIndicator className="menu-check"><Check size={13} /></Menu.ItemIndicator>
|
||||
<span className="menu-label">{tr(m === 'light' ? 'themeLight' : m === 'dark' ? 'themeDark' : 'themeSystem')}</span>
|
||||
</Menu.RadioItem>
|
||||
))}
|
||||
</Menu.RadioGroup>
|
||||
<Menu.Separator className="menu-sep" />
|
||||
{item(tr('sidebarInstallers'), () => onNavigate(INSTALLERS_ID))}
|
||||
{item(tr('sidebarPlugins'), () => onNavigate(PLUGINS_ID))}
|
||||
{item(tr('sidebarHost'), () => onNavigate(HOST_ID))}
|
||||
{item(tr('sidebarSettings'), () => onNavigate(SETTINGS_ID))}
|
||||
</>
|
||||
), true)}
|
||||
{menu('help', tr('menuHelp'), (
|
||||
<>
|
||||
{item(tr('helpProjectPage'), () => onOpenURL(REPO_URL))}
|
||||
{item(tr('helpReportIssue'), () => onOpenURL(`${REPO_URL}/issues`))}
|
||||
{item(tr('helpCheckUpdate'), () => onNavigate(ABOUT_ID))}
|
||||
{item(tr('helpAbout'), () => onNavigate(ABOUT_ID))}
|
||||
<Menu.Separator className="menu-sep" />
|
||||
<Menu.Label className="menu-group-label">Reims-Go {appVersion}</Menu.Label>
|
||||
</>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { ArrowDownToLine, RotateCw, X } from 'lucide-react'
|
||||
import React from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale, Task } from '../types'
|
||||
import { Tip } from '../ui/controls'
|
||||
|
||||
/** Where an available update is: offered, downloading, verified and ready, or failed. */
|
||||
export type UpdatePhase = 'none' | 'available' | 'downloading' | 'ready' | 'failed'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
phase: UpdatePhase
|
||||
latest: string
|
||||
task?: Task | null
|
||||
/** Opens the About page with the full update details. */
|
||||
onOpen: () => void
|
||||
onDownload: () => void
|
||||
onCancel: () => void
|
||||
onInstall: () => void
|
||||
/** Hides the card until the next release ("remind me later"). */
|
||||
onDismiss: () => void
|
||||
}
|
||||
|
||||
/** Capsule card under the sidebar brand: the update's state and one action. */
|
||||
export const UpdateCapsule: React.FC<Props> = ({
|
||||
locale, phase, latest, task, onOpen, onDownload, onCancel, onInstall, onDismiss,
|
||||
}) => {
|
||||
if (phase === 'none') return null
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const pct = task && task.percent >= 0 ? Math.round(task.percent) : null
|
||||
|
||||
let title: string
|
||||
let action: React.ReactNode = null
|
||||
let close: React.ReactNode = null
|
||||
if (phase === 'downloading') {
|
||||
title = pct === null ? tr('updateCapsuleDownloading') : tr('updateCapsuleDownloadingPct', { p: pct })
|
||||
close = (
|
||||
<Tip label={tr('updateCancel')} side="right">
|
||||
<button type="button" className="update-capsule-x" aria-label={tr('updateCancel')} onClick={onCancel}><X size={12} /></button>
|
||||
</Tip>
|
||||
)
|
||||
} else if (phase === 'ready') {
|
||||
title = tr('updateCapsuleReady', { v: latest })
|
||||
action = <button type="button" className="update-capsule-btn is-primary" onClick={onInstall}>{tr('updateRestart')}</button>
|
||||
} else if (phase === 'failed') {
|
||||
title = tr('updateCapsuleFailed')
|
||||
action = (
|
||||
<button type="button" className="update-capsule-btn" onClick={onDownload}>
|
||||
<RotateCw size={11} aria-hidden="true" />{tr('updateRetry')}
|
||||
</button>
|
||||
)
|
||||
} else {
|
||||
title = tr('updateCapsuleAvailable', { v: latest })
|
||||
action = <button type="button" className="update-capsule-btn" onClick={onDownload}>{tr('updateDownload')}</button>
|
||||
close = (
|
||||
<Tip label={tr('updateLater')} side="right">
|
||||
<button type="button" className="update-capsule-x" aria-label={tr('updateLater')} onClick={onDismiss}><X size={12} /></button>
|
||||
</Tip>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`update-capsule is-${phase}`} role="status">
|
||||
<button type="button" className="update-capsule-main" onClick={onOpen} title={tr('updateCapsuleOpen')}>
|
||||
<span className="update-capsule-icon" aria-hidden="true"><ArrowDownToLine size={12} /></span>
|
||||
<span className="update-capsule-title">{title}</span>
|
||||
</button>
|
||||
{action}
|
||||
{close}
|
||||
{phase === 'downloading' && (
|
||||
<span className="update-capsule-bar" aria-hidden="true">
|
||||
<span className={pct === null ? 'is-indeterminate' : ''} style={pct === null ? undefined : { width: `${pct}%` }} />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import React, { useId } from 'react'
|
||||
|
||||
/**
|
||||
* A VM's icon: its macOS major version as frosted-glass digits over soft
|
||||
* folds of colour. Drawn here, with our own palettes; no Apple artwork.
|
||||
* The glass is the background itself, blurred and brightened inside the
|
||||
* digits' outline. Without a known version it shows the name's first letter.
|
||||
*/
|
||||
|
||||
type Palette = [string, string, string, string]
|
||||
|
||||
const PALETTES: Record<number, Palette> = {
|
||||
26: ['#f6e8cf', '#ebc8b4', '#a597d8', '#5450b4'], // sand → rose → lavender
|
||||
15: ['#ddf2e8', '#86ccb8', '#3f8ea3', '#22446e'], // mint → teal
|
||||
14: ['#ffe5d2', '#f5a48d', '#d6688f', '#6a3f8e'], // peach → coral → plum
|
||||
13: ['#fff1cc', '#f7b95e', '#df7140', '#83372b'], // cream → amber
|
||||
12: ['#e4ecff', '#91b1f4', '#5b70df', '#2f3592'], // ice → blue
|
||||
11: ['#e5f5ff', '#88c9ee', '#3f86d0', '#233f88'], // sky → ocean
|
||||
}
|
||||
const FUTURE: Palette[] = [
|
||||
['#f3e9ff', '#c6a8f0', '#7d6ad8', '#3c348f'],
|
||||
['#e8f7f0', '#9fd8c0', '#4f9fa6', '#2a4f73'],
|
||||
['#fff0e0', '#f3b98d', '#d77a74', '#6e3f72'],
|
||||
]
|
||||
const NEUTRAL: Palette = ['#eef0f4', '#c9ceda', '#8d95a9', '#4b5266']
|
||||
|
||||
function paletteFor(major: number | null): Palette {
|
||||
if (major === null) return NEUTRAL
|
||||
if (PALETTES[major]) return PALETTES[major]
|
||||
if (major > 26) return FUTURE[(major - 27) % FUTURE.length]
|
||||
return PALETTES[11]
|
||||
}
|
||||
|
||||
function initial(name: string): string {
|
||||
const ch = Array.from(name.trim().replace(/^macos[\s_-]*/i, ''))[0] ?? '?'
|
||||
return ch.toUpperCase()
|
||||
}
|
||||
|
||||
const SHAPES = {
|
||||
// width, height, font size, weight, glass blur, rim width, shadow blur;
|
||||
// glass: how much white the digits add; shade: how dark the drop under them.
|
||||
tile: { w: 64, h: 64, size: 38, weight: 700, blur: 2.4, rim: 2.2, shadow: 1.6, glass: 1.6, shade: 0.7 },
|
||||
screen: { w: 160, h: 100, size: 76, weight: 600, blur: 3.6, rim: 1.1, shadow: 2.4, glass: 1, shade: 0.36 },
|
||||
}
|
||||
|
||||
export const VersionArt: React.FC<{
|
||||
major: number | null
|
||||
name: string
|
||||
shape: 'tile' | 'screen'
|
||||
className?: string
|
||||
}> = ({ major, name, shape, className }) => {
|
||||
const id = useId().replace(/[^a-zA-Z0-9_-]/g, '')
|
||||
const p = paletteFor(major)
|
||||
const s = SHAPES[shape]
|
||||
const label = major !== null ? String(major) : initial(name)
|
||||
const size = label.length > 2 ? s.size * 0.72 : label.length === 1 ? s.size * 1.08 : s.size
|
||||
const text = {
|
||||
x: s.w / 2,
|
||||
y: s.h / 2 + size * 0.04,
|
||||
textAnchor: 'middle' as const,
|
||||
dominantBaseline: 'central' as const,
|
||||
fontSize: size,
|
||||
fontWeight: s.weight,
|
||||
letterSpacing: label.length > 1 ? -size * 0.04 : 0,
|
||||
style: { fontFamily: 'var(--font-sans)', fontVariantNumeric: 'tabular-nums' as const },
|
||||
}
|
||||
const sx = s.w / 100
|
||||
const sy = s.h / 100
|
||||
|
||||
return (
|
||||
<svg className={className} viewBox={`0 0 ${s.w} ${s.h}`} preserveAspectRatio="xMidYMid slice" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id={`${id}bg`} x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stopColor={p[0]} />
|
||||
<stop offset="0.38" stopColor={p[1]} />
|
||||
<stop offset="0.72" stopColor={p[2]} />
|
||||
<stop offset="1" stopColor={p[3]} />
|
||||
</linearGradient>
|
||||
<linearGradient id={`${id}hi`} x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stopColor="#ffffff" stopOpacity="0.62" />
|
||||
<stop offset="1" stopColor="#ffffff" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
<linearGradient id={`${id}sh`} x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stopColor={p[3]} stopOpacity="0" />
|
||||
<stop offset="1" stopColor={p[3]} stopOpacity="0.6" />
|
||||
</linearGradient>
|
||||
<linearGradient id={`${id}gl`} x1="0" y1="0" x2="0.4" y2="1">
|
||||
<stop offset="0" stopColor="#ffffff" stopOpacity={Math.min(1, 0.62 * s.glass)} />
|
||||
<stop offset="0.55" stopColor="#ffffff" stopOpacity={Math.min(1, 0.22 * s.glass)} />
|
||||
<stop offset="1" stopColor="#ffffff" stopOpacity={Math.min(1, 0.34 * s.glass)} />
|
||||
</linearGradient>
|
||||
<linearGradient id={`${id}rim`} x1="0" y1="0" x2="0.3" y2="1">
|
||||
<stop offset="0" stopColor="#ffffff" stopOpacity="0.98" />
|
||||
<stop offset="0.6" stopColor="#ffffff" stopOpacity="0.45" />
|
||||
<stop offset="1" stopColor="#ffffff" stopOpacity="0.8" />
|
||||
</linearGradient>
|
||||
<filter id={`${id}blur`} x="-20%" y="-20%" width="140%" height="140%">
|
||||
<feGaussianBlur stdDeviation={s.blur} />
|
||||
</filter>
|
||||
<filter id={`${id}soft`} x="-30%" y="-30%" width="160%" height="160%">
|
||||
<feGaussianBlur stdDeviation={s.shadow} />
|
||||
</filter>
|
||||
<clipPath id={`${id}clip`}>
|
||||
<text {...text}>{label}</text>
|
||||
</clipPath>
|
||||
<g id={`${id}scene`}>
|
||||
<rect width={s.w} height={s.h} fill={`url(#${id}bg)`} />
|
||||
<g transform={`scale(${sx} ${sy})`}>
|
||||
<path d="M-5 40 C16 14 40 60 70 32 S104 8 105 6 L105 -5 L-5 -5 Z" fill={`url(#${id}hi)`} />
|
||||
<path d="M-5 58 C24 30 54 80 105 36 L105 50 C56 90 26 46 -5 72 Z" fill="#ffffff" fillOpacity="0.2" />
|
||||
<path d="M-5 74 C22 50 52 94 80 64 S104 46 105 46 L105 105 L-5 105 Z" fill={`url(#${id}sh)`} />
|
||||
<path d="M-5 58 C24 30 54 80 105 36" fill="none" stroke="#ffffff" strokeOpacity="0.55" strokeWidth="0.7" vectorEffect="non-scaling-stroke" />
|
||||
</g>
|
||||
</g>
|
||||
</defs>
|
||||
|
||||
<use href={`#${id}scene`} />
|
||||
{/* A soft shade under the digits so they lift off the background. */}
|
||||
<text {...text} y={text.y + size * 0.05} fill={p[3]} fillOpacity={s.shade} filter={`url(#${id}soft)`}>{label}</text>
|
||||
{/* The glass: the scene blurred and brightened, seen through the digits. */}
|
||||
<g clipPath={`url(#${id}clip)`}>
|
||||
<use href={`#${id}scene`} filter={`url(#${id}blur)`} />
|
||||
<rect width={s.w} height={s.h} fill={`url(#${id}gl)`} />
|
||||
</g>
|
||||
<text {...text} fill="none" stroke={`url(#${id}rim)`} strokeWidth={s.rim} />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
|
||||
export const coreZh: Record<string, string> = {
|
||||
"affinityMenu": "处理器相关性…",
|
||||
"appearance": "外观",
|
||||
"backToEdit": "返回修改",
|
||||
"borderless": "无边框全屏",
|
||||
"cancel": "取消",
|
||||
"cancelCreate": "取消创建",
|
||||
"cancelQueue": "取消排队",
|
||||
"clear": "清空",
|
||||
"close": "关闭",
|
||||
"closeWindow": "关闭",
|
||||
"collapseLogs": "收起日志",
|
||||
"copy": "复制",
|
||||
"copyTechInfo": "复制技术信息",
|
||||
"delete": "删除…",
|
||||
"deleteEllipsis": "删除…",
|
||||
"displays": "显示器数量",
|
||||
"eject": "弹出安装盘",
|
||||
"emptyVMs": "还没有虚拟机",
|
||||
"errCopyDetails": "复制排障信息",
|
||||
"errRawDetailsToggle": "技术详情",
|
||||
"errorBoundaryReload": "重新加载界面",
|
||||
"errorBoundaryTitle": "界面遇到意外错误",
|
||||
"expandLogs": "展开日志",
|
||||
"failCreate": "{name} 创建失败",
|
||||
"failDownload": "下载失败",
|
||||
"failGeneric": "操作失败",
|
||||
"failRuntime": "运行时安装失败",
|
||||
"failSSH": "SSH 操作失败",
|
||||
"fontMissingFoDHint": "当前 Windows 缺少 {script} 可选字体包,部分原生弹窗字形可能回退;可在「Windows 设置 › 应用 › 可选功能」添加对应补充字体。",
|
||||
"footerDiskLabel": "磁盘",
|
||||
"footerDiskTip": "虚拟机数据目录:{dir}",
|
||||
"footerDiskValue": "可用 {gb} GB",
|
||||
"footerHostIssue": "虚拟化未就绪",
|
||||
"footerHostIssueTip": "打开「内核」页查看需要处理的项",
|
||||
"footerMemLabel": "内存",
|
||||
"footerMemTip": "系统内存:已用 {used} GB / 共 {total} GB(可用 {avail} GB)",
|
||||
"footerMemValue": "{used} / {total} GB",
|
||||
"footerRunningVMs": "{n, plural, other {# 台运行中}}",
|
||||
"forceStop": "强制关机",
|
||||
"gpuErrMissingExt": "缺少必需 Vulkan 扩展({ext}),请更新显卡驱动或改用 VMware SVGA",
|
||||
"gpuErrVulkanCpu": "软件 Vulkan 实现不满足 vGPU 加速要求,请改用 VMware SVGA",
|
||||
"gpuErrVulkanTooOld": "Vulkan {ver} 低于 1.3 最低要求,请更新显卡驱动或改用 VMware SVGA",
|
||||
"gpuWarnAmdLegacy": "AMD Vega/Polaris 在 Windows 闭源驱动下存在上游已知黑屏/设备丢失问题({ref});若有其他独显请改选独显,否则建议暂用 VMware SVGA",
|
||||
"gpuWarnAmdRdna2": "该 AMD 显卡在 Windows 下存在上游已知设备丢失风险({ref});若卡死黑屏请升级驱动或暂用 VMware SVGA",
|
||||
"guestKbdPinyin": "拼音键盘",
|
||||
"guestKbdUS": "美式键盘",
|
||||
"guestKbdUSRecommended": "美式键盘,推荐",
|
||||
"guestLang": "macOS 系统语言",
|
||||
"guestLangEnUS": "English (US)",
|
||||
"guestLangJaJP": "日本語",
|
||||
"guestLangKoKR": "한국어",
|
||||
"guestLangZhHansUS": "简体中文",
|
||||
"guestLangZhHantUS": "繁體中文",
|
||||
"helpAbout": "关于 Reims-Go",
|
||||
"helpCheckUpdate": "检查更新…",
|
||||
"helpProjectPage": "项目主页",
|
||||
"helpReportIssue": "报告问题",
|
||||
"hideSidebar": "隐藏侧边栏",
|
||||
"hidpiTipFullscreen": "窗口里的 macOS 只能 1x,文字会发虚;改用全屏可得到 HiDPI",
|
||||
"hidpiTipScale": "这块屏幕上 macOS 只能 1x,文字会发虚;把 Windows 缩放调到 150% 或以上可得到 HiDPI",
|
||||
"hidpiTipUnavailable": "这块屏幕像素不够,macOS 只能以 1x 显示",
|
||||
"hostDisplayHint": "主屏 {w}×{h},{scale}% 缩放",
|
||||
"hostNeedsAction": "需要处理",
|
||||
"hostReady": "就绪",
|
||||
"importRuntime": "导入运行时包",
|
||||
"installersDownloading": "下载中",
|
||||
"installersQueuedDesc": "等待当前下载完成",
|
||||
"installersRetry": "重试",
|
||||
"jumpLatest": "跳到最新",
|
||||
"localeAuto": "跟随系统",
|
||||
"localeAutoDetail": "当前:{tag}",
|
||||
"logActivity": "活动",
|
||||
"logButton": "日志",
|
||||
"logCopy": "复制日志",
|
||||
"logErrorsOnly": "仅错误/警告",
|
||||
"logQemu": "QEMU",
|
||||
"logSearchPlaceholder": "筛选日志…",
|
||||
"logSerial": "串口",
|
||||
"logsEmpty": "暂无日志",
|
||||
"macos.appsUtilitiesTerminal": "应用程序 › 实用工具 › 终端",
|
||||
"macos.diskUtility": "磁盘工具",
|
||||
"macos.erase": "抹掉",
|
||||
"macos.finder": "访达",
|
||||
"macos.guidPartitionMap": "GUID 分区图",
|
||||
"macos.otherSignInSetUpLater": "其他登录选项 › 稍后设置",
|
||||
"macos.recovery": "恢复",
|
||||
"macos.reinstallMacOS": "重新安装 macOS",
|
||||
"macos.setupAssistant": "设置助理",
|
||||
"macos.showAllDevices": "显示 › 显示所有设备",
|
||||
"macos.utilitiesTerminal": "实用工具 › 终端",
|
||||
"macos.volume": "宗卷",
|
||||
"maximize": "最大化",
|
||||
"menuBar": "菜单栏",
|
||||
"menuHelp": "帮助",
|
||||
"menuVM": "虚拟机",
|
||||
"menuView": "视图",
|
||||
"minimize": "最小化",
|
||||
"more": "更多",
|
||||
"newVM": "新建虚拟机",
|
||||
"newVMEllipsis": "新建虚拟机…",
|
||||
"noRuntimeAlert": "先在「内核」导入运行时包",
|
||||
"off": "关闭",
|
||||
"on": "开启",
|
||||
"openFolder": "打开所在文件夹",
|
||||
"panelLoadFailed": "面板加载失败",
|
||||
"pauseDownload": "暂停下载",
|
||||
"pluginSafeModeShort": "安全模式",
|
||||
"refresh": "刷新",
|
||||
"resLooksLike": "看起来像 {w} × {h}",
|
||||
"resizeLogPanel": "拖动调整日志高度",
|
||||
"resolution": "分辨率",
|
||||
"restart": "重启",
|
||||
"safeModeBanner": "安全模式已启用:已跳过全部第三方插件并回退至内置默认主题",
|
||||
"safeModeManagePlugins": "管理插件",
|
||||
"save": "保存",
|
||||
"settings": "设置",
|
||||
"settingsAbout": "关于",
|
||||
"settingsEllipsis": "设置…",
|
||||
"shortcutBarFullscreen": "切换全屏",
|
||||
"shortcutBarRelease": "释放键盘和鼠标",
|
||||
"showSidebar": "显示侧边栏",
|
||||
"sidebarHost": "内核",
|
||||
"sidebarInstallers": "安装包",
|
||||
"sidebarItemAria": "{label},{state}",
|
||||
"sidebarLabel": "侧边栏",
|
||||
"sidebarPlugins": "插件",
|
||||
"sidebarSettings": "设置",
|
||||
"sidebarSystem": "系统",
|
||||
"sidebarVMs": "虚拟机",
|
||||
"start": "启动",
|
||||
"starting": "启动中",
|
||||
"stop": "关机",
|
||||
"taskAppUpdate": "下载 Reims-Go {v}",
|
||||
"taskCreate": "创建 {name}",
|
||||
"taskDownload": "下载 macOS {v}",
|
||||
"taskRecoveryDownload": "正在为 {name} 拉取并挂载在线恢复镜像",
|
||||
"taskRuntime": "安装运行时 {v}",
|
||||
"tasksRunning": "{n, plural, other {# 个任务进行中}}",
|
||||
"themeDark": "深色",
|
||||
"themeLight": "浅色",
|
||||
"themeSwitchDark": "切换深色外观",
|
||||
"themeSwitchLight": "切换浅色外观",
|
||||
"themeSystem": "跟随系统",
|
||||
"toastAffinityApplied": "处理器相关性已应用({count} 个逻辑处理器 · {mask})",
|
||||
"toastAffinitySaved": "处理器相关性已保存,下次启动时生效",
|
||||
"toastBorderlessNextStart": "已保存全屏启动偏好,重启虚拟机后生效",
|
||||
"toastBorderlessUpdated": "已保存全屏启动偏好",
|
||||
"toastCopied": "已复制",
|
||||
"toastCreateCanceled": "已取消创建 {name}",
|
||||
"toastCreateCanceledPartial": "已下载部分已保留,可继续下载或返回修改",
|
||||
"toastCreated": "{name} 已创建",
|
||||
"toastDownloadPaused": "已暂停,再次下载会从中断处继续",
|
||||
"toastInstallerReady": "macOS {v} 安装包已就绪",
|
||||
"toastQueueCanceled": "已取消排队",
|
||||
"toastRuntimeReady": "运行时 {v} 已安装",
|
||||
"toastSSHConfigWritten": "已写入 Host {alias}",
|
||||
"toastSSHUserSaved": "已保存 SSH 用户名",
|
||||
"toastSaved": "已保存",
|
||||
"toastSavedNextStart": "已保存,下次启动生效",
|
||||
"updateCancel": "取消下载",
|
||||
"updateCapsuleAvailable": "{v} 可用",
|
||||
"updateCapsuleDownloading": "正在下载更新",
|
||||
"updateCapsuleDownloadingPct": "正在下载 {p}%",
|
||||
"updateCapsuleFailed": "更新下载失败",
|
||||
"updateCapsuleOpen": "查看更新详情",
|
||||
"updateCapsuleReady": "{v} 已就绪",
|
||||
"updateConfirmBody": "{n, plural, other {有 # 台虚拟机正在运行。它们不会被关闭,但 Reims-Go 重启的几秒内,剪贴板、共享文件夹和输入法桥接会暂停,之后自动恢复。}}",
|
||||
"updateConfirmTitle": "重启并安装 {v}",
|
||||
"updateConfirmWin10": "这台 Windows 10 宿主依赖冷重启补偿:这些虚拟机里的 macOS 下次重启后不会自动开机,需要手动启动一次。",
|
||||
"updateDoneToast": "已更新到 {v}",
|
||||
"updateDownload": "下载",
|
||||
"updateFailed": "更新失败",
|
||||
"updateLater": "以后再提醒我",
|
||||
"updateRestart": "重启并安装",
|
||||
"updateRetry": "重试",
|
||||
"uptimeHoursMinutes": "{h} 小时 {m} 分",
|
||||
"uptimeMinutesSeconds": "{m} 分 {s} 秒",
|
||||
"uptimeSeconds": "{s} 秒",
|
||||
"viewLogs": "查看日志",
|
||||
}
|
||||
|
||||
export const coreEn: Record<string, string> = {
|
||||
"affinityMenu": "Processor Affinity…",
|
||||
"appearance": "Appearance",
|
||||
"backToEdit": "Edit and retry",
|
||||
"borderless": "Borderless full screen",
|
||||
"cancel": "Cancel",
|
||||
"cancelCreate": "Cancel creation",
|
||||
"cancelQueue": "Cancel queued download",
|
||||
"clear": "Clear",
|
||||
"close": "Close",
|
||||
"closeWindow": "Close",
|
||||
"collapseLogs": "Hide logs",
|
||||
"copy": "Copy",
|
||||
"copyTechInfo": "Copy technical details",
|
||||
"delete": "Delete…",
|
||||
"deleteEllipsis": "Delete…",
|
||||
"displays": "Displays",
|
||||
"eject": "Eject installer",
|
||||
"emptyVMs": "No virtual machines",
|
||||
"errCopyDetails": "Copy diagnostic details",
|
||||
"errRawDetailsToggle": "Technical details",
|
||||
"errorBoundaryReload": "Reload window",
|
||||
"errorBoundaryTitle": "Something went wrong in the window",
|
||||
"expandLogs": "Show logs",
|
||||
"failCreate": "Couldn’t create {name}",
|
||||
"failDownload": "Download failed",
|
||||
"failGeneric": "Something went wrong",
|
||||
"failRuntime": "Runtime install failed",
|
||||
"failSSH": "SSH action failed",
|
||||
"fontMissingFoDHint": "Windows optional {script} fonts are not installed; native overlay text may use fallback glyphs. Install them under Windows Settings › Apps › Optional features.",
|
||||
"footerDiskLabel": "Disk",
|
||||
"footerDiskTip": "VM data folder: {dir}",
|
||||
"footerDiskValue": "{gb} GB free",
|
||||
"footerHostIssue": "Virtualization not ready",
|
||||
"footerHostIssueTip": "Open the Engine page to see what needs attention",
|
||||
"footerMemLabel": "Memory",
|
||||
"footerMemTip": "System memory: {used} GB used / {total} GB total ({avail} GB free)",
|
||||
"footerMemValue": "{used} / {total} GB",
|
||||
"footerRunningVMs": "{n, plural, one {# running} other {# running}}",
|
||||
"forceStop": "Force shut down",
|
||||
"gpuErrMissingExt": "Missing required Vulkan extensions ({ext}); update GPU drivers or use VMware SVGA",
|
||||
"gpuErrVulkanCpu": "Software Vulkan implementation cannot accelerate vGPU; use VMware SVGA",
|
||||
"gpuErrVulkanTooOld": "Vulkan {ver} is below the required 1.3 floor; update GPU drivers or use VMware SVGA",
|
||||
"gpuWarnAmdLegacy": "AMD Vega/Polaris on Windows hits known upstream black-screen/device-loss issues ({ref}); prefer another discrete GPU or use VMware SVGA for now",
|
||||
"gpuWarnAmdRdna2": "This AMD GPU hits known Windows device-loss issues upstream ({ref}); update drivers or use VMware SVGA if it freezes",
|
||||
"guestKbdPinyin": "Pinyin",
|
||||
"guestKbdUS": "US Keyboard",
|
||||
"guestKbdUSRecommended": "US Keyboard, recommended",
|
||||
"guestLang": "macOS system language",
|
||||
"guestLangEnUS": "English (US)",
|
||||
"guestLangJaJP": "Japanese",
|
||||
"guestLangKoKR": "Korean",
|
||||
"guestLangZhHansUS": "Simplified Chinese",
|
||||
"guestLangZhHantUS": "Traditional Chinese",
|
||||
"helpAbout": "About Reims-Go",
|
||||
"helpCheckUpdate": "Check for Updates…",
|
||||
"helpProjectPage": "Project Page",
|
||||
"helpReportIssue": "Report an Issue",
|
||||
"hideSidebar": "Hide sidebar",
|
||||
"hidpiTipFullscreen": "In a window macOS runs at 1x with rough text; full screen gives HiDPI",
|
||||
"hidpiTipScale": "macOS runs at 1x on this screen, with rough text; Windows scaling at 150% or more gives HiDPI",
|
||||
"hidpiTipUnavailable": "This screen has too few pixels; macOS runs at 1x",
|
||||
"hostDisplayHint": "Main display {w}×{h} at {scale}%",
|
||||
"hostNeedsAction": "Needs attention",
|
||||
"hostReady": "Ready",
|
||||
"importRuntime": "Import runtime",
|
||||
"installersDownloading": "Downloading",
|
||||
"installersQueuedDesc": "Waiting for current download to finish",
|
||||
"installersRetry": "Retry",
|
||||
"jumpLatest": "Jump to latest",
|
||||
"localeAuto": "System Default",
|
||||
"localeAutoDetail": "Current: {tag}",
|
||||
"logActivity": "Activity",
|
||||
"logButton": "Logs",
|
||||
"logCopy": "Copy logs",
|
||||
"logErrorsOnly": "Errors \u0026 warnings",
|
||||
"logQemu": "QEMU",
|
||||
"logSearchPlaceholder": "Filter logs…",
|
||||
"logSerial": "Serial",
|
||||
"logsEmpty": "No logs yet",
|
||||
"macos.appsUtilitiesTerminal": "Applications › Utilities › Terminal",
|
||||
"macos.diskUtility": "Disk Utility",
|
||||
"macos.erase": "Erase",
|
||||
"macos.finder": "Finder",
|
||||
"macos.guidPartitionMap": "GUID Partition Map",
|
||||
"macos.otherSignInSetUpLater": "Other Sign-In Options › Set Up Later",
|
||||
"macos.recovery": "Recovery",
|
||||
"macos.reinstallMacOS": "Reinstall macOS",
|
||||
"macos.setupAssistant": "Setup Assistant",
|
||||
"macos.showAllDevices": "View › Show All Devices",
|
||||
"macos.utilitiesTerminal": "Utilities › Terminal",
|
||||
"macos.volume": "Volume",
|
||||
"maximize": "Maximize",
|
||||
"menuBar": "Menu bar",
|
||||
"menuHelp": "Help",
|
||||
"menuVM": "VM",
|
||||
"menuView": "View",
|
||||
"minimize": "Minimize",
|
||||
"more": "More",
|
||||
"newVM": "New virtual machine",
|
||||
"newVMEllipsis": "New Virtual Machine…",
|
||||
"noRuntimeAlert": "Import a runtime under Engine first",
|
||||
"off": "Off",
|
||||
"on": "On",
|
||||
"openFolder": "Show in folder",
|
||||
"panelLoadFailed": "Panel failed to load",
|
||||
"pauseDownload": "Pause download",
|
||||
"pluginSafeModeShort": "Safe mode",
|
||||
"refresh": "Refresh",
|
||||
"resLooksLike": "Looks like {w} × {h}",
|
||||
"resizeLogPanel": "Drag to resize log panel",
|
||||
"resolution": "Resolution",
|
||||
"restart": "Restart",
|
||||
"safeModeBanner": "Safe mode is active: all third-party plugins are disabled and the built-in theme is restored",
|
||||
"safeModeManagePlugins": "Manage plugins",
|
||||
"save": "Save",
|
||||
"settings": "Settings",
|
||||
"settingsAbout": "About",
|
||||
"settingsEllipsis": "Settings…",
|
||||
"shortcutBarFullscreen": "Toggle full screen",
|
||||
"shortcutBarRelease": "Release keyboard and mouse",
|
||||
"showSidebar": "Show sidebar",
|
||||
"sidebarHost": "Engine",
|
||||
"sidebarInstallers": "Installers",
|
||||
"sidebarItemAria": "{label}, {state}",
|
||||
"sidebarLabel": "Sidebar",
|
||||
"sidebarPlugins": "Plugins",
|
||||
"sidebarSettings": "Settings",
|
||||
"sidebarSystem": "System",
|
||||
"sidebarVMs": "Virtual machines",
|
||||
"start": "Start",
|
||||
"starting": "Starting",
|
||||
"stop": "Shut down",
|
||||
"taskAppUpdate": "Downloading Reims-Go {v}",
|
||||
"taskCreate": "Creating {name}",
|
||||
"taskDownload": "Downloading macOS {v}",
|
||||
"taskRecoveryDownload": "Downloading online recovery for {name}",
|
||||
"taskRuntime": "Installing runtime {v}",
|
||||
"tasksRunning": "{n, plural, one {# task running} other {# tasks running}}",
|
||||
"themeDark": "Dark",
|
||||
"themeLight": "Light",
|
||||
"themeSwitchDark": "Switch to dark appearance",
|
||||
"themeSwitchLight": "Switch to light appearance",
|
||||
"themeSystem": "System",
|
||||
"toastAffinityApplied": "Processor affinity applied ({count} logical CPUs · {mask})",
|
||||
"toastAffinitySaved": "Processor affinity saved for next start",
|
||||
"toastBorderlessNextStart": "Fullscreen launch saved — applies on next restart",
|
||||
"toastBorderlessUpdated": "Fullscreen launch preference saved",
|
||||
"toastCopied": "Copied",
|
||||
"toastCreateCanceled": "Canceled creating {name}",
|
||||
"toastCreateCanceledPartial": "Downloaded progress is kept; resume anytime or edit and retry",
|
||||
"toastCreated": "{name} created",
|
||||
"toastDownloadPaused": "Paused — downloading again continues where it stopped",
|
||||
"toastInstallerReady": "macOS {v} installer ready",
|
||||
"toastQueueCanceled": "Removed from download queue",
|
||||
"toastRuntimeReady": "Runtime {v} installed",
|
||||
"toastSSHConfigWritten": "Wrote Host {alias}",
|
||||
"toastSSHUserSaved": "Saved SSH username",
|
||||
"toastSaved": "Saved",
|
||||
"toastSavedNextStart": "Saved — applies on next start",
|
||||
"updateCancel": "Cancel download",
|
||||
"updateCapsuleAvailable": "{v} available",
|
||||
"updateCapsuleDownloading": "Downloading update",
|
||||
"updateCapsuleDownloadingPct": "Downloading {p}%",
|
||||
"updateCapsuleFailed": "Update download failed",
|
||||
"updateCapsuleOpen": "Update details",
|
||||
"updateCapsuleReady": "{v} ready",
|
||||
"updateConfirmBody": "{n, plural, one {# VM is running. It will keep running, while clipboard, shared folders and the input bridge pause for a few seconds until Reims-Go is back.} other {# VMs are running. They will keep running, while clipboard, shared folders and the input bridge pause for a few seconds until Reims-Go is back.}}",
|
||||
"updateConfirmTitle": "Restart to install {v}",
|
||||
"updateConfirmWin10": "This Windows 10 host relies on the cold-reboot workaround: the next time macOS in these VMs restarts, start the VM again by hand.",
|
||||
"updateDoneToast": "Updated to {v}",
|
||||
"updateDownload": "Download",
|
||||
"updateFailed": "Update failed",
|
||||
"updateLater": "Remind me later",
|
||||
"updateRestart": "Restart to install",
|
||||
"updateRetry": "Retry",
|
||||
"uptimeHoursMinutes": "{h}h {m}m",
|
||||
"uptimeMinutesSeconds": "{m}m {s}s",
|
||||
"uptimeSeconds": "{s}s",
|
||||
"viewLogs": "View logs",
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
import { registerBuiltinDomain } from '../runtime'
|
||||
|
||||
export const pluginsZh: Record<string, string> = {
|
||||
"pluginAccentSeed": "强调种子色",
|
||||
"pluginActiveCount": "已启用 {active} / {total}",
|
||||
"pluginActiveTheme": "当前主题包",
|
||||
"pluginAlwaysOn": "核心组件,始终启用",
|
||||
"pluginApproveCheckbox": "我已核对来源与权限,确认启用此插件",
|
||||
"pluginApproveConfirm": "确认启用",
|
||||
"pluginApproveL3Warn": "此插件为原生可执行程序(L3 Sidecar),能够以当前 Windows 账户身份执行任意操作",
|
||||
"pluginApproveTitle": "高危权限确认",
|
||||
"pluginBuiltinSection": "内置插件",
|
||||
"pluginColorSchemes": "配色方案",
|
||||
"pluginColorSchemesHint": "修改种子色派生整套界面色阶",
|
||||
"pluginDeleteScheme": "删除方案",
|
||||
"pluginDone": "完成",
|
||||
"pluginEntryPath": "入口路径",
|
||||
"pluginExternalSection": "已安装插件",
|
||||
"pluginFailDeleteScheme": "删除配色方案失败",
|
||||
"pluginFailEnable": "启用插件失败",
|
||||
"pluginFailImport": "导入插件包失败",
|
||||
"pluginFailLinkDev": "链接开发插件失败",
|
||||
"pluginFailLoad": "加载插件列表失败",
|
||||
"pluginFailLoadSettings": "读取插件设置失败",
|
||||
"pluginFailMarketInstall": "安装市场插件失败",
|
||||
"pluginFailMarketLoad": "加载插件市场失败",
|
||||
"pluginFailReadLog": "读取插件日志失败",
|
||||
"pluginFailRemove": "卸载插件失败",
|
||||
"pluginFailSaveScheme": "保存配色方案失败",
|
||||
"pluginFailSaveSettings": "保存插件设置失败",
|
||||
"pluginFailScan": "插件安全扫描失败",
|
||||
"pluginFailSwitchTheme": "切换主题失败",
|
||||
"pluginFailToggle": "切换插件状态失败",
|
||||
"pluginGlobalSettings": "插件全局设置",
|
||||
"pluginHighRiskNotice": "包含高危权限,启用前需确认",
|
||||
"pluginImportBtn": "导入插件",
|
||||
"pluginImportTitle": "导入本地插件包 (.zip)",
|
||||
"pluginInUse": "使用中不可卸载",
|
||||
"pluginLinkDevBtn": "链接插件开发目录",
|
||||
"pluginLinkDevTitle": "链接本地开发插件目录",
|
||||
"pluginLogEmpty": "暂无日志记录",
|
||||
"pluginLogTitle": "{id} — 日志",
|
||||
"pluginMarketEmpty": "当前插件市场暂无可用条目,你仍可导入本地 .zip 插件包或配置自定义市场索引地址",
|
||||
"pluginMarketIncludeAlpha": "显示 Alpha 测试通道",
|
||||
"pluginMarketIncompatible": "不兼容",
|
||||
"pluginMarketInstall": "安装",
|
||||
"pluginMarketInstalled": "已安装",
|
||||
"pluginMarketKindAll": "全部",
|
||||
"pluginMarketKindDriver": "客体驱动",
|
||||
"pluginMarketKindLocale": "语言包",
|
||||
"pluginMarketKindTheme": "主题",
|
||||
"pluginMarketKindTool": "工具",
|
||||
"pluginMarketRefresh": "刷新索引",
|
||||
"pluginMarketSearchPlaceholder": "搜索市场插件、作者或标签",
|
||||
"pluginMarketSourceCache": "本地缓存",
|
||||
"pluginMarketSourceFallback": "离线回退",
|
||||
"pluginMarketSourceRemote": "在线索引",
|
||||
"pluginMarketStaleBanner": "远程插件市场暂不可达,当前显示本地缓存或内置回退索引",
|
||||
"pluginMarketUpdate": "更新至 v{version}",
|
||||
"pluginMarketWithdrawn": "已撤回",
|
||||
"pluginMarketWithdrawnInstalledWarn": "已安装插件 {id} 已从市场撤回:{reason}",
|
||||
"pluginMarketWithdrawnInstead": "建议改用:{target}",
|
||||
"pluginNewScheme": "新建配色方案",
|
||||
"pluginPanelsSection": "插件面板",
|
||||
"pluginPermCount": "{count, plural, other {# 项权限}}",
|
||||
"pluginPermissionsLabel": "权限:{list}",
|
||||
"pluginPublisherLicense": "发布者 / 许可",
|
||||
"pluginRemove": "卸载",
|
||||
"pluginRequestedPerms": "请求权限",
|
||||
"pluginScanAdvisoriesSection": "提示信息与可执行文件",
|
||||
"pluginScanArchiveTitle": "导入前安全检查",
|
||||
"pluginScanBlockedBtn": "已拦截,无法安装",
|
||||
"pluginScanCapabilitiesSection": "能力与权限说明",
|
||||
"pluginScanHardSection": "硬性拦截项(禁止安装)",
|
||||
"pluginScanInspect": "安全扫描",
|
||||
"pluginScanInstallConfirm": "确认导入安装",
|
||||
"pluginScanLoading": "正在扫描插件包…",
|
||||
"pluginScanModalTitle": "插件静态安全报告",
|
||||
"pluginScanMoreItems": "另有 {count} 项已折叠",
|
||||
"pluginSchemeDefault": "默认",
|
||||
"pluginSchemeModalTitle": "新建配色方案",
|
||||
"pluginSchemeName": "方案名称",
|
||||
"pluginSchemePlaceholder": "如:柔蓝",
|
||||
"pluginSearchEmpty": "没有匹配的插件",
|
||||
"pluginSearchPlaceholder": "筛选插件",
|
||||
"pluginSettings": "插件设置",
|
||||
"pluginStateDegraded": "已降级",
|
||||
"pluginStateFailed": "故障",
|
||||
"pluginStatePending": "等待依赖",
|
||||
"pluginSurfaceSeed": "画布种子色(可选)",
|
||||
"pluginTabInstalled": "已安装",
|
||||
"pluginTabMarket": "插件市场",
|
||||
"pluginThemeEmptyHint": "导入本地主题包(.zip)后可在此切换外观与配色方案",
|
||||
"pluginThemeHint": "同一时刻仅启用一个主题包,停用后自动回退默认主题",
|
||||
"pluginThemePackLabel": "主题包",
|
||||
"pluginThemeSafeModeHint": "安全模式下固定使用内置默认主题",
|
||||
"pluginThemeSection": "主题扩展",
|
||||
"pluginTrustCommunity": "社区",
|
||||
"pluginTrustDev": "开发",
|
||||
"pluginTrustOfficial": "官方",
|
||||
"pluginTrustVerified": "已审核",
|
||||
"pluginViewLog": "查看日志",
|
||||
}
|
||||
|
||||
export const pluginsEn: Record<string, string> = {
|
||||
"pluginAccentSeed": "Accent seed",
|
||||
"pluginActiveCount": "{active} / {total} active",
|
||||
"pluginActiveTheme": "Active theme pack",
|
||||
"pluginAlwaysOn": "Core component, always on",
|
||||
"pluginApproveCheckbox": "I have reviewed the source and permissions and confirm enabling this plugin",
|
||||
"pluginApproveConfirm": "Confirm enable",
|
||||
"pluginApproveL3Warn": "This plugin runs native code (L3 Sidecar) and can perform arbitrary actions as your Windows user",
|
||||
"pluginApproveTitle": "Approve high-risk permissions",
|
||||
"pluginBuiltinSection": "Built-in plugins",
|
||||
"pluginColorSchemes": "Color schemes",
|
||||
"pluginColorSchemesHint": "Seed colors derive the full surface, text, and accent ramp",
|
||||
"pluginDeleteScheme": "Delete scheme",
|
||||
"pluginDone": "Done",
|
||||
"pluginEntryPath": "Entry path",
|
||||
"pluginExternalSection": "Installed plugins",
|
||||
"pluginFailDeleteScheme": "Couldn’t delete color scheme",
|
||||
"pluginFailEnable": "Couldn’t enable plugin",
|
||||
"pluginFailImport": "Couldn’t import plugin package",
|
||||
"pluginFailLinkDev": "Couldn’t link dev plugin",
|
||||
"pluginFailLoad": "Couldn’t load plugins",
|
||||
"pluginFailLoadSettings": "Couldn’t load plugin settings",
|
||||
"pluginFailMarketInstall": "Couldn’t install plugin from market",
|
||||
"pluginFailMarketLoad": "Couldn’t load plugin market",
|
||||
"pluginFailReadLog": "Couldn’t read plugin log",
|
||||
"pluginFailRemove": "Couldn’t remove plugin",
|
||||
"pluginFailSaveScheme": "Couldn’t save color scheme",
|
||||
"pluginFailSaveSettings": "Couldn’t save plugin settings",
|
||||
"pluginFailScan": "Couldn’t scan plugin",
|
||||
"pluginFailSwitchTheme": "Couldn’t switch theme",
|
||||
"pluginFailToggle": "Couldn’t toggle plugin",
|
||||
"pluginGlobalSettings": "Plugin settings",
|
||||
"pluginHighRiskNotice": "Contains high-risk permissions; approval required before enabling",
|
||||
"pluginImportBtn": "Import plugin",
|
||||
"pluginImportTitle": "Import plugin package (.zip)",
|
||||
"pluginInUse": "In use",
|
||||
"pluginLinkDevBtn": "Link plugin dev folder",
|
||||
"pluginLinkDevTitle": "Link local dev plugin folder",
|
||||
"pluginLogEmpty": "No log entries yet",
|
||||
"pluginLogTitle": "{id} — Log",
|
||||
"pluginMarketEmpty": "No plugins available in the market index yet. You can still import local .zip packages or configure a custom index URL.",
|
||||
"pluginMarketIncludeAlpha": "Include alpha channel",
|
||||
"pluginMarketIncompatible": "Incompatible",
|
||||
"pluginMarketInstall": "Install",
|
||||
"pluginMarketInstalled": "Installed",
|
||||
"pluginMarketKindAll": "All",
|
||||
"pluginMarketKindDriver": "Drivers",
|
||||
"pluginMarketKindLocale": "Languages",
|
||||
"pluginMarketKindTheme": "Themes",
|
||||
"pluginMarketKindTool": "Tools",
|
||||
"pluginMarketRefresh": "Refresh index",
|
||||
"pluginMarketSearchPlaceholder": "Search market plugins, publishers, or tags",
|
||||
"pluginMarketSourceCache": "Cached index",
|
||||
"pluginMarketSourceFallback": "Offline fallback",
|
||||
"pluginMarketSourceRemote": "Online index",
|
||||
"pluginMarketStaleBanner": "Remote market index is unreachable; showing cached or offline fallback data",
|
||||
"pluginMarketUpdate": "Update to v{version}",
|
||||
"pluginMarketWithdrawn": "Withdrawn",
|
||||
"pluginMarketWithdrawnInstalledWarn": "Installed plugin {id} has been withdrawn: {reason}",
|
||||
"pluginMarketWithdrawnInstead": "Recommended replacement: {target}",
|
||||
"pluginNewScheme": "New scheme",
|
||||
"pluginPanelsSection": "Plugin panels",
|
||||
"pluginPermCount": "{count, plural, one {# permission} other {# permissions}}",
|
||||
"pluginPermissionsLabel": "Permissions: {list}",
|
||||
"pluginPublisherLicense": "Publisher / License",
|
||||
"pluginRemove": "Remove",
|
||||
"pluginRequestedPerms": "Requested permissions",
|
||||
"pluginScanAdvisoriesSection": "Advisories \u0026 executables",
|
||||
"pluginScanArchiveTitle": "Pre-install security check",
|
||||
"pluginScanBlockedBtn": "Blocked — cannot install",
|
||||
"pluginScanCapabilitiesSection": "Capabilities \u0026 privileges",
|
||||
"pluginScanHardSection": "Hard blockers (install refused)",
|
||||
"pluginScanInspect": "Security scan",
|
||||
"pluginScanInstallConfirm": "Proceed with install",
|
||||
"pluginScanLoading": "Scanning plugin package…",
|
||||
"pluginScanModalTitle": "Plugin security report",
|
||||
"pluginScanMoreItems": "...and {count} more",
|
||||
"pluginSchemeDefault": "Default",
|
||||
"pluginSchemeModalTitle": "New color scheme",
|
||||
"pluginSchemeName": "Scheme name",
|
||||
"pluginSchemePlaceholder": "e.g. Soft Blue",
|
||||
"pluginSearchEmpty": "No matching plugins",
|
||||
"pluginSearchPlaceholder": "Filter plugins",
|
||||
"pluginSettings": "Plugin settings",
|
||||
"pluginStateDegraded": "Degraded",
|
||||
"pluginStateFailed": "Failed",
|
||||
"pluginStatePending": "Pending",
|
||||
"pluginSurfaceSeed": "Surface seed (optional)",
|
||||
"pluginTabInstalled": "Installed",
|
||||
"pluginTabMarket": "Market",
|
||||
"pluginThemeEmptyHint": "Import a local theme package (.zip) to switch visual themes and color schemes",
|
||||
"pluginThemeHint": "One active theme pack at a time; disabling falls back to the built-in default",
|
||||
"pluginThemePackLabel": "Theme pack",
|
||||
"pluginThemeSafeModeHint": "Built-in default theme is enforced in safe mode",
|
||||
"pluginThemeSection": "Theme extensions",
|
||||
"pluginTrustCommunity": "Community",
|
||||
"pluginTrustDev": "Dev",
|
||||
"pluginTrustOfficial": "Official",
|
||||
"pluginTrustVerified": "Verified",
|
||||
"pluginViewLog": "View log",
|
||||
}
|
||||
|
||||
registerBuiltinDomain(pluginsZh, pluginsEn)
|
||||
@@ -0,0 +1,634 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
import { registerBuiltinDomain } from '../runtime'
|
||||
|
||||
export const settingsZh: Record<string, string> = {
|
||||
"aboutCommunity": "社区与支持",
|
||||
"aboutCopyQQGroup": "复制群号",
|
||||
"aboutIssueSub": "遇到问题或有功能建议,在 GitHub 提交 Issue",
|
||||
"aboutJoinQQGroup": "加入群聊",
|
||||
"aboutLicensesOpenGitHub": "在 GitHub 查看",
|
||||
"aboutLicensesSub": "Apache-2.0 协议与第三方开源组件声明(离线可查)",
|
||||
"aboutLicensesTabLicense": "Apache-2.0 协议",
|
||||
"aboutLicensesTabNotice": "第三方声明",
|
||||
"aboutLicensesTitle": "开源许可与声明",
|
||||
"aboutLicensesView": "查看",
|
||||
"aboutProjectSub": "GitHub 上的源码、发布版本与使用文档",
|
||||
"aboutQQGroup": "QQ 交流群",
|
||||
"aboutQQGroupSub": "点击直接拉起 QQ 加群,交流使用与问题反馈",
|
||||
"aboutQQLaunchFailed": "未能拉起 QQ,可复制群号手动搜索加入",
|
||||
"aboutQQNotInstalled": "未安装 QQ",
|
||||
"aboutQQNotInstalledSub": "未检测到本地 QQ,可复制群号手动搜索加入",
|
||||
"aboutTagline": "在 Windows 上开一台带 GPU 加速的 macOS 虚拟机——免编译,开箱即用。",
|
||||
"activate": "使用",
|
||||
"affinityApplyNow": "立即应用",
|
||||
"affinityAvoidLPE": "避开 LP-E",
|
||||
"affinityConfigure": "配置…",
|
||||
"affinityEcoQoS": "禁用 Windows 效率模式节流 (EcoQoS)",
|
||||
"affinityEcoQoSDesc": "防止 Windows 11 在窗口失焦或后台运行时把 QEMU 线程压缩到 2 个低功耗核心",
|
||||
"affinityExcludeCPU0": "排除 CPU 0",
|
||||
"affinityLiveMask": "Windows 当前生效:{mask}({count} 线程)",
|
||||
"affinityModeAll": "所有处理器",
|
||||
"affinityModeAllHint": "允许 Windows 将 QEMU 调度到全部宿主机逻辑处理器。",
|
||||
"affinityModeAuto": "自动",
|
||||
"affinityModeAutoHint": "跟随全局策略,在混合大小核处理器上自动避开超售与低功耗核。",
|
||||
"affinityModeCustom": "自定义",
|
||||
"affinityModeCustomHint": "勾选允许运行 QEMU 的逻辑处理器,等价于 Windows 任务管理器的处理器相关性。",
|
||||
"affinityModeNonLPE": "P + E 核",
|
||||
"affinityModeNonLPEHint": "在性能核与能效核(P + E)上运行,仅排除慢速低功耗核(LP-E)。",
|
||||
"affinityModePCores": "仅 P 核",
|
||||
"affinityModePCoresHint": "仅在性能核(P-Core)上运行,减少大小核混调引起的抖动。",
|
||||
"affinityNeedOne": "请至少勾选 1 个逻辑处理器",
|
||||
"affinityOnlyPCores": "仅 P 核",
|
||||
"affinityOversubWarn": "当前只勾选了 {selected} 个逻辑处理器,少于虚拟机分配的 {vcpus} 个 vCPU,可能导致明显卡顿。",
|
||||
"affinityPhysicalOnly": "仅物理核",
|
||||
"affinityRowDesc": "指定虚拟机在哪些核心上运行,立即生效",
|
||||
"affinitySave": "保存",
|
||||
"affinitySelectAll": "所有处理器",
|
||||
"affinitySelectedSummary": "已选 {selected} / {total} 个逻辑处理器 · 掩码 {mask}",
|
||||
"affinitySubtitleRunning": "运行中(PID {pid})· {vcpus} vCPU · 修改后立即生效",
|
||||
"affinitySubtitleStopped": "已停止 · {vcpus} vCPU · 下次启动时自动生效",
|
||||
"affinitySummaryAll": "所有处理器({count} 线程)",
|
||||
"affinitySummaryAuto": "自动({eff} · {count} 线程)",
|
||||
"affinitySummaryCustom": "自定义({count} 线程 · {mask})",
|
||||
"affinitySummaryNonLPE": "P + E 核({count} 线程 · {mask})",
|
||||
"affinitySummaryPCores": "仅 P 核({count} 线程 · {mask})",
|
||||
"affinityTitle": "处理器核心",
|
||||
"appCheckUpdate": "检查更新",
|
||||
"appDownloadUpdate": "前往下载",
|
||||
"appUpToDate": "已是最新",
|
||||
"appUpdateAvailable": "发现新版本 {v}(稳定版)",
|
||||
"appUpdateAvailableAlpha": "发现新版本 {v}(Alpha 测试版)",
|
||||
"appUpdateAvailableDev": "发现新版本 {v}(Dev 滚动版)",
|
||||
"appUpdateChannelAlpha": "Alpha",
|
||||
"appUpdateChannelDev": "Dev",
|
||||
"appUpdateChannelStable": "稳定版",
|
||||
"appUpdateChannelSubKeepOld": "接收 {channel} 预发布版本;启动时不删除旧版程序与已下载安装包,方便随时回退",
|
||||
"appUpdateChannelSubStable": "仅接收经过验证的正式稳定版本",
|
||||
"appUpdateChannelTitle": "更新通道",
|
||||
"appUpdateLookupFailed": "暂时无法连接 GitHub 检查更新",
|
||||
"appVersionTitle": "客户端版本",
|
||||
"appliesNextStart": "下次启动生效",
|
||||
"audioBackendAuto": "自动",
|
||||
"audioBackendDesc": "「静音」保留 macOS 的声卡但不出声,适合排查音频问题",
|
||||
"audioBackendDsound": "DirectSound",
|
||||
"audioBackendNone": "静音",
|
||||
"audioBackendTitle": "声音输出",
|
||||
"audioDesc": "在 Windows 上播放 macOS 的声音",
|
||||
"audioDisabledReason": "请先开启音频",
|
||||
"audioTroubleshootNote": "有爆音时,把 Windows 声音格式设为 48000 Hz;麦克风没声音时,检查 Windows「隐私 › 麦克风」权限",
|
||||
"autoPinPCores": "启动后绑定到性能核",
|
||||
"back": "上一步",
|
||||
"captureInput": "点击窗口时捕获键鼠",
|
||||
"captureInputHint": "开启后 ⌘Tab 等快捷键交给 macOS;关闭时 Win 键和 Alt+Tab 留给 Windows",
|
||||
"catAdvanced": "高级",
|
||||
"catAudio": "音频",
|
||||
"catCompute": "处理器与内存",
|
||||
"catGeneral": "通用",
|
||||
"catGraphics": "图形与显示器",
|
||||
"catInput": "键盘与指针",
|
||||
"catInputAudio": "输入与音频",
|
||||
"catLogs": "日志",
|
||||
"catNetwork": "网络",
|
||||
"catStorage": "存储",
|
||||
"catStorageNet": "存储与网络",
|
||||
"choose": "浏览…",
|
||||
"configured": "已配置",
|
||||
"coresUnit": "核",
|
||||
"cpuOverHint": "留给 Windows 的线程不足 2 个,电脑可能变卡",
|
||||
"cpuRecHint": "推荐 {rec} 核 · 本机共 {n} 线程",
|
||||
"diskCompactAction": "立即回收",
|
||||
"diskCompactDesc": "把 macOS 里已删除文件占用的空间还给 Windows,过程中需要与当前占用差不多的空闲空间",
|
||||
"diskCompactDone": "已回收 {reclaimed}({before} → {after})",
|
||||
"diskCompactNoGain": "没有可回收的空间",
|
||||
"diskCompactQcow2Only": "这块磁盘不支持回收空间",
|
||||
"diskCompactTitle": "回收空间",
|
||||
"diskController": "磁盘接口",
|
||||
"diskControllerInstallHint": "装机时保持 SATA,装完弹出安装盘再改 NVMe",
|
||||
"diskControllerNvmeHint": "NVMe 读写更快",
|
||||
"diskControllerNvmeReadyHint": "NVMe 速度快,也兼容恢复模式,推荐",
|
||||
"diskControllerVirtioHint": "VirtIO 开销更低,仍属实验性;遇到问题请改回 NVMe",
|
||||
"diskControllerWarn": "切换前先弹出安装盘",
|
||||
"diskMode": "使用方式",
|
||||
"diskModeCopy": "复制一份,不改动原盘",
|
||||
"diskModeInPlace": "直接使用原盘",
|
||||
"diskResizeAction": "扩容",
|
||||
"diskResizeDesc": "只能增大。扩大后在 macOS 终端运行提示的命令,新空间才能使用",
|
||||
"diskResizeDone": "已扩大到 {size}。在 macOS 终端运行:",
|
||||
"diskResizeTitle": "扩大磁盘",
|
||||
"diskSize": "磁盘上限",
|
||||
"diskSizeHint": "按实际占用增长",
|
||||
"diskUsageSummary": "已占用 {actual},上限 {virtual}",
|
||||
"displayGroup": "显示器",
|
||||
"driveShareMaster": "共享 Windows 盘符",
|
||||
"driveShareMasterDesc": "在 macOS 访达中显示所选磁盘,立即生效",
|
||||
"driveShareNeedsTools": "需要 Guest Tools {version} 以上:重启虚拟机,再在 macOS 中重新运行安装命令",
|
||||
"driveShareNoDrives": "没有可共享的内部固定磁盘",
|
||||
"driveShareReadOnly": "只读:macOS 可以打开和复制,不能修改",
|
||||
"driveShareSystem": "系统盘,含个人文件和登录信息,请谨慎共享",
|
||||
"driveShareTitle": "Windows 盘符共享",
|
||||
"effectImmediate": "立即生效",
|
||||
"effectNextStart": "下次启动生效",
|
||||
"enableAudio": "音频",
|
||||
"enableLogs": "记录图形与串口日志",
|
||||
"enableNetwork": "网络(NAT)",
|
||||
"enableWHPX": "启用",
|
||||
"extraArgs": "额外 QEMU 参数",
|
||||
"extraArgsDesc": "原样追加到 QEMU 命令行",
|
||||
"failAffinity": "设置处理器相关性失败",
|
||||
"footerDisk": "磁盘可用 {gb} GB",
|
||||
"footerMem": "内存 {pct}%",
|
||||
"footerMemAvail": "可用 {avail} GB",
|
||||
"fullscreenLaunch": "无边框全屏启动",
|
||||
"fullscreenLaunchHint": "启动后直接进入无边框全屏",
|
||||
"gpuAutoOption": "自动(优先独显)",
|
||||
"gpuAutoSub": "将使用 {name}",
|
||||
"gpuAutoTitle": "自动",
|
||||
"gpuCompatUnsupported": "不支持加速",
|
||||
"gpuCompatWarn": "已知兼容风险",
|
||||
"gpuCustomIcd": "自定义 Vulkan ICD",
|
||||
"gpuDiscrete": "独显",
|
||||
"gpuIntegrated": "核显",
|
||||
"gpuKindDiscrete": "独立显卡",
|
||||
"gpuKindIntegrated": "集成显卡",
|
||||
"gpuRecommended": "推荐",
|
||||
"gpuSelect": "显卡",
|
||||
"gpuSvgaReason": "VMware SVGA 不使用宿主显卡",
|
||||
"gpuSwitchSvga": "改用 VMware SVGA",
|
||||
"gpuUnavailableHint": "没有找到能加速的显卡,可改用 VMware SVGA",
|
||||
"gpuUnknown": "未知",
|
||||
"gpuVirtual": "虚拟",
|
||||
"graphicsBackend": "虚拟显卡",
|
||||
"graphicsReimsDesc": "用宿主显卡加速 Metal,推荐",
|
||||
"graphicsReimsShort": "Reims vGPU",
|
||||
"graphicsRunningReason": "关机后才能切换",
|
||||
"graphicsSvgaDesc": "没有硬件加速,只用于排障",
|
||||
"graphicsSvgaShort": "VMware SVGA",
|
||||
"groupGraphics": "图形",
|
||||
"groupMacOS": "macOS",
|
||||
"groupPerformance": "性能",
|
||||
"groupQemu": "QEMU",
|
||||
"gtInstallCmd": "安装命令",
|
||||
"guestLangHint": "恢复模式、设置助理和登录界面使用的语言;选美式键盘,在终端输命令不易出错",
|
||||
"guestLangSettingsHint": "恢复模式、设置助理和登录界面使用的语言",
|
||||
"guestLangShort": "系统语言",
|
||||
"guestMemory": "分配内存",
|
||||
"guestToolsConnected": "已连接",
|
||||
"guestToolsPreventSleepSub": "闲置时让 macOS 保持唤醒,立即生效",
|
||||
"guestToolsReady": "已配置",
|
||||
"hidpiPresetBadge": "HiDPI",
|
||||
"hostAudioInput": "Windows 麦克风",
|
||||
"hostAudioMissingIn": "没有检测到麦克风,macOS 录不到声音",
|
||||
"hostAudioMissingOut": "没有检测到扬声器或耳机,虚拟机将没有声音",
|
||||
"hostAudioOutput": "Windows 播放设备",
|
||||
"hostCPU": "处理器",
|
||||
"hostCoresThreads": "{c} 核 · {t} 线程",
|
||||
"hostDataRoot": "数据目录",
|
||||
"hostDisk": "可用空间",
|
||||
"hostDisplayPrimary": "主屏",
|
||||
"hostDisplays": "物理显示器",
|
||||
"hostGPUs": "显卡",
|
||||
"hostRAM": "内存",
|
||||
"hostRAMAvail": "可用 {n} GB",
|
||||
"hostRAMTotal": "共 {n} GB",
|
||||
"hostRuntime": "运行时",
|
||||
"hostWHPX": "Windows 虚拟机监控程序平台",
|
||||
"installersAvailable": "Apple 提供的版本",
|
||||
"installersCreateVM": "新建虚拟机",
|
||||
"installersDelete": "删除",
|
||||
"installersDeleteConfirm": "确认删除",
|
||||
"installersDownload": "下载",
|
||||
"installersDownloaded": "已下载",
|
||||
"installersDownloadingForVM": "为 {vm} 下载中",
|
||||
"installersDownloadingPct": "下载中 {p}%",
|
||||
"installersEmpty": "还没有下载任何安装包",
|
||||
"installersHint": "下载好的安装包可以重复用来新建虚拟机",
|
||||
"installersKindOffline": "离线完整包",
|
||||
"installersKindOnline": "在线恢复镜像",
|
||||
"installersLatest": "最新",
|
||||
"installersNoSpace": "空间不足:需要约 {need} GB,可用 {free} GB",
|
||||
"installersOlder": "{count, plural, other {# 个旧版本}}",
|
||||
"installersPartial": "未下载完",
|
||||
"installersQueued": "排队中",
|
||||
"installersQueuedForVM": "为 {vm} 排队中",
|
||||
"installersResume": "继续下载",
|
||||
"installersTitle": "安装包",
|
||||
"installersWaitingVM": "{vm} 等待使用",
|
||||
"kernelIrqchipAuto": "自动",
|
||||
"kernelIrqchipLabel": "中断加速",
|
||||
"kernelIrqchipOff": "关闭",
|
||||
"kernelIrqchipOn": "开启",
|
||||
"language": "语言",
|
||||
"languageSub": "内置简体中文与英语,可通过插件扩展更多语言",
|
||||
"logLevel": "日志级别",
|
||||
"logLevelCustom": "自定义",
|
||||
"logLevelDesc": "排查问题时再调高",
|
||||
"macosVersion": "macOS 版本",
|
||||
"memCommitHint": "Windows 还能分配 {avail} GB · 推荐 {rec} GB",
|
||||
"memOverHint": "超过推荐值,启动时可能分配失败",
|
||||
"memRecHint": "推荐 {rec} GB · 本机共 {n} GB",
|
||||
"minimizeToTray": "关闭窗口时最小化到系统托盘",
|
||||
"minimizeToTraySub": "关闭窗口后剪贴板和共享文件夹继续工作,可从托盘启停虚拟机",
|
||||
"multiDisplayHint": "{n, plural, other {检测到 # 块显示器,排列方式在 macOS「系统设置 › 显示器」里调整}}",
|
||||
"navHasIssue": "这一页有需要修改的项",
|
||||
"networkDesc": "通过 Windows 的网络连接上网",
|
||||
"networkOfflineHint": "离线安装默认关闭;看到「设置助理」后退出恢复模式并重启即可联网",
|
||||
"networkTitle": "网络",
|
||||
"next": "下一步",
|
||||
"noChanges": "没有更改",
|
||||
"offlineListFailed": "无法读取 Apple 的版本列表",
|
||||
"opencore": "OpenCore",
|
||||
"optAuto": "已自动开启",
|
||||
"optAvailable": "可用",
|
||||
"optExperimental": "实验性",
|
||||
"optKernelIrqchipExp": "实验性:开启可能更快,启动卡住就改回「自动」(Win10 上自动为关闭)",
|
||||
"optKernelIrqchipNestedErr": "当前 Windows 不支持({code}),「自动」会保持关闭",
|
||||
"optKernelIrqchipRec": "由 Windows 直接处理中断,磁盘和多核更流畅。「自动」即开启",
|
||||
"optKernelIrqchipUnavailable": "当前电脑不支持",
|
||||
"optKernelIrqchipWin10NoPatch": "Win10 上需要先更新运行时才能开启",
|
||||
"optPCoreSub": "仅调度到性能核({detail}),减少卡顿",
|
||||
"optPCoreUnavailable": "当前处理器无大小核架构,无需开启",
|
||||
"optRecommended": "推荐",
|
||||
"optSchedBackground": "后台服务",
|
||||
"optSchedNowBackground": "当前为「后台服务」,适合虚拟机在后台运行(影响整个 Windows)",
|
||||
"optSchedNowPrograms": "当前为「程序优先」,虚拟机在后台时可能变慢,建议改为「后台服务」(影响整个 Windows)",
|
||||
"optSchedOpen": "更改…",
|
||||
"optSchedPrograms": "程序优先",
|
||||
"optSchedSub": "选「后台服务」,虚拟机在后台时更稳定(影响整个 Windows)",
|
||||
"optSchedTitle": "Windows 处理器调度",
|
||||
"optUnavailable": "不可用",
|
||||
"pendingChanges": "{n, plural, other {# 项更改,下次启动生效}}",
|
||||
"platformReadonly": "机型、序列号等平台身份信息不在界面显示",
|
||||
"recommendedBadge": "推荐",
|
||||
"resCustom": "自定义",
|
||||
"resCustomSub": "宽 × 高",
|
||||
"resFullscreen": "全屏",
|
||||
"resInvalid": "格式为 宽x高,例如 2560x1600",
|
||||
"resetAll": "全部还原",
|
||||
"resetField": "还原为当前值",
|
||||
"runtimeDelete": "删除运行时",
|
||||
"runtimeDeleteConfirm": "确认删除",
|
||||
"runtimeDeleted": "已删除运行时 {commit}",
|
||||
"secondsUnit": "秒",
|
||||
"settingsAppearance": "外观与语言",
|
||||
"settingsGeneral": "常规",
|
||||
"settingsTitle": "{name}",
|
||||
"sourceDisk": "已有虚拟磁盘(.qcow2)",
|
||||
"sourceInstaller": "本地安装器镜像(.img / .dmg)",
|
||||
"sshForward": "SSH 端口转发",
|
||||
"sshNeedsNetwork": "需要先开启网络",
|
||||
"sshOffDesc": "从 Windows 用 SSH 登录 macOS",
|
||||
"sshPort": "SSH 转发端口",
|
||||
"startAfterCreate": "创建后立即启动",
|
||||
"statsCPU": "QEMU CPU",
|
||||
"statsDisk": "磁盘占用",
|
||||
"statsDiskSub": "实际 {actual} / 上限 {virtual}",
|
||||
"statsMemory": "宿主机内存",
|
||||
"statsUptime": "运行时长",
|
||||
"stopBeforeDiskOp": "关机后才能操作",
|
||||
"stopTimeout": "关机等待时间",
|
||||
"stopTimeoutHint": "0 表示一直等待",
|
||||
"storageBreakdownTitle": "空间分布",
|
||||
"storageInstallers": "安装包",
|
||||
"storageRuntimes": "Reims-Go",
|
||||
"storageVMs": "虚拟机文件",
|
||||
"themeLabel": "外观",
|
||||
"themePluginDarkDisabled": "默认主题插件已停用,深色与跟随系统外观不可用",
|
||||
"themePluginLightDisabled": "当前主题仅支持深色外观",
|
||||
"updateDownloadInstall": "下载并安装",
|
||||
"updateDownloadingSub": "正在下载 {v}",
|
||||
"updateFailedSub": "下载或校验失败,可以重试",
|
||||
"updateReadySub": "{v} 已下载并通过校验,重启 Reims-Go 即可完成更新",
|
||||
"updateReleaseNotes": "发行说明",
|
||||
"useDefault": "恢复默认",
|
||||
"vcpus": "虚拟处理器",
|
||||
"vmDir": "存放目录",
|
||||
"vmName": "名称",
|
||||
"welcomeCheckHost": "先完成内核环境配置 →",
|
||||
"welcomeSub": "选择系统来源、分配核数与显卡,几步完成配置",
|
||||
"welcomeTitle": "创建第一台 macOS 虚拟机",
|
||||
"whpxMissing": "启用后需要重启 Windows",
|
||||
"whpxMissingShort": "未启用",
|
||||
"whpxNoHv": "在 BIOS 中开启 Intel VT-x / AMD-V",
|
||||
"whpxNoHvShort": "未激活",
|
||||
"whpxReady": "就绪",
|
||||
"whpxTitle": "WHPX",
|
||||
"whpxUnsupported": "当前不是 Windows 宿主",
|
||||
"whpxUnsupportedShort": "不支持",
|
||||
}
|
||||
|
||||
export const settingsEn: Record<string, string> = {
|
||||
"aboutCommunity": "Community \u0026 support",
|
||||
"aboutCopyQQGroup": "Copy group ID",
|
||||
"aboutIssueSub": "Report a problem or suggest a feature on GitHub",
|
||||
"aboutJoinQQGroup": "Join group",
|
||||
"aboutLicensesOpenGitHub": "View on GitHub",
|
||||
"aboutLicensesSub": "Apache-2.0 license and third-party notices (available offline)",
|
||||
"aboutLicensesTabLicense": "Apache-2.0 License",
|
||||
"aboutLicensesTabNotice": "Third-party notices",
|
||||
"aboutLicensesTitle": "Open-source licenses",
|
||||
"aboutLicensesView": "View",
|
||||
"aboutProjectSub": "Source code, releases and docs on GitHub",
|
||||
"aboutQQGroup": "QQ Group",
|
||||
"aboutQQGroupSub": "Launch QQ directly to join for community support and feedback",
|
||||
"aboutQQLaunchFailed": "Couldn’t launch QQ — copy the group ID to join manually",
|
||||
"aboutQQNotInstalled": "QQ not installed",
|
||||
"aboutQQNotInstalledSub": "Local QQ wasn’t detected — copy the group ID to join manually",
|
||||
"aboutTagline": "Run a GPU-accelerated macOS virtual machine on Windows — prebuilt, ready out of the box.",
|
||||
"activate": "Use",
|
||||
"affinityApplyNow": "Apply Now",
|
||||
"affinityAvoidLPE": "Exclude LP-E",
|
||||
"affinityConfigure": "Configure…",
|
||||
"affinityEcoQoS": "Disable Windows EcoQoS power throttling",
|
||||
"affinityEcoQoSDesc": "Prevents Windows 11 from parking unfocused/background QEMU threads onto 2 low-power cores",
|
||||
"affinityExcludeCPU0": "Exclude CPU 0",
|
||||
"affinityLiveMask": "Active in Windows: {mask} ({count} threads)",
|
||||
"affinityModeAll": "All CPUs",
|
||||
"affinityModeAllHint": "Allows Windows to schedule QEMU across all host logical processors.",
|
||||
"affinityModeAuto": "Auto",
|
||||
"affinityModeAutoHint": "Follows global policy and avoids oversubscription and slow LP-E cores on hybrid CPUs.",
|
||||
"affinityModeCustom": "Custom",
|
||||
"affinityModeCustomHint": "Check the host logical CPUs allowed to run QEMU — identical to Windows Task Manager affinity.",
|
||||
"affinityModeNonLPE": "P + E",
|
||||
"affinityModeNonLPEHint": "Runs QEMU on P + E cores while excluding slow SoC LP-E cores.",
|
||||
"affinityModePCores": "P-Cores",
|
||||
"affinityModePCoresHint": "Restricts QEMU to performance cores (P-cores) to minimize scheduling jitter.",
|
||||
"affinityNeedOne": "Select at least 1 logical CPU",
|
||||
"affinityOnlyPCores": "P-cores only",
|
||||
"affinityOversubWarn": "Only {selected} logical CPUs selected for {vcpus} guest vCPUs; this may cause noticeable stalls.",
|
||||
"affinityPhysicalOnly": "Physical cores only",
|
||||
"affinityRowDesc": "Choose which cores the VM runs on. Applies immediately",
|
||||
"affinitySave": "Save",
|
||||
"affinitySelectAll": "All CPUs",
|
||||
"affinitySelectedSummary": "{selected} / {total} logical CPUs selected · Mask {mask}",
|
||||
"affinitySubtitleRunning": "Running (PID {pid}) · {vcpus} vCPU · Applies immediately",
|
||||
"affinitySubtitleStopped": "Stopped · {vcpus} vCPU · Applied on next start",
|
||||
"affinitySummaryAll": "All CPUs ({count}T)",
|
||||
"affinitySummaryAuto": "Auto ({eff} · {count}T)",
|
||||
"affinitySummaryCustom": "Custom ({count}T · {mask})",
|
||||
"affinitySummaryNonLPE": "P + E ({count}T · {mask})",
|
||||
"affinitySummaryPCores": "P-Cores ({count}T · {mask})",
|
||||
"affinityTitle": "CPU cores",
|
||||
"appCheckUpdate": "Check for updates",
|
||||
"appDownloadUpdate": "Download",
|
||||
"appUpToDate": "Up to date",
|
||||
"appUpdateAvailable": "New stable release {v} available",
|
||||
"appUpdateAvailableAlpha": "New alpha release {v} available",
|
||||
"appUpdateAvailableDev": "New dev build {v} available",
|
||||
"appUpdateChannelAlpha": "Alpha",
|
||||
"appUpdateChannelDev": "Dev",
|
||||
"appUpdateChannelStable": "Stable",
|
||||
"appUpdateChannelSubKeepOld": "Receive {channel} prereleases; previous executable and downloaded installers are kept on startup for rollback",
|
||||
"appUpdateChannelSubStable": "Receive verified stable releases only",
|
||||
"appUpdateChannelTitle": "Update channel",
|
||||
"appUpdateLookupFailed": "Couldn’t check GitHub for updates",
|
||||
"appVersionTitle": "App version",
|
||||
"appliesNextStart": "Applies on next start",
|
||||
"audioBackendAuto": "Auto",
|
||||
"audioBackendDesc": "Silent keeps the macOS sound card but plays nothing; useful for troubleshooting",
|
||||
"audioBackendDsound": "DirectSound",
|
||||
"audioBackendNone": "Silent",
|
||||
"audioBackendTitle": "Sound output",
|
||||
"audioDesc": "Plays macOS sound through Windows",
|
||||
"audioDisabledReason": "Enable audio first",
|
||||
"audioTroubleshootNote": "If audio crackles, set the Windows sound format to 48000 Hz. If the mic is silent, check Windows Privacy › Microphone",
|
||||
"autoPinPCores": "Pin to performance cores on start",
|
||||
"back": "Back",
|
||||
"captureInput": "Capture keyboard and mouse on click",
|
||||
"captureInputHint": "When on, shortcuts like ⌘Tab go to macOS; when off, Win and Alt+Tab stay with Windows",
|
||||
"catAdvanced": "Advanced",
|
||||
"catAudio": "Audio",
|
||||
"catCompute": "CPU \u0026 Memory",
|
||||
"catGeneral": "General",
|
||||
"catGraphics": "Graphics \u0026 displays",
|
||||
"catInput": "Keyboard \u0026 pointer",
|
||||
"catInputAudio": "Input \u0026 Audio",
|
||||
"catLogs": "Logs",
|
||||
"catNetwork": "Network",
|
||||
"catStorage": "Storage",
|
||||
"catStorageNet": "Storage \u0026 Network",
|
||||
"choose": "Browse…",
|
||||
"configured": "Configured",
|
||||
"coresUnit": "cores",
|
||||
"cpuOverHint": "Leaves Windows fewer than 2 threads; your PC may slow down",
|
||||
"cpuRecHint": "{rec} cores recommended · this PC has {n} threads",
|
||||
"diskCompactAction": "Reclaim now",
|
||||
"diskCompactDesc": "Gives space from files deleted in macOS back to Windows. Needs about as much free space as the disk uses now",
|
||||
"diskCompactDone": "Reclaimed {reclaimed} ({before} → {after})",
|
||||
"diskCompactNoGain": "Nothing to reclaim",
|
||||
"diskCompactQcow2Only": "This disk does not support reclaiming space",
|
||||
"diskCompactTitle": "Reclaim space",
|
||||
"diskController": "Disk interface",
|
||||
"diskControllerInstallHint": "Keep SATA while installing; switch to NVMe after ejecting the installer",
|
||||
"diskControllerNvmeHint": "NVMe is faster",
|
||||
"diskControllerNvmeReadyHint": "Fast and works with Recovery. Recommended",
|
||||
"diskControllerVirtioHint": "Lower overhead but experimental; switch back to NVMe if you hit problems",
|
||||
"diskControllerWarn": "Eject the installer before switching",
|
||||
"diskMode": "Use disk as",
|
||||
"diskModeCopy": "A copy — original untouched",
|
||||
"diskModeInPlace": "In place",
|
||||
"diskResizeAction": "Expand",
|
||||
"diskResizeDesc": "Grow only. Afterwards, run the command shown in macOS Terminal to use the new space",
|
||||
"diskResizeDone": "Expanded to {size}. Run this in macOS Terminal:",
|
||||
"diskResizeTitle": "Expand disk",
|
||||
"diskSize": "Disk size",
|
||||
"diskSizeHint": "Grows as it fills",
|
||||
"diskUsageSummary": "{actual} used of {virtual}",
|
||||
"displayGroup": "Displays",
|
||||
"driveShareMaster": "Share Windows drives",
|
||||
"driveShareMasterDesc": "Shows the selected drives in macOS Finder. Applies immediately",
|
||||
"driveShareNeedsTools": "Needs Guest Tools {version} or later: restart the VM, then run the install command in macOS again",
|
||||
"driveShareNoDrives": "No internal fixed disks are available to share",
|
||||
"driveShareReadOnly": "Read-only: macOS can open and copy files but not change them",
|
||||
"driveShareSystem": "System drive with personal files and sign-in data; share with care",
|
||||
"driveShareTitle": "Windows drive sharing",
|
||||
"effectImmediate": "Immediate",
|
||||
"effectNextStart": "Next start",
|
||||
"enableAudio": "Audio",
|
||||
"enableLogs": "Keep graphics and serial logs",
|
||||
"enableNetwork": "Network (NAT)",
|
||||
"enableWHPX": "Enable",
|
||||
"extraArgs": "Extra QEMU arguments",
|
||||
"extraArgsDesc": "Appended to the QEMU command line as is",
|
||||
"failAffinity": "Could not update processor affinity",
|
||||
"footerDisk": "Disk {gb} GB free",
|
||||
"footerMem": "Memory {pct}%",
|
||||
"footerMemAvail": "{avail} GB free",
|
||||
"fullscreenLaunch": "Launch borderless fullscreen",
|
||||
"fullscreenLaunchHint": "Opens macOS in borderless full screen",
|
||||
"gpuAutoOption": "Automatic (prefers discrete)",
|
||||
"gpuAutoSub": "Will use {name}",
|
||||
"gpuAutoTitle": "Automatic",
|
||||
"gpuCompatUnsupported": "Unsupported",
|
||||
"gpuCompatWarn": "Known issue",
|
||||
"gpuCustomIcd": "Custom Vulkan ICD",
|
||||
"gpuDiscrete": "Discrete",
|
||||
"gpuIntegrated": "Integrated",
|
||||
"gpuKindDiscrete": "Discrete",
|
||||
"gpuKindIntegrated": "Integrated",
|
||||
"gpuRecommended": "Recommended",
|
||||
"gpuSelect": "GPU",
|
||||
"gpuSvgaReason": "VMware SVGA does not use the host GPU",
|
||||
"gpuSwitchSvga": "Use VMware SVGA",
|
||||
"gpuUnavailableHint": "No GPU available for acceleration; try VMware SVGA",
|
||||
"gpuUnknown": "Unknown",
|
||||
"gpuVirtual": "Virtual",
|
||||
"graphicsBackend": "Virtual graphics",
|
||||
"graphicsReimsDesc": "Accelerates Metal on the host GPU. Recommended",
|
||||
"graphicsReimsShort": "Reims vGPU",
|
||||
"graphicsRunningReason": "Shut down the VM to change this",
|
||||
"graphicsSvgaDesc": "No acceleration; for troubleshooting only",
|
||||
"graphicsSvgaShort": "VMware SVGA",
|
||||
"groupGraphics": "Graphics",
|
||||
"groupMacOS": "macOS",
|
||||
"groupPerformance": "Performance",
|
||||
"groupQemu": "QEMU",
|
||||
"gtInstallCmd": "Install command",
|
||||
"guestLangHint": "Used by Recovery, Setup Assistant and the login window; a US keyboard layout keeps Terminal input reliable",
|
||||
"guestLangSettingsHint": "Used by Recovery, Setup Assistant and the login window",
|
||||
"guestLangShort": "System language",
|
||||
"guestMemory": "Memory",
|
||||
"guestToolsConnected": "Connected",
|
||||
"guestToolsPreventSleepSub": "Keeps macOS awake while idle; applies immediately",
|
||||
"guestToolsReady": "Configured",
|
||||
"hidpiPresetBadge": "HiDPI",
|
||||
"hostAudioInput": "Windows microphone",
|
||||
"hostAudioMissingIn": "No microphone found; macOS will record silence",
|
||||
"hostAudioMissingOut": "No speakers or headphones found; the VM will be silent",
|
||||
"hostAudioOutput": "Windows playback",
|
||||
"hostCPU": "CPU",
|
||||
"hostCoresThreads": "{c} cores · {t} threads",
|
||||
"hostDataRoot": "Data folder",
|
||||
"hostDisk": "Free space",
|
||||
"hostDisplayPrimary": "Primary",
|
||||
"hostDisplays": "Physical displays",
|
||||
"hostGPUs": "Graphics cards",
|
||||
"hostRAM": "Memory",
|
||||
"hostRAMAvail": "{n} GB free",
|
||||
"hostRAMTotal": "{n} GB total",
|
||||
"hostRuntime": "Runtime",
|
||||
"hostWHPX": "Windows Hypervisor Platform",
|
||||
"installersAvailable": "Releases from Apple",
|
||||
"installersCreateVM": "Create VM",
|
||||
"installersDelete": "Delete",
|
||||
"installersDeleteConfirm": "Confirm delete",
|
||||
"installersDownload": "Download",
|
||||
"installersDownloaded": "Downloaded",
|
||||
"installersDownloadingForVM": "Downloading for {vm}",
|
||||
"installersDownloadingPct": "Downloading {p}%",
|
||||
"installersEmpty": "No installers downloaded yet",
|
||||
"installersHint": "Downloaded installers can be reused for new VMs",
|
||||
"installersKindOffline": "Offline installer",
|
||||
"installersKindOnline": "Online recovery",
|
||||
"installersLatest": "Latest",
|
||||
"installersNoSpace": "Not enough space: needs about {need} GB, {free} GB free",
|
||||
"installersOlder": "{count, plural, one {# older version} other {# older versions}}",
|
||||
"installersPartial": "Partly downloaded",
|
||||
"installersQueued": "Queued",
|
||||
"installersQueuedForVM": "Queued for {vm}",
|
||||
"installersResume": "Resume",
|
||||
"installersTitle": "Installers",
|
||||
"installersWaitingVM": "{vm} waiting",
|
||||
"kernelIrqchipAuto": "Auto",
|
||||
"kernelIrqchipLabel": "Interrupt acceleration",
|
||||
"kernelIrqchipOff": "Off",
|
||||
"kernelIrqchipOn": "On",
|
||||
"language": "Language",
|
||||
"languageSub": "Simplified Chinese and English built in; add more via plugins",
|
||||
"logLevel": "Log level",
|
||||
"logLevelCustom": "Custom",
|
||||
"logLevelDesc": "Raise only when troubleshooting",
|
||||
"macosVersion": "macOS version",
|
||||
"memCommitHint": "Windows can allocate {avail} GB more · {rec} GB recommended",
|
||||
"memOverHint": "Above the recommendation; the VM may fail to start",
|
||||
"memRecHint": "{rec} GB recommended · this PC has {n} GB",
|
||||
"minimizeToTray": "Minimize to system tray on close",
|
||||
"minimizeToTraySub": "Clipboard and shared folders keep working; start and stop VMs from the tray",
|
||||
"multiDisplayHint": "{n, plural, one {# display detected; arrange displays inside macOS System Settings › Displays} other {# displays detected; arrange them inside macOS System Settings › Displays}}",
|
||||
"navHasIssue": "This page has settings to fix",
|
||||
"networkDesc": "Uses the Windows network connection",
|
||||
"networkOfflineHint": "Off by default for offline installs. Exit recovery and restart when Setup Assistant appears to enable networking",
|
||||
"networkTitle": "Network",
|
||||
"next": "Next",
|
||||
"noChanges": "No changes",
|
||||
"offlineListFailed": "Couldn’t read Apple’s release list",
|
||||
"opencore": "OpenCore",
|
||||
"optAuto": "Automatic",
|
||||
"optAvailable": "Available",
|
||||
"optExperimental": "Experimental",
|
||||
"optKernelIrqchipExp": "Experimental: may be faster. If startup hangs, go back to Auto (off on Windows 10)",
|
||||
"optKernelIrqchipNestedErr": "Not supported by this Windows ({code}); Auto keeps it off",
|
||||
"optKernelIrqchipRec": "Windows handles interrupts directly for smoother disk and multi-core work. Auto turns it on",
|
||||
"optKernelIrqchipUnavailable": "Not supported on this PC",
|
||||
"optKernelIrqchipWin10NoPatch": "On Windows 10, update the runtime to turn this on",
|
||||
"optPCoreSub": "Schedule QEMU on performance cores only ({detail})",
|
||||
"optPCoreUnavailable": "CPU has no hybrid P/E cores",
|
||||
"optRecommended": "Recommended",
|
||||
"optSchedBackground": "Background services",
|
||||
"optSchedNowBackground": "Set to Background services, which suits a VM running in the background (affects all of Windows)",
|
||||
"optSchedNowPrograms": "Set to Programs, so the VM may slow down in the background. Background services is recommended (affects all of Windows)",
|
||||
"optSchedOpen": "Change…",
|
||||
"optSchedPrograms": "Programs",
|
||||
"optSchedSub": "Background services keeps the VM steady in the background (affects all of Windows)",
|
||||
"optSchedTitle": "Windows processor scheduling",
|
||||
"optUnavailable": "Unavailable",
|
||||
"pendingChanges": "{n, plural, one {# change · applies on next start} other {# changes · applies on next start}}",
|
||||
"platformReadonly": "Model, serial number and other platform identity are never shown",
|
||||
"recommendedBadge": "Recommended",
|
||||
"resCustom": "Custom",
|
||||
"resCustomSub": "Width × height",
|
||||
"resFullscreen": "Full screen",
|
||||
"resInvalid": "Use WIDTHxHEIGHT, e.g. 2560x1600",
|
||||
"resetAll": "Revert all",
|
||||
"resetField": "Revert to current value",
|
||||
"runtimeDelete": "Delete runtime",
|
||||
"runtimeDeleteConfirm": "Confirm delete",
|
||||
"runtimeDeleted": "Removed runtime {commit}",
|
||||
"secondsUnit": "s",
|
||||
"settingsAppearance": "Appearance \u0026 language",
|
||||
"settingsGeneral": "General",
|
||||
"settingsTitle": "{name}",
|
||||
"sourceDisk": "Existing virtual disk (.qcow2)",
|
||||
"sourceInstaller": "Local installer image (.img / .dmg)",
|
||||
"sshForward": "SSH port forwarding",
|
||||
"sshNeedsNetwork": "Turn on the network first",
|
||||
"sshOffDesc": "Log in to macOS over SSH from Windows",
|
||||
"sshPort": "SSH forward port",
|
||||
"startAfterCreate": "Start after creating",
|
||||
"statsCPU": "QEMU CPU",
|
||||
"statsDisk": "Disk usage",
|
||||
"statsDiskSub": "{actual} actual / {virtual} max",
|
||||
"statsMemory": "Host RAM",
|
||||
"statsUptime": "Uptime",
|
||||
"stopBeforeDiskOp": "Shut down the VM first",
|
||||
"stopTimeout": "Shutdown timeout",
|
||||
"stopTimeoutHint": "0 waits indefinitely",
|
||||
"storageBreakdownTitle": "Storage breakdown",
|
||||
"storageInstallers": "Installers",
|
||||
"storageRuntimes": "Reims-Go",
|
||||
"storageVMs": "VM files",
|
||||
"themeLabel": "Appearance",
|
||||
"themePluginDarkDisabled": "Default theme plugin is disabled; dark and system appearances are unavailable",
|
||||
"themePluginLightDisabled": "The active theme supports dark appearance only",
|
||||
"updateDownloadInstall": "Download and install",
|
||||
"updateDownloadingSub": "Downloading {v}",
|
||||
"updateFailedSub": "Download or verification failed; try again",
|
||||
"updateReadySub": "{v} is downloaded and verified; restart Reims-Go to finish",
|
||||
"updateReleaseNotes": "Release notes",
|
||||
"useDefault": "Use Default",
|
||||
"vcpus": "Virtual CPUs",
|
||||
"vmDir": "Folder",
|
||||
"vmName": "Name",
|
||||
"welcomeCheckHost": "Set up Engine first →",
|
||||
"welcomeSub": "Pick an installer, assign cores and GPU, and launch in minutes",
|
||||
"welcomeTitle": "Create your first macOS VM",
|
||||
"whpxMissing": "Windows restarts after enabling",
|
||||
"whpxMissingShort": "Off",
|
||||
"whpxNoHv": "Turn on Intel VT-x / AMD-V in BIOS",
|
||||
"whpxNoHvShort": "Inactive",
|
||||
"whpxReady": "Ready",
|
||||
"whpxTitle": "WHPX",
|
||||
"whpxUnsupported": "This host isn’t Windows",
|
||||
"whpxUnsupportedShort": "Unsupported",
|
||||
}
|
||||
|
||||
registerBuiltinDomain(settingsZh, settingsEn)
|
||||
@@ -0,0 +1,383 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
|
||||
export const vmZh: Record<string, string> = {
|
||||
"attachGuestTools": "挂载 Guest Tools",
|
||||
"attachInstaller": "挂载离线镜像",
|
||||
"brokenHint": "这台虚拟机的配置无法读取",
|
||||
"cloneConfirm": "立即派生",
|
||||
"cloneDesc": "用写时复制瞬间创建副本,几乎不占空间,原虚拟机不受影响",
|
||||
"cloneNameLabel": "新虚拟机名称",
|
||||
"cloneTitle": "从「{name}」派生 CoW 副本",
|
||||
"cloneVM": "秒级派生副本 (CoW)",
|
||||
"connGroup": "连接",
|
||||
"copyScreenshot": "截屏并复制",
|
||||
"cores": "{n, plural, other {# 核}}",
|
||||
"deleteConfirm": "删除",
|
||||
"deleteDesc": "配置和虚拟磁盘会被移除,无法撤销",
|
||||
"deleteDescKeep": "只移除配置,磁盘文件留在原目录",
|
||||
"deleteKeepFiles": "保留磁盘文件",
|
||||
"deleteTitle": "删除「{name}」?",
|
||||
"deliverFileShort": "发送文件…",
|
||||
"detachGuestTools": "弹出工具盘",
|
||||
"diagAhciUpgradeHint": "系统盘还是 SATA,改成 NVMe 读写更快",
|
||||
"diagBackingChainBroken": "当前系统盘 CoW 派生链({depth} 层)存在缺失或无法读取的父镜像,请检查源虚拟机磁盘",
|
||||
"diagBackingChainWarn": "当前系统盘 CoW 派生链深度为 {depth} 层(≥ 2),未分配簇读穿透会拖慢小文件 I/O,建议合并为独立镜像或基于基础镜像重新派生",
|
||||
"diagExternalDriveWarn": "数据目录在外置或网络盘上({dir}),读写会明显变慢",
|
||||
"diagHighMemWarn": "宿主内存已用 {pct}%,虚拟机可能会卡顿",
|
||||
"displayNameEdit": "点按以修改显示名称",
|
||||
"displayNameEditEllipsis": "修改显示名称…",
|
||||
"displayNameLabel": "显示名称",
|
||||
"displayNameTip": "显示名称 · 虚拟机名称为 {name}(点按修改)",
|
||||
"dropFilesHint": "松开以投递到 macOS 共享目录",
|
||||
"enterRecovery": "进入恢复模式",
|
||||
"exportDiagnostics": "导出排障日志 (.zip)",
|
||||
"factBackingChain": "CoW 派生链",
|
||||
"factCPU": "处理器",
|
||||
"factDisk": "存储",
|
||||
"factGraphics": "图形",
|
||||
"factMemory": "内存",
|
||||
"failAttachInstaller": "挂载镜像失败",
|
||||
"failCloneVM": "派生 CoW 副本失败",
|
||||
"failDelete": "删除失败",
|
||||
"failEject": "弹出安装盘失败",
|
||||
"failEnterRecovery": "进入恢复模式失败",
|
||||
"failExportDiagnostics": "导出排障日志失败",
|
||||
"failFinishInstall": "退出恢复模式失败",
|
||||
"failFocus": "无法定位虚拟机窗口",
|
||||
"failGuestTools": "Guest Tools 操作失败",
|
||||
"failOpenFolder": "无法打开文件夹",
|
||||
"failRestart": "重启失败",
|
||||
"failScreenshot": "截屏失败",
|
||||
"failSnapshot": "恢复点操作失败",
|
||||
"failStart": "启动失败",
|
||||
"failStop": "关机失败",
|
||||
"failType": "键入失败",
|
||||
"failUpgradeNVMe": "升级到 NVMe 失败",
|
||||
"fieldAudio": "音频",
|
||||
"fieldCPUModel": "CPU 型号",
|
||||
"fieldController": "磁盘控制器",
|
||||
"fieldDir": "目录",
|
||||
"fieldDisk": "磁盘",
|
||||
"fieldGraphicsBackend": "图形后端",
|
||||
"fieldICD": "Vulkan ICD",
|
||||
"fieldKind": "类型",
|
||||
"fieldNetwork": "网络",
|
||||
"fieldVMName": "虚拟机名称",
|
||||
"finishInstall": "退出恢复模式",
|
||||
"gpuAuto": "自动选择 GPU",
|
||||
"gtInstall": "安装…",
|
||||
"gtInstallSub": "在 macOS 终端里运行",
|
||||
"gtNotInstalledDesc": "未安装:挂载工具盘后在 macOS 中运行安装命令",
|
||||
"gtStatusConnected": "已连接",
|
||||
"gtStatusEnabled": "已启用",
|
||||
"gtStatusNone": "未安装",
|
||||
"gtStatusOff": "已停用",
|
||||
"gtStatusOffTip": "Guest Tools 传输服务已在插件页停用,剪贴板、共享文件夹与防休眠都不可用",
|
||||
"gtStatusUpgrade": "需要更新",
|
||||
"gtStatusWaiting": "未连接",
|
||||
"gtStatusWaitingTip": "在 macOS 里运行安装命令后会自动连接",
|
||||
"gtUpdate": "更新…",
|
||||
"guestToolsModeSync": "文件同步模式",
|
||||
"guestToolsModeWebDAV": "WebDAV 挂载",
|
||||
"guestToolsPreventSleep": "防止 macOS 睡眠",
|
||||
"guestToolsSleepActive": "正在保持唤醒",
|
||||
"guestToolsTitle": "Guest Tools",
|
||||
"guestToolsUpgradeHint": "macOS 里的工具是旧版,重新运行安装命令即可升级",
|
||||
"guideBuiltIn1": "启动后在 OpenCore 引导菜单选择「Recovery」",
|
||||
"guideBuiltIn2": "恢复模式可以联网重装;要离线安装就点「挂载离线镜像」",
|
||||
"guideBuiltIn3": "完成后点「退出恢复模式」",
|
||||
"guideKindBuiltIn": "内置恢复",
|
||||
"guideKindOffline": "离线完整安装",
|
||||
"guideKindOnline": "在线恢复安装",
|
||||
"guideOffline1": "不要点「Reinstall macOS Tahoe」,从菜单栏打开「Utilities › Terminal」",
|
||||
"guideOffline2": "运行下面的命令(点键盘图标可直接键入)。它会把空白磁盘抹成 APFS 并开始安装,中途会重启几次:",
|
||||
"guideOffline3": "看到「设置助理」后,点「退出恢复模式」弹出安装盘并恢复网络",
|
||||
"guideStartHint": "启动后在虚拟机窗口查看安装引导",
|
||||
"guideStep1": "打开「磁盘工具」,选中最大的「QEMU HARDDISK Media」(看不到就选 View › Show All Devices),点 Erase:名称 Macintosh HD,格式 APFS,方案 GUID。抹除时可能停顿 10–30 秒,不要强制关机",
|
||||
"guideStep2": "回到恢复主界面,选「Reinstall macOS Tahoe」,装到刚抹好的磁盘,中途会重启几次",
|
||||
"guideStep3": "看到「设置助理」后,点「退出恢复模式」弹出安装盘",
|
||||
"guideTitle": "恢复模式",
|
||||
"netOff": "无网络",
|
||||
"netShared": "共享网络",
|
||||
"onlineRecoveryConfirm": "拉取并挂载(约 1 GB)",
|
||||
"onlineRecoveryDesc": "本地没有恢复镜像。要从 Apple 下载约 1 GB 的恢复镜像并挂载到「{name}」吗?",
|
||||
"onlineRecoveryTitle": "拉取在线恢复镜像?",
|
||||
"openSharedFolder": "打开共享文件夹",
|
||||
"openShort": "打开",
|
||||
"pendingRestartHint": "重启虚拟机后生效",
|
||||
"pendingTitle": "下次启动生效",
|
||||
"pickRecoveryTitle": "选择离线镜像(.img / .dmg)",
|
||||
"restartToApply": "重启以应用",
|
||||
"sendText": "发送文本到虚拟机…",
|
||||
"sendTextConfirm": "发送 (Ctrl+Enter)",
|
||||
"sendTextDesc": "支持中文、Emoji、宿主机输入法与语音输入,按 Ctrl+Enter 发送到 macOS 当前输入框。",
|
||||
"sendTextDescNoGT": "当前未连接 Guest Tools,仅支持英文/数字等美式键盘字符;安装 Guest Tools 后支持中文与任意文本。",
|
||||
"sendTextPlaceholder": "在这里输入或粘贴要发送到虚拟机的文字…",
|
||||
"sendTextTitle": "发送文本到「{name}」",
|
||||
"sharedFolder": "共享文件夹",
|
||||
"showInstallGuide": "显示安装引导",
|
||||
"showWindow": "显示窗口",
|
||||
"snapshotCreate": "创建恢复点",
|
||||
"snapshotDelete": "删除恢复点",
|
||||
"snapshotEmpty": "尚未创建恢复点,升级系统或大改环境前可先留档",
|
||||
"snapshotHint": "停机快照 · 非异地备份",
|
||||
"snapshotNamePlaceholder": "例如:升级 macOS 前",
|
||||
"snapshotRestore": "回滚",
|
||||
"snapshotRestoreDesc": "当前磁盘在此恢复点之后的改动将被覆盖,且无法撤销。",
|
||||
"snapshotRestoreTitle": "回滚到「{name}」?",
|
||||
"snapshotStopFirst": "停止虚拟机后才可管理恢复点",
|
||||
"snapshotsTitle": "恢复点",
|
||||
"softwareGraphics": "软件渲染",
|
||||
"specCPULiveTip": "处理器 {n} 核,当前占用 {pct}%",
|
||||
"specCPUTip": "{n, plural, other {处理器 # 核}}",
|
||||
"specDiskTip": "存储:{ctl}",
|
||||
"specDiskUsage": "{ctl} · 已用 {used},上限 {max}",
|
||||
"specGraphicsTip": "图形:{gfx}",
|
||||
"specLang": "语言",
|
||||
"specLangTip": "macOS 系统语言:{label}",
|
||||
"specLangTipDetail": "macOS 系统语言:{label}({detail})",
|
||||
"specMemLiveTip": "内存 {mem},虚拟机在宿主上占用 {used}",
|
||||
"specMemTip": "内存 {mem}",
|
||||
"specNetOffTip": "虚拟机没有网络",
|
||||
"specNetSSHTip": "与宿主共享网络连接,SSH 端口 {port}",
|
||||
"specNetTip": "与宿主共享网络连接",
|
||||
"sshMore": "SSH 工具",
|
||||
"sshOpenTerminal": "终端",
|
||||
"sshOpenVSCode": "用 VS Code 打开",
|
||||
"sshSetUser": "设置 SSH 用户名…",
|
||||
"sshUserDesc": "用于打开终端、写入 ~/.ssh/config 和 VS Code 直连(留空则连接时不带用户名)",
|
||||
"sshUserPlaceholder": "例如 admin",
|
||||
"sshUserTitle": "SSH 登录用户名",
|
||||
"sshWriteConfig": "写入 ~/.ssh/config",
|
||||
"state_broken": "出错",
|
||||
"state_creating": "正在创建",
|
||||
"state_driver_unavailable": "驱动不可用",
|
||||
"state_running": "运行中",
|
||||
"state_starting": "启动中",
|
||||
"state_stopped": "已停止",
|
||||
"state_stopping": "停止中",
|
||||
"techInfo": "技术信息",
|
||||
"toastCloned": "已派生 CoW 副本「{name}」",
|
||||
"toastDeleted": "已删除 {name}",
|
||||
"toastDiagExported": "已导出脱敏排障日志包 (.zip)",
|
||||
"toastEjected": "已弹出安装盘",
|
||||
"toastEnterRecovery": "已进入恢复模式,启动后可在引导菜单选 Recovery",
|
||||
"toastEnterRecoveryNextStart": "已准备进入恢复模式,重启后显示引导菜单",
|
||||
"toastExitRecoveryNextStart": "已退出恢复模式,下次启动生效",
|
||||
"toastFileDelivered": "已发送 {name}",
|
||||
"toastFilesDelivered": "{n, plural, other {已投递 # 个文件到共享目录}}",
|
||||
"toastGuestToolsAttached": "已挂载 Guest Tools 工具盘(REIMSTOOLS)",
|
||||
"toastGuestToolsAttachedNextStart": "已挂载 Guest Tools 工具盘,重启虚拟机后在访达中可见",
|
||||
"toastGuestToolsDetached": "已弹出工具盘",
|
||||
"toastGuestToolsDetachedNextStart": "已弹出工具盘,下次启动生效",
|
||||
"toastInstallFinished": "已退出恢复模式",
|
||||
"toastInstallerAttached": "已挂载离线镜像:{name}",
|
||||
"toastInstallerAttachedNextStart": "已挂载离线镜像(重启后生效):{name}",
|
||||
"toastNVMeNextStart": "已切换为 NVMe,下次启动生效",
|
||||
"toastNVMeReady": "已升级到 NVMe 磁盘控制器",
|
||||
"toastOnlineRecoveryAttached": "在线恢复镜像已挂载到 {name}",
|
||||
"toastOnlineRecoveryStarted": "正在拉取在线恢复镜像(约 1 GB),完成后自动挂载",
|
||||
"toastPreventSleepOff": "已关闭 macOS 防休眠守护",
|
||||
"toastPreventSleepOn": "已开启 macOS 防休眠守护",
|
||||
"toastScreenshotCopied": "已复制虚拟机画面",
|
||||
"toastSnapshotCreated": "已创建恢复点 {name}",
|
||||
"toastSnapshotDeleted": "已删除恢复点 {name}",
|
||||
"toastSnapshotRestored": "已回滚到 {name}",
|
||||
"toastStopped": "{name} 已关机",
|
||||
"toastTyped": "{n, plural, other {已键入 # 个字符}}",
|
||||
"typeClipboard": "粘贴剪贴板到虚拟机",
|
||||
"typeIntoVM": "在虚拟机里键入",
|
||||
"typeUntypeable": "未连接 Guest Tools 时仅支持美式键盘 ASCII 字符;安装并连接 Guest Tools 后即可输入中文与任意 Unicode 文本",
|
||||
"upgradeToNVMe": "升级到 NVMe",
|
||||
}
|
||||
|
||||
export const vmEn: Record<string, string> = {
|
||||
"attachGuestTools": "Attach Guest Tools",
|
||||
"attachInstaller": "Attach offline image",
|
||||
"brokenHint": "This VM’s configuration can’t be read",
|
||||
"cloneConfirm": "Create clone",
|
||||
"cloneDesc": "Makes an instant copy-on-write clone that takes almost no space and leaves the original untouched",
|
||||
"cloneNameLabel": "New VM name",
|
||||
"cloneTitle": "Derive CoW clone from “{name}”",
|
||||
"cloneVM": "Derive CoW clone",
|
||||
"connGroup": "Connection",
|
||||
"copyScreenshot": "Copy screenshot",
|
||||
"cores": "{n, plural, one {# core} other {# cores}}",
|
||||
"deleteConfirm": "Delete",
|
||||
"deleteDesc": "Its configuration and virtual disk are removed. This can’t be undone",
|
||||
"deleteDescKeep": "Only the configuration is removed; disk files stay in place",
|
||||
"deleteKeepFiles": "Keep disk files",
|
||||
"deleteTitle": "Delete \"{name}\"?",
|
||||
"deliverFileShort": "Send File…",
|
||||
"detachGuestTools": "Eject tools disk",
|
||||
"diagAhciUpgradeHint": "The system disk still uses SATA; NVMe is faster",
|
||||
"diagBackingChainBroken": "System disk CoW backing chain ({depth} layers) has a missing or unreadable parent image; check the source VM disk",
|
||||
"diagBackingChainWarn": "System disk CoW backing chain is {depth} layers deep (\u003e= 2); read-through slows small-file I/O — consider flattening or re-deriving from the base image",
|
||||
"diagExternalDriveWarn": "The data folder is on an external or network drive ({dir}); disk access will be slow",
|
||||
"diagHighMemWarn": "Host memory is {pct}% used; the VM may stutter",
|
||||
"displayNameEdit": "Click to change the display name",
|
||||
"displayNameEditEllipsis": "Change Display Name…",
|
||||
"displayNameLabel": "Display name",
|
||||
"displayNameTip": "Display name · VM name is {name} (click to change)",
|
||||
"dropFilesHint": "Drop files to send to macOS shared folder",
|
||||
"enterRecovery": "Enter recovery mode",
|
||||
"exportDiagnostics": "Export diagnostics (.zip)",
|
||||
"factBackingChain": "CoW Backing Chain",
|
||||
"factCPU": "CPU",
|
||||
"factDisk": "Storage",
|
||||
"factGraphics": "Graphics",
|
||||
"factMemory": "Memory",
|
||||
"failAttachInstaller": "Couldn’t attach the image",
|
||||
"failCloneVM": "Couldn’t create CoW clone",
|
||||
"failDelete": "Couldn’t delete",
|
||||
"failEject": "Couldn’t eject the installer",
|
||||
"failEnterRecovery": "Couldn’t enter recovery mode",
|
||||
"failExportDiagnostics": "Couldn’t export diagnostics",
|
||||
"failFinishInstall": "Couldn’t exit recovery mode",
|
||||
"failFocus": "Could not focus VM window",
|
||||
"failGuestTools": "Guest Tools operation failed",
|
||||
"failOpenFolder": "Couldn’t open the folder",
|
||||
"failRestart": "Couldn’t restart",
|
||||
"failScreenshot": "Screenshot failed",
|
||||
"failSnapshot": "Restore point failed",
|
||||
"failStart": "Couldn’t start",
|
||||
"failStop": "Couldn’t shut down",
|
||||
"failType": "Couldn’t type into the VM",
|
||||
"failUpgradeNVMe": "Couldn’t upgrade to NVMe",
|
||||
"fieldAudio": "Audio",
|
||||
"fieldCPUModel": "CPU model",
|
||||
"fieldController": "Disk controller",
|
||||
"fieldDir": "Directory",
|
||||
"fieldDisk": "Disk",
|
||||
"fieldGraphicsBackend": "Graphics backend",
|
||||
"fieldICD": "Vulkan ICD",
|
||||
"fieldKind": "Kind",
|
||||
"fieldNetwork": "Network",
|
||||
"fieldVMName": "VM name",
|
||||
"finishInstall": "Exit recovery mode",
|
||||
"gpuAuto": "Automatic GPU",
|
||||
"gtInstall": "Install…",
|
||||
"gtInstallSub": "Run in macOS Terminal",
|
||||
"gtNotInstalledDesc": "Not installed: attach the tools disk and run the installer in macOS",
|
||||
"gtStatusConnected": "Connected",
|
||||
"gtStatusEnabled": "Enabled",
|
||||
"gtStatusNone": "Not installed",
|
||||
"gtStatusOff": "Off",
|
||||
"gtStatusOffTip": "Guest Tools Transport is turned off on the Plugins page; clipboard, shared folders and keep-awake are unavailable",
|
||||
"gtStatusUpgrade": "Update needed",
|
||||
"gtStatusWaiting": "Not connected",
|
||||
"gtStatusWaitingTip": "Connects once the install command has run in macOS",
|
||||
"gtUpdate": "Update…",
|
||||
"guestToolsModeSync": "Folder sync",
|
||||
"guestToolsModeWebDAV": "WebDAV mount",
|
||||
"guestToolsPreventSleep": "Prevent macOS sleep",
|
||||
"guestToolsSleepActive": "Keeping macOS awake",
|
||||
"guestToolsTitle": "Guest Tools",
|
||||
"guestToolsUpgradeHint": "The tools in macOS are out of date; run the install command again to update",
|
||||
"guideBuiltIn1": "After starting, choose “Recovery” in the OpenCore boot menu",
|
||||
"guideBuiltIn2": "Recovery can reinstall over the network; for an offline install, click “Attach offline image”",
|
||||
"guideBuiltIn3": "When you are done, click “Exit recovery mode”",
|
||||
"guideKindBuiltIn": "Built-in recovery",
|
||||
"guideKindOffline": "Offline install",
|
||||
"guideKindOnline": "Online recovery",
|
||||
"guideOffline1": "Don’t click “Reinstall macOS Tahoe”; open Utilities › Terminal from the menu bar",
|
||||
"guideOffline2": "Run the command below (the keyboard icon types it for you). It erases the blank disk as APFS and starts the install; it restarts a few times:",
|
||||
"guideOffline3": "When Setup Assistant appears, click “Exit recovery mode” to eject the installer and turn the network back on",
|
||||
"guideStartHint": "Start the VM to open the installation guide in its window",
|
||||
"guideStep1": "Open Disk Utility and select the largest “QEMU HARDDISK Media” (View › Show All Devices if it is hidden). Click Erase: name Macintosh HD, format APFS, scheme GUID. It may pause for 10–30 seconds; don’t force it off",
|
||||
"guideStep2": "Back in Recovery, choose “Reinstall macOS Tahoe” and install to the disk you erased. It restarts a few times",
|
||||
"guideStep3": "When Setup Assistant appears, click “Exit recovery mode” to eject the installer",
|
||||
"guideTitle": "Recovery mode",
|
||||
"netOff": "No network",
|
||||
"netShared": "Shared network",
|
||||
"onlineRecoveryConfirm": "Download \u0026 attach (~1 GB)",
|
||||
"onlineRecoveryDesc": "No recovery image is on this PC. Download Apple’s recovery image (about 1 GB) and attach it to “{name}”?",
|
||||
"onlineRecoveryTitle": "Download online recovery image?",
|
||||
"openSharedFolder": "Open shared folder",
|
||||
"openShort": "Open",
|
||||
"pendingRestartHint": "Takes effect after a restart",
|
||||
"pendingTitle": "Applies on next start",
|
||||
"pickRecoveryTitle": "Choose an offline image (.img / .dmg)",
|
||||
"restartToApply": "Restart to apply",
|
||||
"sendText": "Send text to VM…",
|
||||
"sendTextConfirm": "Send (Ctrl+Enter)",
|
||||
"sendTextDesc": "Supports Chinese, emoji, host IME, and dictation. Press Ctrl+Enter to inject into the focused macOS field.",
|
||||
"sendTextDescNoGT": "Guest Tools is not connected; only US-keyboard ASCII characters are supported until Guest Tools is connected.",
|
||||
"sendTextPlaceholder": "Type or paste text to send to the VM…",
|
||||
"sendTextTitle": "Send text to “{name}”",
|
||||
"sharedFolder": "Shared folder",
|
||||
"showInstallGuide": "Show install guide",
|
||||
"showWindow": "Show window",
|
||||
"snapshotCreate": "New restore point",
|
||||
"snapshotDelete": "Delete restore point",
|
||||
"snapshotEmpty": "No restore points yet — save one before OS updates or major changes",
|
||||
"snapshotHint": "Offline snapshots · Not a backup",
|
||||
"snapshotNamePlaceholder": "e.g. before-macos-update",
|
||||
"snapshotRestore": "Restore",
|
||||
"snapshotRestoreDesc": "Disk changes made after this restore point will be overwritten and cannot be undone.",
|
||||
"snapshotRestoreTitle": "Restore \"{name}\"?",
|
||||
"snapshotStopFirst": "Stop the VM before managing restore points",
|
||||
"snapshotsTitle": "Restore points",
|
||||
"softwareGraphics": "Software rendering",
|
||||
"specCPULiveTip": "{n, plural, one {# processor core, {pct}% in use} other {# processor cores, {pct}% in use}}",
|
||||
"specCPUTip": "{n, plural, one {# processor core} other {# processor cores}}",
|
||||
"specDiskTip": "Storage: {ctl}",
|
||||
"specDiskUsage": "{ctl} · {used} of {max} used",
|
||||
"specGraphicsTip": "Graphics: {gfx}",
|
||||
"specLang": "Language",
|
||||
"specLangTip": "macOS system language: {label}",
|
||||
"specLangTipDetail": "macOS system language: {label} ({detail})",
|
||||
"specMemLiveTip": "{mem} memory; the VM uses {used} on this PC",
|
||||
"specMemTip": "{mem} memory",
|
||||
"specNetOffTip": "The VM has no network",
|
||||
"specNetSSHTip": "Shares this PC’s network connection; SSH on port {port}",
|
||||
"specNetTip": "Shares this PC’s network connection",
|
||||
"sshMore": "SSH tools",
|
||||
"sshOpenTerminal": "Terminal",
|
||||
"sshOpenVSCode": "Open in VS Code",
|
||||
"sshSetUser": "Set SSH username…",
|
||||
"sshUserDesc": "Used for Terminal, ~/.ssh/config, and VS Code Remote-SSH (leave empty to omit user)",
|
||||
"sshUserPlaceholder": "e.g. admin",
|
||||
"sshUserTitle": "SSH login username",
|
||||
"sshWriteConfig": "Write ~/.ssh/config",
|
||||
"state_broken": "Error",
|
||||
"state_creating": "Creating",
|
||||
"state_driver_unavailable": "Driver unavailable",
|
||||
"state_running": "Running",
|
||||
"state_starting": "Starting",
|
||||
"state_stopped": "Stopped",
|
||||
"state_stopping": "Stopping",
|
||||
"techInfo": "Technical details",
|
||||
"toastCloned": "CoW clone “{name}” created",
|
||||
"toastDeleted": "{name} deleted",
|
||||
"toastDiagExported": "Redacted diagnostics archive exported (.zip)",
|
||||
"toastEjected": "Installer ejected",
|
||||
"toastEnterRecovery": "Recovery mode ready — pick Recovery in OpenCore on next start",
|
||||
"toastEnterRecoveryNextStart": "Recovery mode ready — restart to open the boot menu",
|
||||
"toastExitRecoveryNextStart": "Exited recovery mode — applies at next start",
|
||||
"toastFileDelivered": "Sent {name}",
|
||||
"toastFilesDelivered": "{n, plural, one {Sent # file to the shared folder} other {Sent # files to the shared folder}}",
|
||||
"toastGuestToolsAttached": "Guest Tools disk (REIMSTOOLS) attached",
|
||||
"toastGuestToolsAttachedNextStart": "Guest Tools disk attached — restart VM to mount in Finder",
|
||||
"toastGuestToolsDetached": "Tools disk ejected",
|
||||
"toastGuestToolsDetachedNextStart": "Tools disk ejected; applies on next start",
|
||||
"toastInstallFinished": "Exited recovery mode",
|
||||
"toastInstallerAttached": "Offline image attached: {name}",
|
||||
"toastInstallerAttachedNextStart": "Offline image attached (applies on restart): {name}",
|
||||
"toastNVMeNextStart": "Switched to NVMe — applies on next start",
|
||||
"toastNVMeReady": "Upgraded disk controller to NVMe",
|
||||
"toastOnlineRecoveryAttached": "Online recovery image attached to {name}",
|
||||
"toastOnlineRecoveryStarted": "Downloading online recovery image (~1 GB); will attach when ready",
|
||||
"toastPreventSleepOff": "Prevent-sleep guard disabled",
|
||||
"toastPreventSleepOn": "Prevent-sleep guard enabled",
|
||||
"toastScreenshotCopied": "VM screenshot copied",
|
||||
"toastSnapshotCreated": "Created restore point {name}",
|
||||
"toastSnapshotDeleted": "Deleted restore point {name}",
|
||||
"toastSnapshotRestored": "Restored to {name}",
|
||||
"toastStopped": "{name} shut down",
|
||||
"toastTyped": "{n, plural, one {Typed # character} other {Typed # characters}}",
|
||||
"typeClipboard": "Send clipboard to VM",
|
||||
"typeIntoVM": "Type into the VM",
|
||||
"typeUntypeable": "Only US-keyboard ASCII characters work without Guest Tools; connect Guest Tools for Chinese and Unicode text",
|
||||
"upgradeToNVMe": "Upgrade to NVMe",
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
import { registerBuiltinDomain } from '../runtime'
|
||||
|
||||
export const wizardZh: Record<string, string> = {
|
||||
"commandToggle": "等效命令",
|
||||
"commandToggleHint": "在终端运行下面这条命令效果相同",
|
||||
"createNow": "创建",
|
||||
"createStartedHint": "创建后窗口会关闭,进度在底部状态栏",
|
||||
"issuesCount": "{n, plural, other {有 # 项需要修改}}",
|
||||
"offlineCached": "已下载",
|
||||
"offlineDownloading": "下载中",
|
||||
"offlineHint": "约 20 GB,安装时不联网",
|
||||
"offlineListFailedDetail": "无法读取 Apple 的版本列表:{err}",
|
||||
"offlineLoading": "正在读取 Apple 的版本列表…",
|
||||
"offlineQueued": "排队中",
|
||||
"offlineSpaceWarn": "可用空间 {free} GB,下载这个版本需要约 {need} GB",
|
||||
"runtimeAlpha": "接收 Alpha 版",
|
||||
"runtimeAlphaHint": "Alpha 版由 CI 每天从上游自动构建,未经真实宿主冒烟测试",
|
||||
"runtimeChannel_alpha": "Alpha 版",
|
||||
"runtimeChannel_stable": "稳定版",
|
||||
"runtimeCurrent": "当前运行时",
|
||||
"runtimeInstall": "安装",
|
||||
"runtimeLatest": "最新:{v}",
|
||||
"runtimeLookupFailed": "无法读取运行时列表",
|
||||
"runtimeLookupRateLimit": "GitHub 接口限流(HTTP 403),请稍后重试或手动导入",
|
||||
"runtimeNewer": "有新版本:{v}",
|
||||
"runtimeNoneOnChannel": "这个通道还没有发布运行时",
|
||||
"runtimeOnline": "在线安装",
|
||||
"runtimeRetry": "重试",
|
||||
"runtimeUpToDate": "已是最新",
|
||||
"runtimeUpdate": "更新",
|
||||
"setupCheck": "环境",
|
||||
"setupContinue": "继续",
|
||||
"setupDesc": "虚拟机、安装包和运行时都放在这里",
|
||||
"setupDone": "完成",
|
||||
"setupExternal": "外置盘",
|
||||
"setupFree": "可用 {n} GB",
|
||||
"setupGPU": "显卡(Vulkan)",
|
||||
"setupImport": "导入本地包…",
|
||||
"setupLater": "稍后",
|
||||
"setupNoGPU": "没有检测到 Vulkan 显卡,只能用软件渲染",
|
||||
"setupOther": "其他位置…",
|
||||
"setupRecMem": "推荐 {n} GB",
|
||||
"setupRecommended": "推荐",
|
||||
"setupReuse": "这里已有 Reims-Go 数据,会直接沿用",
|
||||
"setupRuntimeDesc": "运行虚拟机所需的 QEMU 与 reims-ctl,从 GitHub 下载并校验",
|
||||
"setupRuntimeTitle": "检查环境并安装运行时",
|
||||
"setupSystem": "系统盘",
|
||||
"setupTitle": "选择数据目录",
|
||||
"setupWarnExternal": "外置盘拔出时,正在运行的虚拟机会损坏",
|
||||
"setupWarnSpace": "可用空间不足 60 GB:一个离线安装包约 20 GB,虚拟磁盘会随使用增长",
|
||||
"setupWarnSystem": "放在系统盘,空间紧张时会影响 Windows",
|
||||
"srcAppleSub": "恢复镜像,系统在装机时在线下载",
|
||||
"srcAppleTitle": "从 Apple 下载",
|
||||
"srcDiskSub": "已装好 macOS 的 .qcow2 等磁盘",
|
||||
"srcDiskTitle": "已有磁盘",
|
||||
"srcInstallerSub": "本机上的 .img 或 .dmg",
|
||||
"srcInstallerTitle": "安装镜像",
|
||||
"srcOfflineSub": "完整安装包,装机时不联网",
|
||||
"srcOfflineTitle": "离线安装包",
|
||||
"step1": "系统来源",
|
||||
"step2": "处理器与内存",
|
||||
"step3": "存储",
|
||||
"step4": "图形与选项",
|
||||
"step5": "确认",
|
||||
"summaryAppleSource": "从 Apple 下载 · {v}",
|
||||
"summaryDefaultDir": "数据目录(默认)",
|
||||
"summaryDiskGrow": "{size},按实际占用增长",
|
||||
"summaryDiskSource": "已有磁盘 · {file}",
|
||||
"summaryEdit": "修改",
|
||||
"summaryInstallerSource": "本地安装器 · {file}",
|
||||
"summaryLogs": "图形与串口日志",
|
||||
"summaryOfflineSource": "离线安装包 · macOS {v}",
|
||||
"summaryOn": "开",
|
||||
"summarySSH": "SSH 转发",
|
||||
"summarySSHPort": "端口 {n}",
|
||||
"summarySource": "来源",
|
||||
"validationChecking": "正在检查…",
|
||||
"validationPassed": "可以创建",
|
||||
"wizChooseFile": "选择…",
|
||||
"wizNoFile": "还没有选择文件",
|
||||
"wizOptions": "选项",
|
||||
"wizardBasics": "基本信息",
|
||||
"wizardDriverGroup": "客体平台驱动",
|
||||
"wizardDriverType": "驱动类型",
|
||||
"wizardTitle": "新建虚拟机",
|
||||
}
|
||||
|
||||
export const wizardEn: Record<string, string> = {
|
||||
"commandToggle": "Equivalent command",
|
||||
"commandToggleHint": "Running this in a terminal does the same thing",
|
||||
"createNow": "Create",
|
||||
"createStartedHint": "The window closes once creation starts; progress shows in the status bar",
|
||||
"issuesCount": "{n, plural, one {# issue to fix} other {# issues to fix}}",
|
||||
"offlineCached": "Downloaded",
|
||||
"offlineDownloading": "Downloading",
|
||||
"offlineHint": "About 20 GB; installs with no network",
|
||||
"offlineListFailedDetail": "Couldn’t read Apple’s release list: {err}",
|
||||
"offlineLoading": "Reading Apple’s release list…",
|
||||
"offlineQueued": "Queued",
|
||||
"offlineSpaceWarn": "{free} GB free; this release needs about {need} GB",
|
||||
"runtimeAlpha": "Receive alpha builds",
|
||||
"runtimeAlphaHint": "Built daily from upstream by CI; not smoke-tested on a real host",
|
||||
"runtimeChannel_alpha": "Alpha",
|
||||
"runtimeChannel_stable": "Stable",
|
||||
"runtimeCurrent": "Current runtime",
|
||||
"runtimeInstall": "Install",
|
||||
"runtimeLatest": "Latest: {v}",
|
||||
"runtimeLookupFailed": "Couldn’t read the runtime list",
|
||||
"runtimeLookupRateLimit": "GitHub API rate limit reached (HTTP 403); retry later or import a local bundle",
|
||||
"runtimeNewer": "New version: {v}",
|
||||
"runtimeNoneOnChannel": "No runtime published on this channel yet",
|
||||
"runtimeOnline": "Online install",
|
||||
"runtimeRetry": "Retry",
|
||||
"runtimeUpToDate": "Up to date",
|
||||
"runtimeUpdate": "Update",
|
||||
"setupCheck": "Host",
|
||||
"setupContinue": "Continue",
|
||||
"setupDesc": "VMs, installers and runtimes all live here",
|
||||
"setupDone": "Done",
|
||||
"setupExternal": "External",
|
||||
"setupFree": "{n} GB free",
|
||||
"setupGPU": "Graphics (Vulkan)",
|
||||
"setupImport": "Import a local package…",
|
||||
"setupLater": "Later",
|
||||
"setupNoGPU": "No Vulkan GPU found; only software rendering will work",
|
||||
"setupOther": "Other location…",
|
||||
"setupRecMem": "{n} GB recommended",
|
||||
"setupRecommended": "Recommended",
|
||||
"setupReuse": "This folder already has Reims-Go data; it will be reused",
|
||||
"setupRuntimeDesc": "QEMU and reims-ctl, downloaded from GitHub and verified",
|
||||
"setupRuntimeTitle": "Check the host and install the runtime",
|
||||
"setupSystem": "System drive",
|
||||
"setupTitle": "Choose a data folder",
|
||||
"setupWarnExternal": "Unplugging an external drive corrupts running VMs",
|
||||
"setupWarnSpace": "Under 60 GB free: an offline installer is about 20 GB and virtual disks grow with use",
|
||||
"setupWarnSystem": "On the system drive, low space can affect Windows",
|
||||
"srcAppleSub": "A recovery image; macOS downloads during install",
|
||||
"srcAppleTitle": "Download from Apple",
|
||||
"srcDiskSub": "A .qcow2 or other disk with macOS installed",
|
||||
"srcDiskTitle": "Existing disk",
|
||||
"srcInstallerSub": "An .img or .dmg on this PC",
|
||||
"srcInstallerTitle": "Installer image",
|
||||
"srcOfflineSub": "The full installer; installs with no network",
|
||||
"srcOfflineTitle": "Offline installer",
|
||||
"step1": "Source",
|
||||
"step2": "CPU \u0026 memory",
|
||||
"step3": "Storage",
|
||||
"step4": "Graphics \u0026 options",
|
||||
"step5": "Review",
|
||||
"summaryAppleSource": "Download from Apple · {v}",
|
||||
"summaryDefaultDir": "Data folder (default)",
|
||||
"summaryDiskGrow": "{size}, grows with use",
|
||||
"summaryDiskSource": "Existing disk · {file}",
|
||||
"summaryEdit": "Edit",
|
||||
"summaryInstallerSource": "Local installer · {file}",
|
||||
"summaryLogs": "Graphics \u0026 serial logs",
|
||||
"summaryOfflineSource": "Offline installer · macOS {v}",
|
||||
"summaryOn": "On",
|
||||
"summarySSH": "SSH forwarding",
|
||||
"summarySSHPort": "Port {n}",
|
||||
"summarySource": "Source",
|
||||
"validationChecking": "Checking…",
|
||||
"validationPassed": "Ready to create",
|
||||
"wizChooseFile": "Choose…",
|
||||
"wizNoFile": "No file chosen",
|
||||
"wizOptions": "Options",
|
||||
"wizardBasics": "Basics",
|
||||
"wizardDriverGroup": "Guest driver",
|
||||
"wizardDriverType": "Driver",
|
||||
"wizardTitle": "New virtual machine",
|
||||
}
|
||||
|
||||
registerBuiltinDomain(wizardZh, wizardEn)
|
||||
@@ -0,0 +1,376 @@
|
||||
// Zero-dependency isomorphic lightweight ICU MessageFormat evaluator + en-XA pseudo-localizer.
|
||||
// Matches internal/i18n/icu.go 1:1 while delegating plural selection & number formatting
|
||||
// to native zero-bundle-cost browser Intl APIs.
|
||||
|
||||
export type ICUVars = Record<string, string | number | boolean | undefined | null>
|
||||
|
||||
type ICUNode =
|
||||
| { kind: 'text'; text: string }
|
||||
| { kind: 'pound' }
|
||||
| { kind: 'var'; name: string }
|
||||
| { kind: 'number'; name: string; precision: number }
|
||||
| { kind: 'plural' | 'select'; name: string; branches: Array<{ selector: string; nodes: ICUNode[] }> }
|
||||
|
||||
const astCache = new Map<string, ICUNode[] | null>()
|
||||
const pluralRulesCache = new Map<string, Intl.PluralRules>()
|
||||
const numberFormatCache = new Map<string, Intl.NumberFormat>()
|
||||
|
||||
function getPluralRules(locale: string): Intl.PluralRules {
|
||||
const key = locale === 'en-XA' ? 'en-US' : locale
|
||||
let pr = pluralRulesCache.get(key)
|
||||
if (!pr) {
|
||||
try {
|
||||
pr = new Intl.PluralRules(key)
|
||||
} catch {
|
||||
pr = new Intl.PluralRules('en-US')
|
||||
}
|
||||
pluralRulesCache.set(key, pr)
|
||||
}
|
||||
return pr
|
||||
}
|
||||
|
||||
export function formatLocaleNumber(locale: string, value: number, precision = -1): string {
|
||||
const cleanLoc = locale === 'en-XA' ? 'en-US' : locale
|
||||
const cacheKey = `${cleanLoc}:${precision}`
|
||||
let nf = numberFormatCache.get(cacheKey)
|
||||
if (!nf) {
|
||||
const opts: Intl.NumberFormatOptions =
|
||||
precision >= 0
|
||||
? { minimumFractionDigits: precision, maximumFractionDigits: precision, useGrouping: false }
|
||||
: { useGrouping: false }
|
||||
try {
|
||||
nf = new Intl.NumberFormat(cleanLoc, opts)
|
||||
} catch {
|
||||
nf = new Intl.NumberFormat('en-US', opts)
|
||||
}
|
||||
numberFormatCache.set(cacheKey, nf)
|
||||
}
|
||||
return nf.format(value)
|
||||
}
|
||||
|
||||
const MAX_ICU_DEPTH = 16
|
||||
const MAX_ICU_TEMPLATE_LEN = 16384
|
||||
|
||||
export function parseICU(tmpl: string): ICUNode[] | null {
|
||||
if (tmpl.length > MAX_ICU_TEMPLATE_LEN) return null
|
||||
if (astCache.has(tmpl)) {
|
||||
return astCache.get(tmpl) ?? null
|
||||
}
|
||||
let pos = 0
|
||||
const len = tmpl.length
|
||||
|
||||
const skipWS = () => {
|
||||
while (pos < len) {
|
||||
const c = tmpl.charCodeAt(pos)
|
||||
if (c === 32 || c === 9 || c === 10 || c === 13) pos++
|
||||
else break
|
||||
}
|
||||
}
|
||||
|
||||
const readIdent = (): string => {
|
||||
const start = pos
|
||||
while (pos < len) {
|
||||
const c = tmpl.charCodeAt(pos)
|
||||
if (
|
||||
(c >= 97 && c <= 122) ||
|
||||
(c >= 65 && c <= 90) ||
|
||||
(c >= 48 && c <= 57) ||
|
||||
c === 95 || // _
|
||||
c === 45 || // -
|
||||
c === 46 || // .
|
||||
c === 61 // =
|
||||
) {
|
||||
pos++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return tmpl.slice(start, pos)
|
||||
}
|
||||
|
||||
const parseNodes = (stopAtBrace: boolean, inPlural: boolean, depth: number): ICUNode[] | null => {
|
||||
if (depth > MAX_ICU_DEPTH) return null
|
||||
const nodes: ICUNode[] = []
|
||||
let buf = ''
|
||||
const flush = () => {
|
||||
if (buf.length > 0) {
|
||||
nodes.push({ kind: 'text', text: buf })
|
||||
buf = ''
|
||||
}
|
||||
}
|
||||
|
||||
while (pos < len) {
|
||||
const ch = tmpl[pos]
|
||||
if (ch === "'") {
|
||||
if (pos + 1 < len && tmpl[pos + 1] === "'") {
|
||||
buf += "'"
|
||||
pos += 2
|
||||
continue
|
||||
}
|
||||
const next = pos + 1 < len ? tmpl[pos + 1] : ''
|
||||
if (next === '{' || next === '}' || (inPlural && next === '#')) {
|
||||
pos++
|
||||
while (pos < len) {
|
||||
if (tmpl[pos] === "'") {
|
||||
if (pos + 1 < len && tmpl[pos + 1] === "'") {
|
||||
buf += "'"
|
||||
pos += 2
|
||||
continue
|
||||
}
|
||||
pos++
|
||||
break
|
||||
}
|
||||
buf += tmpl[pos++]
|
||||
}
|
||||
continue
|
||||
}
|
||||
buf += "'"
|
||||
pos++
|
||||
continue
|
||||
}
|
||||
|
||||
if (ch === '}') {
|
||||
if (stopAtBrace) {
|
||||
flush()
|
||||
return nodes
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
if (ch === '#' && inPlural) {
|
||||
flush()
|
||||
nodes.push({ kind: 'pound' })
|
||||
pos++
|
||||
continue
|
||||
}
|
||||
|
||||
if (ch === '{') {
|
||||
flush()
|
||||
const node = parsePlaceholder(inPlural, depth + 1)
|
||||
if (!node) return null
|
||||
nodes.push(node)
|
||||
continue
|
||||
}
|
||||
|
||||
buf += ch
|
||||
pos++
|
||||
}
|
||||
|
||||
if (stopAtBrace) return null
|
||||
flush()
|
||||
return nodes
|
||||
}
|
||||
|
||||
const parsePlaceholder = (parentInPlural: boolean, depth: number): ICUNode | null => {
|
||||
if (depth > MAX_ICU_DEPTH) return null
|
||||
pos++ // skip '{'
|
||||
skipWS()
|
||||
const name = readIdent()
|
||||
if (!name) return null
|
||||
skipWS()
|
||||
if (pos < len && tmpl[pos] === '}') {
|
||||
pos++
|
||||
return { kind: 'var', name }
|
||||
}
|
||||
if (pos >= len || tmpl[pos] !== ',') return null
|
||||
pos++
|
||||
skipWS()
|
||||
const fn = readIdent()
|
||||
skipWS()
|
||||
|
||||
if (fn === 'number') {
|
||||
let precision = -1
|
||||
if (pos < len && tmpl[pos] === ',') {
|
||||
pos++
|
||||
skipWS()
|
||||
const style = readIdent()
|
||||
if (/^\.[0-6]$/.test(style)) {
|
||||
precision = Number.parseInt(style.slice(1), 10)
|
||||
} else if (style !== '') {
|
||||
return null
|
||||
}
|
||||
skipWS()
|
||||
}
|
||||
if (pos >= len || tmpl[pos] !== '}') return null
|
||||
pos++
|
||||
return { kind: 'number', name, precision }
|
||||
}
|
||||
|
||||
if (fn === 'plural' || fn === 'select') {
|
||||
if (pos >= len || tmpl[pos] !== ',') return null
|
||||
pos++
|
||||
const isPlural = fn === 'plural'
|
||||
const branches: Array<{ selector: string; nodes: ICUNode[] }> = []
|
||||
let hasOther = false
|
||||
while (true) {
|
||||
skipWS()
|
||||
if (pos < len && tmpl[pos] === '}') {
|
||||
pos++
|
||||
break
|
||||
}
|
||||
const selector = readIdent()
|
||||
if (!selector) return null
|
||||
if (selector === 'other') hasOther = true
|
||||
skipWS()
|
||||
if (pos >= len || tmpl[pos] !== '{') return null
|
||||
pos++
|
||||
const childNodes = parseNodes(true, isPlural || parentInPlural, depth + 1)
|
||||
if (!childNodes || pos >= len || tmpl[pos] !== '}') return null
|
||||
pos++
|
||||
branches.push({ selector, nodes: childNodes })
|
||||
}
|
||||
if (!hasOther) return null
|
||||
return { kind: fn, name, branches }
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
const parsed = parseNodes(false, false, 0)
|
||||
const valid = parsed && pos === len ? parsed : null
|
||||
if (astCache.size > 3000) astCache.clear()
|
||||
astCache.set(tmpl, valid)
|
||||
return valid
|
||||
}
|
||||
|
||||
export function formatICU(locale: string, tmpl: string, vars?: ICUVars, strictVars = false): string | null {
|
||||
if (!vars && !tmpl.includes('{') && !tmpl.includes('}') && !tmpl.includes("'")) {
|
||||
return tmpl
|
||||
}
|
||||
const nodes = parseICU(tmpl)
|
||||
if (!nodes) return null
|
||||
|
||||
const evalList = (list: ICUNode[], poundVal?: string): string | null => {
|
||||
let out = ''
|
||||
for (const nd of list) {
|
||||
switch (nd.kind) {
|
||||
case 'text':
|
||||
out += nd.text
|
||||
break
|
||||
case 'pound':
|
||||
out += poundVal !== undefined ? poundVal : '#'
|
||||
break
|
||||
case 'var': {
|
||||
const val = vars?.[nd.name]
|
||||
if (val === undefined || val === null) {
|
||||
if (strictVars) return null
|
||||
out += `{${nd.name}}`
|
||||
} else {
|
||||
out += String(val)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'number': {
|
||||
const val = vars?.[nd.name]
|
||||
if (val === undefined || val === null) {
|
||||
if (strictVars) return null
|
||||
out += `{${nd.name}}`
|
||||
} else {
|
||||
const num = typeof val === 'number' ? val : Number(val)
|
||||
out += Number.isFinite(num) ? formatLocaleNumber(locale, num, nd.precision) : String(val)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'plural': {
|
||||
const raw = vars?.[nd.name]
|
||||
if ((raw === undefined || raw === null) && strictVars) return null
|
||||
const num = typeof raw === 'number' ? raw : Number(raw ?? 0)
|
||||
const safeNum = Number.isFinite(num) ? num : 0
|
||||
const exact = Number.isInteger(safeNum) ? `=${safeNum}` : ''
|
||||
const cat = getPluralRules(locale).select(safeNum)
|
||||
const chosen =
|
||||
(exact ? nd.branches.find((b) => b.selector === exact) : undefined) ??
|
||||
nd.branches.find((b) => b.selector === cat) ??
|
||||
nd.branches.find((b) => b.selector === 'other') ??
|
||||
nd.branches[nd.branches.length - 1]
|
||||
const formattedNum = formatLocaleNumber(locale, safeNum, -1)
|
||||
const inner = evalList(chosen ? chosen.nodes : [], formattedNum)
|
||||
if (inner === null) return null
|
||||
out += inner
|
||||
break
|
||||
}
|
||||
case 'select': {
|
||||
const raw = vars?.[nd.name]
|
||||
if ((raw === undefined || raw === null) && strictVars) return null
|
||||
const key = raw === undefined || raw === null ? '' : String(raw)
|
||||
const chosen =
|
||||
nd.branches.find((b) => b.selector === key) ??
|
||||
nd.branches.find((b) => b.selector === 'other') ??
|
||||
nd.branches[nd.branches.length - 1]
|
||||
const inner = evalList(chosen ? chosen.nodes : [], poundVal)
|
||||
if (inner === null) return null
|
||||
out += inner
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
return evalList(nodes)
|
||||
}
|
||||
|
||||
const PSEUDO_MAP: Record<string, string> = {
|
||||
a: 'à', b: 'ƀ', c: 'č', d: 'ď', e: 'ë', f: 'ƒ', g: 'ğ', h: 'ĥ', i: 'î', j: 'ĵ', k: 'ķ', l: 'ľ', m: 'ɱ',
|
||||
n: 'ñ', o: 'ô', p: 'þ', q: 'ǫ', r: 'ŕ', s: 'ś', t: 'ť', u: 'ü', v: 'ṽ', w: 'ŵ', x: 'ẋ', y: 'ÿ', z: 'ž',
|
||||
A: 'À', B: 'Ɓ', C: 'Č', D: 'Ď', E: 'Ë', F: 'Ƒ', G: 'Ğ', H: 'Ĥ', I: 'Î', J: 'Ĵ', K: 'Ķ', L: 'Ľ', M: 'Ṁ',
|
||||
N: 'Ñ', O: 'Ô', P: 'Þ', Q: 'Ǫ', R: 'Ŕ', S: 'Š', T: 'Ť', U: 'Ü', V: 'Ṽ', W: 'Ŵ', X: 'Ẋ', Y: 'Ÿ', Z: 'Ž',
|
||||
}
|
||||
|
||||
function accentString(s: string): string {
|
||||
let out = ''
|
||||
for (const ch of s) {
|
||||
out += PSEUDO_MAP[ch] ?? ch
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export function pseudoLocalizeICU(enTmpl: string): string {
|
||||
const nodes = parseICU(enTmpl)
|
||||
if (!nodes) return `⟦${enTmpl}⟧`
|
||||
|
||||
const countChars = (list: ICUNode[]): number =>
|
||||
list.reduce((acc, n) => acc + (n.kind === 'text' ? [...n.text].length : 0), 0)
|
||||
|
||||
const topChars = countChars(nodes)
|
||||
const topPad =
|
||||
topChars === 0
|
||||
? 0
|
||||
: topChars <= 8
|
||||
? Math.max(4, Math.ceil(topChars * 0.85))
|
||||
: Math.ceil(topChars * 0.35)
|
||||
|
||||
const serialize = (list: ICUNode[], pad: number, isTop: boolean): string => {
|
||||
let s = ''
|
||||
for (const nd of list) {
|
||||
if (nd.kind === 'text') {
|
||||
s += accentString(nd.text)
|
||||
.replaceAll("'", "''")
|
||||
.replaceAll('{', "'{'")
|
||||
.replaceAll('}', "'}'")
|
||||
.replaceAll('#', "'#'")
|
||||
} else if (nd.kind === 'pound') {
|
||||
s += '#'
|
||||
} else if (nd.kind === 'var') {
|
||||
s += `{${nd.name}}`
|
||||
} else if (nd.kind === 'number') {
|
||||
s += nd.precision >= 0 ? `{${nd.name}, number, .${nd.precision}}` : `{${nd.name}, number}`
|
||||
} else {
|
||||
s += `{${nd.name}, ${nd.kind}, `
|
||||
s += nd.branches
|
||||
.map((br) => {
|
||||
const brPad = isTop && topChars === 0 ? Math.max(3, Math.ceil(countChars(br.nodes) * 0.35)) : 0
|
||||
return `${br.selector} {${serialize(br.nodes, brPad, false)}}`
|
||||
})
|
||||
.join(' ')
|
||||
s += '}'
|
||||
}
|
||||
}
|
||||
if (pad > 0) {
|
||||
s += ' ' + '·'.repeat(pad)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
return `⟦${serialize(nodes, topPad, true)}⟧`
|
||||
}
|
||||
@@ -0,0 +1,863 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
|
||||
export type I18nKey =
|
||||
| "aboutCommunity"
|
||||
| "aboutCopyQQGroup"
|
||||
| "aboutIssueSub"
|
||||
| "aboutJoinQQGroup"
|
||||
| "aboutLicensesOpenGitHub"
|
||||
| "aboutLicensesSub"
|
||||
| "aboutLicensesTabLicense"
|
||||
| "aboutLicensesTabNotice"
|
||||
| "aboutLicensesTitle"
|
||||
| "aboutLicensesView"
|
||||
| "aboutProjectSub"
|
||||
| "aboutQQGroup"
|
||||
| "aboutQQGroupSub"
|
||||
| "aboutQQLaunchFailed"
|
||||
| "aboutQQNotInstalled"
|
||||
| "aboutQQNotInstalledSub"
|
||||
| "aboutTagline"
|
||||
| "activate"
|
||||
| "affinityApplyNow"
|
||||
| "affinityAvoidLPE"
|
||||
| "affinityConfigure"
|
||||
| "affinityEcoQoS"
|
||||
| "affinityEcoQoSDesc"
|
||||
| "affinityExcludeCPU0"
|
||||
| "affinityLiveMask"
|
||||
| "affinityMenu"
|
||||
| "affinityModeAll"
|
||||
| "affinityModeAllHint"
|
||||
| "affinityModeAuto"
|
||||
| "affinityModeAutoHint"
|
||||
| "affinityModeCustom"
|
||||
| "affinityModeCustomHint"
|
||||
| "affinityModeNonLPE"
|
||||
| "affinityModeNonLPEHint"
|
||||
| "affinityModePCores"
|
||||
| "affinityModePCoresHint"
|
||||
| "affinityNeedOne"
|
||||
| "affinityOnlyPCores"
|
||||
| "affinityOversubWarn"
|
||||
| "affinityPhysicalOnly"
|
||||
| "affinityRowDesc"
|
||||
| "affinitySave"
|
||||
| "affinitySelectAll"
|
||||
| "affinitySelectedSummary"
|
||||
| "affinitySubtitleRunning"
|
||||
| "affinitySubtitleStopped"
|
||||
| "affinitySummaryAll"
|
||||
| "affinitySummaryAuto"
|
||||
| "affinitySummaryCustom"
|
||||
| "affinitySummaryNonLPE"
|
||||
| "affinitySummaryPCores"
|
||||
| "affinityTitle"
|
||||
| "appCheckUpdate"
|
||||
| "appDownloadUpdate"
|
||||
| "appUpToDate"
|
||||
| "appUpdateAvailable"
|
||||
| "appUpdateAvailableAlpha"
|
||||
| "appUpdateAvailableDev"
|
||||
| "appUpdateChannelAlpha"
|
||||
| "appUpdateChannelDev"
|
||||
| "appUpdateChannelStable"
|
||||
| "appUpdateChannelSubKeepOld"
|
||||
| "appUpdateChannelSubStable"
|
||||
| "appUpdateChannelTitle"
|
||||
| "appUpdateLookupFailed"
|
||||
| "appVersionTitle"
|
||||
| "appearance"
|
||||
| "appliesNextStart"
|
||||
| "attachGuestTools"
|
||||
| "attachInstaller"
|
||||
| "audioBackendAuto"
|
||||
| "audioBackendDesc"
|
||||
| "audioBackendDsound"
|
||||
| "audioBackendNone"
|
||||
| "audioBackendTitle"
|
||||
| "audioDesc"
|
||||
| "audioDisabledReason"
|
||||
| "audioTroubleshootNote"
|
||||
| "autoPinPCores"
|
||||
| "back"
|
||||
| "backToEdit"
|
||||
| "borderless"
|
||||
| "brokenHint"
|
||||
| "cancel"
|
||||
| "cancelCreate"
|
||||
| "cancelQueue"
|
||||
| "captureInput"
|
||||
| "captureInputHint"
|
||||
| "catAdvanced"
|
||||
| "catAudio"
|
||||
| "catCompute"
|
||||
| "catGeneral"
|
||||
| "catGraphics"
|
||||
| "catInput"
|
||||
| "catInputAudio"
|
||||
| "catLogs"
|
||||
| "catNetwork"
|
||||
| "catStorage"
|
||||
| "catStorageNet"
|
||||
| "choose"
|
||||
| "clear"
|
||||
| "cloneConfirm"
|
||||
| "cloneDesc"
|
||||
| "cloneNameLabel"
|
||||
| "cloneTitle"
|
||||
| "cloneVM"
|
||||
| "close"
|
||||
| "closeWindow"
|
||||
| "collapseLogs"
|
||||
| "commandToggle"
|
||||
| "commandToggleHint"
|
||||
| "configured"
|
||||
| "connGroup"
|
||||
| "copy"
|
||||
| "copyScreenshot"
|
||||
| "copyTechInfo"
|
||||
| "cores"
|
||||
| "coresUnit"
|
||||
| "cpuOverHint"
|
||||
| "cpuRecHint"
|
||||
| "createNow"
|
||||
| "createStartedHint"
|
||||
| "delete"
|
||||
| "deleteConfirm"
|
||||
| "deleteDesc"
|
||||
| "deleteDescKeep"
|
||||
| "deleteEllipsis"
|
||||
| "deleteKeepFiles"
|
||||
| "deleteTitle"
|
||||
| "deliverFileShort"
|
||||
| "detachGuestTools"
|
||||
| "diagAhciUpgradeHint"
|
||||
| "diagBackingChainBroken"
|
||||
| "diagBackingChainWarn"
|
||||
| "diagExternalDriveWarn"
|
||||
| "diagHighMemWarn"
|
||||
| "diskCompactAction"
|
||||
| "diskCompactDesc"
|
||||
| "diskCompactDone"
|
||||
| "diskCompactNoGain"
|
||||
| "diskCompactQcow2Only"
|
||||
| "diskCompactTitle"
|
||||
| "diskController"
|
||||
| "diskControllerInstallHint"
|
||||
| "diskControllerNvmeHint"
|
||||
| "diskControllerNvmeReadyHint"
|
||||
| "diskControllerVirtioHint"
|
||||
| "diskControllerWarn"
|
||||
| "diskMode"
|
||||
| "diskModeCopy"
|
||||
| "diskModeInPlace"
|
||||
| "diskResizeAction"
|
||||
| "diskResizeDesc"
|
||||
| "diskResizeDone"
|
||||
| "diskResizeTitle"
|
||||
| "diskSize"
|
||||
| "diskSizeHint"
|
||||
| "diskUsageSummary"
|
||||
| "displayGroup"
|
||||
| "displayNameEdit"
|
||||
| "displayNameEditEllipsis"
|
||||
| "displayNameLabel"
|
||||
| "displayNameTip"
|
||||
| "displays"
|
||||
| "driveShareMaster"
|
||||
| "driveShareMasterDesc"
|
||||
| "driveShareNeedsTools"
|
||||
| "driveShareNoDrives"
|
||||
| "driveShareReadOnly"
|
||||
| "driveShareSystem"
|
||||
| "driveShareTitle"
|
||||
| "dropFilesHint"
|
||||
| "effectImmediate"
|
||||
| "effectNextStart"
|
||||
| "eject"
|
||||
| "emptyVMs"
|
||||
| "enableAudio"
|
||||
| "enableLogs"
|
||||
| "enableNetwork"
|
||||
| "enableWHPX"
|
||||
| "enterRecovery"
|
||||
| "errCopyDetails"
|
||||
| "errRawDetailsToggle"
|
||||
| "errorBoundaryReload"
|
||||
| "errorBoundaryTitle"
|
||||
| "expandLogs"
|
||||
| "exportDiagnostics"
|
||||
| "extraArgs"
|
||||
| "extraArgsDesc"
|
||||
| "factBackingChain"
|
||||
| "factCPU"
|
||||
| "factDisk"
|
||||
| "factGraphics"
|
||||
| "factMemory"
|
||||
| "failAffinity"
|
||||
| "failAttachInstaller"
|
||||
| "failCloneVM"
|
||||
| "failCreate"
|
||||
| "failDelete"
|
||||
| "failDownload"
|
||||
| "failEject"
|
||||
| "failEnterRecovery"
|
||||
| "failExportDiagnostics"
|
||||
| "failFinishInstall"
|
||||
| "failFocus"
|
||||
| "failGeneric"
|
||||
| "failGuestTools"
|
||||
| "failOpenFolder"
|
||||
| "failRestart"
|
||||
| "failRuntime"
|
||||
| "failSSH"
|
||||
| "failScreenshot"
|
||||
| "failSnapshot"
|
||||
| "failStart"
|
||||
| "failStop"
|
||||
| "failType"
|
||||
| "failUpgradeNVMe"
|
||||
| "fieldAudio"
|
||||
| "fieldCPUModel"
|
||||
| "fieldController"
|
||||
| "fieldDir"
|
||||
| "fieldDisk"
|
||||
| "fieldGraphicsBackend"
|
||||
| "fieldICD"
|
||||
| "fieldKind"
|
||||
| "fieldNetwork"
|
||||
| "fieldVMName"
|
||||
| "finishInstall"
|
||||
| "fontMissingFoDHint"
|
||||
| "footerDisk"
|
||||
| "footerDiskLabel"
|
||||
| "footerDiskTip"
|
||||
| "footerDiskValue"
|
||||
| "footerHostIssue"
|
||||
| "footerHostIssueTip"
|
||||
| "footerMem"
|
||||
| "footerMemAvail"
|
||||
| "footerMemLabel"
|
||||
| "footerMemTip"
|
||||
| "footerMemValue"
|
||||
| "footerRunningVMs"
|
||||
| "forceStop"
|
||||
| "fullscreenLaunch"
|
||||
| "fullscreenLaunchHint"
|
||||
| "gpuAuto"
|
||||
| "gpuAutoOption"
|
||||
| "gpuAutoSub"
|
||||
| "gpuAutoTitle"
|
||||
| "gpuCompatUnsupported"
|
||||
| "gpuCompatWarn"
|
||||
| "gpuCustomIcd"
|
||||
| "gpuDiscrete"
|
||||
| "gpuErrMissingExt"
|
||||
| "gpuErrVulkanCpu"
|
||||
| "gpuErrVulkanTooOld"
|
||||
| "gpuIntegrated"
|
||||
| "gpuKindDiscrete"
|
||||
| "gpuKindIntegrated"
|
||||
| "gpuRecommended"
|
||||
| "gpuSelect"
|
||||
| "gpuSvgaReason"
|
||||
| "gpuSwitchSvga"
|
||||
| "gpuUnavailableHint"
|
||||
| "gpuUnknown"
|
||||
| "gpuVirtual"
|
||||
| "gpuWarnAmdLegacy"
|
||||
| "gpuWarnAmdRdna2"
|
||||
| "graphicsBackend"
|
||||
| "graphicsReimsDesc"
|
||||
| "graphicsReimsShort"
|
||||
| "graphicsRunningReason"
|
||||
| "graphicsSvgaDesc"
|
||||
| "graphicsSvgaShort"
|
||||
| "groupGraphics"
|
||||
| "groupMacOS"
|
||||
| "groupPerformance"
|
||||
| "groupQemu"
|
||||
| "gtInstall"
|
||||
| "gtInstallCmd"
|
||||
| "gtInstallSub"
|
||||
| "gtNotInstalledDesc"
|
||||
| "gtStatusConnected"
|
||||
| "gtStatusEnabled"
|
||||
| "gtStatusNone"
|
||||
| "gtStatusOff"
|
||||
| "gtStatusOffTip"
|
||||
| "gtStatusUpgrade"
|
||||
| "gtStatusWaiting"
|
||||
| "gtStatusWaitingTip"
|
||||
| "gtUpdate"
|
||||
| "guestKbdPinyin"
|
||||
| "guestKbdUS"
|
||||
| "guestKbdUSRecommended"
|
||||
| "guestLang"
|
||||
| "guestLangEnUS"
|
||||
| "guestLangHint"
|
||||
| "guestLangJaJP"
|
||||
| "guestLangKoKR"
|
||||
| "guestLangSettingsHint"
|
||||
| "guestLangShort"
|
||||
| "guestLangZhHansUS"
|
||||
| "guestLangZhHantUS"
|
||||
| "guestMemory"
|
||||
| "guestToolsConnected"
|
||||
| "guestToolsModeSync"
|
||||
| "guestToolsModeWebDAV"
|
||||
| "guestToolsPreventSleep"
|
||||
| "guestToolsPreventSleepSub"
|
||||
| "guestToolsReady"
|
||||
| "guestToolsSleepActive"
|
||||
| "guestToolsTitle"
|
||||
| "guestToolsUpgradeHint"
|
||||
| "guideBuiltIn1"
|
||||
| "guideBuiltIn2"
|
||||
| "guideBuiltIn3"
|
||||
| "guideKindBuiltIn"
|
||||
| "guideKindOffline"
|
||||
| "guideKindOnline"
|
||||
| "guideOffline1"
|
||||
| "guideOffline2"
|
||||
| "guideOffline3"
|
||||
| "guideStartHint"
|
||||
| "guideStep1"
|
||||
| "guideStep2"
|
||||
| "guideStep3"
|
||||
| "guideTitle"
|
||||
| "helpAbout"
|
||||
| "helpCheckUpdate"
|
||||
| "helpProjectPage"
|
||||
| "helpReportIssue"
|
||||
| "hideSidebar"
|
||||
| "hidpiPresetBadge"
|
||||
| "hidpiTipFullscreen"
|
||||
| "hidpiTipScale"
|
||||
| "hidpiTipUnavailable"
|
||||
| "hostAudioInput"
|
||||
| "hostAudioMissingIn"
|
||||
| "hostAudioMissingOut"
|
||||
| "hostAudioOutput"
|
||||
| "hostCPU"
|
||||
| "hostCoresThreads"
|
||||
| "hostDataRoot"
|
||||
| "hostDisk"
|
||||
| "hostDisplayHint"
|
||||
| "hostDisplayPrimary"
|
||||
| "hostDisplays"
|
||||
| "hostGPUs"
|
||||
| "hostNeedsAction"
|
||||
| "hostRAM"
|
||||
| "hostRAMAvail"
|
||||
| "hostRAMTotal"
|
||||
| "hostReady"
|
||||
| "hostRuntime"
|
||||
| "hostWHPX"
|
||||
| "importRuntime"
|
||||
| "installersAvailable"
|
||||
| "installersCreateVM"
|
||||
| "installersDelete"
|
||||
| "installersDeleteConfirm"
|
||||
| "installersDownload"
|
||||
| "installersDownloaded"
|
||||
| "installersDownloading"
|
||||
| "installersDownloadingForVM"
|
||||
| "installersDownloadingPct"
|
||||
| "installersEmpty"
|
||||
| "installersHint"
|
||||
| "installersKindOffline"
|
||||
| "installersKindOnline"
|
||||
| "installersLatest"
|
||||
| "installersNoSpace"
|
||||
| "installersOlder"
|
||||
| "installersPartial"
|
||||
| "installersQueued"
|
||||
| "installersQueuedDesc"
|
||||
| "installersQueuedForVM"
|
||||
| "installersResume"
|
||||
| "installersRetry"
|
||||
| "installersTitle"
|
||||
| "installersWaitingVM"
|
||||
| "issuesCount"
|
||||
| "jumpLatest"
|
||||
| "kernelIrqchipAuto"
|
||||
| "kernelIrqchipLabel"
|
||||
| "kernelIrqchipOff"
|
||||
| "kernelIrqchipOn"
|
||||
| "language"
|
||||
| "languageSub"
|
||||
| "localeAuto"
|
||||
| "localeAutoDetail"
|
||||
| "logActivity"
|
||||
| "logButton"
|
||||
| "logCopy"
|
||||
| "logErrorsOnly"
|
||||
| "logLevel"
|
||||
| "logLevelCustom"
|
||||
| "logLevelDesc"
|
||||
| "logQemu"
|
||||
| "logSearchPlaceholder"
|
||||
| "logSerial"
|
||||
| "logsEmpty"
|
||||
| "macos.appsUtilitiesTerminal"
|
||||
| "macos.diskUtility"
|
||||
| "macos.erase"
|
||||
| "macos.finder"
|
||||
| "macos.guidPartitionMap"
|
||||
| "macos.otherSignInSetUpLater"
|
||||
| "macos.recovery"
|
||||
| "macos.reinstallMacOS"
|
||||
| "macos.setupAssistant"
|
||||
| "macos.showAllDevices"
|
||||
| "macos.utilitiesTerminal"
|
||||
| "macos.volume"
|
||||
| "macosVersion"
|
||||
| "maximize"
|
||||
| "memCommitHint"
|
||||
| "memOverHint"
|
||||
| "memRecHint"
|
||||
| "menuBar"
|
||||
| "menuHelp"
|
||||
| "menuVM"
|
||||
| "menuView"
|
||||
| "minimize"
|
||||
| "minimizeToTray"
|
||||
| "minimizeToTraySub"
|
||||
| "more"
|
||||
| "multiDisplayHint"
|
||||
| "navHasIssue"
|
||||
| "netOff"
|
||||
| "netShared"
|
||||
| "networkDesc"
|
||||
| "networkOfflineHint"
|
||||
| "networkTitle"
|
||||
| "newVM"
|
||||
| "newVMEllipsis"
|
||||
| "next"
|
||||
| "noChanges"
|
||||
| "noRuntimeAlert"
|
||||
| "off"
|
||||
| "offlineCached"
|
||||
| "offlineDownloading"
|
||||
| "offlineHint"
|
||||
| "offlineListFailed"
|
||||
| "offlineListFailedDetail"
|
||||
| "offlineLoading"
|
||||
| "offlineQueued"
|
||||
| "offlineSpaceWarn"
|
||||
| "on"
|
||||
| "onlineRecoveryConfirm"
|
||||
| "onlineRecoveryDesc"
|
||||
| "onlineRecoveryTitle"
|
||||
| "openFolder"
|
||||
| "openSharedFolder"
|
||||
| "openShort"
|
||||
| "opencore"
|
||||
| "optAuto"
|
||||
| "optAvailable"
|
||||
| "optExperimental"
|
||||
| "optKernelIrqchipExp"
|
||||
| "optKernelIrqchipNestedErr"
|
||||
| "optKernelIrqchipRec"
|
||||
| "optKernelIrqchipUnavailable"
|
||||
| "optKernelIrqchipWin10NoPatch"
|
||||
| "optPCoreSub"
|
||||
| "optPCoreUnavailable"
|
||||
| "optRecommended"
|
||||
| "optSchedBackground"
|
||||
| "optSchedNowBackground"
|
||||
| "optSchedNowPrograms"
|
||||
| "optSchedOpen"
|
||||
| "optSchedPrograms"
|
||||
| "optSchedSub"
|
||||
| "optSchedTitle"
|
||||
| "optUnavailable"
|
||||
| "panelLoadFailed"
|
||||
| "pauseDownload"
|
||||
| "pendingChanges"
|
||||
| "pendingRestartHint"
|
||||
| "pendingTitle"
|
||||
| "pickRecoveryTitle"
|
||||
| "platformReadonly"
|
||||
| "pluginAccentSeed"
|
||||
| "pluginActiveCount"
|
||||
| "pluginActiveTheme"
|
||||
| "pluginAlwaysOn"
|
||||
| "pluginApproveCheckbox"
|
||||
| "pluginApproveConfirm"
|
||||
| "pluginApproveL3Warn"
|
||||
| "pluginApproveTitle"
|
||||
| "pluginBuiltinSection"
|
||||
| "pluginColorSchemes"
|
||||
| "pluginColorSchemesHint"
|
||||
| "pluginDeleteScheme"
|
||||
| "pluginDone"
|
||||
| "pluginEntryPath"
|
||||
| "pluginExternalSection"
|
||||
| "pluginFailDeleteScheme"
|
||||
| "pluginFailEnable"
|
||||
| "pluginFailImport"
|
||||
| "pluginFailLinkDev"
|
||||
| "pluginFailLoad"
|
||||
| "pluginFailLoadSettings"
|
||||
| "pluginFailMarketInstall"
|
||||
| "pluginFailMarketLoad"
|
||||
| "pluginFailReadLog"
|
||||
| "pluginFailRemove"
|
||||
| "pluginFailSaveScheme"
|
||||
| "pluginFailSaveSettings"
|
||||
| "pluginFailScan"
|
||||
| "pluginFailSwitchTheme"
|
||||
| "pluginFailToggle"
|
||||
| "pluginGlobalSettings"
|
||||
| "pluginHighRiskNotice"
|
||||
| "pluginImportBtn"
|
||||
| "pluginImportTitle"
|
||||
| "pluginInUse"
|
||||
| "pluginLinkDevBtn"
|
||||
| "pluginLinkDevTitle"
|
||||
| "pluginLogEmpty"
|
||||
| "pluginLogTitle"
|
||||
| "pluginMarketEmpty"
|
||||
| "pluginMarketIncludeAlpha"
|
||||
| "pluginMarketIncompatible"
|
||||
| "pluginMarketInstall"
|
||||
| "pluginMarketInstalled"
|
||||
| "pluginMarketKindAll"
|
||||
| "pluginMarketKindDriver"
|
||||
| "pluginMarketKindLocale"
|
||||
| "pluginMarketKindTheme"
|
||||
| "pluginMarketKindTool"
|
||||
| "pluginMarketRefresh"
|
||||
| "pluginMarketSearchPlaceholder"
|
||||
| "pluginMarketSourceCache"
|
||||
| "pluginMarketSourceFallback"
|
||||
| "pluginMarketSourceRemote"
|
||||
| "pluginMarketStaleBanner"
|
||||
| "pluginMarketUpdate"
|
||||
| "pluginMarketWithdrawn"
|
||||
| "pluginMarketWithdrawnInstalledWarn"
|
||||
| "pluginMarketWithdrawnInstead"
|
||||
| "pluginNewScheme"
|
||||
| "pluginPanelsSection"
|
||||
| "pluginPermCount"
|
||||
| "pluginPermissionsLabel"
|
||||
| "pluginPublisherLicense"
|
||||
| "pluginRemove"
|
||||
| "pluginRequestedPerms"
|
||||
| "pluginSafeModeShort"
|
||||
| "pluginScanAdvisoriesSection"
|
||||
| "pluginScanArchiveTitle"
|
||||
| "pluginScanBlockedBtn"
|
||||
| "pluginScanCapabilitiesSection"
|
||||
| "pluginScanHardSection"
|
||||
| "pluginScanInspect"
|
||||
| "pluginScanInstallConfirm"
|
||||
| "pluginScanLoading"
|
||||
| "pluginScanModalTitle"
|
||||
| "pluginScanMoreItems"
|
||||
| "pluginSchemeDefault"
|
||||
| "pluginSchemeModalTitle"
|
||||
| "pluginSchemeName"
|
||||
| "pluginSchemePlaceholder"
|
||||
| "pluginSearchEmpty"
|
||||
| "pluginSearchPlaceholder"
|
||||
| "pluginSettings"
|
||||
| "pluginStateDegraded"
|
||||
| "pluginStateFailed"
|
||||
| "pluginStatePending"
|
||||
| "pluginSurfaceSeed"
|
||||
| "pluginTabInstalled"
|
||||
| "pluginTabMarket"
|
||||
| "pluginThemeEmptyHint"
|
||||
| "pluginThemeHint"
|
||||
| "pluginThemePackLabel"
|
||||
| "pluginThemeSafeModeHint"
|
||||
| "pluginThemeSection"
|
||||
| "pluginTrustCommunity"
|
||||
| "pluginTrustDev"
|
||||
| "pluginTrustOfficial"
|
||||
| "pluginTrustVerified"
|
||||
| "pluginViewLog"
|
||||
| "recommendedBadge"
|
||||
| "refresh"
|
||||
| "resCustom"
|
||||
| "resCustomSub"
|
||||
| "resFullscreen"
|
||||
| "resInvalid"
|
||||
| "resLooksLike"
|
||||
| "resetAll"
|
||||
| "resetField"
|
||||
| "resizeLogPanel"
|
||||
| "resolution"
|
||||
| "restart"
|
||||
| "restartToApply"
|
||||
| "runtimeAlpha"
|
||||
| "runtimeAlphaHint"
|
||||
| "runtimeChannel_alpha"
|
||||
| "runtimeChannel_stable"
|
||||
| "runtimeCurrent"
|
||||
| "runtimeDelete"
|
||||
| "runtimeDeleteConfirm"
|
||||
| "runtimeDeleted"
|
||||
| "runtimeInstall"
|
||||
| "runtimeLatest"
|
||||
| "runtimeLookupFailed"
|
||||
| "runtimeLookupRateLimit"
|
||||
| "runtimeNewer"
|
||||
| "runtimeNoneOnChannel"
|
||||
| "runtimeOnline"
|
||||
| "runtimeRetry"
|
||||
| "runtimeUpToDate"
|
||||
| "runtimeUpdate"
|
||||
| "safeModeBanner"
|
||||
| "safeModeManagePlugins"
|
||||
| "save"
|
||||
| "secondsUnit"
|
||||
| "sendText"
|
||||
| "sendTextConfirm"
|
||||
| "sendTextDesc"
|
||||
| "sendTextDescNoGT"
|
||||
| "sendTextPlaceholder"
|
||||
| "sendTextTitle"
|
||||
| "settings"
|
||||
| "settingsAbout"
|
||||
| "settingsAppearance"
|
||||
| "settingsEllipsis"
|
||||
| "settingsGeneral"
|
||||
| "settingsTitle"
|
||||
| "setupCheck"
|
||||
| "setupContinue"
|
||||
| "setupDesc"
|
||||
| "setupDone"
|
||||
| "setupExternal"
|
||||
| "setupFree"
|
||||
| "setupGPU"
|
||||
| "setupImport"
|
||||
| "setupLater"
|
||||
| "setupNoGPU"
|
||||
| "setupOther"
|
||||
| "setupRecMem"
|
||||
| "setupRecommended"
|
||||
| "setupReuse"
|
||||
| "setupRuntimeDesc"
|
||||
| "setupRuntimeTitle"
|
||||
| "setupSystem"
|
||||
| "setupTitle"
|
||||
| "setupWarnExternal"
|
||||
| "setupWarnSpace"
|
||||
| "setupWarnSystem"
|
||||
| "sharedFolder"
|
||||
| "shortcutBarFullscreen"
|
||||
| "shortcutBarRelease"
|
||||
| "showInstallGuide"
|
||||
| "showSidebar"
|
||||
| "showWindow"
|
||||
| "sidebarHost"
|
||||
| "sidebarInstallers"
|
||||
| "sidebarItemAria"
|
||||
| "sidebarLabel"
|
||||
| "sidebarPlugins"
|
||||
| "sidebarSettings"
|
||||
| "sidebarSystem"
|
||||
| "sidebarVMs"
|
||||
| "snapshotCreate"
|
||||
| "snapshotDelete"
|
||||
| "snapshotEmpty"
|
||||
| "snapshotHint"
|
||||
| "snapshotNamePlaceholder"
|
||||
| "snapshotRestore"
|
||||
| "snapshotRestoreDesc"
|
||||
| "snapshotRestoreTitle"
|
||||
| "snapshotStopFirst"
|
||||
| "snapshotsTitle"
|
||||
| "softwareGraphics"
|
||||
| "sourceDisk"
|
||||
| "sourceInstaller"
|
||||
| "specCPULiveTip"
|
||||
| "specCPUTip"
|
||||
| "specDiskTip"
|
||||
| "specDiskUsage"
|
||||
| "specGraphicsTip"
|
||||
| "specLang"
|
||||
| "specLangTip"
|
||||
| "specLangTipDetail"
|
||||
| "specMemLiveTip"
|
||||
| "specMemTip"
|
||||
| "specNetOffTip"
|
||||
| "specNetSSHTip"
|
||||
| "specNetTip"
|
||||
| "srcAppleSub"
|
||||
| "srcAppleTitle"
|
||||
| "srcDiskSub"
|
||||
| "srcDiskTitle"
|
||||
| "srcInstallerSub"
|
||||
| "srcInstallerTitle"
|
||||
| "srcOfflineSub"
|
||||
| "srcOfflineTitle"
|
||||
| "sshForward"
|
||||
| "sshMore"
|
||||
| "sshNeedsNetwork"
|
||||
| "sshOffDesc"
|
||||
| "sshOpenTerminal"
|
||||
| "sshOpenVSCode"
|
||||
| "sshPort"
|
||||
| "sshSetUser"
|
||||
| "sshUserDesc"
|
||||
| "sshUserPlaceholder"
|
||||
| "sshUserTitle"
|
||||
| "sshWriteConfig"
|
||||
| "start"
|
||||
| "startAfterCreate"
|
||||
| "starting"
|
||||
| "state_broken"
|
||||
| "state_creating"
|
||||
| "state_driver_unavailable"
|
||||
| "state_running"
|
||||
| "state_starting"
|
||||
| "state_stopped"
|
||||
| "state_stopping"
|
||||
| "statsCPU"
|
||||
| "statsDisk"
|
||||
| "statsDiskSub"
|
||||
| "statsMemory"
|
||||
| "statsUptime"
|
||||
| "step1"
|
||||
| "step2"
|
||||
| "step3"
|
||||
| "step4"
|
||||
| "step5"
|
||||
| "stop"
|
||||
| "stopBeforeDiskOp"
|
||||
| "stopTimeout"
|
||||
| "stopTimeoutHint"
|
||||
| "storageBreakdownTitle"
|
||||
| "storageInstallers"
|
||||
| "storageRuntimes"
|
||||
| "storageVMs"
|
||||
| "summaryAppleSource"
|
||||
| "summaryDefaultDir"
|
||||
| "summaryDiskGrow"
|
||||
| "summaryDiskSource"
|
||||
| "summaryEdit"
|
||||
| "summaryInstallerSource"
|
||||
| "summaryLogs"
|
||||
| "summaryOfflineSource"
|
||||
| "summaryOn"
|
||||
| "summarySSH"
|
||||
| "summarySSHPort"
|
||||
| "summarySource"
|
||||
| "taskAppUpdate"
|
||||
| "taskCreate"
|
||||
| "taskDownload"
|
||||
| "taskRecoveryDownload"
|
||||
| "taskRuntime"
|
||||
| "tasksRunning"
|
||||
| "techInfo"
|
||||
| "themeDark"
|
||||
| "themeLabel"
|
||||
| "themeLight"
|
||||
| "themePluginDarkDisabled"
|
||||
| "themePluginLightDisabled"
|
||||
| "themeSwitchDark"
|
||||
| "themeSwitchLight"
|
||||
| "themeSystem"
|
||||
| "toastAffinityApplied"
|
||||
| "toastAffinitySaved"
|
||||
| "toastBorderlessNextStart"
|
||||
| "toastBorderlessUpdated"
|
||||
| "toastCloned"
|
||||
| "toastCopied"
|
||||
| "toastCreateCanceled"
|
||||
| "toastCreateCanceledPartial"
|
||||
| "toastCreated"
|
||||
| "toastDeleted"
|
||||
| "toastDiagExported"
|
||||
| "toastDownloadPaused"
|
||||
| "toastEjected"
|
||||
| "toastEnterRecovery"
|
||||
| "toastEnterRecoveryNextStart"
|
||||
| "toastExitRecoveryNextStart"
|
||||
| "toastFileDelivered"
|
||||
| "toastFilesDelivered"
|
||||
| "toastGuestToolsAttached"
|
||||
| "toastGuestToolsAttachedNextStart"
|
||||
| "toastGuestToolsDetached"
|
||||
| "toastGuestToolsDetachedNextStart"
|
||||
| "toastInstallFinished"
|
||||
| "toastInstallerAttached"
|
||||
| "toastInstallerAttachedNextStart"
|
||||
| "toastInstallerReady"
|
||||
| "toastNVMeNextStart"
|
||||
| "toastNVMeReady"
|
||||
| "toastOnlineRecoveryAttached"
|
||||
| "toastOnlineRecoveryStarted"
|
||||
| "toastPreventSleepOff"
|
||||
| "toastPreventSleepOn"
|
||||
| "toastQueueCanceled"
|
||||
| "toastRuntimeReady"
|
||||
| "toastSSHConfigWritten"
|
||||
| "toastSSHUserSaved"
|
||||
| "toastSaved"
|
||||
| "toastSavedNextStart"
|
||||
| "toastScreenshotCopied"
|
||||
| "toastSnapshotCreated"
|
||||
| "toastSnapshotDeleted"
|
||||
| "toastSnapshotRestored"
|
||||
| "toastStopped"
|
||||
| "toastTyped"
|
||||
| "typeClipboard"
|
||||
| "typeIntoVM"
|
||||
| "typeUntypeable"
|
||||
| "updateCancel"
|
||||
| "updateCapsuleAvailable"
|
||||
| "updateCapsuleDownloading"
|
||||
| "updateCapsuleDownloadingPct"
|
||||
| "updateCapsuleFailed"
|
||||
| "updateCapsuleOpen"
|
||||
| "updateCapsuleReady"
|
||||
| "updateConfirmBody"
|
||||
| "updateConfirmTitle"
|
||||
| "updateConfirmWin10"
|
||||
| "updateDoneToast"
|
||||
| "updateDownload"
|
||||
| "updateDownloadInstall"
|
||||
| "updateDownloadingSub"
|
||||
| "updateFailed"
|
||||
| "updateFailedSub"
|
||||
| "updateLater"
|
||||
| "updateReadySub"
|
||||
| "updateReleaseNotes"
|
||||
| "updateRestart"
|
||||
| "updateRetry"
|
||||
| "upgradeToNVMe"
|
||||
| "uptimeHoursMinutes"
|
||||
| "uptimeMinutesSeconds"
|
||||
| "uptimeSeconds"
|
||||
| "useDefault"
|
||||
| "validationChecking"
|
||||
| "validationPassed"
|
||||
| "vcpus"
|
||||
| "viewLogs"
|
||||
| "vmDir"
|
||||
| "vmName"
|
||||
| "welcomeCheckHost"
|
||||
| "welcomeSub"
|
||||
| "welcomeTitle"
|
||||
| "whpxMissing"
|
||||
| "whpxMissingShort"
|
||||
| "whpxNoHv"
|
||||
| "whpxNoHvShort"
|
||||
| "whpxReady"
|
||||
| "whpxTitle"
|
||||
| "whpxUnsupported"
|
||||
| "whpxUnsupportedShort"
|
||||
| "wizChooseFile"
|
||||
| "wizNoFile"
|
||||
| "wizOptions"
|
||||
| "wizardBasics"
|
||||
| "wizardDriverGroup"
|
||||
| "wizardDriverType"
|
||||
| "wizardTitle";
|
||||
@@ -0,0 +1,12 @@
|
||||
import { coreEn, coreZh } from './domains/core.gen'
|
||||
import { vmEn, vmZh } from './domains/vm.gen'
|
||||
|
||||
export const builtinDict: Record<'zh-CN' | 'en-US', Record<string, string>> = {
|
||||
'zh-CN': { ...coreZh, ...vmZh },
|
||||
'en-US': { ...coreEn, ...vmEn },
|
||||
}
|
||||
|
||||
export function registerBuiltinDomain(zh: Record<string, string>, en: Record<string, string>): void {
|
||||
Object.assign(builtinDict['zh-CN'], zh)
|
||||
Object.assign(builtinDict['en-US'], en)
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
import { t } from '../i18n'
|
||||
import { GPUInfo, HostReport, Locale, VMDetail } from '../types'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { formatLocaleNumber } from '../i18n/icu'
|
||||
import { DisplayPreset, GPUInfo, HostReport, Locale, VMDetail } from '../types'
|
||||
|
||||
// Human-readable values for the main view (docs/ui-redesign.md §4.3).
|
||||
function currentDocLocale(): string {
|
||||
if (typeof document === 'undefined') return 'en-US'
|
||||
return document.documentElement.dataset.locale || document.documentElement.lang || 'en-US'
|
||||
}
|
||||
|
||||
// Human-readable values for the main view (docs/design-guidelines.md §7.1).
|
||||
// Raw values stay available under "Technical details".
|
||||
|
||||
const MEMORY_CHOICES = [4, 6, 8, 12, 16, 24, 32, 48, 64]
|
||||
@@ -17,15 +23,42 @@ export function recommendedMemoryGB(host: HostReport): number {
|
||||
return MEMORY_CHOICES.reduce((best, m) => (m <= limit ? m : best), MEMORY_CHOICES[0])
|
||||
}
|
||||
|
||||
/** "16G" / "16384M" / "16GiB" → "16 GB". Unknown shapes pass through. */
|
||||
export function formatMemory(raw: string): string {
|
||||
/** Memory sizes offered as quick picks, in GB. */
|
||||
export const MEMORY_MARKS = MEMORY_CHOICES
|
||||
|
||||
/**
|
||||
* Largest memory size in GB that still fits the same limits
|
||||
* recommendedMemoryGB applies; above it the settings slider turns amber.
|
||||
*/
|
||||
export function memorySafeLimitGB(host: HostReport): number {
|
||||
let limit = host.total_ram_gb * 0.6
|
||||
if (host.commit_avail_gb > 0) limit = Math.min(limit, host.commit_avail_gb - 3)
|
||||
return Math.max(Math.floor(limit), recommendedMemoryGB(host))
|
||||
}
|
||||
|
||||
/** vCPU count suggested for a new VM; same rule as the create wizard. */
|
||||
export function recommendedCPUs(host: HostReport): number {
|
||||
const rec = host.logical_cpus >= 12 ? 8 : 4
|
||||
return host.logical_cpus > 0 ? Math.min(rec, host.logical_cpus) : rec
|
||||
}
|
||||
|
||||
/** "16G" / "16384M" / "16GiB" → 16. Null when the shape is unknown. */
|
||||
export function parseMemoryGB(raw: string | undefined): number | null {
|
||||
const m = /^\s*(\d+(?:\.\d+)?)\s*([KMGT])?(?:i?B)?\s*$/i.exec(raw ?? '')
|
||||
if (!m) return raw
|
||||
if (!m) return null
|
||||
const n = Number(m[1])
|
||||
const unit = (m[2] ?? 'M').toUpperCase()
|
||||
const gb = unit === 'T' ? n * 1024 : unit === 'G' ? n : unit === 'M' ? n / 1024 : n / 1024 / 1024
|
||||
return unit === 'T' ? n * 1024 : unit === 'G' ? n : unit === 'M' ? n / 1024 : n / 1024 / 1024
|
||||
}
|
||||
|
||||
/** "16G" / "16384M" / "16GiB" → "16 GB" (or "16,5 GB" in comma-decimal locales). */
|
||||
export function formatMemory(raw: string, locale?: Locale): string {
|
||||
const gb = parseMemoryGB(raw)
|
||||
if (gb === null) return raw
|
||||
const rounded = gb >= 10 ? Math.round(gb) : Math.round(gb * 10) / 10
|
||||
return `${rounded} GB`
|
||||
const loc = locale ?? currentDocLocale()
|
||||
const precision = Number.isInteger(rounded) ? 0 : 1
|
||||
return `${formatLocaleNumber(loc, rounded, precision)} GB`
|
||||
}
|
||||
|
||||
export function controllerLabel(raw: string): string {
|
||||
@@ -37,9 +70,63 @@ export function controllerLabel(raw: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
function findGPU(host: HostReport, icd: string): GPUInfo | undefined {
|
||||
const norm = (s: string) => s.replace(/\//g, '\\').toLowerCase()
|
||||
return (host.gpus ?? []).find((g) => norm(g.vulkan_icd) === norm(icd))
|
||||
const normPath = (s: string) => s.replace(/\//g, '\\').toLowerCase()
|
||||
|
||||
export function gpuKey(g: GPUInfo, idx = 0): string {
|
||||
const pci = g.vendor_id && g.device_id ? `${g.vendor_id}:${g.device_id}` : ''
|
||||
return `${pci}|${normPath(g.vulkan_icd || '')}|${g.name}|${idx}`
|
||||
}
|
||||
|
||||
export function sameGPU(a?: GPUInfo, b?: GPUInfo): boolean {
|
||||
if (!a || !b) return false
|
||||
if (a.vendor_id && a.device_id && b.vendor_id && b.device_id) {
|
||||
return a.vendor_id === b.vendor_id && a.device_id === b.device_id
|
||||
}
|
||||
return !!a.vulkan_icd && normPath(a.vulkan_icd) === normPath(b.vulkan_icd) && a.name === b.name
|
||||
}
|
||||
|
||||
/** Stable `--gpu` value for a GPU: its ICD path when unique, else its name (for shared AMD ICDs). */
|
||||
export function gpuOptionValue(g: GPUInfo, all: GPUInfo[]): string {
|
||||
if (g.vulkan_icd) {
|
||||
const target = normPath(g.vulkan_icd)
|
||||
const shared = all.filter((o) => o.vulkan_icd && normPath(o.vulkan_icd) === target).length > 1
|
||||
if (!shared) return g.vulkan_icd
|
||||
}
|
||||
return g.name
|
||||
}
|
||||
|
||||
export function findGPU(host: HostReport, value: string | undefined): GPUInfo | undefined {
|
||||
if (!value || value === 'auto') return host.recommended_gpu
|
||||
const norm = normPath(value)
|
||||
return (host.gpus ?? []).find(
|
||||
(g) => (g.vulkan_icd && normPath(g.vulkan_icd) === norm) || g.name.toLowerCase() === value.toLowerCase(),
|
||||
)
|
||||
}
|
||||
|
||||
export function gpuMetaLine(g: GPUInfo): string {
|
||||
const parts: string[] = []
|
||||
if (g.vendor_id && g.device_id) parts.push(`${g.vendor_id}:${g.device_id}`)
|
||||
if (g.vulkan_version) parts.push(`Vulkan ${g.vulkan_version}`)
|
||||
if (g.driver_version) parts.push(g.driver_version)
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
export function gpuCompatHint(locale: Locale, g?: GPUInfo): string {
|
||||
if (!g) return ''
|
||||
switch (g.compat_code) {
|
||||
case 'amd_legacy_win_driver':
|
||||
return t(locale, 'gpuWarnAmdLegacy', { ref: g.compat_detail || 'steelbrain/reims-vgpu#181' })
|
||||
case 'amd_rdna2_device_lost':
|
||||
return t(locale, 'gpuWarnAmdRdna2', { ref: g.compat_detail || 'steelbrain/reims-vgpu#173' })
|
||||
case 'vulkan_too_old':
|
||||
return t(locale, 'gpuErrVulkanTooOld', { ver: g.compat_detail || g.vulkan_version || '?' })
|
||||
case 'vulkan_missing_extensions':
|
||||
return t(locale, 'gpuErrMissingExt', { ext: g.compat_detail || '' })
|
||||
case 'vulkan_cpu':
|
||||
return t(locale, 'gpuErrVulkanCpu')
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
/** Drop vendor boilerplate: "NVIDIA GeForce RTX 4070 Ti" → "RTX 4070 Ti". */
|
||||
@@ -79,3 +166,169 @@ export function graphicsLabel(locale: Locale, d: VMDetail, host: HostReport): st
|
||||
export function sshCommand(port: number): string {
|
||||
return `ssh -p ${port} 127.0.0.1`
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number, locale?: Locale): string {
|
||||
if (!bytes || bytes <= 0) return '0 B'
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
let v = bytes
|
||||
let i = 0
|
||||
while (v >= 1024 && i < units.length - 1) {
|
||||
v /= 1024
|
||||
i++
|
||||
}
|
||||
const digits = v >= 100 || i === 0 ? 0 : v >= 10 ? 1 : 2
|
||||
const loc = locale ?? currentDocLocale()
|
||||
return `${formatLocaleNumber(loc, v, digits)} ${units[i]}`
|
||||
}
|
||||
|
||||
/** Compact "54 / 128 GB" when both are gigabytes, falling back to full units. */
|
||||
export function formatDiskUsage(actual: number, virtual: number, locale?: Locale): string {
|
||||
const GiB = 1024 ** 3
|
||||
const loc = locale ?? currentDocLocale()
|
||||
if (actual >= GiB && virtual >= GiB && virtual < 1024 * GiB) {
|
||||
const a = actual / GiB
|
||||
const v = virtual / GiB
|
||||
const aStr = a >= 10 ? formatLocaleNumber(loc, Math.round(a), 0) : formatLocaleNumber(loc, a, 1)
|
||||
const vStr = formatLocaleNumber(loc, Math.round(v), 0)
|
||||
return `${aStr} / ${vStr} GB`
|
||||
}
|
||||
return `${formatBytes(actual, loc)} / ${formatBytes(virtual, loc)}`
|
||||
}
|
||||
|
||||
export function formatUptime(sec: number, locale: Locale): string {
|
||||
if (!sec || sec <= 0) return '—'
|
||||
const h = Math.floor(sec / 3600)
|
||||
const m = Math.floor((sec % 3600) / 60)
|
||||
const s = sec % 60
|
||||
if (h > 0) return t(locale, 'uptimeHoursMinutes', { h, m })
|
||||
if (m > 0) return t(locale, 'uptimeMinutesSeconds', { m, s })
|
||||
return t(locale, 'uptimeSeconds', { s })
|
||||
}
|
||||
|
||||
// Used only when the host report has no presets: with nothing known about the
|
||||
// screen, no size can be called HiDPI (internal/host/display.go).
|
||||
const DEFAULT_DISPLAY_PRESETS: DisplayPreset[] = [
|
||||
{ resolution: '1920x1080', label: '1920 × 1080', hidpi: false, recommended: true },
|
||||
{ resolution: '2560x1440', label: '2560 × 1440', hidpi: false },
|
||||
{ resolution: '2880x1800', label: '2880 × 1800', hidpi: false },
|
||||
]
|
||||
|
||||
type Tr = (k: I18nKey, v?: Record<string, string | number>) => string
|
||||
|
||||
// The resolution row's description: the main display and its scaling.
|
||||
export function hostDisplayDesc(host: HostReport, tr: Tr): string | undefined {
|
||||
const d = host.primary_display
|
||||
if (!d) return undefined
|
||||
return tr('hostDisplayHint', { w: d.width, h: d.height, scale: d.scale_pct || 100 })
|
||||
}
|
||||
|
||||
// How to get a HiDPI (sharp-text) macOS desktop when no window size gives
|
||||
// one on this screen; undefined when one does.
|
||||
export function hostDisplayAdvice(host: HostReport, tr: Tr): string | undefined {
|
||||
const tip: Record<string, I18nKey> = {
|
||||
fullscreen: 'hidpiTipFullscreen',
|
||||
scale: 'hidpiTipScale',
|
||||
unavailable: 'hidpiTipUnavailable',
|
||||
}
|
||||
const key = host.hidpi_advice ? tip[host.hidpi_advice] : undefined
|
||||
return key ? tr(key) : undefined
|
||||
}
|
||||
|
||||
// "Looks like" size of a HiDPI preset: macOS draws it at half each way.
|
||||
export function hidpiLooksLike(resolution: string, tr: Tr): string | undefined {
|
||||
const m = /^(\d+)\s*[x×]\s*(\d+)$/i.exec(resolution)
|
||||
return m ? tr('resLooksLike', { w: Math.round(Number(m[1]) / 2), h: Math.round(Number(m[2]) / 2) }) : undefined
|
||||
}
|
||||
|
||||
export function recommendedDisplayPresets(host: HostReport): DisplayPreset[] {
|
||||
if (host.display_presets && host.display_presets.length > 0) {
|
||||
return host.display_presets
|
||||
}
|
||||
return DEFAULT_DISPLAY_PRESETS
|
||||
}
|
||||
|
||||
export function recommendedResolution(host: HostReport): string {
|
||||
if (host.recommended_resolution) return host.recommended_resolution
|
||||
const rec = recommendedDisplayPresets(host).find((p) => p.recommended)
|
||||
return rec?.resolution ?? '1920x1080'
|
||||
}
|
||||
|
||||
export interface GuestLangPreset {
|
||||
value: string
|
||||
labelKey: I18nKey
|
||||
detailKey?: I18nKey
|
||||
}
|
||||
|
||||
export const GUEST_LANG_PRESETS: GuestLangPreset[] = [
|
||||
{ value: 'zh-Hans:0', labelKey: 'guestLangZhHansUS', detailKey: 'guestKbdUSRecommended' },
|
||||
{ value: 'zh-Hans:252', labelKey: 'guestLangZhHansUS', detailKey: 'guestKbdPinyin' },
|
||||
{ value: 'zh-Hant:0', labelKey: 'guestLangZhHantUS', detailKey: 'guestKbdUS' },
|
||||
{ value: 'en-US:0', labelKey: 'guestLangEnUS' },
|
||||
{ value: 'ja-JP:0', labelKey: 'guestLangJaJP', detailKey: 'guestKbdUS' },
|
||||
{ value: 'ko-KR:0', labelKey: 'guestLangKoKR', detailKey: 'guestKbdUS' },
|
||||
]
|
||||
|
||||
export function guestLangOptions(locale: Locale): Array<{ value: string; label: string; detail?: string }> {
|
||||
return GUEST_LANG_PRESETS.map((p) => ({
|
||||
value: p.value,
|
||||
label: t(locale, p.labelKey),
|
||||
detail: p.detailKey ? t(locale, p.detailKey) : undefined,
|
||||
}))
|
||||
}
|
||||
|
||||
export function defaultGuestLang(locale: Locale): string {
|
||||
const l = locale.toLowerCase()
|
||||
if (l === 'zh-tw' || l === 'zh-hk' || l === 'zh-mo' || l.startsWith('zh-hant')) return 'zh-Hant:0'
|
||||
if (l.startsWith('zh')) return 'zh-Hans:0'
|
||||
if (l.startsWith('ja')) return 'ja-JP:0'
|
||||
if (l.startsWith('ko')) return 'ko-KR:0'
|
||||
return 'en-US:0'
|
||||
}
|
||||
|
||||
export function resolveGuestLang(locale: Locale, code: string | undefined): { label: string; detail?: string } {
|
||||
const target = code || defaultGuestLang(locale)
|
||||
const hit = GUEST_LANG_PRESETS.find((p) => p.value === target)
|
||||
if (!hit) return { label: target }
|
||||
const label = t(locale, hit.labelKey)
|
||||
const detail = hit.detailKey ? t(locale, hit.detailKey) : undefined
|
||||
return { label, detail }
|
||||
}
|
||||
|
||||
export function guestLangLabel(locale: Locale, code: string | undefined): string {
|
||||
const { label, detail } = resolveGuestLang(locale, code)
|
||||
return detail ? `${label} (${detail})` : label
|
||||
}
|
||||
|
||||
/**
|
||||
* Split "简体中文(美式键盘,推荐)" / "Simplified Chinese (US Keyboard)" into a
|
||||
* pop-up label and its grey detail, so the menu reads like macOS.
|
||||
*/
|
||||
export function splitLangLabel(value: string, text: string): { value: string; label: string; detail?: string } {
|
||||
const m = /^(.*?)\s*[((](.*)[))]\s*$/.exec(text)
|
||||
return m ? { value, label: m[1], detail: m[2] } : { value, label: text }
|
||||
}
|
||||
|
||||
/**
|
||||
* A change saved while the VM runs, as the user would say it:
|
||||
* `memory 8G→16G` becomes "内存 8 GB → 16 GB". Field names come from
|
||||
* PendingChange in internal/app/app.go.
|
||||
*/
|
||||
export function pendingChangeText(locale: Locale, p: { field: string; from: string; to: string }, host: HostReport): string {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const bool = (v: string) => tr(v === 'true' ? 'on' : 'off')
|
||||
const lang = (v: string) => resolveGuestLang(locale, v).label
|
||||
const fields: Record<string, { label: I18nKey; fmt: (v: string) => string }> = {
|
||||
cpus: { label: 'factCPU', fmt: (v) => tr('cores', { n: v }) },
|
||||
memory: { label: 'factMemory', fmt: (v) => formatMemory(v, locale) },
|
||||
resolution: { label: 'resolution', fmt: resolutionLabel },
|
||||
gpu: { label: 'factGraphics', fmt: (v) => gpuLabel(locale, v, host) },
|
||||
displays: { label: 'displays', fmt: (v) => v },
|
||||
borderless: { label: 'borderless', fmt: bool },
|
||||
audio: { label: 'fieldAudio', fmt: bool },
|
||||
audio_backend: { label: 'fieldAudio', fmt: (v) => v },
|
||||
guest_lang: { label: 'specLang', fmt: lang },
|
||||
}
|
||||
const f = fields[p.field]
|
||||
if (!f) return `${p.field} ${p.from} → ${p.to}`
|
||||
return `${tr(f.label)} ${f.fmt(p.from)} → ${f.fmt(p.to)}`
|
||||
}
|
||||
@@ -11,15 +11,18 @@ export const MAX_LOG_LINES = 2000
|
||||
|
||||
// Progress no longer reaches the log: the backend turns it into tasks
|
||||
// (tasks.go, "reims:task"). Levels are still guessed from the text until the
|
||||
// backend tags them (docs/ui-redesign.md §6 B2).
|
||||
// backend tags them explicitly.
|
||||
const ERROR_RE = /\b(error|failed|fatal|panic)\b/i
|
||||
const WARN_RE = /\bwarn(ing)?\b/i
|
||||
|
||||
let nextId = 1
|
||||
|
||||
export function classify(entry: LogEntry): LogLine {
|
||||
const level: LogLevel = ERROR_RE.test(entry.line) ? 'error' : WARN_RE.test(entry.line) ? 'warn' : 'info'
|
||||
return { ...entry, id: nextId++, level }
|
||||
const ts = typeof entry?.ts === 'string' ? entry.ts : ''
|
||||
const source = typeof entry?.source === 'string' ? entry.source : ''
|
||||
const line = typeof entry?.line === 'string' ? entry.line : String(entry?.line ?? '')
|
||||
const level: LogLevel = ERROR_RE.test(line) ? 'error' : WARN_RE.test(line) ? 'warn' : 'info'
|
||||
return { ts, source, line, id: nextId++, level }
|
||||
}
|
||||
|
||||
export function appendLog(prev: LogLine[], entry: LogEntry): LogLine[] {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// Which macOS major version a VM runs, for its icon. The release comes from
|
||||
// GetVMMacOS (.reims-go-macos, written at creation: "26.7.3" or "tahoe");
|
||||
// VMs without one are guessed from their name or display name.
|
||||
|
||||
const CODENAMES: [string, number][] = [
|
||||
['tahoe', 26],
|
||||
['sequoia', 15],
|
||||
['sonoma', 14],
|
||||
['ventura', 13],
|
||||
['monterey', 12],
|
||||
['bigsur', 11],
|
||||
['big sur', 11],
|
||||
['big-sur', 11],
|
||||
]
|
||||
|
||||
function fromText(text: string): number | null {
|
||||
const s = text.trim().toLowerCase()
|
||||
if (!s) return null
|
||||
const ver = /^(\d{2})(?:\.\d+)*$/.exec(s)
|
||||
if (ver) return Number(ver[1])
|
||||
for (const [name, major] of CODENAMES) if (s.includes(name)) return major
|
||||
const tagged = /macos[\s_-]*(\d{2})(?!\d)/.exec(s)
|
||||
if (tagged) {
|
||||
const n = Number(tagged[1])
|
||||
if (n >= 10 && n <= 60) return n
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** The major version (26, 15, …) from the recorded release, else from the hints. */
|
||||
export function macOSMajor(release: string | undefined, ...hints: (string | undefined)[]): number | null {
|
||||
for (const text of [release, ...hints]) {
|
||||
const n = text ? fromText(text) : null
|
||||
if (n !== null) return n
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale, Optimization, OptimizationStatus } from '../types'
|
||||
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
import { t } from '../i18n'
|
||||
import { Locale, Task } from '../types'
|
||||
import { CachedInstaller, InstallerKind, InstallerPhase, Locale, Task } from '../types'
|
||||
|
||||
// Match the finished-task retention period in internal/app/tasks.go.
|
||||
export const finishedTaskTTL = 10 * 60 * 1000
|
||||
|
||||
export function pruneFinishedTasks(tasks: Record<string, Task>, cutoff: number): Record<string, Task> {
|
||||
let next = tasks
|
||||
for (const task of Object.values(tasks)) {
|
||||
if (task.status === 'running' || task.updated_at >= cutoff) continue
|
||||
if (next === tasks) next = { ...tasks }
|
||||
delete next[task.id]
|
||||
}
|
||||
return next
|
||||
}
|
||||
|
||||
/** Insert or replace a task by id; events can arrive out of order, keep the newest. */
|
||||
export function upsertTask(prev: Record<string, Task>, task: Task): Record<string, Task> {
|
||||
@@ -8,10 +21,15 @@ export function upsertTask(prev: Record<string, Task>, task: Task): Record<strin
|
||||
return { ...prev, [task.id]: task }
|
||||
}
|
||||
|
||||
/** The task to show in the status bar: the most recently updated running one. */
|
||||
/** The task to show in the status bar: active work ahead of queued downloads, newest first. */
|
||||
export function currentTask(all: Record<string, Task>): { task: Task | null; running: number } {
|
||||
const running = Object.values(all).filter((x) => x.status === 'running')
|
||||
running.sort((a, b) => b.updated_at - a.updated_at)
|
||||
running.sort((a, b) => {
|
||||
const aq = a.installer_phase === 'queued' ? 1 : 0
|
||||
const bq = b.installer_phase === 'queued' ? 1 : 0
|
||||
if (aq !== bq) return aq - bq
|
||||
return b.updated_at - a.updated_at
|
||||
})
|
||||
return { task: running[0] ?? null, running: running.length }
|
||||
}
|
||||
|
||||
@@ -22,6 +40,7 @@ export function taskTitle(locale: Locale, task: Task): string {
|
||||
case 'recovery-download': return t(locale, 'taskRecoveryDownload', { name: task.subject })
|
||||
case 'vm-create': return t(locale, 'taskCreate', { name: task.subject })
|
||||
case 'runtime-install': return t(locale, 'taskRuntime', { v: task.subject })
|
||||
case 'app-update': return t(locale, 'taskAppUpdate', { v: task.subject })
|
||||
default: return task.subject
|
||||
}
|
||||
}
|
||||
@@ -35,6 +54,134 @@ export function taskDetail(task: Task): string {
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
export function isInstallerTask(task: Task): boolean {
|
||||
return task.kind === 'installer-download' || task.kind === 'recovery-download' || !!task.installer_kind
|
||||
}
|
||||
|
||||
export function taskInstallerKind(task: Task): InstallerKind | '' {
|
||||
if (task.installer_kind === 'offline' || task.installer_kind === 'online') return task.installer_kind
|
||||
if (task.kind === 'installer-download') return 'offline'
|
||||
if (task.kind === 'recovery-download') return 'online'
|
||||
return ''
|
||||
}
|
||||
|
||||
export function taskInstallerVersion(task: Task): string {
|
||||
const v = (task.installer_version ?? '').trim()
|
||||
if (v) return v
|
||||
if (task.kind === 'installer-download') return task.subject.trim()
|
||||
if (task.kind === 'recovery-download') return 'latest'
|
||||
return ''
|
||||
}
|
||||
|
||||
export function taskInstallerPhase(task: Task): InstallerPhase | '' {
|
||||
if (task.status !== 'running') return ''
|
||||
if (task.installer_phase === 'queued' || task.installer_phase === 'downloading') return task.installer_phase
|
||||
if (task.kind === 'installer-download' || task.kind === 'recovery-download') return 'downloading'
|
||||
return ''
|
||||
}
|
||||
|
||||
export function isActiveInstallerTask(task: Task): boolean {
|
||||
return taskInstallerPhase(task) !== ''
|
||||
}
|
||||
|
||||
export function taskInstallerKey(task: Task): string {
|
||||
const kind = taskInstallerKind(task)
|
||||
if (!kind) return ''
|
||||
let v = taskInstallerVersion(task).toLowerCase()
|
||||
if (kind === 'online' && !v) v = 'latest'
|
||||
return `${kind}:${v}`
|
||||
}
|
||||
|
||||
export function matchesOnlineInstallerTitle(title: string | undefined, target: string): boolean {
|
||||
const want = target.trim().toLowerCase()
|
||||
if (!want) return false
|
||||
const norm = (title ?? '').trim().toLowerCase().replace(/^macos\s+/, '')
|
||||
return norm === want || norm.replace(/\s+/g, '-') === want
|
||||
}
|
||||
|
||||
export function matchesCachedInstaller(item: CachedInstaller, task: Task): boolean {
|
||||
if (!isActiveInstallerTask(task)) return false
|
||||
const kind = taskInstallerKind(task)
|
||||
if (!kind || kind !== item.kind) return false
|
||||
const v = taskInstallerVersion(task).toLowerCase()
|
||||
if (kind === 'offline') {
|
||||
if (item.version && item.version.toLowerCase() === v) return true
|
||||
return item.partial && !!v && !/^\d/.test(v) && matchesOnlineInstallerTitle(item.title, v)
|
||||
}
|
||||
if (!v || v === 'latest') return item.partial
|
||||
return matchesOnlineInstallerTitle(item.title, v)
|
||||
}
|
||||
|
||||
export interface ActiveInstallerMatch {
|
||||
primary: Task
|
||||
waitingVMs: string[]
|
||||
matchedIDs: string[]
|
||||
}
|
||||
|
||||
function isStandaloneDownload(task: Task): boolean {
|
||||
return task.kind === 'installer-download' || task.kind === 'recovery-download'
|
||||
}
|
||||
|
||||
function pickPrimaryInstallerTask(matches: Task[]): ActiveInstallerMatch | null {
|
||||
if (matches.length === 0) return null
|
||||
const sorted = [...matches].sort((a, b) => {
|
||||
const aStandalone = isStandaloneDownload(a) ? 0 : 1
|
||||
const bStandalone = isStandaloneDownload(b) ? 0 : 1
|
||||
if (aStandalone !== bStandalone) return aStandalone - bStandalone
|
||||
const aQueued = taskInstallerPhase(a) === 'queued' ? 1 : 0
|
||||
const bQueued = taskInstallerPhase(b) === 'queued' ? 1 : 0
|
||||
if (aQueued !== bQueued) return aQueued - bQueued
|
||||
return a.started_at - b.started_at
|
||||
})
|
||||
const primary = sorted[0]
|
||||
const waitingVMs: string[] = []
|
||||
for (const other of sorted.slice(1)) {
|
||||
if (other.kind !== 'vm-create') continue
|
||||
const vm = (other.vm || other.subject).trim()
|
||||
if (vm && !waitingVMs.includes(vm)) waitingVMs.push(vm)
|
||||
}
|
||||
return { primary, waitingVMs, matchedIDs: sorted.map((x) => x.id) }
|
||||
}
|
||||
|
||||
export function findActiveOfflineTask(tasks: Task[], version: string): ActiveInstallerMatch | null {
|
||||
const want = version.trim().toLowerCase()
|
||||
if (!want) return null
|
||||
const matches = tasks.filter(
|
||||
(x) => isActiveInstallerTask(x) && taskInstallerKind(x) === 'offline' && taskInstallerVersion(x).toLowerCase() === want,
|
||||
)
|
||||
return pickPrimaryInstallerTask(matches)
|
||||
}
|
||||
|
||||
export function findActiveCachedTask(tasks: Task[], item: CachedInstaller): ActiveInstallerMatch | null {
|
||||
const matches = tasks.filter((x) => matchesCachedInstaller(item, x))
|
||||
return pickPrimaryInstallerTask(matches)
|
||||
}
|
||||
|
||||
export function groupUnmatchedInstallerTasks(activeTasks: Task[], matchedTaskIDs: Set<string>): ActiveInstallerMatch[] {
|
||||
const buckets = new Map<string, Task[]>()
|
||||
for (const task of activeTasks) {
|
||||
if (matchedTaskIDs.has(task.id)) continue
|
||||
const key = taskInstallerKey(task)
|
||||
if (!key) continue
|
||||
const list = buckets.get(key)
|
||||
if (list) list.push(task)
|
||||
else buckets.set(key, [task])
|
||||
}
|
||||
const out: ActiveInstallerMatch[] = []
|
||||
for (const group of buckets.values()) {
|
||||
const picked = pickPrimaryInstallerTask(group)
|
||||
if (picked) out.push(picked)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export function taskStopAction(locale: Locale, task: Task): { kind: 'pause' | 'cancel'; label: string } {
|
||||
if (task.kind === 'vm-create') return { kind: 'cancel', label: t(locale, 'cancelCreate') }
|
||||
if (task.kind === 'app-update') return { kind: 'cancel', label: t(locale, 'updateCancel') }
|
||||
if (taskInstallerPhase(task) === 'queued') return { kind: 'cancel', label: t(locale, 'cancelQueue') }
|
||||
return { kind: 'pause', label: t(locale, 'pauseDownload') }
|
||||
}
|
||||
|
||||
function bytes(b: number): string {
|
||||
if (b >= 1e9) return `${(b / 1e9).toFixed(1)} GB`
|
||||
return `${Math.max(1, Math.ceil(b / 1e6))} MB`
|
||||
|
||||
@@ -0,0 +1,639 @@
|
||||
// Three-tier Theme Engine (docs/plugin-architecture.md §5.1):
|
||||
// - Builtin theme: zero extra CSS injected, zero UI SDK loaded (§8.1).
|
||||
// - Tier 1 (Token theme): seed colors + declarative lightness/chroma/alpha derivation,
|
||||
// bundled fonts, brand mark, background, and event sounds.
|
||||
// - Tier 2 (Style theme): sanitized stylesheet wrapped in `@layer theme` +
|
||||
// declarative state-driven slot decorations.
|
||||
// - Tier 3 (Interactive theme): lazy-loads `./uiSdk` only when a trusted `ui_script_url` is active.
|
||||
|
||||
import { UI_CONTRACT_TOKENS } from '../styles/ui-contract'
|
||||
import type { ActiveThemePayload, ThemeDecoration, ThemeDecorationState, TokenDeriveRule } from '../types'
|
||||
|
||||
const LEGACY_CACHE_KEY = 'reims-go-theme-tokens-v1'
|
||||
const THEME_CACHE_KEY = 'reims-go-theme-tokens-v2'
|
||||
const PREPAINT_EL_ID = 'rg-theme-prepaint'
|
||||
const STYLE_EL_ID = 'rg-active-theme-style'
|
||||
const FONT_EL_ID = 'rg-active-theme-fonts'
|
||||
|
||||
const ALLOWED_CONTRACT_TOKENS = new Set<string>(UI_CONTRACT_TOKENS)
|
||||
const RE_FONT_WEIGHT = /^[0-9a-zA-Z -]+$/
|
||||
const RE_FONT_STYLE = /^(normal|italic|oblique( +-?[0-9]+(\.[0-9]+)?deg)?)$/
|
||||
const RE_UNICODE_RANGE = /^[U+0-9a-fA-F?, -]+$/
|
||||
const RE_SAFE_ASSET_REL = /^[a-zA-Z0-9._/@ -]+$/
|
||||
const RE_ASSET_BASE_URL = /^\/plugin-assets\/[a-f0-9]+\/[a-z0-9][a-z0-9._-]*\/$/
|
||||
const RE_SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/
|
||||
const FORBIDDEN_FOCUS_RING_VALUES = new Set(['none', '0', '0px', 'transparent', 'initial', 'unset', 'revert', 'revert-layer'])
|
||||
|
||||
interface ThemeTokenCache {
|
||||
themeId: string
|
||||
activeScheme: string
|
||||
light?: Record<string, string>
|
||||
dark?: Record<string, string>
|
||||
}
|
||||
|
||||
export interface UIStateSnapshot {
|
||||
appearance: 'light' | 'dark'
|
||||
motion: 'full' | 'reduced'
|
||||
locale: string
|
||||
dir: 'ltr' | 'rtl'
|
||||
view: string
|
||||
vmName: string
|
||||
vmState: string
|
||||
busy: boolean
|
||||
hasError: boolean
|
||||
sidebarCollapsed: boolean
|
||||
safeMode: boolean
|
||||
vms: Array<{ name: string; state: string }>
|
||||
}
|
||||
|
||||
export interface ThemeSDKHostActions {
|
||||
toggleSidebar: () => void
|
||||
openSettings: () => void
|
||||
focusVMWindow: (name: string) => void
|
||||
}
|
||||
|
||||
let activeUIScriptCleanup: (() => void) | null = null
|
||||
let activeUIScriptNotifier: ((snap: UIStateSnapshot) => void) | null = null
|
||||
let activeUIScriptURL = ''
|
||||
let applyGeneration = 0
|
||||
|
||||
function decodeCSSEscapes(s: string): string {
|
||||
if (!s.includes('\\')) return s
|
||||
let out = ''
|
||||
for (let i = 0; i < s.length; ) {
|
||||
if (s[i] === '\\' && i + 1 < s.length) {
|
||||
i++
|
||||
const hexMatch = /^[0-9a-fA-F]{1,6}(?:\r\n|[ \t\n\r\f])?/.exec(s.slice(i))
|
||||
if (hexMatch) {
|
||||
const cp = parseInt(hexMatch[0].trim(), 16)
|
||||
out += cp > 0 && cp <= 0x10ffff ? String.fromCodePoint(cp) : '\uFFFD'
|
||||
i += hexMatch[0].length
|
||||
} else {
|
||||
out += s[i]
|
||||
i++
|
||||
}
|
||||
} else {
|
||||
out += s[i]
|
||||
i++
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** Validates a token key+value against the UI Contract whitelist and CSS injection rules (B5). */
|
||||
export function sanitizeTokenValue(key: string, value: string): string | null {
|
||||
if (!ALLOWED_CONTRACT_TOKENS.has(key)) return null
|
||||
if (typeof value !== 'string') return null
|
||||
const trimmed = value.trim()
|
||||
if (!trimmed || /[\r\n\0{};]/.test(trimmed) || trimmed.endsWith('\\')) return null
|
||||
if (trimmed.includes('/*') || trimmed.includes('*/')) return null
|
||||
const decoded = decodeCSSEscapes(trimmed).toLowerCase()
|
||||
if (/[\r\n\0{};]/.test(decoded)) return null
|
||||
for (const bad of ['</style', 'url(', 'src(', 'image-set(', '-webkit-image-set(', 'expression(', '@import', 'javascript:', 'data:', 'http://', 'https://', '//']) {
|
||||
if (decoded.includes(bad)) return null
|
||||
}
|
||||
if (key === '--focus-ring' && (FORBIDDEN_FOCUS_RING_VALUES.has(decoded) || /\btransparent\b/.test(decoded))) {
|
||||
return null
|
||||
}
|
||||
return trimmed
|
||||
}
|
||||
|
||||
function sanitizeRelativeAssetPath(rel: string): string | null {
|
||||
if (typeof rel !== 'string') return null
|
||||
const cleaned = rel.trim().replace(/^\/+/, '')
|
||||
if (!cleaned || /["'\\;{}()\r\n\0]/.test(cleaned) || !RE_SAFE_ASSET_REL.test(cleaned)) return null
|
||||
if (RE_SCHEME.test(cleaned)) return null
|
||||
for (const seg of cleaned.split('/')) {
|
||||
if (seg === '..') return null
|
||||
}
|
||||
return cleaned
|
||||
}
|
||||
|
||||
/** Verifies stylesheet has balanced braces and no unclosed strings/comments so it cannot escape `@layer theme` (B5). */
|
||||
export function isBalancedThemeCSS(css: string): boolean {
|
||||
if (css.toLowerCase().includes('</style')) return false
|
||||
let depth = 0
|
||||
const n = css.length
|
||||
for (let i = 0; i < n; ) {
|
||||
const c = css[i]
|
||||
if (c === '/' && i + 1 < n && css[i + 1] === '*') {
|
||||
const end = css.indexOf('*/', i + 2)
|
||||
if (end < 0) return false
|
||||
i = end + 2
|
||||
continue
|
||||
}
|
||||
if (c === '"' || c === "'") {
|
||||
const q = c
|
||||
i++
|
||||
let closed = false
|
||||
while (i < n) {
|
||||
if (css[i] === '\\') {
|
||||
i += 2
|
||||
continue
|
||||
}
|
||||
if (css[i] === '\n' || css[i] === '\r') return false
|
||||
if (css[i] === q) {
|
||||
i++
|
||||
closed = true
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
if (!closed) return false
|
||||
continue
|
||||
}
|
||||
if (c === '\\') {
|
||||
// Backslash escapes the next char (e.g. `\{` or `\}`) outside strings so it cannot affect brace depth.
|
||||
if (i + 1 >= n) return false
|
||||
i += 2
|
||||
continue
|
||||
}
|
||||
if (c === '{') depth++
|
||||
else if (c === '}') {
|
||||
depth--
|
||||
if (depth < 0) return false
|
||||
}
|
||||
i++
|
||||
}
|
||||
return depth === 0
|
||||
}
|
||||
|
||||
function resolveInitialAppearance(): 'light' | 'dark' {
|
||||
try {
|
||||
const saved = localStorage.getItem('reims-go-theme')
|
||||
if (saved === 'dark' || saved === 'light') return saved
|
||||
} catch {
|
||||
// ignore storage errors
|
||||
}
|
||||
return window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
function clearLegacyInlineCache(): void {
|
||||
try {
|
||||
const raw = localStorage.getItem(LEGACY_CACHE_KEY)
|
||||
if (raw) {
|
||||
const prev = JSON.parse(raw) as Record<string, string>
|
||||
if (prev && typeof prev === 'object') {
|
||||
for (const k of Object.keys(prev)) {
|
||||
if (k.startsWith('--')) document.documentElement.style.removeProperty(k)
|
||||
}
|
||||
}
|
||||
localStorage.removeItem(LEGACY_CACHE_KEY)
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
function buildTokenVarLines(tokens: Record<string, string>): string {
|
||||
const lines: string[] = []
|
||||
for (const [k, v] of Object.entries(tokens)) {
|
||||
const safe = sanitizeTokenValue(k, v)
|
||||
if (safe) lines.push(` ${k}: ${safe};`)
|
||||
}
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies cached theme tokens via a `@layer theme` `<style>` element (never
|
||||
* inline `element.style`, B8) keyed by appearance to avoid FOUC (§5.1).
|
||||
*/
|
||||
export function applyCachedThemeTokensSync(): void {
|
||||
clearLegacyInlineCache()
|
||||
try {
|
||||
const raw = localStorage.getItem(THEME_CACHE_KEY)
|
||||
if (!raw) return
|
||||
const cache = JSON.parse(raw) as ThemeTokenCache
|
||||
if (!cache || typeof cache !== 'object') return
|
||||
const appearance = resolveInitialAppearance()
|
||||
const tokens = cache[appearance]
|
||||
if (!tokens || typeof tokens !== 'object') return
|
||||
const varLines = buildTokenVarLines(tokens)
|
||||
if (!varLines) return
|
||||
let el = document.getElementById(PREPAINT_EL_ID) as HTMLStyleElement | null
|
||||
if (!el) {
|
||||
el = document.createElement('style')
|
||||
el.id = PREPAINT_EL_ID
|
||||
document.head.appendChild(el)
|
||||
}
|
||||
el.textContent = `@layer theme {\n:root {\n${varLines}\n}\n}`
|
||||
} catch {
|
||||
// ignore corrupt cache
|
||||
}
|
||||
}
|
||||
|
||||
function clearDynamicThemeStyles(): void {
|
||||
document.getElementById(PREPAINT_EL_ID)?.remove()
|
||||
document.getElementById(STYLE_EL_ID)?.remove()
|
||||
document.getElementById(FONT_EL_ID)?.remove()
|
||||
clearLegacyInlineCache()
|
||||
try {
|
||||
localStorage.removeItem(THEME_CACHE_KEY)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
const RE_VALID_HEX = /^(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
|
||||
|
||||
/** Parses a #RGB or #RRGGBB hex string into [h (0..360), s (0..1), l (0..1)]. */
|
||||
function hexToHSL(hex: string): [number, number, number] | null {
|
||||
const clean = hex.trim().replace(/^#/, '')
|
||||
if (!RE_VALID_HEX.test(clean)) return null
|
||||
let r = 0, g = 0, b = 0
|
||||
if (clean.length === 3) {
|
||||
r = parseInt(clean[0] + clean[0], 16) / 255
|
||||
g = parseInt(clean[1] + clean[1], 16) / 255
|
||||
b = parseInt(clean[2] + clean[2], 16) / 255
|
||||
} else {
|
||||
r = parseInt(clean.slice(0, 2), 16) / 255
|
||||
g = parseInt(clean.slice(2, 4), 16) / 255
|
||||
b = parseInt(clean.slice(4, 6), 16) / 255
|
||||
}
|
||||
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return null
|
||||
const max = Math.max(r, g, b)
|
||||
const min = Math.min(r, g, b)
|
||||
const l = (max + min) / 2
|
||||
if (max === min) return [0, 0, l]
|
||||
const d = max - min
|
||||
const s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
|
||||
let h = 0
|
||||
if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6
|
||||
else if (max === g) h = ((b - r) / d + 2) / 6
|
||||
else h = ((r - g) / d + 4) / 6
|
||||
return [h * 360, s, l]
|
||||
}
|
||||
|
||||
function clamp01(x: number): number {
|
||||
return Math.max(0, Math.min(1, x))
|
||||
}
|
||||
|
||||
function srgbChannelToLinear(c: number): number {
|
||||
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4)
|
||||
}
|
||||
|
||||
/** Computes WCAG 2.1 relative luminance (0..1) for a #RGB or #RRGGBB hex string. */
|
||||
function hexRelativeLuminance(hex: string): number | null {
|
||||
const clean = hex.trim().replace(/^#/, '')
|
||||
if (!RE_VALID_HEX.test(clean)) return null
|
||||
let r = 0, g = 0, b = 0
|
||||
if (clean.length === 3) {
|
||||
r = parseInt(clean[0] + clean[0], 16) / 255
|
||||
g = parseInt(clean[1] + clean[1], 16) / 255
|
||||
b = parseInt(clean[2] + clean[2], 16) / 255
|
||||
} else {
|
||||
r = parseInt(clean.slice(0, 2), 16) / 255
|
||||
g = parseInt(clean.slice(2, 4), 16) / 255
|
||||
b = parseInt(clean.slice(4, 6), 16) / 255
|
||||
}
|
||||
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return null
|
||||
return 0.2126 * srgbChannelToLinear(r) + 0.7152 * srgbChannelToLinear(g) + 0.0722 * srgbChannelToLinear(b)
|
||||
}
|
||||
|
||||
function hslRelativeLuminance(hDeg: number, s: number, l: number): number {
|
||||
const c = (1 - Math.abs(2 * l - 1)) * s
|
||||
const hp = ((hDeg % 360) + 360) % 360 / 60
|
||||
const x = c * (1 - Math.abs((hp % 2) - 1))
|
||||
let r1 = 0, g1 = 0, b1 = 0
|
||||
if (hp < 1) [r1, g1, b1] = [c, x, 0]
|
||||
else if (hp < 2) [r1, g1, b1] = [x, c, 0]
|
||||
else if (hp < 3) [r1, g1, b1] = [0, c, x]
|
||||
else if (hp < 4) [r1, g1, b1] = [0, x, c]
|
||||
else if (hp < 5) [r1, g1, b1] = [x, 0, c]
|
||||
else [r1, g1, b1] = [c, 0, x]
|
||||
const m = l - c / 2
|
||||
return (
|
||||
0.2126 * srgbChannelToLinear(clamp01(r1 + m)) +
|
||||
0.7152 * srgbChannelToLinear(clamp01(g1 + m)) +
|
||||
0.0722 * srgbChannelToLinear(clamp01(b1 + m))
|
||||
)
|
||||
}
|
||||
|
||||
function contrastRatio(lumA: number, lumB: number): number {
|
||||
const hi = Math.max(lumA, lumB)
|
||||
const lo = Math.min(lumA, lumB)
|
||||
return (hi + 0.05) / (lo + 0.05)
|
||||
}
|
||||
|
||||
function pickAccessibleSoftAccentText(h: number, s: number, l: number, appearance: 'light' | 'dark'): string {
|
||||
// Target surface luminance: light canvas/soft (~0.92), dark surface (~0.015 for #1d1e23).
|
||||
const surfaceLum = appearance === 'dark' ? 0.015 : 0.92
|
||||
const targetRatio = 4.6
|
||||
let candidateL = appearance === 'dark' ? Math.max(l, 0.66) : Math.min(l, 0.42)
|
||||
if (contrastRatio(hslRelativeLuminance(h, s, candidateL), surfaceLum) < targetRatio) {
|
||||
let lo = appearance === 'dark' ? candidateL : 0
|
||||
let hi = appearance === 'dark' ? 1 : candidateL
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (lo + hi) / 2
|
||||
const ok = contrastRatio(hslRelativeLuminance(h, s, mid), surfaceLum) >= targetRatio
|
||||
if (appearance === 'dark') {
|
||||
if (ok) hi = mid
|
||||
else lo = mid
|
||||
} else {
|
||||
if (ok) lo = mid
|
||||
else hi = mid
|
||||
}
|
||||
}
|
||||
candidateL = appearance === 'dark' ? hi : lo
|
||||
}
|
||||
return `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(clamp01(candidateL) * 100)}%)`
|
||||
}
|
||||
|
||||
function pickHighContrastAccentText(hex: string): string {
|
||||
const lum = hexRelativeLuminance(hex)
|
||||
if (lum === null) return '#ffffff'
|
||||
const whiteContrast = 1.05 / (lum + 0.05)
|
||||
const darkInkLum = 0.0123 // #1d1d1f
|
||||
const darkContrast = (lum + 0.05) / (darkInkLum + 0.05)
|
||||
return darkContrast > whiteContrast ? '#1d1d1f' : '#ffffff'
|
||||
}
|
||||
|
||||
/** Derives CSS variable values from seed colors using declarative rules (§5.1). */
|
||||
export function deriveTokensFromSeeds(
|
||||
seeds: Record<string, string>,
|
||||
rules: TokenDeriveRule[] | undefined,
|
||||
appearance: 'light' | 'dark',
|
||||
): Record<string, string> {
|
||||
const out: Record<string, string> = {}
|
||||
if (seeds.accent) {
|
||||
const hsl = hexToHSL(seeds.accent)
|
||||
out['--accent'] = seeds.accent
|
||||
if (hsl) {
|
||||
const [h, s, l] = hsl
|
||||
out['--accent-text'] = pickHighContrastAccentText(seeds.accent)
|
||||
out['--accent-hover'] = `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(clamp01(l + (appearance === 'dark' ? 0.06 : -0.06)) * 100)}%)`
|
||||
out['--accent-soft'] = `hsla(${Math.round(h)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%, ${appearance === 'dark' ? 0.2 : 0.12})`
|
||||
out['--accent-soft-text'] = pickAccessibleSoftAccentText(h, s, l, appearance)
|
||||
out['--focus-ring'] = `0 0 0 3px hsla(${Math.round(h)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%, ${appearance === 'dark' ? 0.45 : 0.30})`
|
||||
}
|
||||
}
|
||||
if (seeds.surface) {
|
||||
out['--surface-0'] = seeds.surface
|
||||
out['--surface-canvas'] = seeds.surface
|
||||
}
|
||||
if (seeds.text) {
|
||||
out['--text'] = seeds.text
|
||||
}
|
||||
for (const rule of rules ?? []) {
|
||||
if (rule.appearance && rule.appearance !== appearance) continue
|
||||
if (!ALLOWED_CONTRACT_TOKENS.has(rule.token)) continue
|
||||
const seedVal = seeds[rule.fromSeed]
|
||||
if (!seedVal) continue
|
||||
const hsl = hexToHSL(seedVal)
|
||||
if (!hsl) continue
|
||||
const h = Math.round(hsl[0])
|
||||
const s = Math.round(clamp01(rule.chroma && rule.chroma > 0 ? hsl[1] * rule.chroma : hsl[1]) * 100)
|
||||
const l = Math.round(clamp01(hsl[2] + (rule.lightness ?? 0)) * 100)
|
||||
if (rule.alpha && rule.alpha > 0 && rule.alpha < 1) {
|
||||
out[rule.token] = `hsla(${h}, ${s}%, ${l}%, ${rule.alpha.toFixed(3)})`
|
||||
} else {
|
||||
out[rule.token] = `hsl(${h} ${s}% ${l}%)`
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** Evaluates a declarative ThemeDecoration state expression (e.g. "vmState==running"). */
|
||||
export function matchDecorationState(
|
||||
decoration: ThemeDecoration,
|
||||
snap: UIStateSnapshot,
|
||||
): ThemeDecorationState | null {
|
||||
let fallback: ThemeDecorationState | null = null
|
||||
for (const st of decoration.states ?? []) {
|
||||
const expr = (st.when || '').trim()
|
||||
if (!expr || expr === 'default') {
|
||||
fallback = st
|
||||
continue
|
||||
}
|
||||
const [rawKey, rawVal] = expr.split('==').map((s) => s.trim())
|
||||
if (!rawKey) continue
|
||||
const map: Record<string, string> = {
|
||||
vmState: snap.vmState,
|
||||
view: snap.view,
|
||||
theme: snap.appearance,
|
||||
busy: String(snap.busy),
|
||||
hasError: String(snap.hasError),
|
||||
sidebarCollapsed: String(snap.sidebarCollapsed),
|
||||
}
|
||||
if (map[rawKey] === rawVal) return st
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
/** Applies the active theme payload to the document, tearing down any previous theme first. */
|
||||
export async function applyActiveTheme(
|
||||
payload: ActiveThemePayload | null,
|
||||
appearance: 'light' | 'dark',
|
||||
getState: () => UIStateSnapshot,
|
||||
actions: ThemeSDKHostActions,
|
||||
): Promise<void> {
|
||||
const gen = ++applyGeneration
|
||||
|
||||
// Always drop prepaint & legacy inline tokens so live theme/builtin always wins (B8).
|
||||
document.getElementById(PREPAINT_EL_ID)?.remove()
|
||||
clearLegacyInlineCache()
|
||||
|
||||
// Always tear down previous interactive theme script if URL changed or disabled.
|
||||
const nextScriptURL = payload?.ui_script_url ?? ''
|
||||
if (activeUIScriptCleanup && activeUIScriptURL !== nextScriptURL) {
|
||||
try { activeUIScriptCleanup() } catch {}
|
||||
activeUIScriptCleanup = null
|
||||
activeUIScriptURL = ''
|
||||
}
|
||||
|
||||
// Builtin default theme (or safe mode) -> zero extra CSS injected (§8.1).
|
||||
if (!payload || !payload.theme || payload.theme_id === 'builtin.theme.default') {
|
||||
clearDynamicThemeStyles()
|
||||
return
|
||||
}
|
||||
|
||||
const th = payload.theme
|
||||
const rawBaseURL = payload.asset_base_url ?? ''
|
||||
const baseURL = RE_ASSET_BASE_URL.test(rawBaseURL) && !rawBaseURL.includes('..') ? rawBaseURL : ''
|
||||
|
||||
// 1. Resolve active seed colors (custom scheme -> built-in scheme -> theme default seeds).
|
||||
let seeds: Record<string, string> = { ...(th.seeds ?? {}) }
|
||||
if (payload.active_scheme) {
|
||||
const custom = (payload.custom_schemes ?? []).find((s) => s.id === payload.active_scheme && s.theme_id === payload.theme_id)
|
||||
const preset = (th.schemes ?? []).find((s) => s.id === payload.active_scheme)
|
||||
if (custom?.seeds) seeds = { ...seeds, ...custom.seeds }
|
||||
else if (preset?.seeds) seeds = { ...seeds, ...preset.seeds }
|
||||
}
|
||||
|
||||
// 2. Compute derived + explicit tokens and filter strictly through UI Contract whitelist (B5).
|
||||
const rawTokens: Record<string, string> = {
|
||||
...deriveTokensFromSeeds(seeds, th.deriveRules, appearance),
|
||||
...(th.tokens ?? {}),
|
||||
...(appearance === 'dark' ? (th.darkTokens ?? {}) : {}),
|
||||
}
|
||||
const sanitizedTokens: Record<string, string> = {}
|
||||
for (const [k, v] of Object.entries(rawTokens)) {
|
||||
const safe = sanitizeTokenValue(k, v)
|
||||
if (safe) sanitizedTokens[k] = safe
|
||||
}
|
||||
|
||||
// 3. Inject validated bundled @font-face declarations (B5).
|
||||
let fontCSS = ''
|
||||
for (const f of th.fonts ?? []) {
|
||||
const family = typeof f.family === 'string' ? f.family.trim() : ''
|
||||
if (!family || /["'\\;{}\r\n\0]/.test(family) || family.toLowerCase().includes('</style')) continue
|
||||
const safeFile = sanitizeRelativeAssetPath(f.file)
|
||||
if (!safeFile || !baseURL) continue
|
||||
const safeURL = baseURL + safeFile
|
||||
const weight = f.weight && RE_FONT_WEIGHT.test(f.weight) ? `font-weight:${f.weight};` : ''
|
||||
const style = f.style && RE_FONT_STYLE.test(f.style.trim()) ? `font-style:${f.style.trim()};` : ''
|
||||
const range = f.unicodeRange && RE_UNICODE_RANGE.test(f.unicodeRange) ? `unicode-range:${f.unicodeRange};` : ''
|
||||
fontCSS += `@font-face{font-family:"${family}";src:url("${safeURL}");font-display:swap;${weight}${style}${range}}\n`
|
||||
}
|
||||
if (fontCSS) {
|
||||
let el = document.getElementById(FONT_EL_ID) as HTMLStyleElement | null
|
||||
if (!el) {
|
||||
el = document.createElement('style')
|
||||
el.id = FONT_EL_ID
|
||||
document.head.appendChild(el)
|
||||
}
|
||||
el.textContent = fontCSS
|
||||
} else {
|
||||
document.getElementById(FONT_EL_ID)?.remove()
|
||||
}
|
||||
|
||||
// 4. Write validated token CSS + Tier-2 stylesheet wrapped inside `@layer theme` (§5.1, B5/B7).
|
||||
const varLines = buildTokenVarLines(sanitizedTokens)
|
||||
let bgCSS = ''
|
||||
if (th.background && baseURL) {
|
||||
const safeBg = sanitizeRelativeAssetPath(th.background)
|
||||
if (safeBg) {
|
||||
bgCSS = `.rg-p-shell { background-image: url("${baseURL}${safeBg}"); background-size: cover; }\n`
|
||||
}
|
||||
}
|
||||
const rawThemeCSS = payload.css && isBalancedThemeCSS(payload.css) ? payload.css : ''
|
||||
const fullCSS = `@layer theme {\n:root {\n${varLines}\n}\n${bgCSS}${rawThemeCSS}\n}`
|
||||
|
||||
let styleEl = document.getElementById(STYLE_EL_ID) as HTMLStyleElement | null
|
||||
if (!styleEl) {
|
||||
styleEl = document.createElement('style')
|
||||
styleEl.id = STYLE_EL_ID
|
||||
document.head.appendChild(styleEl)
|
||||
}
|
||||
styleEl.textContent = fullCSS
|
||||
|
||||
// Persist appearance-keyed cache for prepaint (B8).
|
||||
try {
|
||||
let nextCache: ThemeTokenCache = {
|
||||
themeId: payload.theme_id,
|
||||
activeScheme: payload.active_scheme ?? '',
|
||||
}
|
||||
const prevRaw = localStorage.getItem(THEME_CACHE_KEY)
|
||||
if (prevRaw) {
|
||||
const prev = JSON.parse(prevRaw) as ThemeTokenCache
|
||||
if (prev && prev.themeId === nextCache.themeId && prev.activeScheme === nextCache.activeScheme) {
|
||||
nextCache = { ...prev }
|
||||
}
|
||||
}
|
||||
nextCache[appearance] = sanitizedTokens
|
||||
localStorage.setItem(THEME_CACHE_KEY, JSON.stringify(nextCache))
|
||||
} catch {
|
||||
// ignore storage quota
|
||||
}
|
||||
|
||||
// 5. Tier 3: lazy-load UI SDK ONLY when an approved interactive theme script is present (§8.1).
|
||||
if (nextScriptURL && nextScriptURL !== activeUIScriptURL) {
|
||||
try {
|
||||
const { mountInteractiveThemeScript, notifyThemeSDKState } = await import('./uiSdk')
|
||||
if (gen !== applyGeneration) return
|
||||
const cleanup = await mountInteractiveThemeScript(nextScriptURL, getState, actions)
|
||||
if (gen !== applyGeneration) {
|
||||
try { cleanup() } catch {}
|
||||
return
|
||||
}
|
||||
activeUIScriptCleanup = () => {
|
||||
activeUIScriptNotifier = null
|
||||
cleanup()
|
||||
}
|
||||
activeUIScriptNotifier = notifyThemeSDKState
|
||||
activeUIScriptURL = nextScriptURL
|
||||
} catch {
|
||||
if (gen === applyGeneration) {
|
||||
// Fallback gracefully to the scriptless style/token theme (§4.2).
|
||||
activeUIScriptCleanup = null
|
||||
activeUIScriptURL = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const LOCALE_FONT_EL_ID = 'rg-active-locale-fonts'
|
||||
const RE_SAFE_FONT_URL = /^\/plugin-assets\/[a-f0-9]+\/[a-z0-9][a-z0-9._-]*\/[a-zA-Z0-9._/@ -]+\.woff2$/i
|
||||
const RE_SAFE_FONT_FAMILY = /^[\p{L}\p{N} _-]{1,80}$/u
|
||||
|
||||
/**
|
||||
* Injects optional bundled `.woff2` WebFonts declared by the active language pack
|
||||
* into `--font-locale-pack` (scoped strictly inside `@layer theme`, zero cost when empty).
|
||||
*/
|
||||
export function applyActiveLocaleFonts(
|
||||
fonts: Array<{ family: string; url: string; weight?: string; style?: string; unicodeRange?: string }> | undefined,
|
||||
): void {
|
||||
const existing = document.getElementById(LOCALE_FONT_EL_ID)
|
||||
if (!fonts || fonts.length === 0) {
|
||||
existing?.remove()
|
||||
return
|
||||
}
|
||||
const rules: string[] = []
|
||||
const families: string[] = []
|
||||
for (const f of fonts) {
|
||||
const fam = (f.family || '').trim()
|
||||
if (!RE_SAFE_FONT_FAMILY.test(fam) || fam.toLowerCase().includes('</style')) continue
|
||||
if (!f.url || f.url.includes('..') || !RE_SAFE_FONT_URL.test(f.url)) continue
|
||||
const weight = f.weight && RE_FONT_WEIGHT.test(f.weight) ? f.weight : '400'
|
||||
const style = f.style && RE_FONT_STYLE.test(f.style) ? f.style : 'normal'
|
||||
const ur = f.unicodeRange && RE_UNICODE_RANGE.test(f.unicodeRange) ? `unicode-range: ${f.unicodeRange};` : ''
|
||||
rules.push(
|
||||
`@font-face { font-family: "${fam}"; src: url("${f.url}") format("woff2"); font-weight: ${weight}; font-style: ${style}; font-display: swap; ${ur} }`,
|
||||
)
|
||||
if (!families.includes(`"${fam}"`)) {
|
||||
families.push(`"${fam}"`)
|
||||
}
|
||||
}
|
||||
if (rules.length === 0) {
|
||||
existing?.remove()
|
||||
return
|
||||
}
|
||||
let styleEl = existing as HTMLStyleElement | null
|
||||
if (!styleEl) {
|
||||
styleEl = document.createElement('style')
|
||||
styleEl.id = LOCALE_FONT_EL_ID
|
||||
document.head.appendChild(styleEl)
|
||||
}
|
||||
styleEl.textContent = `@layer theme {\n:root {\n --font-locale-pack: ${families.join(', ')}, ;\n}\n${rules.join('\n')}\n}`
|
||||
}
|
||||
|
||||
/** Tears down injected theme/locale style nodes and active UI scripts on unmount. */
|
||||
export function disposeActiveThemeAndLocaleFonts(): void {
|
||||
if (activeUIScriptCleanup) {
|
||||
try { activeUIScriptCleanup() } catch {}
|
||||
activeUIScriptCleanup = null
|
||||
activeUIScriptNotifier = null
|
||||
activeUIScriptURL = ''
|
||||
}
|
||||
clearDynamicThemeStyles()
|
||||
document.getElementById(LOCALE_FONT_EL_ID)?.remove()
|
||||
}
|
||||
|
||||
export function notifyInteractiveThemeState(snap: UIStateSnapshot): void {
|
||||
activeUIScriptNotifier?.(snap)
|
||||
}
|
||||
|
||||
/** Plays a theme-configured sound for an event if present (fail-silent). */
|
||||
export function playThemeSound(payload: ActiveThemePayload | null, eventName: string): void {
|
||||
const file = payload?.theme?.sounds?.[eventName]
|
||||
if (!file || !payload?.asset_base_url) return
|
||||
const safe = sanitizeRelativeAssetPath(file)
|
||||
if (!safe) return
|
||||
try {
|
||||
const audio = new Audio(payload.asset_base_url + safe)
|
||||
audio.volume = 0.35
|
||||
void audio.play().catch(() => {})
|
||||
} catch {
|
||||
// ignore audio decode/autoplay errors
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
// Lazy-loaded Tier-3 Interactive Theme UI SDK (docs/plugin-architecture.md §5.1).
|
||||
// Loaded ONLY when a trusted interactive theme with `ui:script` is enabled (§8.1).
|
||||
|
||||
import { UI_API_VERSION, UI_CONTRACT_PARTS, UI_CONTRACT_SLOTS, type UIContractPart, type UIContractSlot } from '../styles/ui-contract'
|
||||
import { hideWailsGlobals } from '../wails'
|
||||
import type { ThemeSDKHostActions, UIStateSnapshot } from './themeEngine'
|
||||
|
||||
export interface ReimsUISDK {
|
||||
readonly uiApi: string
|
||||
/** Registers a cleanup callback run in LIFO order on theme switch/disable. */
|
||||
onDispose: (fn: () => void) => void
|
||||
/** Runs a named feature isolated so errors disable only that feature. */
|
||||
feature: (name: string, setup: (dispose: (fn: () => void) => void) => void) => void
|
||||
/** Read-only non-sensitive state snapshot & subscription. */
|
||||
getState: () => UIStateSnapshot
|
||||
subscribeState: (cb: (snap: UIStateSnapshot) => void) => () => void
|
||||
/** Queries elements strictly by contract part class (`rg-p-*`). */
|
||||
queryPart: (part: UIContractPart) => HTMLElement | null
|
||||
/** Shared MutationObserver bus scoped to a contract part. */
|
||||
observePart: (part: UIContractPart, cb: () => void) => () => void
|
||||
/** Shared RAF read/write batch pipeline to avoid layout thrashing. */
|
||||
scheduleRead: (fn: () => void) => void
|
||||
scheduleWrite: (fn: () => void) => void
|
||||
/** Framework-agnostic DOM mounting into a declared slot anchor. */
|
||||
mountSlot: (slot: UIContractSlot, node: HTMLElement) => () => void
|
||||
/** Restricted non-destructive UI actions only (no start/stop/delete/config write). */
|
||||
actions: ThemeSDKHostActions
|
||||
}
|
||||
|
||||
const stateListeners = new Set<(snap: UIStateSnapshot) => void>()
|
||||
|
||||
export function notifyThemeSDKState(snap: UIStateSnapshot): void {
|
||||
if (stateListeners.size === 0) return
|
||||
for (const cb of stateListeners) {
|
||||
try { cb(snap) } catch {}
|
||||
}
|
||||
}
|
||||
|
||||
// Shared RAF read/write pipeline.
|
||||
let readQueue: Array<() => void> = []
|
||||
let writeQueue: Array<() => void> = []
|
||||
let rafScheduled = false
|
||||
|
||||
function flushFrame() {
|
||||
rafScheduled = false
|
||||
const reads = readQueue
|
||||
const writes = writeQueue
|
||||
readQueue = []
|
||||
writeQueue = []
|
||||
for (const r of reads) { try { r() } catch {} }
|
||||
for (const w of writes) { try { w() } catch {} }
|
||||
}
|
||||
|
||||
function scheduleRAF() {
|
||||
if (rafScheduled) return
|
||||
rafScheduled = true
|
||||
requestAnimationFrame(flushFrame)
|
||||
}
|
||||
|
||||
export async function mountInteractiveThemeScript(
|
||||
scriptURL: string,
|
||||
getState: () => UIStateSnapshot,
|
||||
actions: ThemeSDKHostActions,
|
||||
): Promise<() => void> {
|
||||
if (!scriptURL.startsWith('/plugin-assets/') || scriptURL.includes('..')) {
|
||||
throw new Error('Refused to load theme script outside /plugin-assets/')
|
||||
}
|
||||
let disposed = false
|
||||
const disposers = new Set<() => void>()
|
||||
const partSet = new Set<string>(UI_CONTRACT_PARTS)
|
||||
const slotSet = new Set<string>(UI_CONTRACT_SLOTS)
|
||||
|
||||
const addDisposer = (fn: () => void) => {
|
||||
if (disposed) return
|
||||
disposers.add(fn)
|
||||
}
|
||||
|
||||
const disposeAll = () => {
|
||||
if (disposed) return
|
||||
disposed = true
|
||||
const list = Array.from(disposers).reverse()
|
||||
disposers.clear()
|
||||
for (const fn of list) {
|
||||
try { fn() } catch {}
|
||||
}
|
||||
}
|
||||
|
||||
const sdk: ReimsUISDK = {
|
||||
uiApi: UI_API_VERSION,
|
||||
onDispose: addDisposer,
|
||||
feature: (_name, setup) => {
|
||||
if (disposed) return
|
||||
const localDisposers: Array<() => void> = []
|
||||
const localDispose = () => {
|
||||
while (localDisposers.length > 0) {
|
||||
try { localDisposers.pop()?.() } catch {}
|
||||
}
|
||||
}
|
||||
addDisposer(localDispose)
|
||||
try {
|
||||
setup((fn) => localDisposers.push(fn))
|
||||
} catch {
|
||||
// Feature-isolated error: tear down only this feature (§4.2, §5.1).
|
||||
localDispose()
|
||||
}
|
||||
},
|
||||
getState: () => {
|
||||
const s = getState()
|
||||
return { ...s, vms: s.vms.map((v) => ({ ...v })) }
|
||||
},
|
||||
subscribeState: (cb) => {
|
||||
if (disposed) return () => {}
|
||||
stateListeners.add(cb)
|
||||
const off = () => {
|
||||
stateListeners.delete(cb)
|
||||
disposers.delete(off)
|
||||
}
|
||||
addDisposer(off)
|
||||
return off
|
||||
},
|
||||
queryPart: (part) => {
|
||||
if (disposed || !partSet.has(part)) return null
|
||||
return document.querySelector<HTMLElement>(`.${part}`)
|
||||
},
|
||||
observePart: (part, cb) => {
|
||||
if (disposed || !partSet.has(part)) return () => {}
|
||||
const target = document.querySelector<HTMLElement>(`.${part}`)
|
||||
if (!target) return () => {}
|
||||
const obs = new MutationObserver(() => {
|
||||
if (disposed) return
|
||||
try { cb() } catch {}
|
||||
})
|
||||
obs.observe(target, { attributes: true, childList: true, subtree: false })
|
||||
const off = () => {
|
||||
obs.disconnect()
|
||||
disposers.delete(off)
|
||||
}
|
||||
addDisposer(off)
|
||||
return off
|
||||
},
|
||||
scheduleRead: (fn) => {
|
||||
if (disposed) return
|
||||
readQueue.push(() => { if (!disposed) fn() })
|
||||
scheduleRAF()
|
||||
},
|
||||
scheduleWrite: (fn) => {
|
||||
if (disposed) return
|
||||
writeQueue.push(() => { if (!disposed) fn() })
|
||||
scheduleRAF()
|
||||
},
|
||||
mountSlot: (slot, node) => {
|
||||
if (disposed || !slotSet.has(slot)) return () => {}
|
||||
const host = document.querySelector<HTMLElement>(`[data-rg-slot="${CSS.escape(slot)}"]`)
|
||||
if (!host) return () => {}
|
||||
host.appendChild(node)
|
||||
const off = () => {
|
||||
node.remove()
|
||||
disposers.delete(off)
|
||||
}
|
||||
addDisposer(off)
|
||||
return off
|
||||
},
|
||||
actions: {
|
||||
toggleSidebar: actions.toggleSidebar,
|
||||
openSettings: actions.openSettings,
|
||||
focusVMWindow: actions.focusVMWindow,
|
||||
},
|
||||
}
|
||||
|
||||
// Hide Wails binding globals from `window` before executing any theme script,
|
||||
// and shadow bridge identifiers inside its closure (§5.1, B6). Note: scripts
|
||||
// in the main window still run in the same DOM realm, so `ui:script` remains
|
||||
// a high-trust permission requiring explicit user approval.
|
||||
hideWailsGlobals()
|
||||
|
||||
const resp = await fetch(scriptURL, { credentials: 'same-origin' })
|
||||
if (!resp.ok) throw new Error(`Failed to fetch theme script (${resp.status})`)
|
||||
const source = await resp.text()
|
||||
const runner = new Function('sdk', 'go', 'runtime', 'WailsInvoke', 'wails', `"use strict";\n${source}`)
|
||||
try {
|
||||
runner(sdk, undefined, undefined, undefined, undefined)
|
||||
} catch (err) {
|
||||
disposeAll()
|
||||
throw err
|
||||
}
|
||||
return disposeAll
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { VMStats } from '../types'
|
||||
import { api } from '../wails'
|
||||
|
||||
// Shared VM stats poller (stats_flow.go). Components that show stats
|
||||
// subscribe with useVMStats, so a tick re-renders only them, not the whole
|
||||
// App. One timer per VM however many subscribe; it pauses while the window
|
||||
// is hidden and samples once on return.
|
||||
|
||||
const RUNNING_MS = 3000
|
||||
// A stopped VM only changes disk usage, so it is sampled rarely.
|
||||
const STOPPED_MS = 30000
|
||||
|
||||
interface Entry {
|
||||
subs: Set<(s: VMStats) => void>
|
||||
running: boolean
|
||||
last: VMStats | null
|
||||
timer?: number
|
||||
}
|
||||
|
||||
const entries = new Map<string, Entry>()
|
||||
|
||||
function sample(name: string) {
|
||||
api.GetVMStats(name)
|
||||
.then((s) => {
|
||||
const e = entries.get(name)
|
||||
if (!e) return
|
||||
e.last = s
|
||||
e.subs.forEach((f) => f(s))
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function schedule(name: string, e: Entry) {
|
||||
if (e.timer) window.clearInterval(e.timer)
|
||||
e.timer = undefined
|
||||
if (document.hidden || e.subs.size === 0) return
|
||||
e.timer = window.setInterval(() => sample(name), e.running ? RUNNING_MS : STOPPED_MS)
|
||||
}
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
entries.forEach((e, name) => {
|
||||
if (!document.hidden && e.subs.size > 0) sample(name)
|
||||
schedule(name, e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/** Latest stats seen for a VM, without subscribing (e.g. when a dialog opens). */
|
||||
export function latestVMStats(name: string | undefined | null): VMStats | null {
|
||||
return name ? entries.get(name)?.last ?? null : null
|
||||
}
|
||||
|
||||
/** Live stats for one VM; `running` picks the sampling rate. Null name: none. */
|
||||
export function useVMStats(name: string | null, running: boolean): VMStats | null {
|
||||
const [stats, setStats] = useState<VMStats | null>(() => latestVMStats(name))
|
||||
|
||||
useEffect(() => {
|
||||
if (!name) { setStats(null); return }
|
||||
let e = entries.get(name)
|
||||
if (!e) {
|
||||
e = { subs: new Set(), running, last: null }
|
||||
entries.set(name, e)
|
||||
}
|
||||
setStats(e.last)
|
||||
const sub = (s: VMStats) => setStats(s)
|
||||
e.subs.add(sub)
|
||||
// A state change (start/stop) samples at once and re-paces the timer.
|
||||
e.running = running
|
||||
sample(name)
|
||||
schedule(name, e)
|
||||
return () => {
|
||||
const cur = entries.get(name)
|
||||
if (!cur) return
|
||||
cur.subs.delete(sub)
|
||||
if (cur.subs.size === 0) {
|
||||
if (cur.timer) window.clearInterval(cur.timer)
|
||||
entries.delete(name)
|
||||
}
|
||||
}
|
||||
}, [name, running])
|
||||
|
||||
return stats
|
||||
}
|
||||
@@ -1,10 +1,45 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import { App } from './App'
|
||||
import { ErrorBoundary } from './components/ErrorBoundary'
|
||||
import { applyCachedThemeTokensSync } from './lib/themeEngine'
|
||||
import './styles/app.css'
|
||||
import { events } from './wails'
|
||||
|
||||
// Inline cached theme tokens before first paint to prevent FOUC (§5.1).
|
||||
applyCachedThemeTokensSync()
|
||||
|
||||
let lastReportedErr = ''
|
||||
let lastReportedAt = 0
|
||||
|
||||
function reportUIError(msg: string) {
|
||||
const trimmed = msg.trim()
|
||||
if (!trimmed) return
|
||||
// Benign Chromium ResizeObserver delivery notice fired during rapid layout/resize.
|
||||
if (trimmed.includes('ResizeObserver loop completed with undelivered notifications') || trimmed.includes('ResizeObserver loop limit exceeded')) {
|
||||
return
|
||||
}
|
||||
const now = Date.now()
|
||||
if (trimmed === lastReportedErr && now - lastReportedAt < 5000) return
|
||||
lastReportedErr = trimmed
|
||||
lastReportedAt = now
|
||||
events.emitUIError(trimmed.slice(0, 1500))
|
||||
}
|
||||
|
||||
window.addEventListener('error', (e) => {
|
||||
const msg = e.error instanceof Error ? `${e.error.message}\n${e.error.stack ?? ''}` : (e.message || 'Unknown window error')
|
||||
reportUIError(`window.error: ${msg}`)
|
||||
})
|
||||
window.addEventListener('unhandledrejection', (e) => {
|
||||
const r = e.reason
|
||||
const msg = r instanceof Error ? `${r.message}\n${r.stack ?? ''}` : String(r ?? 'Unknown rejection')
|
||||
reportUIError(`unhandledrejection: ${msg}`)
|
||||
})
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
<ErrorBoundary>
|
||||
<App />
|
||||
</ErrorBoundary>
|
||||
</React.StrictMode>,
|
||||
)
|
||||
@@ -1,25 +1,75 @@
|
||||
/* Design tokens — macOS Tahoe System Settings aesthetic (Light default, Dark optional). */
|
||||
/* Bundled open-source Inter Variable (SIL OFL 1.1, Latin ~47 KB) — optical twin of Apple SF Pro. */
|
||||
@font-face {
|
||||
font-family: "ReimsSans";
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
font-weight: 100 900;
|
||||
src: url("@fontsource-variable/inter/files/inter-latin-wght-normal.woff2") format("woff2-variations");
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
|
||||
/* Scoped Simplified Chinese weight-mapping face ("ReimsCJK-SC").
|
||||
IMPORTANT: Never attach this unconditionally to all languages — doing so
|
||||
hijacks Han Unification `locl` glyphs and turns Traditional Chinese / Japanese
|
||||
Kanji into Mainland Simplified forms. Only `:lang(zh-CN|zh-SG|zh-Hans)` activates it. */
|
||||
@font-face {
|
||||
font-family: "ReimsCJK-SC";
|
||||
font-style: normal;
|
||||
font-weight: 400 550;
|
||||
src:
|
||||
local("PingFang SC Medium"), local("PingFangSC-Medium"),
|
||||
local("HarmonyOS Sans SC"), local("HarmonyOS_Sans_SC"),
|
||||
local("MiSans Regular"), local("MiSans"),
|
||||
local("Noto Sans SC Medium"), local("NotoSansSC-Medium"),
|
||||
local("Noto Sans SC"), local("NotoSansSC-Regular"),
|
||||
local("Source Han Sans CN Medium"), local("SourceHanSansCN-Medium"),
|
||||
local("Source Han Sans CN Regular"), local("SourceHanSansCN-Regular");
|
||||
unicode-range: U+2E80-9FFF, U+3000-303F, U+FF00-FFEF, U+F900-FAFF;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "ReimsCJK-SC";
|
||||
font-style: normal;
|
||||
font-weight: 560 900;
|
||||
src:
|
||||
local("PingFang SC Semibold"), local("PingFangSC-Semibold"),
|
||||
local("PingFang SC Bold"), local("PingFangSC-Bold"),
|
||||
local("HarmonyOS Sans SC Bold"), local("HarmonyOS_Sans_SC_Bold"),
|
||||
local("MiSans Demibold"), local("MiSans Semibold"), local("MiSans Bold"),
|
||||
local("Noto Sans SC SemiBold"), local("NotoSansSC-SemiBold"), local("Noto Sans SC Bold"),
|
||||
local("Source Han Sans CN Bold"), local("SourceHanSansCN-Bold");
|
||||
unicode-range: U+2E80-9FFF, U+3000-303F, U+FF00-FFEF, U+F900-FAFF;
|
||||
}
|
||||
|
||||
/* Design tokens — macOS Tahoe aesthetic with Windows platform craft (Light default, Dark & System supported). */
|
||||
@layer base {
|
||||
:root {
|
||||
color-scheme: light;
|
||||
|
||||
/* Type */
|
||||
--font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
|
||||
--font-mono: "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
|
||||
/* Typography — regional CJK family injected via --font-cjk per :lang() */
|
||||
--font-locale-pack: ;
|
||||
--font-cjk: "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
|
||||
--font-sans: "ReimsSans", var(--font-locale-pack) -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", var(--font-cjk), system-ui, sans-serif;
|
||||
--font-mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
|
||||
--body-lh: 1.48;
|
||||
--heading-tracking: -0.015em;
|
||||
--fs-11: 11px;
|
||||
--fs-12: 12px;
|
||||
--fs-13: 13px;
|
||||
--fs-14: 14px;
|
||||
--fs-15: 15px;
|
||||
--fs-16: 16px;
|
||||
--fs-20: 20px;
|
||||
--fs-24: 24px;
|
||||
--fw-regular: 400;
|
||||
--fw-medium: 500;
|
||||
--fw-strong: 600;
|
||||
--fw-regular: 450;
|
||||
--fw-medium: 540;
|
||||
--fw-strong: 640;
|
||||
|
||||
/* Spacing (4px grid) */
|
||||
--sp-1: 4px;
|
||||
--sp-2: 8px;
|
||||
--sp-3: 12px;
|
||||
--sp-4: 16px;
|
||||
--sp-5: 20px;
|
||||
--sp-6: 24px;
|
||||
--sp-8: 32px;
|
||||
|
||||
@@ -32,88 +82,112 @@
|
||||
/* Surfaces (macOS Tahoe Light) */
|
||||
--surface-0: #ffffff;
|
||||
--surface-canvas: #ffffff;
|
||||
--surface-sidebar: linear-gradient(180deg, #eff5fc 0%, #eaf2fa 100%);
|
||||
--surface-sidebar-border: rgba(15, 23, 42, 0.07);
|
||||
--surface-sidebar-shadow: 0 2px 14px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
||||
--surface-chrome: rgba(255, 255, 255, 0.88);
|
||||
--surface-sidebar-rail: linear-gradient(180deg, #e7f0fa 0%, #dde8f7 100%);
|
||||
--surface-sidebar: linear-gradient(180deg, rgba(255, 255, 255, 0.80) 0%, rgba(247, 250, 255, 0.72) 100%);
|
||||
--surface-sidebar-border: rgba(255, 255, 255, 0.90);
|
||||
--surface-sidebar-shadow: 0 4px 18px rgba(15, 35, 70, 0.065), 0 0 0 1px rgba(15, 23, 42, 0.06);
|
||||
--surface-chrome: linear-gradient(180deg, #eff4fb 0%, #e8f0fa 100%);
|
||||
--surface-statusbar: #eef3fa;
|
||||
--surface-1: #f5f6f8;
|
||||
--surface-card-elevated: #ffffff;
|
||||
--surface-2: rgba(255, 255, 255, 0.96);
|
||||
--surface-2: rgba(255, 255, 255, 0.94);
|
||||
--surface-input: #ffffff;
|
||||
--surface-hover: rgba(15, 23, 42, 0.05);
|
||||
--surface-active: rgba(15, 23, 42, 0.09);
|
||||
--border: rgba(15, 23, 42, 0.075);
|
||||
--surface-hover: rgba(15, 23, 42, 0.048);
|
||||
--surface-active: rgba(15, 23, 42, 0.085);
|
||||
--border: rgba(15, 23, 42, 0.08);
|
||||
--border-strong: rgba(15, 23, 42, 0.14);
|
||||
--highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.85);
|
||||
--scrim: rgba(15, 23, 42, 0.28);
|
||||
--shadow-btn: 0 1px 2px rgba(15, 23, 42, 0.06);
|
||||
--shadow-overlay: 0 20px 56px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06);
|
||||
--shadow-btn: 0 1px 2px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.7);
|
||||
--shadow-card: 0 1px 2px rgba(15, 23, 42, 0.025);
|
||||
--shadow-overlay: 0 22px 58px rgba(15, 23, 42, 0.18), 0 4px 14px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.06);
|
||||
--blur-chrome: blur(20px) saturate(180%);
|
||||
--blur-overlay: blur(18px) saturate(165%);
|
||||
|
||||
/* Text */
|
||||
--text: #1d1d1f;
|
||||
--text-2: #515154;
|
||||
--text-3: #86868b;
|
||||
--text-2: #424247;
|
||||
--text-3: #6e6e73;
|
||||
--text-code: #2c2c30;
|
||||
|
||||
/* Semantics (Apple System Colours) */
|
||||
--accent: #007aff;
|
||||
--accent-hover: #006be6;
|
||||
--accent-text: #ffffff;
|
||||
--accent-soft: rgba(0, 122, 255, 0.12);
|
||||
--accent-soft: rgba(0, 122, 255, 0.11);
|
||||
--accent-soft-text: #0066d6;
|
||||
--focus-ring: 0 0 0 3px rgba(0, 122, 255, 0.3);
|
||||
--focus-ring: 0 0 0 3px rgba(0, 122, 255, 0.30);
|
||||
|
||||
--status-running: #28cd41;
|
||||
--status-busy: #ff9f0a;
|
||||
--status-error: #ff3b30;
|
||||
--status-idle: #aeaeb2;
|
||||
|
||||
--ok-soft: rgba(40, 205, 65, 0.13);
|
||||
--ok-text: #188c2c;
|
||||
--warn-soft: rgba(255, 159, 10, 0.14);
|
||||
--warn-text: #a86200;
|
||||
|
||||
--danger: #ff3b30;
|
||||
--danger-soft: rgba(255, 59, 48, 0.10);
|
||||
--danger-border: rgba(255, 59, 48, 0.28);
|
||||
--danger-text: #d70015;
|
||||
--notice-soft: rgba(255, 159, 10, 0.11);
|
||||
--notice-border: rgba(255, 159, 10, 0.32);
|
||||
--notice-soft: rgba(255, 159, 10, 0.10);
|
||||
--notice-border: rgba(255, 159, 10, 0.28);
|
||||
|
||||
/* Motion */
|
||||
--dur-fast: 120ms;
|
||||
--dur: 200ms;
|
||||
--seg-thumb: #ffffff;
|
||||
|
||||
/* Motion (emil-design-eng & apple-design curves) */
|
||||
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
||||
--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
|
||||
--ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
|
||||
--dur-press: 100ms;
|
||||
--dur-fast: 130ms;
|
||||
--dur: 180ms;
|
||||
--dur-modal: 220ms;
|
||||
--dur-toast: 280ms;
|
||||
|
||||
/* Layout */
|
||||
--titlebar-h: 42px;
|
||||
--logbar-h: 32px;
|
||||
--sidebar-w: 244px;
|
||||
--page-max: 700px;
|
||||
--sidebar-w: 248px;
|
||||
--page-max: 632px;
|
||||
}
|
||||
|
||||
:root[data-theme="dark"] {
|
||||
color-scheme: dark;
|
||||
|
||||
--surface-0: #1e1e22;
|
||||
--surface-canvas: #1e1e22;
|
||||
--surface-sidebar: linear-gradient(180deg, #27282e 0%, #23242a 100%);
|
||||
--surface-sidebar-border: rgba(255, 255, 255, 0.08);
|
||||
--surface-sidebar-shadow: 0 4px 18px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
--surface-chrome: rgba(28, 28, 32, 0.92);
|
||||
--surface-1: rgba(255, 255, 255, 0.05);
|
||||
--surface-card-elevated: rgba(255, 255, 255, 0.07);
|
||||
--surface-2: #2b2c32;
|
||||
--surface-0: #1b1c20;
|
||||
--surface-canvas: #1d1e23;
|
||||
--surface-sidebar-rail: #17181c;
|
||||
--surface-sidebar: linear-gradient(180deg, rgba(40, 41, 48, 0.94) 0%, rgba(34, 35, 41, 0.92) 100%);
|
||||
--surface-sidebar-border: rgba(255, 255, 255, 0.09);
|
||||
--surface-sidebar-shadow: 0 6px 22px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
||||
--surface-chrome: linear-gradient(180deg, #212228 0%, #1c1d22 100%);
|
||||
--surface-statusbar: #18191e;
|
||||
--surface-1: rgba(255, 255, 255, 0.048);
|
||||
--surface-card-elevated: rgba(255, 255, 255, 0.075);
|
||||
--surface-2: rgba(42, 43, 50, 0.94);
|
||||
--surface-input: rgba(0, 0, 0, 0.28);
|
||||
--surface-hover: rgba(255, 255, 255, 0.07);
|
||||
--surface-hover: rgba(255, 255, 255, 0.075);
|
||||
--surface-active: rgba(255, 255, 255, 0.12);
|
||||
--border: rgba(255, 255, 255, 0.09);
|
||||
--border: rgba(255, 255, 255, 0.085);
|
||||
--border-strong: rgba(255, 255, 255, 0.16);
|
||||
--scrim: rgba(0, 0, 0, 0.55);
|
||||
--shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.28);
|
||||
--shadow-overlay: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
|
||||
--highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
||||
--scrim: rgba(0, 0, 0, 0.56);
|
||||
--shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.18);
|
||||
--shadow-overlay: 0 26px 68px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.09);
|
||||
|
||||
--text: #f5f5f7;
|
||||
--text-2: #b4b4bc;
|
||||
--text-3: #86868e;
|
||||
--text-2: #c2c2ca;
|
||||
--text-3: #92929c;
|
||||
--text-code: #d4d6e0;
|
||||
|
||||
--accent: #0a84ff;
|
||||
--accent-hover: #2492ff;
|
||||
--accent-text: #ffffff;
|
||||
--accent-soft: rgba(10, 132, 255, 0.22);
|
||||
--accent-soft: rgba(10, 132, 255, 0.20);
|
||||
--accent-soft-text: #64b0ff;
|
||||
--focus-ring: 0 0 0 3px rgba(10, 132, 255, 0.45);
|
||||
|
||||
@@ -122,16 +196,90 @@
|
||||
--status-error: #ff453a;
|
||||
--status-idle: #6e6e76;
|
||||
|
||||
--ok-soft: rgba(48, 209, 88, 0.16);
|
||||
--ok-text: #30d158;
|
||||
--warn-soft: rgba(255, 214, 10, 0.15);
|
||||
--warn-text: #ffd60a;
|
||||
|
||||
--danger: #ff453a;
|
||||
--danger-soft: rgba(255, 69, 58, 0.16);
|
||||
--danger-soft: rgba(255, 69, 58, 0.15);
|
||||
--danger-border: rgba(255, 69, 58, 0.34);
|
||||
--danger-text: #ff8b83;
|
||||
--notice-soft: rgba(255, 214, 10, 0.11);
|
||||
--notice-border: rgba(255, 214, 10, 0.30);
|
||||
--notice-soft: rgba(255, 214, 10, 0.10);
|
||||
--notice-border: rgba(255, 214, 10, 0.28);
|
||||
|
||||
--seg-thumb: #555760;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
:root {
|
||||
--dur-press: 0ms;
|
||||
--dur-fast: 0ms;
|
||||
--dur: 0ms;
|
||||
--dur-modal: 0ms;
|
||||
--dur-toast: 0ms;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-transparency: reduce) {
|
||||
:root {
|
||||
--surface-chrome: #ffffff;
|
||||
--surface-2: #ffffff;
|
||||
--surface-sidebar: #eef3fa;
|
||||
--blur-chrome: none;
|
||||
--blur-overlay: none;
|
||||
}
|
||||
:root[data-theme="dark"] {
|
||||
--surface-chrome: #1b1c20;
|
||||
--surface-2: #2a2b32;
|
||||
--surface-sidebar: #24252b;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-contrast: more) {
|
||||
:root {
|
||||
--border: rgba(15, 23, 42, 0.20);
|
||||
--border-strong: rgba(15, 23, 42, 0.34);
|
||||
--text-2: #3a3a3d;
|
||||
--text-3: #5a5a5f;
|
||||
}
|
||||
:root[data-theme="dark"] {
|
||||
--border: rgba(255, 255, 255, 0.20);
|
||||
--border-strong: rgba(255, 255, 255, 0.34);
|
||||
--text-2: #d2d2da;
|
||||
--text-3: #a6a6b0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Regional script & OpenType `locl` typography stacks:
|
||||
- Simplified Chinese: DirectWrite Medium ink compensation ("ReimsCJK-SC")
|
||||
- Traditional Chinese (TW/HK/MO): Orthodox Traditional glyph stack, 400 regular weight
|
||||
and taller line-height (1.56) so dense 20+ stroke characters never blob at 11–13px
|
||||
- Japanese: Kana/Kanji stack, 400 regular weight, strict kinsoku line-breaking
|
||||
- Korean: Hangul stack, 400 regular weight, `word-break: keep-all` syllable-word integrity */
|
||||
:root:lang(zh-CN), :root:lang(zh-SG), :root:lang(zh-Hans) {
|
||||
--font-cjk: "ReimsCJK-SC", "PingFang SC Medium", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Source Han Sans CN", "Microsoft YaHei UI", sans-serif;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
|
||||
:root:lang(zh-TW), :root:lang(zh-HK), :root:lang(zh-MO), :root:lang(zh-Hant) {
|
||||
--font-cjk: "PingFang TC", "Noto Sans TC", "Source Han Sans TC", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif;
|
||||
--fw-regular: 400;
|
||||
--body-lh: 1.56;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
|
||||
:root:lang(ja) {
|
||||
--font-cjk: "Hiragino Sans", "Noto Sans JP", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo UI", "Meiryo", sans-serif;
|
||||
--fw-regular: 400;
|
||||
--body-lh: 1.58;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
|
||||
:root:lang(ko) {
|
||||
--font-cjk: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
|
||||
--fw-regular: 400;
|
||||
--body-lh: 1.54;
|
||||
--heading-tracking: 0em;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Single source of truth for UI Contract v1 (docs/plugin-architecture.md §5.1).
|
||||
// Renaming or removing any part, state attribute, or token here is a uiApi major bump.
|
||||
|
||||
export const UI_API_VERSION = '1.0.0' as const
|
||||
|
||||
export const UI_CONTRACT_PARTS = [
|
||||
'rg-p-shell',
|
||||
'rg-p-titlebar',
|
||||
'rg-p-brand',
|
||||
'rg-p-workspace',
|
||||
'rg-p-sidebar',
|
||||
'rg-p-sidebar-head',
|
||||
'rg-p-nav',
|
||||
'rg-p-main',
|
||||
'rg-p-vm-page',
|
||||
'rg-p-vm-header',
|
||||
'rg-p-vm-preview',
|
||||
'rg-p-vm-summary',
|
||||
'rg-p-statusbar',
|
||||
'rg-p-logpanel',
|
||||
'rg-p-settings',
|
||||
'rg-p-empty',
|
||||
] as const
|
||||
|
||||
export type UIContractPart = (typeof UI_CONTRACT_PARTS)[number]
|
||||
|
||||
export const UI_CONTRACT_STATE_ATTRS = [
|
||||
'data-theme',
|
||||
'data-motion',
|
||||
'data-locale',
|
||||
'data-view',
|
||||
'data-vm-state',
|
||||
'data-busy',
|
||||
'data-has-error',
|
||||
'data-sidebar-collapsed',
|
||||
'data-safe-mode',
|
||||
] as const
|
||||
|
||||
export const UI_CONTRACT_SLOTS = [
|
||||
'sidebar.footer',
|
||||
'statusbar.right',
|
||||
'vm.toolbar',
|
||||
'vm.card',
|
||||
'settings.plugin',
|
||||
'vm.preview.tl',
|
||||
'vm.preview.tr',
|
||||
'vm.preview.bl',
|
||||
'vm.preview.br',
|
||||
'empty.state',
|
||||
] as const
|
||||
|
||||
export type UIContractSlot = (typeof UI_CONTRACT_SLOTS)[number]
|
||||
|
||||
export const UI_CONTRACT_TOKENS = [
|
||||
'--font-sans', '--font-cjk', '--font-mono',
|
||||
'--body-lh', '--heading-tracking',
|
||||
'--fs-11', '--fs-12', '--fs-13', '--fs-14', '--fs-15', '--fs-16', '--fs-20', '--fs-24',
|
||||
'--fw-regular', '--fw-medium', '--fw-strong',
|
||||
'--sp-1', '--sp-2', '--sp-3', '--sp-4', '--sp-5', '--sp-6', '--sp-8',
|
||||
'--r-sm', '--r-md', '--r-lg', '--r-xl',
|
||||
'--surface-0', '--surface-canvas', '--surface-sidebar-rail', '--surface-sidebar',
|
||||
'--surface-sidebar-border', '--surface-sidebar-shadow', '--surface-chrome',
|
||||
'--surface-statusbar', '--surface-1', '--surface-card-elevated', '--surface-2',
|
||||
'--surface-input', '--surface-hover', '--surface-active',
|
||||
'--border', '--border-strong', '--highlight-top', '--scrim',
|
||||
'--shadow-btn', '--shadow-card', '--shadow-overlay',
|
||||
'--blur-chrome', '--blur-overlay',
|
||||
'--text', '--text-2', '--text-3', '--text-code',
|
||||
'--accent', '--accent-hover', '--accent-text', '--accent-soft', '--accent-soft-text', '--focus-ring',
|
||||
'--status-running', '--status-busy', '--status-error', '--status-idle',
|
||||
'--ok-soft', '--ok-text', '--warn-soft', '--warn-text',
|
||||
'--danger', '--danger-soft', '--danger-border', '--danger-text',
|
||||
'--notice-soft', '--notice-border', '--seg-thumb',
|
||||
'--ease-out', '--ease-in-out', '--ease-spring',
|
||||
'--dur-press', '--dur-fast', '--dur', '--dur-modal', '--dur-toast',
|
||||
'--titlebar-h', '--logbar-h', '--sidebar-w', '--page-max',
|
||||
] as const
|
||||
|
||||
export const UI_CONTRACT = {
|
||||
uiApi: UI_API_VERSION,
|
||||
parts: [...UI_CONTRACT_PARTS],
|
||||
stateAttrs: [...UI_CONTRACT_STATE_ATTRS],
|
||||
slots: [...UI_CONTRACT_SLOTS],
|
||||
tokens: [...UI_CONTRACT_TOKENS],
|
||||
}
|
||||
@@ -1,295 +1,172 @@
|
||||
export type Locale = 'zh-CN' | 'en-US'
|
||||
// Backend types come from the Wails-generated models (wailsjs/go/models.ts,
|
||||
// regenerated by `wails dev` / `wails build`). This file only adds what Go
|
||||
// cannot say: string unions, and `| null` for slices Go may send as nil.
|
||||
import { app, config, driver, host, installer, plugin, reims, runtime, version } from '../wailsjs/go/models'
|
||||
|
||||
export interface Config {
|
||||
data_root: string
|
||||
/** A generated class as a plain data shape (no convertValues helper). */
|
||||
type Model<T> = Omit<T, 'convertValues'>
|
||||
|
||||
export type BuiltinLocale = 'zh-CN' | 'en-US'
|
||||
export type Locale = BuiltinLocale | (string & {})
|
||||
|
||||
export type Config = Model<config.Config> & {
|
||||
locale: Locale
|
||||
active_runtime?: string
|
||||
auto_pin_pcores: boolean
|
||||
default_gpu?: string
|
||||
runtime_channel?: 'stable' | 'candidate' | ''
|
||||
runtime_channel?: 'stable' | 'alpha' | ''
|
||||
}
|
||||
|
||||
export interface GPUInfo {
|
||||
name: string
|
||||
vulkan_icd: string
|
||||
export type DisplayInfo = host.DisplayInfo
|
||||
export type DisplayPreset = host.DisplayPreset
|
||||
export type AudioInfo = host.AudioInfo
|
||||
export type WHPXCapabilities = host.WHPXCapabilities
|
||||
export type LogicalCPUInfo = host.LogicalCPUInfo
|
||||
|
||||
export type GPUCompat = 'supported' | 'warn' | 'unsupported' | 'unknown'
|
||||
|
||||
export type GPUInfo = Omit<Model<host.GPUInfo>, 'compat'> & {
|
||||
kind: 'discrete' | 'integrated' | 'virtual' | 'unknown'
|
||||
}
|
||||
|
||||
export interface WHPXCapabilities {
|
||||
modern_os: boolean
|
||||
apic_emulation: boolean
|
||||
kernel_irqchip_available: boolean
|
||||
nested_virt_property: boolean
|
||||
nested_virt_probe_error?: string
|
||||
compat?: GPUCompat
|
||||
}
|
||||
|
||||
export type OptimizationStatus = 'recommended' | 'available' | 'experimental' | 'auto' | 'unavailable'
|
||||
|
||||
export interface Optimization {
|
||||
export type Optimization = Model<host.Optimization> & {
|
||||
id: 'pcore_pin' | 'kernel_irqchip' | 'cold_reboot' | 'discrete_gpu' | string
|
||||
status: OptimizationStatus
|
||||
supported: boolean
|
||||
recommended: boolean
|
||||
detail?: string
|
||||
}
|
||||
|
||||
export interface HostReport {
|
||||
os: string
|
||||
arch: string
|
||||
logical_cpus: number
|
||||
physical_cores: number
|
||||
has_hybrid_cores: boolean
|
||||
p_core_count: number
|
||||
e_core_count: number
|
||||
p_core_mask: number
|
||||
p_core_mask_hex: string
|
||||
p_core_logical_cpus?: number[]
|
||||
e_core_logical_cpus?: number[]
|
||||
lpe_core_count?: number
|
||||
non_lpe_mask?: number
|
||||
non_lpe_mask_hex?: string
|
||||
non_lpe_logical_cpus?: number[]
|
||||
total_ram_gb: number
|
||||
avail_ram_gb: number
|
||||
memory_load_pct?: number
|
||||
/** Windows commit memory: QEMU commits all guest RAM at start. */
|
||||
commit_avail_gb: number
|
||||
commit_limit_gb: number
|
||||
data_root: string
|
||||
data_root_drive_type?: string
|
||||
free_disk_gb: number
|
||||
export type HostReport = Omit<Model<host.Report>, 'gpus' | 'recommended_gpu'> & {
|
||||
whpx: 'ready' | 'no_hypervisor' | 'missing' | 'unsupported'
|
||||
whpx_caps?: WHPXCapabilities
|
||||
needs_cold_reboot_workaround?: boolean
|
||||
gpus: GPUInfo[]
|
||||
recommended_gpu?: GPUInfo
|
||||
}
|
||||
|
||||
export interface RuntimeManifest {
|
||||
commit: string
|
||||
full_commit: string
|
||||
qemu_version: string
|
||||
util_version: string
|
||||
built_at: string
|
||||
file_count: number
|
||||
dll_count: number
|
||||
raw_bytes: number
|
||||
export type RuntimeManifest = Model<runtime.Manifest>
|
||||
export type InstalledRuntime = Model<runtime.Installed>
|
||||
|
||||
export type RemoteRuntime = Model<runtime.Remote> & {
|
||||
channel: 'stable' | 'alpha'
|
||||
}
|
||||
|
||||
export interface InstalledRuntime {
|
||||
commit: string
|
||||
dir: string
|
||||
active: boolean
|
||||
manifest: RuntimeManifest
|
||||
}
|
||||
|
||||
export interface VMListItem {
|
||||
name: string
|
||||
dir: string
|
||||
pid: number | null
|
||||
export type VMListItem = Model<reims.VMListItem> & {
|
||||
state: 'running' | 'stopped' | 'broken'
|
||||
}
|
||||
|
||||
export interface PendingChange {
|
||||
field: string
|
||||
from: string
|
||||
to: string
|
||||
}
|
||||
export type PendingChange = app.PendingChange
|
||||
|
||||
export interface AppState {
|
||||
export type AppState = Omit<Model<app.AppState>, 'config' | 'host' | 'optimizations' | 'runtimes' | 'active_runtime' | 'vms'> & {
|
||||
config: Config
|
||||
host: HostReport
|
||||
optimizations?: Optimization[]
|
||||
runtimes: InstalledRuntime[] | null
|
||||
active_runtime?: InstalledRuntime
|
||||
vms: VMListItem[] | null
|
||||
transitions: Record<string, string>
|
||||
pending_changes: Record<string, PendingChange[]>
|
||||
/** First launch: no data folder chosen yet (setup.go). */
|
||||
needs_setup: boolean
|
||||
app_version?: string
|
||||
}
|
||||
|
||||
export interface AppUpdateInfo {
|
||||
current: string
|
||||
latest: string
|
||||
has_update: boolean
|
||||
page_url?: string
|
||||
download_url?: string
|
||||
asset_name?: string
|
||||
asset_size?: number
|
||||
published_at?: string
|
||||
export type AppUpdateInfo = version.UpdateInfo
|
||||
export type VMDetail = reims.VMDetail
|
||||
export type VMStats = app.VMStats
|
||||
export type DriveShareSettings = Model<app.DriveShareSettings>
|
||||
export type VMAffinityMode = 'auto' | 'all' | 'pcores' | 'non_lpe' | 'custom'
|
||||
export type VMAffinityUpdate = {
|
||||
mode: VMAffinityMode
|
||||
cpus?: number[]
|
||||
disable_eco_qos: boolean
|
||||
}
|
||||
|
||||
export interface VMDetail {
|
||||
name: string
|
||||
state: string
|
||||
kind: string
|
||||
directory: string
|
||||
cpus: number
|
||||
memory: string
|
||||
disk: string
|
||||
disk_controller: string
|
||||
graphics: string
|
||||
display: string
|
||||
displays: number
|
||||
resolution: string
|
||||
gpu: string
|
||||
has_opencore: boolean
|
||||
has_installer: boolean
|
||||
recovery_mode?: boolean
|
||||
installer_path?: string
|
||||
cpu_model: string
|
||||
audio: boolean
|
||||
audio_raw: string
|
||||
network: boolean
|
||||
network_summary: string
|
||||
ssh_port: number
|
||||
logs: boolean
|
||||
log_level: string
|
||||
stop_timeout: number
|
||||
capture: boolean
|
||||
borderless: boolean
|
||||
extra_args: string
|
||||
guest_tools_attached?: boolean
|
||||
guest_tools_configured?: boolean
|
||||
guest_tools_connected?: boolean
|
||||
shared_dir?: string
|
||||
export type VMAffinityStatus = Omit<Model<app.VMAffinityStatus>, 'mode' | 'effective_mode'> & {
|
||||
mode: VMAffinityMode
|
||||
effective_mode: VMAffinityMode
|
||||
}
|
||||
/** One frame of a VM's screen (internal/app/thumbnail_flow.go). Empty data_url: none yet. */
|
||||
export type VMThumbnail = app.VMThumbnail
|
||||
export type ValidationIssue = reims.ValidationIssue
|
||||
export type DiskResizeResult = reims.DiskResizeResult
|
||||
export type DiskCompactResult = reims.DiskCompactResult
|
||||
export type DiskSnapshot = reims.DiskSnapshot
|
||||
export type StorageBreakdown = Model<app.StorageBreakdown>
|
||||
export type SetOpts = reims.SetOpts
|
||||
|
||||
export interface ValidationIssue {
|
||||
field: string
|
||||
code: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface CreateOpts {
|
||||
name: string
|
||||
dir?: string
|
||||
export type CreateOpts = Model<reims.CreateOpts> & {
|
||||
source_mode?: 'offline' | 'apple' | 'installer' | 'disk'
|
||||
/** With macos: an offline installer of that release (reims-ctl create --offline). */
|
||||
offline?: boolean
|
||||
macos?: string
|
||||
installer?: string
|
||||
cpus: number
|
||||
memory: string
|
||||
disk_size?: string
|
||||
disk?: string
|
||||
disk_mode?: 'copy' | 'in-place'
|
||||
disk_controller?: 'nvme' | 'ahci' | 'virtio'
|
||||
graphics: 'reims-vgpu' | 'vmware-svga'
|
||||
cpus: number
|
||||
memory: string
|
||||
gpu: string
|
||||
resolution: string
|
||||
displays: number
|
||||
borderless?: boolean
|
||||
capture?: boolean
|
||||
audio?: boolean
|
||||
network?: boolean
|
||||
ssh_port?: number
|
||||
logs?: boolean
|
||||
start?: boolean
|
||||
}
|
||||
|
||||
export interface SetOpts {
|
||||
name: string
|
||||
cpus?: number
|
||||
memory?: string
|
||||
graphics?: string
|
||||
displays?: number
|
||||
disk_controller?: string
|
||||
resolution?: string
|
||||
borderless?: boolean
|
||||
capture?: boolean
|
||||
gpu?: string
|
||||
logs?: boolean
|
||||
log_level?: string
|
||||
audio?: boolean
|
||||
audio_backend?: string
|
||||
network?: boolean
|
||||
ssh_port?: number
|
||||
stop_timeout?: number
|
||||
extra_args?: string
|
||||
export type TaskStatus = 'running' | 'done' | 'failed' | 'canceled'
|
||||
|
||||
export type InstallerKind = 'offline' | 'online'
|
||||
export type InstallerPhase = 'queued' | 'downloading'
|
||||
|
||||
/** A tracked long-running job pushed as "reims:task" (internal/app/tasks.go). */
|
||||
export type Task = Model<app.Task> & {
|
||||
kind: 'installer-download' | 'recovery-download' | 'vm-create' | 'runtime-install' | 'app-update' | string
|
||||
installer_kind?: InstallerKind | ''
|
||||
installer_phase?: InstallerPhase | ''
|
||||
status: TaskStatus
|
||||
}
|
||||
|
||||
/** An offline installer Apple offers (`reims-util offline-installer list`). */
|
||||
export type Release = installer.Release
|
||||
|
||||
/** A file kept in the installers directory. */
|
||||
export type CachedInstaller = Model<installer.Cached> & {
|
||||
kind: 'offline' | 'online' | 'ipsw' | 'other'
|
||||
}
|
||||
|
||||
export type DataRootChoice = app.DataRootChoice
|
||||
export type DataRootCheck = app.DataRootCheck
|
||||
|
||||
export type LocalizedText = plugin.LocalizedText
|
||||
export type PermissionSpec = plugin.PermissionSpec
|
||||
export type SettingProperty = plugin.SettingProperty
|
||||
export type SettingsSchema = plugin.SettingsSchema
|
||||
export type PluginInfo = plugin.PluginInfo
|
||||
export type DoctorFinding = plugin.DoctorFinding
|
||||
export type ScanFinding = plugin.ScanFinding
|
||||
export type ExecutableFile = plugin.ExecutableFile
|
||||
export type CapabilityItem = plugin.CapabilityItem
|
||||
export type ScanReport = plugin.ScanReport
|
||||
export type MarketEntry = plugin.MarketEntry
|
||||
export type MarketWithdrawal = plugin.MarketWithdrawal
|
||||
export type MarketCatalogItem = plugin.MarketCatalogItem
|
||||
export type MarketBrowseResult = plugin.MarketBrowseResult
|
||||
export type TokenDeriveRule = plugin.TokenDeriveRule
|
||||
export type ThemeScheme = plugin.ThemeScheme
|
||||
export type ThemeDecoration = plugin.ThemeDecoration
|
||||
export type ThemeDecorationState = plugin.ThemeDecorationState
|
||||
export type ThemeContribution = plugin.ThemeContribution
|
||||
export type CustomThemeScheme = plugin.CustomThemeScheme
|
||||
export type ActiveThemePayload = plugin.ActiveThemePayload
|
||||
export interface ResolvedLocaleFont {
|
||||
family: string
|
||||
url: string
|
||||
weight?: string
|
||||
style?: string
|
||||
unicodeRange?: string
|
||||
}
|
||||
|
||||
export type ResolvedLocalePack = Model<plugin.ResolvedLocalePack> & {
|
||||
has_ui_messages?: boolean
|
||||
plugin_messages?: Record<string, Record<string, string>>
|
||||
fonts?: ResolvedLocaleFont[]
|
||||
}
|
||||
export type MenuContribution = plugin.MenuContribution
|
||||
export type VMCardContribution = plugin.VMCardContribution
|
||||
export type PanelContribution = plugin.PanelContribution
|
||||
export type StatusItemContribution = plugin.StatusItemContribution
|
||||
export type PluginUIContributions = app.PluginUIContributions
|
||||
export type DriverSummary = driver.DriverSummary
|
||||
export type DriverCreateRequest = driver.CreateRequest
|
||||
export type RuntimeKindSpec = runtime.KindSpec
|
||||
|
||||
/** A "reims:log" event (internal/app/app.go emitLog); not a Go struct, so not generated. */
|
||||
export interface LogEntry {
|
||||
ts: string
|
||||
source: string
|
||||
line: string
|
||||
}
|
||||
|
||||
export type TaskStatus = 'running' | 'done' | 'failed' | 'canceled'
|
||||
|
||||
/** A tracked long-running job pushed as "reims:task" (tasks.go). */
|
||||
export interface Task {
|
||||
id: string
|
||||
kind: 'installer-download' | 'vm-create' | string
|
||||
subject: string
|
||||
vm?: string
|
||||
step: string
|
||||
done: number
|
||||
total: number
|
||||
/** -1 when unknown */
|
||||
percent: number
|
||||
/** bytes per second, 0 when unknown */
|
||||
rate: number
|
||||
status: TaskStatus
|
||||
error?: string
|
||||
result?: string
|
||||
cancelable: boolean
|
||||
started_at: number
|
||||
updated_at: number
|
||||
}
|
||||
|
||||
/** An offline installer Apple offers (`reims-util offline-installer list`). */
|
||||
export interface Release {
|
||||
product: string
|
||||
title: string
|
||||
version: string
|
||||
build: string
|
||||
posted: string
|
||||
size: number
|
||||
}
|
||||
|
||||
/** A file kept in the installers directory. */
|
||||
export interface CachedInstaller {
|
||||
name: string
|
||||
path: string
|
||||
bytes: number
|
||||
kind: 'offline' | 'online' | 'ipsw' | 'other'
|
||||
partial: boolean
|
||||
title?: string
|
||||
version?: string
|
||||
build?: string
|
||||
}
|
||||
|
||||
/** A published runtime (GitHub Release, internal/runtime/remote.go). */
|
||||
export interface RemoteRuntime {
|
||||
commit: string
|
||||
tag: string
|
||||
channel: 'stable' | 'candidate'
|
||||
published_at: string
|
||||
page_url: string
|
||||
archive_name: string
|
||||
archive_url: string
|
||||
archive_size: number
|
||||
sums_url: string
|
||||
source_name?: string
|
||||
source_url?: string
|
||||
}
|
||||
|
||||
export interface DataRootChoice {
|
||||
path: string
|
||||
free_gb: number
|
||||
system: boolean
|
||||
external: boolean
|
||||
recommended: boolean
|
||||
}
|
||||
|
||||
export interface DataRootCheck {
|
||||
path: string
|
||||
free_gb: number
|
||||
system: boolean
|
||||
external: boolean
|
||||
has_config: boolean
|
||||
error?: string
|
||||
}
|
||||
@@ -10,21 +10,28 @@ interface TipProps {
|
||||
label: string
|
||||
shortcut?: string
|
||||
side?: 'top' | 'bottom' | 'left' | 'right'
|
||||
disabled?: boolean
|
||||
children: React.ReactElement
|
||||
}
|
||||
|
||||
/** Tooltip around a single focusable child. */
|
||||
export const Tip: React.FC<TipProps> = ({ label, shortcut, side = 'bottom', children }) => (
|
||||
<RTooltip.Root>
|
||||
<RTooltip.Trigger asChild>{children}</RTooltip.Trigger>
|
||||
<RTooltip.Portal>
|
||||
<RTooltip.Content className="tooltip" side={side} sideOffset={6} collisionPadding={8}>
|
||||
{label}
|
||||
{shortcut && <kbd>{shortcut}</kbd>}
|
||||
</RTooltip.Content>
|
||||
</RTooltip.Portal>
|
||||
</RTooltip.Root>
|
||||
)
|
||||
export const Tip: React.FC<TipProps> = ({ label, shortcut, side = 'bottom', disabled, children }) => {
|
||||
const [open, setOpen] = React.useState(false)
|
||||
React.useEffect(() => {
|
||||
if (disabled) setOpen(false)
|
||||
}, [disabled])
|
||||
return (
|
||||
<RTooltip.Root open={disabled ? false : open} onOpenChange={(next) => setOpen(disabled ? false : next)}>
|
||||
<RTooltip.Trigger asChild>{children}</RTooltip.Trigger>
|
||||
<RTooltip.Portal>
|
||||
<RTooltip.Content className="tooltip" side={side} sideOffset={6} collisionPadding={8}>
|
||||
{label}
|
||||
{shortcut && <kbd>{shortcut}</kbd>}
|
||||
</RTooltip.Content>
|
||||
</RTooltip.Portal>
|
||||
</RTooltip.Root>
|
||||
)
|
||||
}
|
||||
|
||||
type ButtonVariant = 'secondary' | 'primary' | 'danger' | 'ghost'
|
||||
|
||||
@@ -44,7 +51,7 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
aria-busy={busy || undefined}
|
||||
{...rest}
|
||||
>
|
||||
{busy ? <LoaderCircle size={14} className="spin" /> : icon}
|
||||
{busy ? <LoaderCircle size={14} className="spin" aria-hidden="true" /> : icon}
|
||||
{children}
|
||||
</button>
|
||||
),
|
||||
@@ -73,7 +80,7 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
||||
aria-busy={busy || undefined}
|
||||
{...rest}
|
||||
>
|
||||
{busy ? <LoaderCircle size={16} className="spin" /> : icon}
|
||||
{busy ? <LoaderCircle size={16} className="spin" aria-hidden="true" /> : icon}
|
||||
</button>
|
||||
</Tip>
|
||||
),
|
||||
@@ -85,6 +92,7 @@ export type StatusKind = 'running' | 'stopped' | 'busy' | 'broken' | 'warn'
|
||||
export function statusKind(state: string): StatusKind {
|
||||
if (state === 'running') return 'running'
|
||||
if (state === 'starting' || state === 'stopping' || state === 'creating') return 'busy'
|
||||
if (state === 'driver_unavailable') return 'warn'
|
||||
if (state === 'broken') return 'broken'
|
||||
return 'stopped'
|
||||
}
|
||||
|
||||
@@ -10,21 +10,34 @@ interface Props {
|
||||
/** While false, Esc / outside click / ✕ are ignored (e.g. during a create). */
|
||||
dismissable?: boolean
|
||||
onClose: () => void
|
||||
/** Extra class on the dialog box, e.g. a wider variant. */
|
||||
className?: string
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
/** Modal frame: head with title and ✕; children supply body/steps/foot sections. */
|
||||
export const Modal: React.FC<Props> = ({ title, subtitle, closeLabel, dismissable = true, onClose, children }) => (
|
||||
export const Modal: React.FC<Props> = ({ title, subtitle, closeLabel, dismissable = true, onClose, className, children }) => (
|
||||
<RDialog.Root open onOpenChange={(open) => { if (!open && dismissable) onClose() }}>
|
||||
<RDialog.Portal>
|
||||
<RDialog.Overlay className="overlay" />
|
||||
<RDialog.Content
|
||||
className="dialog"
|
||||
className={className ? `dialog ${className}` : 'dialog'}
|
||||
onInteractOutside={(e) => e.preventDefault()}
|
||||
// Focus the first form field rather than ✕, so the close tooltip doesn't pop on open.
|
||||
// Focus the first enabled form field, or the dialog container itself when there is
|
||||
// none, so the top-right ✕ close button's tooltip never pops on open.
|
||||
onOpenAutoFocus={(e) => {
|
||||
const first = (e.currentTarget as HTMLElement | null)?.querySelector<HTMLElement>('input, select, textarea')
|
||||
if (first) { e.preventDefault(); first.focus() }
|
||||
const root = e.currentTarget as HTMLElement | null
|
||||
if (!root) return
|
||||
e.preventDefault()
|
||||
const first = root.querySelector<HTMLElement>(
|
||||
'input:not(:disabled):not([type="hidden"]):not([type="radio"]:not(:checked)), select:not(:disabled), textarea:not(:disabled)',
|
||||
)
|
||||
if (first) {
|
||||
first.focus({ preventScroll: true })
|
||||
}
|
||||
if (!root.contains(document.activeElement)) {
|
||||
root.focus({ preventScroll: true })
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="dialog-head">
|
||||
|
||||
@@ -0,0 +1,420 @@
|
||||
import * as Menu from '@radix-ui/react-dropdown-menu'
|
||||
import { Check, ChevronsUpDown, CircleAlert, Lock, RotateCcw } from 'lucide-react'
|
||||
import React, { useEffect, useId, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { IconButton } from './controls'
|
||||
|
||||
// Settings page primitives (docs/design-guidelines.md §2–3):
|
||||
// one row shell — title and description on the left, the control on the
|
||||
// right — plus the switch, segmented control, range field and option cards
|
||||
// every category builds its rows from, so the whole panel reads as one set.
|
||||
|
||||
/** A labelled block of rows, like a grouped list in macOS System Settings. */
|
||||
export const SetGroup: React.FC<{ title?: string; note?: React.ReactNode; children: React.ReactNode }> = ({ title, note, children }) => (
|
||||
<section className="sgroup">
|
||||
{title && <h3 className="sgroup-title">{title}</h3>}
|
||||
<div className="sgroup-list">{children}</div>
|
||||
{note && <p className="sgroup-note">{note}</p>}
|
||||
</section>
|
||||
)
|
||||
|
||||
interface RowProps {
|
||||
title: string
|
||||
desc?: React.ReactNode
|
||||
/** Control drawn on the right of the title. */
|
||||
control?: React.ReactNode
|
||||
/** Control drawn under the title at full width (sliders, cards). */
|
||||
block?: React.ReactNode
|
||||
/** The value differs from what the VM has now. */
|
||||
dirty?: boolean
|
||||
onReset?: () => void
|
||||
resetLabel?: string
|
||||
/** The row can't act right now; `reason` says why. */
|
||||
disabled?: boolean
|
||||
reason?: string
|
||||
error?: string
|
||||
/** Anchor so a validation error can scroll its row into view. */
|
||||
field?: string
|
||||
}
|
||||
|
||||
/** One setting: title, one line of description, a control, and its state marks. */
|
||||
export const SetRow: React.FC<RowProps> = ({ title, desc, control, block, dirty, onReset, resetLabel, disabled, reason, error, field }) => {
|
||||
const titleId = useId()
|
||||
return (
|
||||
<div
|
||||
className="srow"
|
||||
data-field={field}
|
||||
data-dirty={dirty || undefined}
|
||||
data-disabled={disabled || undefined}
|
||||
data-error={error ? true : undefined}
|
||||
role="group"
|
||||
aria-labelledby={titleId}
|
||||
>
|
||||
<div className="srow-head">
|
||||
<div className="srow-text">
|
||||
<div className="srow-title" id={titleId}>
|
||||
{title}
|
||||
{dirty && <span className="dirty-dot" aria-hidden="true" />}
|
||||
</div>
|
||||
{desc && <div className="srow-desc">{desc}</div>}
|
||||
{disabled && reason && (
|
||||
<div className="srow-reason"><Lock size={12} aria-hidden="true" />{reason}</div>
|
||||
)}
|
||||
</div>
|
||||
{(control || (dirty && onReset)) && (
|
||||
<div className="srow-ctrl">
|
||||
{dirty && onReset && !disabled && (
|
||||
<IconButton small label={resetLabel ?? 'Reset'} icon={<RotateCcw size={13} />} onClick={onReset} className="srow-reset" tipSide="top" />
|
||||
)}
|
||||
{control && <fieldset className="srow-fieldset" disabled={disabled}>{control}</fieldset>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{block && <fieldset className="srow-fieldset srow-block" disabled={disabled}>{block}</fieldset>}
|
||||
{error && <div className="srow-error" role="alert"><CircleAlert size={13} aria-hidden="true" />{error}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Read-only row: a label and its value. */
|
||||
export const SetValue: React.FC<{ title: string; value: React.ReactNode; mono?: boolean }> = ({ title, value, mono }) => (
|
||||
<div className="srow srow-kv">
|
||||
<div className="srow-head">
|
||||
<div className="srow-title">{title}</div>
|
||||
<div className={`srow-value${mono ? ' mono' : ''}`}>{value}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
export const Switch: React.FC<{ checked: boolean; onChange: (v: boolean) => void; label: string; disabled?: boolean }> = ({ checked, onChange, label, disabled }) => (
|
||||
<label className="switch">
|
||||
<input type="checkbox" role="switch" aria-label={label} checked={checked} disabled={disabled} onChange={(e) => onChange(e.target.checked)} />
|
||||
<span className="slider" />
|
||||
</label>
|
||||
)
|
||||
|
||||
export interface SegOption<V> {
|
||||
value: V
|
||||
label: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Segmented control with a sliding highlight. A radio group under the hood:
|
||||
* arrow keys move the choice, Tab leaves the group.
|
||||
*/
|
||||
export function Segmented<V extends string | number>({ options, value, onChange, label, wide }: {
|
||||
options: SegOption<V>[]
|
||||
value: V | undefined
|
||||
onChange: (v: V) => void
|
||||
label: string
|
||||
/** Stretch to the row's width with equal segments. */
|
||||
wide?: boolean
|
||||
}) {
|
||||
const box = useRef<HTMLDivElement>(null)
|
||||
const [thumb, setThumb] = useState<{ x: number; w: number } | null>(null)
|
||||
|
||||
const measure = () => {
|
||||
const el = box.current?.querySelector<HTMLElement>('[aria-checked="true"]')
|
||||
const next = el ? { x: el.offsetLeft, w: el.offsetWidth } : null
|
||||
setThumb((prev) => {
|
||||
if (!prev && !next) return prev
|
||||
if (prev && next && prev.x === next.x && prev.w === next.w) return prev
|
||||
return next
|
||||
})
|
||||
}
|
||||
useLayoutEffect(measure, [value, options])
|
||||
useEffect(() => {
|
||||
if (!box.current || typeof ResizeObserver === 'undefined') return
|
||||
let raf = 0
|
||||
const ro = new ResizeObserver(() => {
|
||||
if (raf) cancelAnimationFrame(raf)
|
||||
raf = requestAnimationFrame(() => {
|
||||
raf = 0
|
||||
measure()
|
||||
})
|
||||
})
|
||||
ro.observe(box.current)
|
||||
return () => {
|
||||
if (raf) cancelAnimationFrame(raf)
|
||||
ro.disconnect()
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
const onKey = (e: React.KeyboardEvent) => {
|
||||
if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return
|
||||
e.preventDefault()
|
||||
const enabled = options.filter((o) => !o.disabled)
|
||||
const i = enabled.findIndex((o) => o.value === value)
|
||||
const isRTL = box.current ? getComputedStyle(box.current).direction === 'rtl' : false
|
||||
const delta = (e.key === 'ArrowRight') !== isRTL ? 1 : -1
|
||||
const next = enabled[(i + delta + enabled.length) % enabled.length]
|
||||
if (next) {
|
||||
onChange(next.value)
|
||||
requestAnimationFrame(() => box.current?.querySelector<HTMLElement>('[aria-checked="true"]')?.focus())
|
||||
}
|
||||
}
|
||||
|
||||
const hasActive = options.some((o) => o.value === value)
|
||||
return (
|
||||
<div ref={box} className={`seg${wide ? ' seg-wide' : ''}`} role="radiogroup" aria-label={label} onKeyDown={onKey}>
|
||||
{thumb && <span className="seg-thumb" style={{ transform: `translateX(${thumb.x}px)`, width: thumb.w }} aria-hidden="true" />}
|
||||
{options.map((o, i) => {
|
||||
const on = o.value === value
|
||||
return (
|
||||
<button
|
||||
key={String(o.value)}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={on}
|
||||
tabIndex={on || (!hasActive && i === 0) ? 0 : -1}
|
||||
disabled={o.disabled}
|
||||
onClick={() => onChange(o.value)}
|
||||
>
|
||||
{o.label}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface NumberProps {
|
||||
value: number
|
||||
min: number
|
||||
max: number
|
||||
step?: number
|
||||
unit?: string
|
||||
label: string
|
||||
onChange: (v: number) => void
|
||||
/** Width in characters; the default fits five digits. */
|
||||
size?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Number field with a unit suffix and no spinner. It keeps what is typed so
|
||||
* far and commits a whole, clamped number on Enter or blur; ↑/↓ step it.
|
||||
*/
|
||||
export const NumberField: React.FC<NumberProps> = ({ value, min, max, step = 1, unit, label, onChange, size = 5 }) => {
|
||||
const [text, setText] = useState(String(value))
|
||||
useEffect(() => { setText(String(value)) }, [value])
|
||||
const clamp = (v: number) => Math.min(max, Math.max(min, Math.round(v / step) * step))
|
||||
const commit = () => {
|
||||
const n = Number.parseFloat(text)
|
||||
if (!Number.isFinite(n)) { setText(String(value)); return }
|
||||
const c = clamp(n)
|
||||
setText(String(c))
|
||||
if (c !== value) onChange(c)
|
||||
}
|
||||
return (
|
||||
<div className="num-field">
|
||||
<input
|
||||
className="num-input"
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
aria-label={label}
|
||||
style={{ width: `${size + 1.5}ch` }}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value.replace(/[^\d.]/g, ''))}
|
||||
onBlur={commit}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') { e.preventDefault(); commit() }
|
||||
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
||||
e.preventDefault()
|
||||
onChange(clamp(value + (e.key === 'ArrowUp' ? step : -step)))
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{unit && <span className="num-unit">{unit}</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Drop marks that would sit closer than `gap` percent to the one before. */
|
||||
function thinMarks(marks: RangeMark[], min: number, max: number, gap = 9): RangeMark[] {
|
||||
const span = Math.max(max - min, 1)
|
||||
const out: RangeMark[] = []
|
||||
let last = -Infinity
|
||||
for (const m of marks) {
|
||||
if (m.value < min || m.value > max) continue
|
||||
const p = ((m.value - min) / span) * 100
|
||||
if (p - last < gap) continue
|
||||
out.push(m)
|
||||
last = p
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export interface RangeMark {
|
||||
value: number
|
||||
label: string
|
||||
}
|
||||
|
||||
interface RangeProps {
|
||||
value: number
|
||||
min: number
|
||||
max: number
|
||||
step?: number
|
||||
unit: string
|
||||
label: string
|
||||
onChange: (v: number) => void
|
||||
/** Clickable labels under the track. */
|
||||
marks?: RangeMark[]
|
||||
/** Highlighted "recommended" span of the track. */
|
||||
recommend?: [number, number]
|
||||
/** From here to the end the track turns amber. */
|
||||
warnFrom?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Slider and number field bound to one value. The slider and the marks write
|
||||
* straight away; the field commits on Enter or blur (NumberField).
|
||||
*/
|
||||
export const RangeField: React.FC<RangeProps> = ({ value, min, max, step = 1, unit, label, onChange, marks, recommend, warnFrom }) => {
|
||||
const span = Math.max(max - min, 1)
|
||||
const pct = (v: number) => `${((Math.min(max, Math.max(min, v)) - min) / span) * 100}%`
|
||||
const shown = marks ? thinMarks(marks, min, max) : []
|
||||
|
||||
const over = warnFrom !== undefined && value >= warnFrom
|
||||
return (
|
||||
<div className="range-field" data-warn={over || undefined}>
|
||||
<div className="range-main">
|
||||
<div className="range-rail-wrap" dir="ltr">
|
||||
<div className="range-rail" aria-hidden="true">
|
||||
<div className="range-track" />
|
||||
{recommend && (
|
||||
<div className="range-band rec" style={{ left: pct(recommend[0]), width: `calc(${pct(recommend[1])} - ${pct(recommend[0])})` }} />
|
||||
)}
|
||||
{warnFrom !== undefined && warnFrom <= max && (
|
||||
<div className="range-band warn" style={{ left: pct(warnFrom), right: 0 }} />
|
||||
)}
|
||||
<div className="range-fill" style={{ width: pct(value) }} />
|
||||
</div>
|
||||
<input
|
||||
className="range"
|
||||
type="range"
|
||||
aria-label={label}
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
value={value}
|
||||
onChange={(e) => onChange(Number(e.target.value))}
|
||||
/>
|
||||
{shown.length > 0 && (
|
||||
<div className="range-marks">
|
||||
{shown.map((m) => (
|
||||
<button
|
||||
key={m.value}
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
className="range-mark"
|
||||
aria-pressed={m.value === value}
|
||||
style={{ left: pct(m.value) }}
|
||||
onClick={() => onChange(m.value)}
|
||||
>
|
||||
{m.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<NumberField value={value} min={min} max={max} step={step} unit={unit} label={label} onChange={onChange} size={3} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export interface CardOption<V> {
|
||||
value: V
|
||||
title: string
|
||||
sub?: string
|
||||
badges?: string[]
|
||||
/** Small picture drawn above the title (e.g. a screen shape). */
|
||||
art?: React.ReactNode
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
/** A row of option cards, one picked: a radio group with larger targets. */
|
||||
export function OptionCards<V extends string>({ options, value, onChange, label, columns }: {
|
||||
options: CardOption<V>[]
|
||||
value: V | undefined
|
||||
onChange: (v: V) => void
|
||||
label: string
|
||||
columns?: number
|
||||
}) {
|
||||
const name = useId()
|
||||
return (
|
||||
<div className="opt-cards" role="radiogroup" aria-label={label} style={columns ? { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` } : undefined}>
|
||||
{options.map((o) => (
|
||||
<label key={o.value} className="opt-card" data-selected={o.value === value || undefined} data-disabled={o.disabled || undefined}>
|
||||
<input type="radio" name={name} checked={o.value === value} disabled={o.disabled} onChange={() => onChange(o.value)} />
|
||||
{o.art}
|
||||
<span className="opt-card-title" title={o.title}>{o.title}</span>
|
||||
{o.sub && <span className="opt-card-sub">{o.sub}</span>}
|
||||
{o.badges && o.badges.length > 0 && (
|
||||
<span className="opt-card-badges">{o.badges.map((b) => <span key={b} className="badge badge-accent">{b}</span>)}</span>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export interface PopupOption<V> {
|
||||
value: V
|
||||
label: string
|
||||
/** Secondary text drawn after the label in grey, e.g. a build number. */
|
||||
detail?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop-up button (HIG pop-up-buttons.md): shows the current choice with ⌃⌄
|
||||
* and opens a menu where the current item carries a checkmark. Replaces the
|
||||
* native <select>, whose Windows list ignores the app's theme.
|
||||
*/
|
||||
export function PopupSelect<V extends string>({ value, options, onChange, label, placeholder, wide, id }: {
|
||||
value: V | undefined
|
||||
options: PopupOption<V>[]
|
||||
onChange: (v: V) => void
|
||||
label: string
|
||||
placeholder?: string
|
||||
/** Fill the container's width instead of sizing to the label. */
|
||||
wide?: boolean
|
||||
id?: string
|
||||
}) {
|
||||
const cur = options.find((o) => o.value === value)
|
||||
return (
|
||||
<Menu.Root modal={false}>
|
||||
<Menu.Trigger asChild>
|
||||
<button type="button" id={id} className={`popup-btn${wide ? ' popup-wide' : ''}`} aria-label={label}>
|
||||
<span className="popup-value">
|
||||
{cur ? cur.label : <span className="muted">{placeholder ?? value ?? ''}</span>}
|
||||
{cur?.detail && <span className="popup-detail">{cur.detail}</span>}
|
||||
</span>
|
||||
<ChevronsUpDown size={13} aria-hidden="true" className="popup-chevron" />
|
||||
</button>
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Content className="menu popup-menu" align="start" sideOffset={4} collisionPadding={8}>
|
||||
<Menu.RadioGroup value={value ?? ''} onValueChange={(v) => onChange(v as V)}>
|
||||
{options.map((o) => (
|
||||
<Menu.RadioItem key={o.value} value={o.value} disabled={o.disabled} className="menu-item popup-item">
|
||||
<Menu.ItemIndicator className="popup-check"><Check size={13} /></Menu.ItemIndicator>
|
||||
<span className="popup-item-label">{o.label}</span>
|
||||
{o.detail && <span className="popup-detail">{o.detail}</span>}
|
||||
</Menu.RadioItem>
|
||||
))}
|
||||
</Menu.RadioGroup>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu.Root>
|
||||
)
|
||||
}
|
||||
|
||||
/** A screen outline with the resolution's aspect ratio. */
|
||||
export const ScreenArt: React.FC<{ w: number; h: number }> = ({ w, h }) => {
|
||||
const W = 44
|
||||
const H = Math.max(18, Math.min(34, Math.round((W * h) / Math.max(w, 1))))
|
||||
return <span className="screen-art" style={{ width: W, height: H }} aria-hidden="true" />
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as RToast from '@radix-ui/react-toast'
|
||||
import { CircleCheck, CircleX, X } from 'lucide-react'
|
||||
import { Check, CircleCheck, CircleX, X } from 'lucide-react'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { IconButton } from './controls'
|
||||
|
||||
@@ -7,6 +7,10 @@ export interface ToastInput {
|
||||
kind: 'ok' | 'error'
|
||||
title: string
|
||||
description?: string
|
||||
errorCode?: string
|
||||
rawDetail?: string
|
||||
detailsLabel?: string
|
||||
copyDetailsLabel?: string
|
||||
action?: { label: string; onClick: () => void }
|
||||
}
|
||||
|
||||
@@ -25,35 +29,109 @@ export function useToasts() {
|
||||
return { items, push, remove }
|
||||
}
|
||||
|
||||
interface ToasterProps {
|
||||
items: ToastItem[]
|
||||
interface ToastCardProps {
|
||||
item: ToastItem
|
||||
onRemove: (id: number) => void
|
||||
closeLabel: string
|
||||
}
|
||||
|
||||
export const Toaster: React.FC<ToasterProps> = ({ items, onRemove, closeLabel }) => (
|
||||
<RToast.Provider swipeDirection="right">
|
||||
{items.map((item) => (
|
||||
<RToast.Root
|
||||
key={item.id}
|
||||
className={`toast ${item.kind}`}
|
||||
duration={item.kind === 'error' ? 8000 : 3000}
|
||||
onOpenChange={(open) => { if (!open) onRemove(item.id) }}
|
||||
>
|
||||
{item.kind === 'ok' ? <CircleCheck size={16} /> : <CircleX size={16} />}
|
||||
const ToastCard: React.FC<ToastCardProps> = ({ item, onRemove, closeLabel }) => {
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
const copyDiagnostic = () => {
|
||||
const full = [
|
||||
item.errorCode ? `[${item.errorCode}] ${item.title}` : item.title,
|
||||
item.description,
|
||||
item.rawDetail,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
navigator.clipboard
|
||||
?.writeText(full)
|
||||
.then(() => {
|
||||
setCopied(true)
|
||||
window.setTimeout(() => setCopied(false), 1500)
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
return (
|
||||
<RToast.Root
|
||||
className={`toast ${item.kind}${item.rawDetail || item.action ? ' has-extra' : ''}`}
|
||||
duration={expanded ? 600_000 : item.kind === 'error' ? 10_000 : item.action ? 8000 : 3000}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onRemove(item.id)
|
||||
}}
|
||||
>
|
||||
<div className="toast-main-row">
|
||||
{item.kind === 'ok' ? (
|
||||
<CircleCheck size={16} aria-hidden="true" />
|
||||
) : (
|
||||
<CircleX size={16} aria-hidden="true" />
|
||||
)}
|
||||
<div className="toast-text">
|
||||
<RToast.Title className="toast-title">{item.title}</RToast.Title>
|
||||
{item.description && <RToast.Description className="toast-desc">{item.description}</RToast.Description>}
|
||||
<div className="toast-title-row">
|
||||
<RToast.Title className="toast-title">{item.title}</RToast.Title>
|
||||
{item.errorCode && <span className="toast-code selectable">{item.errorCode}</span>}
|
||||
</div>
|
||||
{item.description && (
|
||||
<RToast.Description className="toast-desc">{item.description}</RToast.Description>
|
||||
)}
|
||||
</div>
|
||||
{item.action && (
|
||||
{item.action && !item.rawDetail && (
|
||||
<RToast.Action asChild altText={item.action.label}>
|
||||
<button type="button" className="btn" onClick={item.action.onClick}>{item.action.label}</button>
|
||||
<button type="button" className="btn" onClick={item.action.onClick}>
|
||||
{item.action.label}
|
||||
</button>
|
||||
</RToast.Action>
|
||||
)}
|
||||
<RToast.Close asChild>
|
||||
<IconButton small label={closeLabel} icon={<X size={14} />} tipSide="top" />
|
||||
<IconButton small label={closeLabel} icon={<X size={14} aria-hidden="true" />} tipSide="top" />
|
||||
</RToast.Close>
|
||||
</RToast.Root>
|
||||
</div>
|
||||
{(item.rawDetail || (item.action && item.rawDetail)) && (
|
||||
<div className="toast-footer">
|
||||
{item.rawDetail && (
|
||||
<details
|
||||
className="toast-details"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onToggle={(e) => setExpanded(e.currentTarget.open)}
|
||||
>
|
||||
<summary>{item.detailsLabel}</summary>
|
||||
<div className="toast-details-body selectable">{item.rawDetail}</div>
|
||||
{item.copyDetailsLabel && (
|
||||
<button type="button" className="toast-copy-btn" onClick={copyDiagnostic}>
|
||||
{copied ? <Check size={12} aria-hidden="true" /> : null}
|
||||
<span>{item.copyDetailsLabel}</span>
|
||||
</button>
|
||||
)}
|
||||
</details>
|
||||
)}
|
||||
{item.action && (
|
||||
<RToast.Action asChild altText={item.action.label}>
|
||||
<button type="button" className="btn toast-action-btn" onClick={item.action.onClick}>
|
||||
{item.action.label}
|
||||
</button>
|
||||
</RToast.Action>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</RToast.Root>
|
||||
)
|
||||
}
|
||||
|
||||
interface ToasterProps {
|
||||
items: ToastItem[]
|
||||
onRemove: (id: number) => void
|
||||
closeLabel: string
|
||||
dir?: 'ltr' | 'rtl'
|
||||
}
|
||||
|
||||
export const Toaster: React.FC<ToasterProps> = ({ items, onRemove, closeLabel, dir = 'ltr' }) => (
|
||||
<RToast.Provider swipeDirection={dir === 'rtl' ? 'left' : 'right'}>
|
||||
{items.map((item) => (
|
||||
<ToastCard key={item.id} item={item} onRemove={onRemove} closeLabel={closeLabel} />
|
||||
))}
|
||||
<RToast.Viewport className="toast-viewport" />
|
||||
</RToast.Provider>
|
||||
|
||||
@@ -1,148 +1,169 @@
|
||||
// Backend calls are the Wails-generated bindings (wailsjs/go/app/App). Only
|
||||
// the calls whose results carry the unions or nil slices added in types.ts are
|
||||
// re-typed here; everything else passes through unchanged.
|
||||
//
|
||||
// At module boot we privately capture `window.go.app.App` and `window.runtime`
|
||||
// so `hideWailsGlobals()` can remove them from `window` before running any
|
||||
// Tier-3 interactive theme script without breaking the app's own calls (§5.1, B6).
|
||||
import * as Go from '../wailsjs/go/app/App'
|
||||
import {
|
||||
AppState,
|
||||
AppUpdateInfo,
|
||||
CachedInstaller,
|
||||
DataRootCheck,
|
||||
DataRootChoice,
|
||||
RemoteRuntime,
|
||||
Release,
|
||||
Task,
|
||||
CreateOpts,
|
||||
InstalledRuntime,
|
||||
LogEntry,
|
||||
SetOpts,
|
||||
ValidationIssue,
|
||||
VMDetail,
|
||||
EventsEmit as RawEventsEmit,
|
||||
EventsOn as RawEventsOn,
|
||||
OnFileDrop as RawOnFileDrop,
|
||||
OnFileDropOff as RawOnFileDropOff,
|
||||
WindowMinimise as RawWindowMinimise,
|
||||
WindowToggleMaximise as RawWindowToggleMaximise,
|
||||
} from '../wailsjs/runtime/runtime'
|
||||
import type {
|
||||
ActiveThemePayload, AppState, CachedInstaller, DataRootChoice, DriverSummary,
|
||||
LogEntry, MarketBrowseResult, PluginInfo, PluginUIContributions, RemoteRuntime,
|
||||
RuntimeKindSpec, ScanReport, Task, VMAffinityStatus, VMAffinityUpdate,
|
||||
} from './types'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
go?: {
|
||||
main?: {
|
||||
App?: {
|
||||
GetState(): Promise<AppState>
|
||||
GetVMDetail(name: string): Promise<VMDetail>
|
||||
SetLocale(locale: string): Promise<void>
|
||||
SetAutoPinPCores(enabled: boolean): Promise<void>
|
||||
SetDataRoot(dir: string): Promise<void>
|
||||
PickDirectory(title: string): Promise<string>
|
||||
PickFile(title: string, pattern: string): Promise<string>
|
||||
EnableWHPX(): Promise<void>
|
||||
InstallRuntimeArchive(path: string): Promise<InstalledRuntime>
|
||||
UseRuntime(commit: string): Promise<void>
|
||||
ValidateCreate(opts: CreateOpts): Promise<ValidationIssue[]>
|
||||
PreviewCreate(opts: CreateOpts): Promise<string>
|
||||
CreateVM(opts: CreateOpts): Promise<void>
|
||||
ValidateSet(opts: SetOpts): Promise<ValidationIssue[]>
|
||||
ApplyVMSettings(opts: SetOpts): Promise<void>
|
||||
StartVM(name: string): Promise<void>
|
||||
StopVM(name: string, force: boolean): Promise<void>
|
||||
RestartVM(name: string): Promise<void>
|
||||
EjectInstaller(name: string): Promise<void>
|
||||
DeleteVM(name: string, keepFiles: boolean): Promise<void>
|
||||
ReadVMLogs(name: string, serial: boolean): Promise<string>
|
||||
OpenVMFolder(name: string): Promise<void>
|
||||
FinishInstall(name: string): Promise<void>
|
||||
EnterRecovery(name: string): Promise<void>
|
||||
AttachInstaller(name: string, installerPath: string): Promise<string>
|
||||
DownloadAndAttachOnlineRecovery(name: string, version: string): Promise<string>
|
||||
AttachGuestTools(name: string): Promise<void>
|
||||
DetachGuestTools(name: string): Promise<void>
|
||||
OpenSharedFolder(name: string): Promise<void>
|
||||
UpgradeDiskToNVMe(name: string): Promise<void>
|
||||
ExportDiagnostics(name: string): Promise<string>
|
||||
CloneVMCoW(sourceName: string, cloneName: string): Promise<void>
|
||||
TypeText(name: string, text: string): Promise<number>
|
||||
TypeClipboard(name: string): Promise<number>
|
||||
GetTasks(): Promise<Task[]>
|
||||
CancelTask(id: string): Promise<void>
|
||||
DismissTask(id: string): Promise<void>
|
||||
ListOfflineReleases(): Promise<Release[]>
|
||||
DownloadInstaller(version: string): Promise<string>
|
||||
ListInstallers(): Promise<CachedInstaller[] | null>
|
||||
DeleteInstaller(name: string): Promise<void>
|
||||
SuggestDataRoots(): Promise<DataRootChoice[] | null>
|
||||
CheckDataRoot(dir: string): Promise<DataRootCheck>
|
||||
CompleteSetup(dir: string): Promise<void>
|
||||
ListRemoteRuntimes(): Promise<RemoteRuntime[] | null>
|
||||
SetRuntimeChannel(channel: string): Promise<void>
|
||||
InstallRuntimeOnline(commit: string): Promise<string>
|
||||
CheckAppUpdate(force: boolean): Promise<AppUpdateInfo>
|
||||
OpenURL(url: string): Promise<void>
|
||||
}
|
||||
}
|
||||
}
|
||||
runtime?: {
|
||||
EventsOn(event: string, cb: (...args: any[]) => void): () => void
|
||||
WindowMinimise(): void
|
||||
WindowToggleMaximise(): void
|
||||
Quit(): void
|
||||
}
|
||||
type AnyFn = (...args: never[]) => unknown
|
||||
|
||||
interface WailsWindow {
|
||||
go?: { app?: { App?: Record<string, AnyFn> } }
|
||||
runtime?: Record<string, AnyFn>
|
||||
}
|
||||
|
||||
const wailsWin = window as unknown as WailsWindow
|
||||
const capturedGoApp: Record<string, AnyFn> = wailsWin.go?.app?.App ? { ...wailsWin.go.app.App } : {}
|
||||
const capturedRuntime: Record<string, AnyFn> = wailsWin.runtime ? { ...wailsWin.runtime } : {}
|
||||
let globalsHidden = false
|
||||
|
||||
const boundGo = {} as typeof Go
|
||||
for (const key of Object.keys(Go) as Array<keyof typeof Go>) {
|
||||
const fn = capturedGoApp[key as string]
|
||||
;(boundGo as Record<string, unknown>)[key as string] = fn
|
||||
? (...args: never[]) => fn(...args)
|
||||
: Go[key]
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides Wails binding globals (`window.go` and unsafe `window.runtime` methods)
|
||||
* before mounting an interactive theme script (§5.1, B6). Only `ResolveFilePaths`
|
||||
* (required internally by Wails's native drag-and-drop bridge) is retained on a
|
||||
* frozen runtime stub.
|
||||
*/
|
||||
export function hideWailsGlobals(): void {
|
||||
if (globalsHidden) return
|
||||
globalsHidden = true
|
||||
try {
|
||||
delete wailsWin.go
|
||||
Object.defineProperty(window, 'go', {
|
||||
value: undefined,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
})
|
||||
} catch {
|
||||
// non-configurable in some test environments
|
||||
}
|
||||
try {
|
||||
const minimalRuntime = typeof capturedRuntime.ResolveFilePaths === 'function'
|
||||
? Object.freeze({ ResolveFilePaths: capturedRuntime.ResolveFilePaths })
|
||||
: undefined
|
||||
delete wailsWin.runtime
|
||||
Object.defineProperty(window, 'runtime', {
|
||||
value: minimalRuntime,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
})
|
||||
} catch {
|
||||
// ignore if non-configurable
|
||||
}
|
||||
}
|
||||
|
||||
function app() {
|
||||
const api = window.go?.main?.App
|
||||
if (!api) {
|
||||
throw new Error('Wails backend not attached')
|
||||
export function OnFileDrop(
|
||||
callback: (x: number, y: number, paths: string[]) => void,
|
||||
useDropTarget: boolean,
|
||||
): void {
|
||||
if (typeof capturedRuntime.OnFileDrop === 'function') {
|
||||
;(capturedRuntime.OnFileDrop as (cb: typeof callback, useTarget: boolean) => void)(callback, useDropTarget)
|
||||
return
|
||||
}
|
||||
return api
|
||||
RawOnFileDrop(callback, useDropTarget)
|
||||
}
|
||||
|
||||
export const backend = {
|
||||
getState: () => app().GetState(),
|
||||
getVMDetail: (name: string) => app().GetVMDetail(name),
|
||||
setLocale: (locale: string) => app().SetLocale(locale),
|
||||
setAutoPinPCores: (enabled: boolean) => app().SetAutoPinPCores(enabled),
|
||||
setDataRoot: (dir: string) => app().SetDataRoot(dir),
|
||||
pickDirectory: (title: string) => app().PickDirectory(title),
|
||||
pickFile: (title: string, pattern: string) => app().PickFile(title, pattern),
|
||||
enableWHPX: () => app().EnableWHPX(),
|
||||
installRuntimeArchive: (path: string) => app().InstallRuntimeArchive(path),
|
||||
useRuntime: (commit: string) => app().UseRuntime(commit),
|
||||
validateCreate: (opts: CreateOpts) => app().ValidateCreate(opts),
|
||||
previewCreate: (opts: CreateOpts) => app().PreviewCreate(opts),
|
||||
createVM: (opts: CreateOpts) => app().CreateVM(opts),
|
||||
validateSet: (opts: SetOpts) => app().ValidateSet(opts),
|
||||
applyVMSettings: (opts: SetOpts) => app().ApplyVMSettings(opts),
|
||||
startVM: (name: string) => app().StartVM(name),
|
||||
stopVM: (name: string, force: boolean) => app().StopVM(name, force),
|
||||
restartVM: (name: string) => app().RestartVM(name),
|
||||
ejectInstaller: (name: string) => app().EjectInstaller(name),
|
||||
deleteVM: (name: string, keepFiles: boolean) => app().DeleteVM(name, keepFiles),
|
||||
readVMLogs: (name: string, serial: boolean) => app().ReadVMLogs(name, serial),
|
||||
openVMFolder: (name: string) => app().OpenVMFolder(name),
|
||||
finishInstall: (name: string) => app().FinishInstall(name),
|
||||
enterRecovery: (name: string) => app().EnterRecovery(name),
|
||||
attachInstaller: (name: string, installerPath = '') => app().AttachInstaller(name, installerPath),
|
||||
downloadAndAttachOnlineRecovery: (name: string, version = 'latest') => app().DownloadAndAttachOnlineRecovery(name, version),
|
||||
attachGuestTools: (name: string) => app().AttachGuestTools(name),
|
||||
detachGuestTools: (name: string) => app().DetachGuestTools(name),
|
||||
openSharedFolder: (name: string) => app().OpenSharedFolder(name),
|
||||
upgradeDiskToNVMe: (name: string) => app().UpgradeDiskToNVMe(name),
|
||||
exportDiagnostics: (name: string) => app().ExportDiagnostics(name),
|
||||
cloneVMCoW: (sourceName: string, cloneName: string) => app().CloneVMCoW(sourceName, cloneName),
|
||||
typeText: (name: string, text: string) => app().TypeText(name, text),
|
||||
typeClipboard: (name: string) => app().TypeClipboard(name),
|
||||
getTasks: () => app().GetTasks(),
|
||||
cancelTask: (id: string) => app().CancelTask(id),
|
||||
dismissTask: (id: string) => app().DismissTask(id),
|
||||
listOfflineReleases: () => app().ListOfflineReleases(),
|
||||
downloadInstaller: (version: string) => app().DownloadInstaller(version),
|
||||
listInstallers: () => app().ListInstallers(),
|
||||
deleteInstaller: (name: string) => app().DeleteInstaller(name),
|
||||
suggestDataRoots: () => app().SuggestDataRoots(),
|
||||
checkDataRoot: (dir: string) => app().CheckDataRoot(dir),
|
||||
completeSetup: (dir: string) => app().CompleteSetup(dir),
|
||||
listRemoteRuntimes: () => app().ListRemoteRuntimes(),
|
||||
setRuntimeChannel: (channel: string) => app().SetRuntimeChannel(channel),
|
||||
installRuntimeOnline: (commit: string) => app().InstallRuntimeOnline(commit),
|
||||
checkAppUpdate: (force = false) => app().CheckAppUpdate(force),
|
||||
openURL: (url: string) => app().OpenURL(url),
|
||||
onTask: (cb: (task: Task) => void) => window.runtime?.EventsOn('reims:task', cb) ?? (() => {}),
|
||||
onStateChanged: (cb: () => void) => window.runtime?.EventsOn('reims:state-changed', cb) ?? (() => {}),
|
||||
onLog: (cb: (entry: LogEntry) => void) => window.runtime?.EventsOn('reims:log', cb) ?? (() => {}),
|
||||
winMinimise: () => window.runtime?.WindowMinimise(),
|
||||
winToggleMaximise: () => window.runtime?.WindowToggleMaximise(),
|
||||
winQuit: () => window.runtime?.Quit(),
|
||||
export function OnFileDropOff(): void {
|
||||
if (typeof capturedRuntime.OnFileDropOff === 'function') {
|
||||
;(capturedRuntime.OnFileDropOff as () => void)()
|
||||
return
|
||||
}
|
||||
RawOnFileDropOff()
|
||||
}
|
||||
|
||||
export function WindowMinimise(): void {
|
||||
if (typeof capturedRuntime.WindowMinimise === 'function') {
|
||||
;(capturedRuntime.WindowMinimise as () => void)()
|
||||
return
|
||||
}
|
||||
RawWindowMinimise()
|
||||
}
|
||||
|
||||
export function WindowToggleMaximise(): void {
|
||||
if (typeof capturedRuntime.WindowToggleMaximise === 'function') {
|
||||
;(capturedRuntime.WindowToggleMaximise as () => void)()
|
||||
return
|
||||
}
|
||||
RawWindowToggleMaximise()
|
||||
}
|
||||
|
||||
function eventsOn<T>(eventName: string, cb: (data: T) => void): () => void {
|
||||
if (typeof capturedRuntime.EventsOnMultiple === 'function') {
|
||||
return (capturedRuntime.EventsOnMultiple as (name: string, fn: (data: T) => void, max: number) => () => void)(
|
||||
eventName,
|
||||
cb,
|
||||
-1,
|
||||
)
|
||||
}
|
||||
return RawEventsOn(eventName, cb)
|
||||
}
|
||||
|
||||
function eventsEmit(eventName: string, ...args: unknown[]): void {
|
||||
try {
|
||||
if (typeof capturedRuntime.EventsEmit === 'function') {
|
||||
;(capturedRuntime.EventsEmit as (name: string, ...data: unknown[]) => void)(eventName, ...args)
|
||||
return
|
||||
}
|
||||
;(RawEventsEmit as (name: string, ...data: unknown[]) => void)(eventName, ...args)
|
||||
} catch {
|
||||
// ignore if Wails runtime is unavailable (e.g. standalone preview)
|
||||
}
|
||||
}
|
||||
|
||||
export const api = {
|
||||
...boundGo,
|
||||
GetState: boundGo.GetState as () => Promise<AppState>,
|
||||
GetTasks: boundGo.GetTasks as () => Promise<Task[]>,
|
||||
GetVMAffinity: boundGo.GetVMAffinity as (name: string) => Promise<VMAffinityStatus>,
|
||||
SetVMAffinity: boundGo.SetVMAffinity as (name: string, req: VMAffinityUpdate) => Promise<VMAffinityStatus>,
|
||||
ListInstallers: boundGo.ListInstallers as () => Promise<CachedInstaller[] | null>,
|
||||
ListRemoteRuntimes: boundGo.ListRemoteRuntimes as () => Promise<RemoteRuntime[] | null>,
|
||||
SuggestDataRoots: boundGo.SuggestDataRoots as () => Promise<DataRootChoice[] | null>,
|
||||
ListPlugins: boundGo.ListPlugins as () => Promise<PluginInfo[] | null>,
|
||||
InspectPluginArchive: boundGo.InspectPluginArchive as (path: string) => Promise<ScanReport>,
|
||||
ScanInstalledPlugin: boundGo.ScanInstalledPlugin as (id: string) => Promise<ScanReport>,
|
||||
BrowsePluginMarket: boundGo.BrowsePluginMarket as (query: string, kind: string, includeAlpha: boolean, forceRefresh: boolean) => Promise<MarketBrowseResult>,
|
||||
InstallMarketPlugin: boundGo.InstallMarketPlugin as (id: string, includeAlpha: boolean) => Promise<PluginInfo>,
|
||||
GetPluginUIContributions: boundGo.GetPluginUIContributions as () => Promise<PluginUIContributions>,
|
||||
GetActiveTheme: boundGo.GetActiveTheme as () => Promise<ActiveThemePayload>,
|
||||
ListDrivers: boundGo.ListDrivers as () => Promise<DriverSummary[] | null>,
|
||||
ListRuntimeKinds: boundGo.ListRuntimeKinds as () => Promise<RuntimeKindSpec[] | null>,
|
||||
}
|
||||
|
||||
export const events = {
|
||||
onTask: (cb: (task: Task) => void) => eventsOn('reims:task', cb),
|
||||
onStateChanged: (cb: () => void) => eventsOn('reims:state-changed', cb),
|
||||
onLog: (cb: (entry: LogEntry) => void) => eventsOn('reims:log', cb),
|
||||
// Tray menu (internal/app/app.go trayVMAction): "Show in Reims-Go" and "New VM…".
|
||||
onTraySelectVM: (cb: (name: string) => void) => eventsOn('reims:tray-select-vm', cb),
|
||||
onTrayNewVM: (cb: () => void) => eventsOn('reims:tray-new-vm', cb),
|
||||
// Renderer health watchdog & crash reporting (internal/app/ui_health.go).
|
||||
onUIPing: (cb: () => void) => eventsOn('reims:ui-ping', cb),
|
||||
emitUIPong: () => eventsEmit('reims:ui-pong'),
|
||||
emitUIError: (detail: string) => eventsEmit('reims:ui-error', detail),
|
||||
emitTheme: (theme: 'light' | 'dark') => eventsEmit('reims:theme', theme),
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"uiApi": "1.0.0",
|
||||
"tokens": [
|
||||
"--font-sans",
|
||||
"--font-cjk",
|
||||
"--font-mono",
|
||||
"--body-lh",
|
||||
"--heading-tracking",
|
||||
"--fs-11",
|
||||
"--fs-12",
|
||||
"--fs-13",
|
||||
"--fs-14",
|
||||
"--fs-15",
|
||||
"--fs-16",
|
||||
"--fs-20",
|
||||
"--fs-24",
|
||||
"--fw-regular",
|
||||
"--fw-medium",
|
||||
"--fw-strong",
|
||||
"--sp-1",
|
||||
"--sp-2",
|
||||
"--sp-3",
|
||||
"--sp-4",
|
||||
"--sp-5",
|
||||
"--sp-6",
|
||||
"--sp-8",
|
||||
"--r-sm",
|
||||
"--r-md",
|
||||
"--r-lg",
|
||||
"--r-xl",
|
||||
"--surface-0",
|
||||
"--surface-canvas",
|
||||
"--surface-sidebar-rail",
|
||||
"--surface-sidebar",
|
||||
"--surface-sidebar-border",
|
||||
"--surface-sidebar-shadow",
|
||||
"--surface-chrome",
|
||||
"--surface-statusbar",
|
||||
"--surface-1",
|
||||
"--surface-card-elevated",
|
||||
"--surface-2",
|
||||
"--surface-input",
|
||||
"--surface-hover",
|
||||
"--surface-active",
|
||||
"--border",
|
||||
"--border-strong",
|
||||
"--highlight-top",
|
||||
"--scrim",
|
||||
"--shadow-btn",
|
||||
"--shadow-card",
|
||||
"--shadow-overlay",
|
||||
"--blur-chrome",
|
||||
"--blur-overlay",
|
||||
"--text",
|
||||
"--text-2",
|
||||
"--text-3",
|
||||
"--text-code",
|
||||
"--accent",
|
||||
"--accent-hover",
|
||||
"--accent-text",
|
||||
"--accent-soft",
|
||||
"--accent-soft-text",
|
||||
"--focus-ring",
|
||||
"--status-running",
|
||||
"--status-busy",
|
||||
"--status-error",
|
||||
"--status-idle",
|
||||
"--ok-soft",
|
||||
"--ok-text",
|
||||
"--warn-soft",
|
||||
"--warn-text",
|
||||
"--danger",
|
||||
"--danger-soft",
|
||||
"--danger-border",
|
||||
"--danger-text",
|
||||
"--notice-soft",
|
||||
"--notice-border",
|
||||
"--seg-thumb",
|
||||
"--ease-out",
|
||||
"--ease-in-out",
|
||||
"--ease-spring",
|
||||
"--dur-press",
|
||||
"--dur-fast",
|
||||
"--dur",
|
||||
"--dur-modal",
|
||||
"--dur-toast",
|
||||
"--titlebar-h",
|
||||
"--logbar-h",
|
||||
"--sidebar-w",
|
||||
"--page-max"
|
||||
],
|
||||
"parts": [
|
||||
"rg-p-shell",
|
||||
"rg-p-titlebar",
|
||||
"rg-p-brand",
|
||||
"rg-p-workspace",
|
||||
"rg-p-sidebar",
|
||||
"rg-p-sidebar-head",
|
||||
"rg-p-nav",
|
||||
"rg-p-main",
|
||||
"rg-p-vm-page",
|
||||
"rg-p-vm-header",
|
||||
"rg-p-vm-preview",
|
||||
"rg-p-vm-summary",
|
||||
"rg-p-statusbar",
|
||||
"rg-p-logpanel",
|
||||
"rg-p-settings",
|
||||
"rg-p-empty"
|
||||
],
|
||||
"stateAttrs": [
|
||||
"data-theme",
|
||||
"data-motion",
|
||||
"data-locale",
|
||||
"data-view",
|
||||
"data-vm-state",
|
||||
"data-busy",
|
||||
"data-has-error",
|
||||
"data-sidebar-collapsed",
|
||||
"data-safe-mode"
|
||||
],
|
||||
"slots": [
|
||||
"sidebar.footer",
|
||||
"statusbar.right",
|
||||
"vm.toolbar",
|
||||
"vm.card",
|
||||
"settings.plugin",
|
||||
"vm.preview.tl",
|
||||
"vm.preview.tr",
|
||||
"vm.preview.bl",
|
||||
"vm.preview.br",
|
||||
"empty.state"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
import {reims} from '../models';
|
||||
import {plugin} from '../models';
|
||||
import {version} from '../models';
|
||||
import {app} from '../models';
|
||||
import {driver} from '../models';
|
||||
import {runtime} from '../models';
|
||||
import {installer} from '../models';
|
||||
import {http} from '../models';
|
||||
|
||||
export function ApplyVMSettings(arg1:reims.SetOpts):Promise<void>;
|
||||
|
||||
export function AttachGuestTools(arg1:string):Promise<void>;
|
||||
|
||||
export function AttachInstaller(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function BrowsePluginMarket(arg1:string,arg2:string,arg3:boolean,arg4:boolean):Promise<plugin.MarketBrowseResult>;
|
||||
|
||||
export function CanOpenQQGroup():Promise<boolean>;
|
||||
|
||||
export function CancelTask(arg1:string):Promise<void>;
|
||||
|
||||
export function CheckAppUpdate(arg1:boolean):Promise<version.UpdateInfo>;
|
||||
|
||||
export function CheckDataRoot(arg1:string):Promise<app.DataRootCheck>;
|
||||
|
||||
export function CloneVMCoW(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CompactVMDisk(arg1:string):Promise<reims.DiskCompactResult>;
|
||||
|
||||
export function CompleteSetup(arg1:string):Promise<void>;
|
||||
|
||||
export function CopyVMScreenshot(arg1:string):Promise<void>;
|
||||
|
||||
export function CreateSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CreateVM(arg1:reims.CreateOpts):Promise<void>;
|
||||
|
||||
export function CreateVMWithDriver(arg1:driver.CreateRequest):Promise<void>;
|
||||
|
||||
export function DeleteCustomThemeScheme(arg1:string):Promise<void>;
|
||||
|
||||
export function DeleteInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function DeleteSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function DeleteVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function DeliverFileToGuest(arg1:string):Promise<string>;
|
||||
|
||||
export function DeliverPathsToGuest(arg1:string,arg2:Array<string>):Promise<Array<string>>;
|
||||
|
||||
export function DetachGuestTools(arg1:string):Promise<void>;
|
||||
|
||||
export function DisablePlugin(arg1:string):Promise<void>;
|
||||
|
||||
export function DismissTask(arg1:string):Promise<void>;
|
||||
|
||||
export function DoctorPlugin(arg1:string):Promise<Array<plugin.DoctorFinding>>;
|
||||
|
||||
export function DownloadAndAttachOnlineRecovery(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function DownloadAppUpdate():Promise<string>;
|
||||
|
||||
export function DownloadInstaller(arg1:string):Promise<string>;
|
||||
|
||||
export function EjectInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function EnablePlugin(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function EnableWHPX():Promise<void>;
|
||||
|
||||
export function EnterRecovery(arg1:string):Promise<void>;
|
||||
|
||||
export function ExportDiagnostics(arg1:string):Promise<string>;
|
||||
|
||||
export function FinishInstall(arg1:string):Promise<void>;
|
||||
|
||||
export function FocusVMWindow(arg1:string):Promise<void>;
|
||||
|
||||
export function GetActiveTheme():Promise<plugin.ActiveThemePayload>;
|
||||
|
||||
export function GetLicenseTexts():Promise<app.LicenseTexts>;
|
||||
|
||||
export function GetPluginSettings(arg1:string,arg2:string):Promise<Record<string, any>>;
|
||||
|
||||
export function GetPluginUIContributions():Promise<app.PluginUIContributions>;
|
||||
|
||||
export function GetState():Promise<app.AppState>;
|
||||
|
||||
export function GetStorageBreakdown():Promise<app.StorageBreakdown>;
|
||||
|
||||
export function GetTasks():Promise<Array<app.Task>>;
|
||||
|
||||
export function GetVMAffinity(arg1:string):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function GetVMDetail(arg1:string):Promise<reims.VMDetail>;
|
||||
|
||||
export function GetVMDriveShareSettings(arg1:string):Promise<app.DriveShareSettings>;
|
||||
|
||||
export function GetVMMacOS(arg1:string):Promise<string>;
|
||||
|
||||
export function GetVMNote(arg1:string):Promise<string>;
|
||||
|
||||
export function GetVMPluginSettings(arg1:string):Promise<Record<string, Record<string, any>>>;
|
||||
|
||||
export function GetVMSSHUser(arg1:string):Promise<string>;
|
||||
|
||||
export function GetVMStats(arg1:string):Promise<app.VMStats>;
|
||||
|
||||
export function GetVMThumbnail(arg1:string):Promise<app.VMThumbnail>;
|
||||
|
||||
export function InspectPluginArchive(arg1:string):Promise<plugin.ScanReport>;
|
||||
|
||||
export function InstallAppUpdate():Promise<void>;
|
||||
|
||||
export function InstallMarketPlugin(arg1:string,arg2:boolean):Promise<plugin.PluginInfo>;
|
||||
|
||||
export function InstallPluginArchive(arg1:string):Promise<plugin.PluginInfo>;
|
||||
|
||||
export function InstallRuntimeArchive(arg1:string):Promise<runtime.Installed>;
|
||||
|
||||
export function InstallRuntimeOnline(arg1:string):Promise<string>;
|
||||
|
||||
export function InvokePluginCommand(arg1:string,arg2:string,arg3:Record<string, any>):Promise<any>;
|
||||
|
||||
export function LinkPluginDev(arg1:string):Promise<plugin.PluginInfo>;
|
||||
|
||||
export function ListDrivers():Promise<Array<driver.DriverSummary>>;
|
||||
|
||||
export function ListInstallers():Promise<Array<installer.Cached>>;
|
||||
|
||||
export function ListOfflineReleases():Promise<Array<installer.Release>>;
|
||||
|
||||
export function ListPlugins():Promise<Array<plugin.PluginInfo>>;
|
||||
|
||||
export function ListRemoteRuntimes():Promise<Array<runtime.Remote>>;
|
||||
|
||||
export function ListRuntimeKinds():Promise<Array<runtime.KindSpec>>;
|
||||
|
||||
export function ListSnapshots(arg1:string):Promise<Array<reims.DiskSnapshot>>;
|
||||
|
||||
export function OpenProcessorScheduling():Promise<void>;
|
||||
|
||||
export function OpenQQGroup():Promise<void>;
|
||||
|
||||
export function OpenSSHTerminal(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function OpenSharedFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenURL(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenVMFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenVSCodeSSH(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function PanelBridgeCall(arg1:string,arg2:string,arg3:Record<string, any>):Promise<any>;
|
||||
|
||||
export function PickDirectory(arg1:string):Promise<string>;
|
||||
|
||||
export function PickFile(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function PluginAssetHandler():Promise<http.Handler>;
|
||||
|
||||
export function PreviewCreate(arg1:reims.CreateOpts):Promise<string>;
|
||||
|
||||
export function QuitApp():Promise<void>;
|
||||
|
||||
export function ReadPluginLog(arg1:string):Promise<string>;
|
||||
|
||||
export function ReadVMLogs(arg1:string,arg2:boolean):Promise<string>;
|
||||
|
||||
export function RemovePlugin(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function RemoveRuntime(arg1:string):Promise<void>;
|
||||
|
||||
export function RequestClose():Promise<void>;
|
||||
|
||||
export function ResizeVMDisk(arg1:string,arg2:string):Promise<reims.DiskResizeResult>;
|
||||
|
||||
export function RestartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function RestoreSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SaveCustomThemeScheme(arg1:plugin.CustomThemeScheme):Promise<void>;
|
||||
|
||||
export function ScanInstalledPlugin(arg1:string):Promise<plugin.ScanReport>;
|
||||
|
||||
export function SetActiveTheme(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetAppUpdateChannel(arg1:string):Promise<void>;
|
||||
|
||||
export function SetAutoPinPCores(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetDataRoot(arg1:string):Promise<void>;
|
||||
|
||||
export function SetGuestPreventSleep(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function SetLocale(arg1:string):Promise<void>;
|
||||
|
||||
export function SetMinimizeToTray(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetPluginSettings(arg1:string,arg2:string,arg3:Record<string, any>):Promise<void>;
|
||||
|
||||
export function SetRuntimeChannel(arg1:string):Promise<void>;
|
||||
|
||||
export function SetVMAffinity(arg1:string,arg2:app.VMAffinityUpdate):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function SetVMDriveShareSettings(arg1:string,arg2:boolean,arg3:Array<string>):Promise<app.DriveShareSettings>;
|
||||
|
||||
export function SetVMNote(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetVMSSHUser(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function ShowMainWindow():Promise<void>;
|
||||
|
||||
export function StartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function StopVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function SuggestDataRoots():Promise<Array<app.DataRootChoice>>;
|
||||
|
||||
export function ToggleBorderless(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function TypeClipboard(arg1:string):Promise<number>;
|
||||
|
||||
export function TypeText(arg1:string,arg2:string):Promise<number>;
|
||||
|
||||
export function UpgradeDiskToNVMe(arg1:string):Promise<void>;
|
||||
|
||||
export function UseRuntime(arg1:string):Promise<void>;
|
||||
|
||||
export function ValidateCreate(arg1:reims.CreateOpts):Promise<Array<reims.ValidationIssue>>;
|
||||
|
||||
export function ValidateSet(arg1:reims.SetOpts):Promise<Array<reims.ValidationIssue>>;
|
||||
|
||||
export function WriteSSHConfig(arg1:string,arg2:string):Promise<string>;
|
||||
@@ -0,0 +1,459 @@
|
||||
// @ts-check
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function ApplyVMSettings(arg1) {
|
||||
return window['go']['app']['App']['ApplyVMSettings'](arg1);
|
||||
}
|
||||
|
||||
export function AttachGuestTools(arg1) {
|
||||
return window['go']['app']['App']['AttachGuestTools'](arg1);
|
||||
}
|
||||
|
||||
export function AttachInstaller(arg1, arg2) {
|
||||
return window['go']['app']['App']['AttachInstaller'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function BrowsePluginMarket(arg1, arg2, arg3, arg4) {
|
||||
return window['go']['app']['App']['BrowsePluginMarket'](arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
export function CanOpenQQGroup() {
|
||||
return window['go']['app']['App']['CanOpenQQGroup']();
|
||||
}
|
||||
|
||||
export function CancelTask(arg1) {
|
||||
return window['go']['app']['App']['CancelTask'](arg1);
|
||||
}
|
||||
|
||||
export function CheckAppUpdate(arg1) {
|
||||
return window['go']['app']['App']['CheckAppUpdate'](arg1);
|
||||
}
|
||||
|
||||
export function CheckDataRoot(arg1) {
|
||||
return window['go']['app']['App']['CheckDataRoot'](arg1);
|
||||
}
|
||||
|
||||
export function CloneVMCoW(arg1, arg2) {
|
||||
return window['go']['app']['App']['CloneVMCoW'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CompactVMDisk(arg1) {
|
||||
return window['go']['app']['App']['CompactVMDisk'](arg1);
|
||||
}
|
||||
|
||||
export function CompleteSetup(arg1) {
|
||||
return window['go']['app']['App']['CompleteSetup'](arg1);
|
||||
}
|
||||
|
||||
export function CopyVMScreenshot(arg1) {
|
||||
return window['go']['app']['App']['CopyVMScreenshot'](arg1);
|
||||
}
|
||||
|
||||
export function CreateSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['CreateSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CreateVM(arg1) {
|
||||
return window['go']['app']['App']['CreateVM'](arg1);
|
||||
}
|
||||
|
||||
export function CreateVMWithDriver(arg1) {
|
||||
return window['go']['app']['App']['CreateVMWithDriver'](arg1);
|
||||
}
|
||||
|
||||
export function DeleteCustomThemeScheme(arg1) {
|
||||
return window['go']['app']['App']['DeleteCustomThemeScheme'](arg1);
|
||||
}
|
||||
|
||||
export function DeleteInstaller(arg1) {
|
||||
return window['go']['app']['App']['DeleteInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function DeleteSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['DeleteSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DeleteVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['DeleteVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DeliverFileToGuest(arg1) {
|
||||
return window['go']['app']['App']['DeliverFileToGuest'](arg1);
|
||||
}
|
||||
|
||||
export function DeliverPathsToGuest(arg1, arg2) {
|
||||
return window['go']['app']['App']['DeliverPathsToGuest'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DetachGuestTools(arg1) {
|
||||
return window['go']['app']['App']['DetachGuestTools'](arg1);
|
||||
}
|
||||
|
||||
export function DisablePlugin(arg1) {
|
||||
return window['go']['app']['App']['DisablePlugin'](arg1);
|
||||
}
|
||||
|
||||
export function DismissTask(arg1) {
|
||||
return window['go']['app']['App']['DismissTask'](arg1);
|
||||
}
|
||||
|
||||
export function DoctorPlugin(arg1) {
|
||||
return window['go']['app']['App']['DoctorPlugin'](arg1);
|
||||
}
|
||||
|
||||
export function DownloadAndAttachOnlineRecovery(arg1, arg2) {
|
||||
return window['go']['app']['App']['DownloadAndAttachOnlineRecovery'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DownloadAppUpdate() {
|
||||
return window['go']['app']['App']['DownloadAppUpdate']();
|
||||
}
|
||||
|
||||
export function DownloadInstaller(arg1) {
|
||||
return window['go']['app']['App']['DownloadInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function EjectInstaller(arg1) {
|
||||
return window['go']['app']['App']['EjectInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function EnablePlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['EnablePlugin'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function EnableWHPX() {
|
||||
return window['go']['app']['App']['EnableWHPX']();
|
||||
}
|
||||
|
||||
export function EnterRecovery(arg1) {
|
||||
return window['go']['app']['App']['EnterRecovery'](arg1);
|
||||
}
|
||||
|
||||
export function ExportDiagnostics(arg1) {
|
||||
return window['go']['app']['App']['ExportDiagnostics'](arg1);
|
||||
}
|
||||
|
||||
export function FinishInstall(arg1) {
|
||||
return window['go']['app']['App']['FinishInstall'](arg1);
|
||||
}
|
||||
|
||||
export function FocusVMWindow(arg1) {
|
||||
return window['go']['app']['App']['FocusVMWindow'](arg1);
|
||||
}
|
||||
|
||||
export function GetActiveTheme() {
|
||||
return window['go']['app']['App']['GetActiveTheme']();
|
||||
}
|
||||
|
||||
export function GetLicenseTexts() {
|
||||
return window['go']['app']['App']['GetLicenseTexts']();
|
||||
}
|
||||
|
||||
export function GetPluginSettings(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetPluginSettings'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetPluginUIContributions() {
|
||||
return window['go']['app']['App']['GetPluginUIContributions']();
|
||||
}
|
||||
|
||||
export function GetState() {
|
||||
return window['go']['app']['App']['GetState']();
|
||||
}
|
||||
|
||||
export function GetStorageBreakdown() {
|
||||
return window['go']['app']['App']['GetStorageBreakdown']();
|
||||
}
|
||||
|
||||
export function GetTasks() {
|
||||
return window['go']['app']['App']['GetTasks']();
|
||||
}
|
||||
|
||||
export function GetVMAffinity(arg1) {
|
||||
return window['go']['app']['App']['GetVMAffinity'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMDetail(arg1) {
|
||||
return window['go']['app']['App']['GetVMDetail'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMDriveShareSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMDriveShareSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMMacOS(arg1) {
|
||||
return window['go']['app']['App']['GetVMMacOS'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMNote(arg1) {
|
||||
return window['go']['app']['App']['GetVMNote'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMPluginSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMPluginSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMSSHUser(arg1) {
|
||||
return window['go']['app']['App']['GetVMSSHUser'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMStats(arg1) {
|
||||
return window['go']['app']['App']['GetVMStats'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMThumbnail(arg1) {
|
||||
return window['go']['app']['App']['GetVMThumbnail'](arg1);
|
||||
}
|
||||
|
||||
export function InspectPluginArchive(arg1) {
|
||||
return window['go']['app']['App']['InspectPluginArchive'](arg1);
|
||||
}
|
||||
|
||||
export function InstallAppUpdate() {
|
||||
return window['go']['app']['App']['InstallAppUpdate']();
|
||||
}
|
||||
|
||||
export function InstallMarketPlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['InstallMarketPlugin'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function InstallPluginArchive(arg1) {
|
||||
return window['go']['app']['App']['InstallPluginArchive'](arg1);
|
||||
}
|
||||
|
||||
export function InstallRuntimeArchive(arg1) {
|
||||
return window['go']['app']['App']['InstallRuntimeArchive'](arg1);
|
||||
}
|
||||
|
||||
export function InstallRuntimeOnline(arg1) {
|
||||
return window['go']['app']['App']['InstallRuntimeOnline'](arg1);
|
||||
}
|
||||
|
||||
export function InvokePluginCommand(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['InvokePluginCommand'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function LinkPluginDev(arg1) {
|
||||
return window['go']['app']['App']['LinkPluginDev'](arg1);
|
||||
}
|
||||
|
||||
export function ListDrivers() {
|
||||
return window['go']['app']['App']['ListDrivers']();
|
||||
}
|
||||
|
||||
export function ListInstallers() {
|
||||
return window['go']['app']['App']['ListInstallers']();
|
||||
}
|
||||
|
||||
export function ListOfflineReleases() {
|
||||
return window['go']['app']['App']['ListOfflineReleases']();
|
||||
}
|
||||
|
||||
export function ListPlugins() {
|
||||
return window['go']['app']['App']['ListPlugins']();
|
||||
}
|
||||
|
||||
export function ListRemoteRuntimes() {
|
||||
return window['go']['app']['App']['ListRemoteRuntimes']();
|
||||
}
|
||||
|
||||
export function ListRuntimeKinds() {
|
||||
return window['go']['app']['App']['ListRuntimeKinds']();
|
||||
}
|
||||
|
||||
export function ListSnapshots(arg1) {
|
||||
return window['go']['app']['App']['ListSnapshots'](arg1);
|
||||
}
|
||||
|
||||
export function OpenProcessorScheduling() {
|
||||
return window['go']['app']['App']['OpenProcessorScheduling']();
|
||||
}
|
||||
|
||||
export function OpenQQGroup() {
|
||||
return window['go']['app']['App']['OpenQQGroup']();
|
||||
}
|
||||
|
||||
export function OpenSSHTerminal(arg1, arg2) {
|
||||
return window['go']['app']['App']['OpenSSHTerminal'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenSharedFolder(arg1) {
|
||||
return window['go']['app']['App']['OpenSharedFolder'](arg1);
|
||||
}
|
||||
|
||||
export function OpenURL(arg1) {
|
||||
return window['go']['app']['App']['OpenURL'](arg1);
|
||||
}
|
||||
|
||||
export function OpenVMFolder(arg1) {
|
||||
return window['go']['app']['App']['OpenVMFolder'](arg1);
|
||||
}
|
||||
|
||||
export function OpenVSCodeSSH(arg1, arg2) {
|
||||
return window['go']['app']['App']['OpenVSCodeSSH'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function PanelBridgeCall(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['PanelBridgeCall'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function PickDirectory(arg1) {
|
||||
return window['go']['app']['App']['PickDirectory'](arg1);
|
||||
}
|
||||
|
||||
export function PickFile(arg1, arg2) {
|
||||
return window['go']['app']['App']['PickFile'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function PluginAssetHandler() {
|
||||
return window['go']['app']['App']['PluginAssetHandler']();
|
||||
}
|
||||
|
||||
export function PreviewCreate(arg1) {
|
||||
return window['go']['app']['App']['PreviewCreate'](arg1);
|
||||
}
|
||||
|
||||
export function QuitApp() {
|
||||
return window['go']['app']['App']['QuitApp']();
|
||||
}
|
||||
|
||||
export function ReadPluginLog(arg1) {
|
||||
return window['go']['app']['App']['ReadPluginLog'](arg1);
|
||||
}
|
||||
|
||||
export function ReadVMLogs(arg1, arg2) {
|
||||
return window['go']['app']['App']['ReadVMLogs'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RemovePlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['RemovePlugin'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RemoveRuntime(arg1) {
|
||||
return window['go']['app']['App']['RemoveRuntime'](arg1);
|
||||
}
|
||||
|
||||
export function RequestClose() {
|
||||
return window['go']['app']['App']['RequestClose']();
|
||||
}
|
||||
|
||||
export function ResizeVMDisk(arg1, arg2) {
|
||||
return window['go']['app']['App']['ResizeVMDisk'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RestartVM(arg1) {
|
||||
return window['go']['app']['App']['RestartVM'](arg1);
|
||||
}
|
||||
|
||||
export function RestoreSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['RestoreSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SaveCustomThemeScheme(arg1) {
|
||||
return window['go']['app']['App']['SaveCustomThemeScheme'](arg1);
|
||||
}
|
||||
|
||||
export function ScanInstalledPlugin(arg1) {
|
||||
return window['go']['app']['App']['ScanInstalledPlugin'](arg1);
|
||||
}
|
||||
|
||||
export function SetActiveTheme(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetActiveTheme'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetAppUpdateChannel(arg1) {
|
||||
return window['go']['app']['App']['SetAppUpdateChannel'](arg1);
|
||||
}
|
||||
|
||||
export function SetAutoPinPCores(arg1) {
|
||||
return window['go']['app']['App']['SetAutoPinPCores'](arg1);
|
||||
}
|
||||
|
||||
export function SetDataRoot(arg1) {
|
||||
return window['go']['app']['App']['SetDataRoot'](arg1);
|
||||
}
|
||||
|
||||
export function SetGuestPreventSleep(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetGuestPreventSleep'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetLocale(arg1) {
|
||||
return window['go']['app']['App']['SetLocale'](arg1);
|
||||
}
|
||||
|
||||
export function SetMinimizeToTray(arg1) {
|
||||
return window['go']['app']['App']['SetMinimizeToTray'](arg1);
|
||||
}
|
||||
|
||||
export function SetPluginSettings(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetPluginSettings'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetRuntimeChannel(arg1) {
|
||||
return window['go']['app']['App']['SetRuntimeChannel'](arg1);
|
||||
}
|
||||
|
||||
export function SetVMAffinity(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMAffinity'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetVMDriveShareSettings(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMDriveShareSettings'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMNote(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMNote'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetVMSSHUser(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMSSHUser'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ShowMainWindow() {
|
||||
return window['go']['app']['App']['ShowMainWindow']();
|
||||
}
|
||||
|
||||
export function StartVM(arg1) {
|
||||
return window['go']['app']['App']['StartVM'](arg1);
|
||||
}
|
||||
|
||||
export function StopVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['StopVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SuggestDataRoots() {
|
||||
return window['go']['app']['App']['SuggestDataRoots']();
|
||||
}
|
||||
|
||||
export function ToggleBorderless(arg1, arg2) {
|
||||
return window['go']['app']['App']['ToggleBorderless'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function TypeClipboard(arg1) {
|
||||
return window['go']['app']['App']['TypeClipboard'](arg1);
|
||||
}
|
||||
|
||||
export function TypeText(arg1, arg2) {
|
||||
return window['go']['app']['App']['TypeText'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function UpgradeDiskToNVMe(arg1) {
|
||||
return window['go']['app']['App']['UpgradeDiskToNVMe'](arg1);
|
||||
}
|
||||
|
||||
export function UseRuntime(arg1) {
|
||||
return window['go']['app']['App']['UseRuntime'](arg1);
|
||||
}
|
||||
|
||||
export function ValidateCreate(arg1) {
|
||||
return window['go']['app']['App']['ValidateCreate'](arg1);
|
||||
}
|
||||
|
||||
export function ValidateSet(arg1) {
|
||||
return window['go']['app']['App']['ValidateSet'](arg1);
|
||||
}
|
||||
|
||||
export function WriteSSHConfig(arg1, arg2) {
|
||||
return window['go']['app']['App']['WriteSSHConfig'](arg1, arg2);
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
import {reims} from '../models';
|
||||
import {version} from '../models';
|
||||
import {main} from '../models';
|
||||
import {runtime} from '../models';
|
||||
import {installer} from '../models';
|
||||
|
||||
export function ApplyVMSettings(arg1:reims.SetOpts):Promise<void>;
|
||||
|
||||
export function AttachGuestTools(arg1:string):Promise<void>;
|
||||
|
||||
export function AttachInstaller(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function CancelTask(arg1:string):Promise<void>;
|
||||
|
||||
export function CheckAppUpdate(arg1:boolean):Promise<version.UpdateInfo>;
|
||||
|
||||
export function CheckDataRoot(arg1:string):Promise<main.DataRootCheck>;
|
||||
|
||||
export function CloneVMCoW(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CompleteSetup(arg1:string):Promise<void>;
|
||||
|
||||
export function CreateVM(arg1:reims.CreateOpts):Promise<void>;
|
||||
|
||||
export function DeleteInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function DeleteVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function DetachGuestTools(arg1:string):Promise<void>;
|
||||
|
||||
export function DismissTask(arg1:string):Promise<void>;
|
||||
|
||||
export function DownloadAndAttachOnlineRecovery(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function DownloadInstaller(arg1:string):Promise<string>;
|
||||
|
||||
export function EjectInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function EnableWHPX():Promise<void>;
|
||||
|
||||
export function EnterRecovery(arg1:string):Promise<void>;
|
||||
|
||||
export function ExportDiagnostics(arg1:string):Promise<string>;
|
||||
|
||||
export function FinishInstall(arg1:string):Promise<void>;
|
||||
|
||||
export function GetState():Promise<main.AppState>;
|
||||
|
||||
export function GetTasks():Promise<Array<main.Task>>;
|
||||
|
||||
export function GetVMDetail(arg1:string):Promise<reims.VMDetail>;
|
||||
|
||||
export function InstallRuntimeArchive(arg1:string):Promise<runtime.Installed>;
|
||||
|
||||
export function InstallRuntimeOnline(arg1:string):Promise<string>;
|
||||
|
||||
export function ListInstallers():Promise<Array<installer.Cached>>;
|
||||
|
||||
export function ListOfflineReleases():Promise<Array<installer.Release>>;
|
||||
|
||||
export function ListRemoteRuntimes():Promise<Array<runtime.Remote>>;
|
||||
|
||||
export function OpenSharedFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenURL(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenVMFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function PickDirectory(arg1:string):Promise<string>;
|
||||
|
||||
export function PickFile(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function PreviewCreate(arg1:reims.CreateOpts):Promise<string>;
|
||||
|
||||
export function ReadVMLogs(arg1:string,arg2:boolean):Promise<string>;
|
||||
|
||||
export function RestartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function SetAutoPinPCores(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetDataRoot(arg1:string):Promise<void>;
|
||||
|
||||
export function SetLocale(arg1:string):Promise<void>;
|
||||
|
||||
export function SetRuntimeChannel(arg1:string):Promise<void>;
|
||||
|
||||
export function StartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function StopVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function SuggestDataRoots():Promise<Array<main.DataRootChoice>>;
|
||||
|
||||
export function TypeClipboard(arg1:string):Promise<number>;
|
||||
|
||||
export function TypeText(arg1:string,arg2:string):Promise<number>;
|
||||
|
||||
export function UpgradeDiskToNVMe(arg1:string):Promise<void>;
|
||||
|
||||
export function UseRuntime(arg1:string):Promise<void>;
|
||||
|
||||
export function ValidateCreate(arg1:reims.CreateOpts):Promise<Array<reims.ValidationIssue>>;
|
||||
|
||||
export function ValidateSet(arg1:reims.SetOpts):Promise<Array<reims.ValidationIssue>>;
|
||||