Merge pull request #51 from ELDment/feat/vm-management

feat(app): add VM shutdown mode selection and one-click force quit
This commit is contained in:
Nwflower committed 2026-12-01 04:23:18 -07:00
commit fbfe376403
24 files changed
+519 -48

No files matched your search

+73 -11
View File
@@ -139,10 +139,11 @@ flowchart TB
| `hooks` | Builtin · L1 · L2 · L3 | 有序列表 | 按事件模式(§4.3) |
| `commands` | Builtin · L2 · L3 | 按 id | 报错并提示 |
| `menus` / `vmCards` / `settingsPages` / `statusItems` | 声明式 | 列表,设数量上限 | 隐藏该项 |
| `panels` | L4 iframe | 限定槽位 | 错误占位 + 重试 |
| `panels` | L4 iframe,嵌在槽位内 | 限定槽位,限高 | 错误占位 + 重试 |
| `views` | L4 iframe,整页或标签页(§5.6) | 按位置设数量上限 | 错误页 + 重试;不影响其他视图 |
| `diagnostics` | Builtin · L3 | 列表 | 跳过;输出强制脱敏 |
UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`、`settings.plugin`,后续按真实需求再增加 `sidebar.footer`、`statusbar.right`、`create.source`;插件只能向已声明槽位贡献。
UI 槽位采用「声明即占有」:插件只能向宿主槽位目录(§5.1)中的槽位贡献。目录中的每个槽位、每种视图位置都必须由宿主实际渲染,前端构建检查覆盖这一点;不能出现可以声明、界面上却不显示的位置(§6.3)。
### 4.3 Hook 事件与分发模式
@@ -187,11 +188,14 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
| 契约 | 内容 |
| :--- | :--- |
| 设计令牌 | 单一来源(令牌数据同时生成 CSS 变量与前端常量),覆盖颜色、字体排印、形状、阴影、动效时长与缓动、层级;动效档位(含系统「减少动态效果」)在一处解析为文档属性,样式与脚本读同一个值 |
| 部件 | 关键区域与控件挂稳定的部件类名(如 `rg-p-sidebar`、`rg-p-vm-header`、`rg-p-statusbar`),每个部件一个独立类名,便于浏览器按类名分桶匹配;主题选择器只允许使用部件、状态属性与令牌,不得依赖内部类名或界面文字 |
| 状态属性 | 文档与区域上的只读状态:外观、当前视图、VM 显示状态、忙碌态、是否有错误、侧栏折叠 |
| 槽位锚点 | 装饰与扩展内容的挂载点(如侧栏底部、VM 预览四角、状态栏、空状态区) |
| 部件 | 区域与控件挂稳定的部件类名,每个部件一个独立类名,便于浏览器按类名分桶匹配;主题选择器只允许使用部件、状态属性与令牌,不得依赖内部类名或界面文字。区域级:`rg-p-shell`、`rg-p-titlebar`、`rg-p-sidebar`、`rg-p-nav`、`rg-p-main`、`rg-p-vm-page`、`rg-p-statusbar`、`rg-p-logpanel`、`rg-p-settings` 等;控件级:`rg-p-nav-group`、`rg-p-nav-item`、`rg-p-button`、`rg-p-icon-button`、`rg-p-card`、`rg-p-badge`、`rg-p-tabs`、`rg-p-tab`、`rg-p-menu`、`rg-p-menu-item`、`rg-p-dialog`、`rg-p-toast`、`rg-p-tooltip`、`rg-p-input`、`rg-p-switch`、`rg-p-progress`、`rg-p-vm-actions`、`rg-p-plugin-view` |
| 状态属性 | 文档级只读状态:外观、动效档位、语种与书写方向、当前视图、侧栏折叠、安全模式、布局选项;逐项状态:导航项与 VM 区域带 `data-vm-state`、`data-driver`、`data-selected`、`data-busy`,按钮带 `data-variant`、`data-busy`,对话框与提示条带 `data-tone`。主题可据此为单个 VM 条目做动效,不必解析界面文字 |
| 槽位目录 | 每个槽位声明上限与可挂内容(装饰、SDK 挂载、`panels`、`menus`、`statusItems`):`titlebar.center`、`sidebar.header`、`sidebar.footer`、`nav.item.trailing`(逐个 VM 条目)、`vm.header.trailing`、`vm.toolbar`、`vm.card`、`vm.preview.tl/tr/bl/br`、`statusbar.left`、`statusbar.right`、`empty.state`、`create.source`、`settings.plugin` |
| 图层 | 全窗口背景层 `layer.background` 与前景装饰层 `layer.overlay`:不拦截指针、不参与焦点,「减少动态效果」时停播动画;用于动态壁纸、粒子与满屏吉祥物 |
| 布局选项 | 主题清单的 `layout` 声明:侧栏位置(左/右)、侧栏形态(完整/图标窄栏/悬浮)、密度(紧凑/常规/宽松)、标题栏样式。只改摆放与尺寸,不能隐藏操作入口 |
| 图标 | 宿主公开图标名清单(如 `start`、`stop`、`settings`、`plugin`、`vm.state.running`);主题以 `icons` 映射到包内单色 SVG,宿主按令牌着色 |
契约内的部件、状态属性与令牌的重命名或删除属于 `uiApi` 主版本变更;前端构建检查契约中的每个部件仍由某个组件输出。
契约内的部件、状态属性、槽位、图层、布局选项、图标名与令牌的重命名或删除属于 `uiApi` 主版本变更;前端构建检查契约中的每个部件、槽位与图层都由某个组件输出(§6.3)。
**三档主题能力**
@@ -205,6 +209,7 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
- 生命周期:主题脚本导出装载函数,所有订阅、计时器与挂载都登记释放函数;切换或停用主题时逆序拆除,单个功能抛错不影响其余功能。
- 只读状态订阅:非敏感的 VM 摘要、任务进度、当前视图、外观;不提供原始路径与敏感字段。
- 事件流:VM 状态变化(含过渡态)、任务开始/进度/结束、提示条出现、视图切换,供主题做转场动画,不必轮询状态。
- 宿主提供的页面观察总线、帧读写管线与按部件查询:主题不自建节点观察者,也不整页查询文档。
- 槽位挂载:框架无关的 DOM 挂载,不共享宿主的 React 实例,避免随宿主依赖升级断裂。
- 受限动作:仅开放非破坏性界面动作(折叠侧栏、打开设置、前置 VM 窗口等);启停、删除、配置写入不在 SDK 中。
@@ -216,7 +221,8 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
- 样式清洗:禁止外部 `url()` 与远程 `@import`,资源只能引用包内清单中的文件;窗口拖拽区、焦点环与最小点击热区等可用性属性由宿主在更高层保留,不被主题覆盖。
- 同一时刻只启用一个主题包,切换时先停用旧主题再装载新主题;安全模式一律回到内置主题。
- 首帧前按当前主题内联令牌防闪烁;无边框窗口的标题栏由前端绘制,可随主题变化。
- 主题只改视觉与交互呈现,不改文案、信息层级与操作入口([`design-guidelines.md`](design-guidelines.md) 的主操作与破坏性操作约束由宿主守住)。
- 主题只改视觉与交互呈现,不改文案、信息层级与操作入口([`design-guidelines.md`](design-guidelines.md) 的主操作与破坏性操作约束由宿主守住)。布局选项可以挪动区域、改变侧栏形态,但 VM 列表、新建、设置与插件入口始终可达。
- 主题不提供功能页面;需要自有界面的插件走 §5.6 的视图,不经 `ui:script`。
- 需要读写用户文件或常驻服务的主题,以同包 L3 Sidecar 实现。
- 开发支持:`reims-go plugin link` 链接本地目录并热重载;`reims-go plugin doctor` 校验样式只使用契约内的部件、状态属性与令牌。
@@ -285,6 +291,44 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
| 窗口内部消息循环拦截(如 SDL 窗口内字符消息) | `patches/`,宿主侧做部分补偿 | 跨进程拦截需 DLL 注入,杀软误报风险高,不做成插件 |
| 宿主侧绕过、兜底补偿与宿客桥接 | 内置扩展(§5.4) | 运行时缺少对应补丁时平滑降级;依据运行时 `capabilities` 判断 |
### 5.6 插件自有界面
插件需要界面时按以下顺序选择形式,能用前一种就不用后一种:
| 形式 | 适用 | 渲染与信任 |
| :--- | :--- | :--- |
| **声明式界面** | 应用与按 VM 设置、VM 卡片信息、工具栏按钮与菜单、状态栏项、通知、确认框、表单对话框、任务进度 | 宿主原生渲染,自动跟随主题、语种、键盘操作与无障碍;只需低、中危权限 |
| **视图(`views`)与面板(`panels`)** | 自定义可视化、控制台、多步向导、需要自绘交互的页面 | 沙箱 iframe(不透明源),只经插件界面桥(bridge)与宿主通信,能力由权限约束 |
| **交互主题脚本** | 仅限主题的视觉与交互增强 | 主窗口受信任脚本(`ui:script`);功能插件不得使用 |
**视图位置**(`views[].location`;面板仍按槽位嵌入,限高):
| 位置 | 呈现 | 上限 |
| :--- | :--- | :--- |
| `sidebar` | 侧栏「扩展」分组中的导航项,点击后在主区域整页打开;导航项的图标、标题、角标与选中态由宿主绘制 | 每插件 2 个;超出部分折叠进「更多」 |
| `vm.tab` | VM 页内的标签页;以 `when` 限定驱动或能力位(如只对某驱动的 VM 显示控制台) | 每个 VM 页 4 个 |
| `settings` | 设置中的独立分节,用于放不进 Schema 表单的复杂设置 | 每插件 1 个 |
| `dialog` | 不常驻;由命令或 bridge 的 `ui.openView` 以模态打开,可返回结果 | 同一时刻 1 个 |
视图字段:`id`、`title`、`icon`(包内单色 SVG,宿主按令牌着色)、`location`、`entry`(包内 HTML)、`order`、`when`、`minWidth`。宿主负责外框:标题、返回、加载与错误占位、重试、尺寸、焦点进出与快捷键。视图惰性加载;同一时刻保持存活的视图有上限,切走的视图超过上限即卸载,插件停用时全部卸载。
**插件界面桥(`bridgeApi` 1.0)**:iframe 与宿主之间的请求/响应与事件消息,宿主只应答来源窗口为该 iframe 的消息,每个方法在 Go 侧按权限二次校验并限流。
| 命名空间 | 方法与事件 | 权限 |
| :--- | :--- | :--- |
| 握手 | `hello`:返回 `bridgeApi`、`features`、语种与书写方向、完整契约令牌、视图上下文(位置、所在 VM 的 `VMRef`) | 无 |
| `ui` | `notify`、`confirm`(宿主原生确认框)、`showForm`(以 Schema 弹出原生表单并返回值)、`setTitle`、`setBadge`、`openView`、`close`(`dialog` 返回结果)、`navigate`(只限宿主路由白名单)、`openExternal`(宿主确认后用系统浏览器打开) | `ui:notify` / `ui:slot` |
| `vm` | `list`、`get`(通用 VM 模型,不含敏感字段);事件 `vm.stateChanged` | `vm:read` |
| `command` | `invoke`:只能调用本插件声明的命令;VM 启停等动作由命令处理方经 `vm:control` 执行 | `ui:slot` |
| `settings` | 读写本插件的应用级与按 VM 设置 | 无(限本插件) |
| `storage` | 本插件私有键值存储,位于 `data/<id>/`,有配额 | `fs:plugin_data` |
| `file` | `pick` / `save` 弹出宿主文件对话框,只返回不透明句柄;按句柄分块读写,不暴露路径 | `fs:pick` |
| `task` | 开始、更新、结束任务;在宿主任务区显示进度并可取消 | `task:progress` |
| `net` | `fetch` 经宿主代理发出(iframe 自身 `connect-src 'none'`) | `net:<origin>` |
| `events` | 订阅主题与语种变化、视图可见性、任务事件 | 无 |
大对象分块传输,单条消息设大小上限。宿主以 `/plugin-ui-kit/<uiApi>/` 提供界面套件(令牌样式表与常用控件样式),主题或语种变化时经 bridge 推送新令牌,插件界面因此与宿主外观一致,不必自带一套设计系统。
---
## 6. 插件包与清单
@@ -310,7 +354,7 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
| `name` / `description` | 多语种本地化文本(内置 `zh-CN` / `en-US` 及任意 BCP-47 扩展键),**无需执行插件代码即可读取** |
| `l10n` | 可选的包内私有词表目录(如 `"locales"`),存放 `<locale>.json` 供插件自身 UI、iframe 面板与 Sidecar 使用;独立语言包可通过 `pluginOverrides` 在外部补充或覆盖任意第三方插件的清单字段与私有词条 |
| `publisher` / `license` / `homepage` | 来源与许可,市场审核依据 |
| `engines` | `reims-go` 版本范围与 `pluginApi` 范围,**下载前预检** |
| `engines` | `reims-go` 版本范围,以及所依赖契约面的范围:`pluginApi`、`uiApi`(主题与面板样式)、`bridgeApi`(视图与面板);**下载前与激活前预检**(§6.3) |
| `platforms` | 如 `windows-x64` |
| `entry` | Sidecar 可执行文件、脚本文件、面板 HTML 根目录;层级由内容推导,不信任自报 |
| `contributes` | 各扩展点贡献(§4.2) |
@@ -321,6 +365,24 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
| `defaultEnabled` | 安装或首次启动时的默认启用状态;仅内置扩展与随主程序附带的插件可为 `true` |
| `provenance` | **运行时包必填**:上游仓库与 commit、补丁清单与哈希、源码包文件名 |
### 6.3 契约版本与演进规则
公开契约分三个版本面,各自按 SemVer 演进,插件在 `engines` 中声明依赖范围:
| 版本面 | 范围 |
| :--- | :--- |
| `pluginApi` | 清单字段、扩展点、Hook 事件与载荷、权限名、Sidecar JSON-RPC 协议 |
| `uiApi` | 主题可依赖的界面契约:令牌、部件、状态属性、槽位目录、图层、布局选项、图标名、UI SDK |
| `bridgeApi` | 视图与面板的消息协议(§5.6) |
- **契约先于生态定全**:扩展点、槽位目录、视图位置与 bridge 方法在第三方插件依赖它们之前一次定全。目前生态只有语言包(只依赖 `pluginApi`),`uiApi` 与 `bridgeApi` 在首个第三方主题或界面插件出现前定稿为 `uiApi` 2.0 与 `bridgeApi` 1.0,定稿前可做不兼容清理。
- **公开即实现**:每个公开的扩展点、槽位、视图位置、图层与 bridge 方法在发布前都要有宿主实现和契约测试。前端构建检查每个槽位、视图位置与图层都被渲染;Go 测试检查每个扩展点都有消费者。尚未落地的项在清单 Schema 中标 `x-experimental`:`plugin doctor` 警告,不受兼容承诺约束,市场不允许稳定版插件依赖它。
- **主版本内只增不改**:新增字段一律可选,缺省时保持旧行为;新增枚举值(事件、视图位置、bridge 方法)只投递给声明了相应次版本的插件。改名、删除或改变语义只在主版本发生。
- **按特性协商,不按版本号猜**:宿主在 Sidecar 握手、bridge 握手与 UI SDK 中下发 `features` 列表(如 `view.sidebar`、`bridge.file.pick`、`layer.overlay`),插件据此降级。
- **未知字段**:宿主忽略清单中的未知字段并由 `plugin doctor` 警告,插件因此可以使用新字段同时兼容旧宿主;`engines` 下限高于宿主版本时拒绝安装与激活。
- **命名空间**:`builtin.*` 插件 id、`rg-` 前缀的类名、`data-rg-` 属性与契约令牌归宿主;插件自有 CSS 变量使用 `--x-<插件短名>-` 前缀;命令 id 由宿主自动加上插件 id 前缀。
- **弃用**:先在至少一个次版本中给出 `plugin doctor` 警告与替代项,下一个主版本再删除;契约文件(`ui-contract.json`、bridge 类型定义)随版本发布,作者可在本地校验。
---
## 7. 权限、信任与安全边界
@@ -330,7 +392,7 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
| 等级 | 权限 | 审批 |
| :--- | :--- | :--- |
| **低** | `vm:read`(通用模型,不含敏感字段)、`ui:notify`、`task:progress`、`fs:plugin_data`、`log:read` | 启用时展示说明 |
| **中** | `vm:intent`、`runtime:source`、`net:<origin>`(经宿主代理发出)、`ui:slot`、`input:filter`(声明输入过滤规则) | 首次启用逐项确认 |
| **中** | `vm:intent`、`runtime:source`、`net:<origin>`(经宿主代理发出)、`ui:slot`、`input:filter`(声明输入过滤规则)、`fs:pick`(经宿主文件对话框读写用户选中的文件) | 首次启用逐项确认 |
| **高** | `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` | 插件只能请求宿主发起人工确认流程 |
@@ -344,7 +406,7 @@ UI 槽位采用「声明即占有」:宿主预定义 `vm.toolbar`、`vm.card`
### 7.3 UI 与本地接口安全
- 插件资源经 Wails AssetServer 的独立路由提供,路径带每次运行随机生成的令牌,校验目录穿越,附 `X-Content-Type-Options: nosniff` 与 CSP;SVG 一律禁脚本。
- iframe 面板(后置):`sandbox="allow-scripts"`、`connect-src 'none'`;bridge 只应答来源窗口为自身 iframe 的消息,所有读取在 Go 侧按 `permissions` 二次校验并限流;主题令牌经 bridge 下发。
- iframe 视图与面板:`sandbox="allow-scripts"`(不加 `allow-same-origin`、`allow-popups`、`allow-top-navigation`)、`connect-src 'none'`;bridge 只应答来源窗口为自身 iframe 的消息,所有读写在 Go 侧按 `permissions` 二次校验并限流;文件只以句柄交换,网络只经宿主代理;主题令牌经 bridge 下发。
- 宿主本地 HTTP 接口(如 Guest Tools)拒绝 `Origin: null`、跨站请求与 `Sec-Fetch-Dest: iframe` 请求,防止被沙箱 iframe 或外部网页借道调用。
---
@@ -443,7 +505,7 @@ flowchart LR
| **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 的功能清单逐项确认可由三档主题能力承载或列出缺口 |
| **Phase 5** | 签名体系与市场索引、`uiApi` 2.0 与 `bridgeApi` 1.0 定稿(§5.1、§5.6、§6.3)、iframe 视图与面板、交互主题 UI SDK、按需引入 L2 脚本宿主 | 契约检查覆盖全部槽位、视图位置、图层与 bridge 方法,无「可声明但不渲染」项;第三方插件经审核上架;iframe 视图无法越权读取、联网或拿到文件路径;参照 dsh-claude-style 的功能清单逐项确认可由三档主题能力承载或列出缺口 |
---
@@ -1,4 +1,5 @@
import React from 'react'
import { PowerOff } from 'lucide-react'
import '../i18n/domains/settings.gen'
import { getLocaleOptions, I18nKey, t } from '../i18n'
import { findOptimization, optBadgeClass, optStatusLabel } from '../lib/optimizations'
@@ -27,6 +28,7 @@ export const AppSettingsPage: React.FC<Props> = ({
}) => {
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
const { host, config, optimizations } = state
const quitMode = state.quit_mode
const pcoreOpt = findOptimization(optimizations, 'pcore_pin')
const missingFontScript = state.missing_font_hint || ''
@@ -45,6 +47,14 @@ export const AppSettingsPage: React.FC<Props> = ({
if (dir) await api.SetDataRoot(dir)
})
const forceQuit = async () => {
try {
await api.ForceQuitApp()
} catch (e) {
onError(tr('quitFailed'), e)
}
}
return (
<div className="page rg-p-settings">
<header className="page-head">
@@ -97,6 +107,17 @@ export const AppSettingsPage: React.FC<Props> = ({
/>
</div>
</div>
<div className="row">
<div className="row-main">
<div className="row-title">{tr('forceQuitAppTitle')}</div>
<div className="row-sub">{tr('forceQuitAppSub')}</div>
</div>
<div className="row-right">
<Button variant="danger" onClick={forceQuit} busy={quitMode === 'force'} icon={<PowerOff size={14} aria-hidden="true" />}>
{tr(quitMode === 'force' ? 'forceQuitInProgress' : 'forceQuitAppButton')}
</Button>
</div>
</div>
</div>
</section>
+36 -1
View File
@@ -7,6 +7,7 @@ import {
Archive,
Camera,
Check,
ChevronDown,
ChevronRight,
Code2,
Copy,
@@ -127,6 +128,40 @@ type Tone = '' | ' warn' | ' high'
const meterTone = (pct: number, warn = 75, high = 90): Tone => (pct >= high ? ' high' : pct >= warn ? ' warn' : '')
const clampPct = (v: number) => Math.min(100, Math.max(0, v))
function ShutdownButton({ locale, busyAction, onAction }: Pick<Props, 'locale' | 'busyAction' | 'onAction'>) {
const [mode, setMode] = useState<'stop' | 'forceStop'>('stop')
const forced = mode === 'forceStop'
const variant = forced ? 'danger' : 'secondary'
const label = t(locale, 'shutdownMode')
const Icon = forced ? Power : Square
return (
<div className="shutdown-button" role="group" aria-label={label}>
<Button variant={variant} icon={<Icon size={13} aria-hidden="true" />} busy={busyAction === mode}
disabled={!!busyAction} onClick={() => onAction(mode)}>{t(locale, mode)}</Button>
<Menu.Root dir={localeDir(locale)}>
<Menu.Trigger asChild>
<Button variant={variant} disabled={!!busyAction} aria-label={label} title={label}>
<ChevronDown size={13} aria-hidden="true" />
</Button>
</Menu.Trigger>
<Menu.Portal>
<Menu.Content className="menu" align="end" sideOffset={4} collisionPadding={8}>
<Menu.RadioGroup value={mode} onValueChange={(v) => setMode(v === 'forceStop' ? 'forceStop' : 'stop')}>
{(['stop', 'forceStop'] as const).map((action) => (
<Menu.RadioItem key={action} value={action} className={`menu-item menu-item-check${action === 'forceStop' ? ' danger' : ''}`}>
<Menu.ItemIndicator className="menu-check"><Check size={13} /></Menu.ItemIndicator>
{t(locale, action)}
</Menu.RadioItem>
))}
</Menu.RadioGroup>
</Menu.Content>
</Menu.Portal>
</Menu.Root>
</div>
)
}
interface Spec {
key: string
/** Shown only in the wide, single-column layout. */
@@ -379,7 +414,7 @@ export const VMPage: React.FC<Props> = ({
{tr('suspend')}
</Button>
)}
<Button icon={<Square size={12} aria-hidden="true" />} busy={busyAction === 'stop'} disabled={busy} onClick={() => onAction('stop')}>{tr('stop')}</Button>
<ShutdownButton key={name} locale={locale} busyAction={busyAction} onAction={onAction} />
</>
)
} else if (state === 'broken') {
+7 -1
View File
@@ -46,7 +46,7 @@ export const coreZh: Record<string, string> = {
"footerMemTip": "系统内存:已用 {used} GB / 共 {total} GB(可用 {avail} GB)",
"footerMemValue": "{used} / {total} GB",
"footerRunningVMs": "{n, plural, other {# 台运行中}}",
"forceStop": "强制关机",
"forceStop": "硬关机",
"gpuErrMissingExt": "缺少必需 Vulkan 扩展({ext}),请更新显卡驱动或改用 VMware SVGA",
"gpuErrVulkanCpu": "软件 Vulkan 实现不满足 vGPU 加速要求,请改用 VMware SVGA",
"gpuErrVulkanTooOld": "Vulkan {ver} 低于 1.3 最低要求,请更新显卡驱动或改用 VMware SVGA",
@@ -115,6 +115,8 @@ export const coreZh: Record<string, string> = {
"panelLoadFailed": "面板加载失败",
"pauseDownload": "暂停下载",
"pluginSafeModeShort": "安全模式",
"quitFailed": "已取消退出",
"quitInProgress": "正在退出…",
"refresh": "刷新",
"resLooksLike": "看起来像 {w} × {h}",
"resizeLogPanel": "拖动调整日志高度",
@@ -129,6 +131,7 @@ export const coreZh: Record<string, string> = {
"shortcutBarFullscreen": "切换全屏",
"shortcutBarRelease": "释放键盘和鼠标",
"showSidebar": "显示侧边栏",
"shutdownMode": "关机方式",
"sidebarHost": "内核",
"sidebarInstallers": "安装包",
"sidebarItemAria": "{label},{state}",
@@ -304,6 +307,8 @@ export const coreEn: Record<string, string> = {
"panelLoadFailed": "Panel failed to load",
"pauseDownload": "Pause download",
"pluginSafeModeShort": "Safe mode",
"quitFailed": "Quit canceled",
"quitInProgress": "Quitting…",
"refresh": "Refresh",
"resLooksLike": "Looks like {w} × {h}",
"resizeLogPanel": "Drag to resize log panel",
@@ -318,6 +323,7 @@ export const coreEn: Record<string, string> = {
"shortcutBarFullscreen": "Toggle full screen",
"shortcutBarRelease": "Release keyboard and mouse",
"showSidebar": "Show sidebar",
"shutdownMode": "Shutdown mode",
"sidebarHost": "Engine",
"sidebarInstallers": "Installers",
"sidebarItemAria": "{label}, {state}",
@@ -142,6 +142,10 @@ export const settingsZh: Record<string, string> = {
"footerDisk": "磁盘可用 {gb} GB",
"footerMem": "内存 {pct}%",
"footerMemAvail": "可用 {avail} GB",
"forceQuitAppButton": "强制退出",
"forceQuitAppSub": "对所有运行中的虚拟机执行硬关机,未保存的数据可能丢失。",
"forceQuitAppTitle": "强制退出 Reims-Go",
"forceQuitInProgress": "正在强制退出…",
"fullscreenDecoupledHint": "窗口铺满屏幕;下方分辨率可独立设为原生或超采样 HiDPI(如 4K 1.5× = 5120×2880),由 GPU 自动缩放",
"fullscreenLaunch": "无边框全屏启动",
"fullscreenLaunchHint": "启动后直接进入无边框全屏",
@@ -463,6 +467,10 @@ export const settingsEn: Record<string, string> = {
"footerDisk": "Disk {gb} GB free",
"footerMem": "Memory {pct}%",
"footerMemAvail": "{avail} GB free",
"forceQuitAppButton": "Force quit",
"forceQuitAppSub": "Cuts power to running virtual machines. Unsaved data may be lost.",
"forceQuitAppTitle": "Force quit Reims-Go",
"forceQuitInProgress": "Force quitting…",
"fullscreenDecoupledHint": "Fills the monitor; pick native or supersampled HiDPI (e.g. 5120×2880 for 4K 1.5×) below, scaled on the GPU",
"fullscreenLaunch": "Launch borderless fullscreen",
"fullscreenLaunchHint": "Opens macOS in borderless full screen",
+7
View File
@@ -263,6 +263,10 @@ export type I18nKey =
| "footerMemTip"
| "footerMemValue"
| "footerRunningVMs"
| "forceQuitAppButton"
| "forceQuitAppSub"
| "forceQuitAppTitle"
| "forceQuitInProgress"
| "forceStop"
| "fullscreenDecoupledHint"
| "fullscreenLaunch"
@@ -624,6 +628,8 @@ export type I18nKey =
| "pluginTrustOfficial"
| "pluginTrustVerified"
| "pluginViewLog"
| "quitFailed"
| "quitInProgress"
| "recommendedBadge"
| "refresh"
| "resCustom"
@@ -703,6 +709,7 @@ export type I18nKey =
| "showInstallGuide"
| "showSidebar"
| "showWindow"
| "shutdownMode"
| "sidebarHost"
| "sidebarInstallers"
| "sidebarItemAria"
+5
View File
@@ -534,6 +534,11 @@ h1, h2, h3, p { margin: 0; }
box-shadow: 0 1px 3px rgba(255, 59, 48, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); background: var(--danger); }
.shutdown-button { display: inline-flex; }
.shutdown-button > .btn:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.shutdown-button > .btn:last-child {
padding-inline: 6px; border-start-start-radius: 0; border-end-start-radius: 0; border-inline-start: 0;
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
+2
View File
@@ -102,6 +102,8 @@ export function FocusVMWindow(arg1:string):Promise<void>;
export function FocusVMWindowWithDriver(arg1:string,arg2:string):Promise<void>;
export function ForceQuitApp():Promise<void>;
export function GetActiveTheme():Promise<plugin.ActiveThemePayload>;
export function GetLicenseTexts():Promise<app.LicenseTexts>;
+4
View File
@@ -186,6 +186,10 @@ export function FocusVMWindowWithDriver(arg1, arg2) {
return window['go']['app']['App']['FocusVMWindowWithDriver'](arg1, arg2);
}
export function ForceQuitApp() {
return window['go']['app']['App']['ForceQuitApp']();
}
export function GetActiveTheme() {
return window['go']['app']['App']['GetActiveTheme']();
}
+2
View File
@@ -1,6 +1,7 @@
export namespace app {
export class AppState {
quit_mode?: string;
config?: config.Config;
host: host.Report;
optimizations: host.Optimization[];
@@ -28,6 +29,7 @@ export namespace app {
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.quit_mode = source["quit_mode"];
this.config = this.convertValues(source["config"], config.Config);
this.host = this.convertValues(source["host"], host.Report);
this.optimizations = this.convertValues(source["optimizations"], host.Optimization);
+17 -25
View File
@@ -35,6 +35,7 @@ type PendingChange struct {
}
type AppState struct {
QuitMode string `json:"quit_mode,omitempty"`
Config *config.Config `json:"config"`
Host host.Report `json:"host"`
Optimizations []host.Optimization `json:"optimizations"`
@@ -90,6 +91,8 @@ type App struct {
imeBridge *host.IMEBridge
trayMgr *tray.Manager
allowQuit bool
quitMode string
vmStarts sync.WaitGroup
lastVMs []driver.VMListItem
lastVMsAt time.Time // when pollVMs last refreshed lastVMs; zero = stale
pollWake chan struct{} // wakePoll: run pollVMs now instead of at its next tick
@@ -199,10 +202,17 @@ func (a *App) startIMEBridge() {
func (a *App) beforeClose(ctx context.Context) bool {
a.mu.Lock()
allow := a.allowQuit
quitting := a.quitMode != ""
toTray := a.cfg.ShouldMinimizeToTray()
hasTray := a.trayMgr != nil
a.mu.Unlock()
if !allow && toTray && hasTray {
if allow {
return false
}
if quitting {
return true
}
if toTray && hasTray {
a.setWindowHidden(true)
wailsRuntime.WindowHide(ctx)
return true
@@ -675,7 +685,11 @@ func (a *App) GetState() AppState {
activeGuides = guideMgr.ActiveNames()
}
a.mu.Lock()
quitMode := a.quitMode
a.mu.Unlock()
return AppState{
QuitMode: quitMode,
Config: &cfgCopy,
Host: rep,
Optimizations: opts,
@@ -745,28 +759,8 @@ func (a *App) ShowMainWindow() {
// RequestClose handles the custom titlebar close button: hides to system tray
// when MinimizeToTray is enabled, or quits the application otherwise.
func (a *App) RequestClose() {
if a.ctx == nil {
return
}
a.mu.Lock()
toTray := a.cfg.ShouldMinimizeToTray()
hasTray := a.trayMgr != nil
a.mu.Unlock()
if toTray && hasTray {
a.setWindowHidden(true)
wailsRuntime.WindowHide(a.ctx)
return
}
a.QuitApp()
}
// QuitApp exits Reims-Go completely (bypassing minimize-to-tray).
func (a *App) QuitApp() {
a.mu.Lock()
a.allowQuit = true
a.mu.Unlock()
if a.ctx != nil {
wailsRuntime.Quit(a.ctx)
wailsRuntime.Quit(a.ctx) // beforeClose applies the window-close preference.
}
}
@@ -782,9 +776,7 @@ func (a *App) startTray() {
}
},
OnVMAction: a.trayVMAction,
OnQuit: func() {
a.QuitApp()
},
OnQuit: a.QuitApp,
GetSnapshot: func() tray.Snapshot {
a.mu.Lock()
cfgCopy := *a.cfg
+11 -3
View File
@@ -95,6 +95,10 @@ func (a *App) GetVMInfo(driverID, name string) (driver.VMInfo, error) {
func (a *App) StartVM(name string) error { return a.StartVMWithDriver("", name) }
func (a *App) StartVMWithDriver(driverID, name string) error {
if err := a.beginVMStart(); err != nil {
return err
}
defer a.vmStarts.Done()
if err := a.requireWritableDataRoot(); err != nil {
return err
}
@@ -157,6 +161,10 @@ func (a *App) StartVMWithDriver(driverID, name string) error {
func (a *App) StopVM(name string, force bool) error { return a.StopVMWithDriver("", name, force) }
func (a *App) StopVMWithDriver(driverID, name string, force bool) error {
return a.stopVMWithDriverCtx(context.Background(), driverID, name, force)
}
func (a *App) stopVMWithDriverCtx(ctx context.Context, driverID, name string, force bool) error {
a.mu.Lock()
svc := a.lifecycleSvc
a.mu.Unlock()
@@ -164,9 +172,9 @@ func (a *App) StopVMWithDriver(driverID, name string, force bool) error {
if driverID != "" && driver.CanonicalDriverID(driverID) != driver.BuiltinReimsMacOSDriverID {
return errors.New("driver is unavailable without the plugin manager")
}
return a.stopVMLegacy(name, force)
return a.stopVMLegacyCtx(ctx, name, force)
}
_, vm, err := svc.Resolve(context.Background(), driverID, name)
_, vm, err := svc.Resolve(ctx, driverID, name)
if err != nil {
return err
}
@@ -181,7 +189,7 @@ func (a *App) StopVMWithDriver(driverID, name string, force bool) error {
a.mu.Unlock()
a.emitLifecycleStateChanged()
w := vmstart.LineWriter(func(line string) { a.emitVMLogForDriver(ref.DriverID, ref.Name, line) })
if err := svc.Stop(context.Background(), ref, force, w, w); err != nil {
if err := svc.Stop(ctx, ref, force, w, w); err != nil {
a.mu.Lock()
delete(a.transitions, key)
a.mu.Unlock()
+6 -2
View File
@@ -347,6 +347,10 @@ func (a *App) startVMLegacy(name string) error {
}
func (a *App) stopVMLegacy(name string, force bool) error {
return a.stopVMLegacyCtx(context.Background(), name, force)
}
func (a *App) stopVMLegacyCtx(ctx context.Context, name string, force bool) error {
c, err := a.client()
if err != nil {
return err
@@ -368,9 +372,9 @@ func (a *App) stopVMLegacy(name string, force bool) error {
w := vmstart.LineWriter(func(line string) { a.emitVMLog(name, line) })
a.emitVMLog(name, fmt.Sprintf("Stopping %s (force=%v)...", name, force))
if force {
err = c.StopForce(context.Background(), name, w, w)
err = c.StopForce(ctx, name, w, w)
} else {
err = c.Stop(context.Background(), name, w, w)
err = c.Stop(ctx, name, w, w)
}
if err != nil {
a.mu.Lock()
+126
View File
@@ -0,0 +1,126 @@
package app
import (
"context"
"errors"
"os"
"path/filepath"
"time"
"github.com/Nwflower/reims-go/internal/driver"
"github.com/Nwflower/reims-go/internal/i18n"
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
)
func (a *App) beginVMStart() error {
a.mu.Lock()
defer a.mu.Unlock()
if a.quitMode != "" || a.allowQuit {
return errors.New(i18n.T(a.cfg.Locale, "quitInProgress"))
}
a.vmStarts.Add(1)
return nil
}
// QuitApp exits the desktop app and leaves its guests running.
func (a *App) QuitApp() {
_ = a.quitApp(false)
}
// ForceQuitApp powers off all running guests before exiting.
func (a *App) ForceQuitApp() error {
return a.quitApp(true)
}
func (a *App) quitApp(force bool) error {
a.mu.Lock()
if a.allowQuit || a.quitMode != "" {
a.mu.Unlock()
return nil
}
if force {
a.quitMode = "force"
a.mu.Unlock()
a.emitStateChanged()
a.vmStarts.Wait()
err := a.forceStopRunningVMs(a.baseCtx())
a.mu.Lock()
if err != nil {
a.quitMode = ""
a.mu.Unlock()
a.emitStateChanged()
return err
}
}
a.allowQuit = true
a.mu.Unlock()
if a.ctx != nil {
wailsRuntime.Quit(a.ctx)
}
return nil
}
func (a *App) forceStopRunningVMs(ctx context.Context) error {
a.mu.Lock()
cfg := *a.cfg
svc := a.lifecycleSvc
a.mu.Unlock()
loc := i18n.EffectiveLocale(cfg.Locale)
list := func(ctx context.Context) ([]driver.VMListItem, error) {
vms, err := a.listVMsInternal(ctx)
if err != nil && svc == nil {
// A fresh installation can quit before its first runtime is installed.
_, registryErr := os.Stat(filepath.Join(cfg.XDGConfigDir(), "reims-ctl", "vms.toml"))
dirs, dirErr := os.ReadDir(filepath.Join(cfg.XDGDataDir(), "reims-ctl", "vms"))
if os.IsNotExist(registryErr) && (os.IsNotExist(dirErr) || (dirErr == nil && len(dirs) == 0)) {
return nil, nil
}
}
return vms, err
}
return stopListedVMs(ctx, loc, list, func(ctx context.Context, vm driver.VMListItem) error {
return a.stopVMWithDriverCtx(ctx, vm.DriverID, vm.Name, true)
})
}
const quitVMTimeout = 10 * time.Second
func stopListedVMs(ctx context.Context, loc i18n.Locale, list func(context.Context) ([]driver.VMListItem, error), stop func(context.Context, driver.VMListItem) error) error {
stopped := make(map[string]bool)
for {
listCtx, cancel := context.WithTimeout(ctx, quitVMTimeout)
vms, err := list(listCtx)
cancel()
if err != nil {
return err
}
var next *driver.VMListItem
for i := range vms {
vm := vms[i]
if vm.State == "running" {
key := vmKeyForDriver(vm.DriverID, vm.Name)
if stopped[key] {
return errors.New(i18n.M(loc, "err.quit.stop_failed", i18n.Vars{"name": vm.Name}))
}
if next == nil {
cp := vm
next = &cp
}
}
}
if next == nil {
return nil
}
stopCtx, cancel := context.WithTimeout(ctx, quitVMTimeout)
err = stop(stopCtx, *next)
ctxErr := stopCtx.Err()
cancel()
if errors.Is(ctxErr, context.DeadlineExceeded) || errors.Is(err, context.DeadlineExceeded) {
return errors.New(i18n.M(loc, "err.quit.timeout", i18n.Vars{"name": next.Name}))
}
if err != nil {
return errors.New(i18n.M(loc, "err.quit.stop_failed", i18n.Vars{"name": next.Name}))
}
stopped[vmKeyForDriver(next.DriverID, next.Name)] = true
}
}
+154
View File
@@ -0,0 +1,154 @@
package app
import (
"context"
"errors"
"os"
"path/filepath"
"slices"
"testing"
"testing/synctest"
"time"
"github.com/Nwflower/reims-go/internal/config"
"github.com/Nwflower/reims-go/internal/driver"
"github.com/Nwflower/reims-go/internal/i18n"
)
func TestStopListedVMs(t *testing.T) {
for _, tc := range []struct {
name, wantErr string
}{
{name: "all stopped"},
{name: "failure", wantErr: "无法关闭虚拟机「two」,已取消退出。"},
{name: "still running", wantErr: "无法关闭虚拟机「two」,已取消退出。"},
{name: "timeout", wantErr: "虚拟机「two」关机超时,已取消退出。"},
} {
t.Run(tc.name, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
vms := []driver.VMListItem{
{Name: "one", State: "running"}, {Name: "off", State: "stopped"},
{Name: "two", State: "running"}, {Name: "saved", State: "suspended"}, {Name: "three", State: "running"},
}
var calls []string
err := stopListedVMs(t.Context(), i18n.ZhCN, func(context.Context) ([]driver.VMListItem, error) {
return vms, nil
}, func(ctx context.Context, vm driver.VMListItem) error {
name := vm.Name
calls = append(calls, name)
if name == "two" {
switch tc.name {
case "failure":
return errors.New("stop failed")
case "still running":
return nil
case "timeout":
started := time.Now()
<-ctx.Done()
if elapsed := time.Since(started); elapsed != 10*time.Second {
t.Errorf("shutdown timed out after %v, want 10s", elapsed)
}
return errors.New("exit status 1")
}
}
for i := range vms {
if vms[i].Name == name {
vms[i].State = "stopped"
}
}
return nil
})
want := []string{"one", "two", "three"}
if tc.wantErr != "" {
want = want[:2]
if err == nil || err.Error() != tc.wantErr {
t.Fatalf("error = %v, want %q", err, tc.wantErr)
}
} else if err != nil {
t.Fatal(err)
}
if !slices.Equal(calls, want) {
t.Fatalf("stop calls = %v, want %v", calls, want)
}
})
})
}
}
func TestQuitAppLeavesVMsRunning(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
a := &App{lastVMs: []driver.VMListItem{{Name: "one", State: "running"}}}
if err := a.beginVMStart(); err != nil {
t.Fatal(err)
}
defer a.vmStarts.Done()
done := make(chan struct{})
go func() {
a.QuitApp()
close(done)
}()
synctest.Wait()
select {
case <-done:
if !a.allowQuit || a.quitMode != "" {
t.Fatalf("tray exit: allowQuit=%v mode=%q", a.allowQuit, a.quitMode)
}
default:
t.Fatal("tray exit waited for VM operations")
}
})
}
func TestForceQuitAppWaitsForStartsAndCanRetry(t *testing.T) {
a := &App{cfg: &config.Config{DataRoot: t.TempDir(), Locale: i18n.EnUS}}
if err := a.beginVMStart(); err != nil {
t.Fatal(err)
}
quit := make(chan error, 1)
go func() { quit <- a.ForceQuitApp() }()
deadline := time.Now().Add(3 * time.Second)
for {
a.mu.Lock()
quitting := a.quitMode != ""
a.mu.Unlock()
if quitting {
break
}
if time.Now().After(deadline) {
t.Fatal("quit did not start")
}
time.Sleep(time.Millisecond)
}
for _, launch := range []func(string) error{a.StartVM, a.ResumeVM} {
if err := launch("new"); err == nil || err.Error() != i18n.T(i18n.EnUS, "quitInProgress") {
t.Fatalf("launch during shutdown: %v", err)
}
}
a.QuitApp()
if !a.beforeClose(context.Background()) {
t.Fatal("another close bypassed the pending shutdown")
}
if err := a.ForceQuitApp(); err != nil {
t.Fatal(err)
}
if a.quitMode != "force" || a.allowQuit {
t.Fatalf("duplicate quit: mode=%q allowQuit=%v", a.quitMode, a.allowQuit)
}
// The in-flight start creates a VM entry after the quit request. Without
// a runtime, shutdown must now fail instead of assuming an empty library.
dir := filepath.Join(a.cfg.XDGDataDir(), "reims-ctl", "vms", "starting")
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
a.vmStarts.Done()
if err := <-quit; err == nil || a.allowQuit || a.quitMode != "" {
t.Fatalf("failed shutdown: err=%v allowQuit=%v mode=%q", err, a.allowQuit, a.quitMode)
}
if err := os.Remove(dir); err != nil {
t.Fatal(err)
}
if err := a.ForceQuitApp(); err != nil || !a.allowQuit || a.beforeClose(context.Background()) {
t.Fatalf("retry with empty library: err=%v allowQuit=%v", err, a.allowQuit)
}
}
+4
View File
@@ -72,6 +72,10 @@ func (a *App) ResumeVM(name string) error {
}
func (a *App) ResumeVMWithDriver(driverID, name string) error {
if err := a.beginVMStart(); err != nil {
return err
}
defer a.vmStarts.Done()
if err := a.requireWritableDataRoot(); err != nil {
return err
}
+13 -1
View File
@@ -144,6 +144,8 @@ var catalog = map[Locale]map[string]string{
"err.plugin.in_use": "插件「{id}」正在被虚拟机使用,无法停用或卸载:{reason}",
"err.plugin.safe_mode": "当前处于安全模式,已暂停加载和变更第三方插件",
"err.plugin.system_locked": "系统核心组件「{id}」不可停用或卸载",
"err.quit.stop_failed": "无法关闭虚拟机「{name}」,已取消退出。",
"err.quit.timeout": "虚拟机「{name}」关机超时,已取消退出。",
"err.runtime_not_installed": "未找到已激活的便携运行时,请先执行 `reims-go runtime install <归档路径>`",
"err.snapshot.name_empty": "请输入恢复点名称",
"err.snapshot.name_invalid": "恢复点名称包含不支持的控制字符或引号",
@@ -196,7 +198,7 @@ var catalog = map[Locale]map[string]string{
"footerMemTip": "系统内存:已用 {used} GB / 共 {total} GB(可用 {avail} GB)",
"footerMemValue": "{used} / {total} GB",
"footerRunningVMs": "{n, plural, other {# 台运行中}}",
"forceStop": "强制关机",
"forceStop": "硬关机",
"gpuErrMissingExt": "缺少必需 Vulkan 扩展({ext}),请更新显卡驱动或改用 VMware SVGA",
"gpuErrVulkanCpu": "软件 Vulkan 实现不满足 vGPU 加速要求,请改用 VMware SVGA",
"gpuErrVulkanTooOld": "Vulkan {ver} 低于 1.3 最低要求,请更新显卡驱动或改用 VMware SVGA",
@@ -387,6 +389,8 @@ var catalog = map[Locale]map[string]string{
"plugin.removed": "已卸载 {id}(purge={purge})",
"plugin.target_not_found": "未找到插件或目录 \"{target}\"",
"pluginSafeModeShort": "安全模式",
"quitFailed": "已取消退出",
"quitInProgress": "正在退出…",
"refresh": "刷新",
"resLooksLike": "看起来像 {w} × {h}",
"resizeLogPanel": "拖动调整日志高度",
@@ -416,6 +420,7 @@ var catalog = map[Locale]map[string]string{
"shortcutBarFullscreen": "切换全屏",
"shortcutBarRelease": "释放键盘和鼠标",
"showSidebar": "显示侧边栏",
"shutdownMode": "关机方式",
"sidebarHost": "内核",
"sidebarInstallers": "安装包",
"sidebarItemAria": "{label},{state}",
@@ -696,6 +701,8 @@ var catalog = map[Locale]map[string]string{
"err.plugin.in_use": "Plugin “{id}” is currently in use and cannot be disabled or removed: {reason}",
"err.plugin.safe_mode": "Safe mode is active; third-party plugin changes are paused",
"err.plugin.system_locked": "Core system component “{id}” cannot be disabled or removed",
"err.quit.stop_failed": "Could not shut down “{name}”. Quit canceled.",
"err.quit.timeout": "Shutdown timed out for “{name}”. Quit canceled.",
"err.runtime_not_installed": "no active portable runtime found; run `reims-go runtime install <archive>` first",
"err.snapshot.name_empty": "Enter a restore point name",
"err.snapshot.name_invalid": "Restore point name contains unsupported characters or quotes",
@@ -939,6 +946,8 @@ var catalog = map[Locale]map[string]string{
"plugin.removed": "Removed {id} (purge={purge})",
"plugin.target_not_found": "plugin or directory \"{target}\" not found",
"pluginSafeModeShort": "Safe mode",
"quitFailed": "Quit canceled",
"quitInProgress": "Quitting…",
"refresh": "Refresh",
"resLooksLike": "Looks like {w} × {h}",
"resizeLogPanel": "Drag to resize log panel",
@@ -968,6 +977,7 @@ var catalog = map[Locale]map[string]string{
"shortcutBarFullscreen": "Toggle full screen",
"shortcutBarRelease": "Release keyboard and mouse",
"showSidebar": "Show sidebar",
"shutdownMode": "Shutdown mode",
"sidebarHost": "Engine",
"sidebarInstallers": "Installers",
"sidebarItemAria": "{label}, {state}",
@@ -1157,6 +1167,8 @@ var paramOrder = map[string][]string{
"err.plugin.high_risk_unapproved": {"id"},
"err.plugin.in_use": {"id", "reason"},
"err.plugin.system_locked": {"id"},
"err.quit.stop_failed": {"name"},
"err.quit.timeout": {"name"},
"err.snapshot.qemu_img_failed": {"snap"},
"err.snapshot.vm_running": {"name"},
"err.suspend.action_blocked": {"name"},
+4 -3
View File
@@ -752,12 +752,13 @@ func (c *Client) Start(ctx context.Context, name string, stdout, stderr io.Write
return c.run(ctx, stdout, stderr, "start", name)
}
func (c *Client) Stop(ctx context.Context, name string, stdout, stderr io.Writer) error {
return c.run(ctx, stdout, stderr, "stop", name)
func (c *Client) Stop(ctx context.Context, name string, stdout, stderr io.Writer, flags ...string) error {
args := append([]string{"stop"}, flags...)
return c.run(ctx, stdout, stderr, append(args, name)...)
}
func (c *Client) StopForce(ctx context.Context, name string, stdout, stderr io.Writer) error {
return c.run(ctx, stdout, stderr, "stop", "--force", name)
return c.Stop(ctx, name, stdout, stderr, "--force")
}
func (c *Client) Eject(ctx context.Context, name string, stdout, stderr io.Writer) error {
+3
View File
@@ -4,6 +4,8 @@
"sidebarHost": "Engine",
"sidebarPlugins": "Plugins",
"sidebarSettings": "Settings",
"quitInProgress": "Quitting…",
"quitFailed": "Quit canceled",
"sidebarInstallers": "Installers",
"installersRetry": "Retry",
"emptyVMs": "No virtual machines",
@@ -87,6 +89,7 @@
},
"restart": "Restart",
"forceStop": "Force shut down",
"shutdownMode": "Shutdown mode",
"eject": "Eject installer",
"settings": "Settings",
"more": {
+2
View File
@@ -1034,6 +1034,8 @@
]
},
"err.dataroot.busy_vms": "Stop all running virtual machines before switching the data folder",
"err.quit.stop_failed": "Could not shut down “{name}”. Quit canceled.",
"err.quit.timeout": "Shutdown timed out for “{name}”. Quit canceled.",
"err.dataroot.busy_tasks": "Wait for active download or creation tasks to finish before switching the data folder",
"font.script.zh_hant": "Traditional Chinese (繁體中文)",
"font.script.zh_hans": "Simplified Chinese (简体中文)",
+4
View File
@@ -282,6 +282,10 @@
"gpuUnavailableHint": "No GPU available for acceleration; try VMware SVGA",
"minimizeToTray": "Minimize to system tray on close",
"minimizeToTraySub": "Clipboard and shared folders keep working; start and stop VMs from the tray",
"forceQuitAppTitle": "Force quit Reims-Go",
"forceQuitAppSub": "Cuts power to running virtual machines. Unsaved data may be lost.",
"forceQuitAppButton": "Force quit",
"forceQuitInProgress": "Force quitting…",
"hostDisplays": "Physical displays",
"hostDisplayPrimary": "Primary",
"multiDisplayHint": {
+4 -1
View File
@@ -4,6 +4,8 @@
"sidebarHost": "内核",
"sidebarPlugins": "插件",
"sidebarSettings": "设置",
"quitInProgress": "正在退出…",
"quitFailed": "已取消退出",
"sidebarInstallers": "安装包",
"installersRetry": "重试",
"emptyVMs": "还没有虚拟机",
@@ -86,7 +88,8 @@
"$maxLength": 16
},
"restart": "重启",
"forceStop": "强制关机",
"forceStop": "硬关机",
"shutdownMode": "关机方式",
"eject": "弹出安装盘",
"settings": "设置",
"more": {
+2
View File
@@ -1034,6 +1034,8 @@
]
},
"err.dataroot.busy_vms": "仍有虚拟机正在运行,请先全部关机后再切换数据目录",
"err.quit.stop_failed": "无法关闭虚拟机「{name}」,已取消退出。",
"err.quit.timeout": "虚拟机「{name}」关机超时,已取消退出。",
"err.dataroot.busy_tasks": "仍有后台下载或创建任务进行中,请等待任务结束或取消后再切换数据目录",
"font.script.zh_hant": "繁体中文(繁體中文)",
"font.script.zh_hans": "简体中文",
+4
View File
@@ -282,6 +282,10 @@
"gpuUnavailableHint": "没有找到能加速的显卡,可改用 VMware SVGA",
"minimizeToTray": "关闭窗口时最小化到系统托盘",
"minimizeToTraySub": "关闭窗口后剪贴板和共享文件夹继续工作,可从托盘启停虚拟机",
"forceQuitAppTitle": "强制退出 Reims-Go",
"forceQuitAppSub": "对所有运行中的虚拟机执行硬关机,未保存的数据可能丢失。",
"forceQuitAppButton": "强制退出",
"forceQuitInProgress": "正在强制退出…",
"hostDisplays": "物理显示器",
"hostDisplayPrimary": "主屏",
"multiDisplayHint": {