feat(app): add VM shutdown mode selection and one-click force quit

This commit is contained in:
ELDment committed 2026-12-01 17:29:58 +08:00
1 parent 5f96f4ab08
commit 0bb1e1a8a6
21 files changed
+436 -38

No files matched your search

@@ -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,
@@ -126,6 +127,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>
<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. */
@@ -378,7 +413,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
@@ -39,7 +39,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",
@@ -108,6 +108,8 @@ export const coreZh: Record<string, string> = {
"panelLoadFailed": "面板加载失败",
"pauseDownload": "暂停下载",
"pluginSafeModeShort": "安全模式",
"quitFailed": "已取消退出",
"quitInProgress": "正在退出…",
"refresh": "刷新",
"resLooksLike": "看起来像 {w} × {h}",
"resizeLogPanel": "拖动调整日志高度",
@@ -122,6 +124,7 @@ export const coreZh: Record<string, string> = {
"shortcutBarFullscreen": "切换全屏",
"shortcutBarRelease": "释放键盘和鼠标",
"showSidebar": "显示侧边栏",
"shutdownMode": "关机方式",
"sidebarHost": "内核",
"sidebarInstallers": "安装包",
"sidebarItemAria": "{label},{state}",
@@ -290,6 +293,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",
@@ -304,6 +309,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}",
@@ -138,6 +138,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": "启动后直接进入无边框全屏",
@@ -455,6 +459,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
@@ -252,6 +252,10 @@ export type I18nKey =
| "footerMemTip"
| "footerMemValue"
| "footerRunningVMs"
| "forceQuitAppButton"
| "forceQuitAppSub"
| "forceQuitAppTitle"
| "forceQuitInProgress"
| "forceStop"
| "fullscreenDecoupledHint"
| "fullscreenLaunch"
@@ -610,6 +614,8 @@ export type I18nKey =
| "pluginTrustOfficial"
| "pluginTrustVerified"
| "pluginViewLog"
| "quitFailed"
| "quitInProgress"
| "recommendedBadge"
| "refresh"
| "resCustom"
@@ -689,6 +695,7 @@ export type I18nKey =
| "showInstallGuide"
| "showSidebar"
| "showWindow"
| "shutdownMode"
| "sidebarHost"
| "sidebarInstallers"
| "sidebarItemAria"
+5
View File
@@ -529,6 +529,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
@@ -81,6 +81,8 @@ export function FinishInstall(arg1:string):Promise<void>;
export function FocusVMWindow(arg1:string):Promise<void>;
export function ForceQuitApp():Promise<void>;
export function GetActiveTheme():Promise<plugin.ActiveThemePayload>;
export function GetLicenseTexts():Promise<app.LicenseTexts>;
+4
View File
@@ -146,6 +146,10 @@ export function FocusVMWindow(arg1) {
return window['go']['app']['App']['FocusVMWindow'](arg1);
}
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[];
@@ -26,6 +27,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);
+32 -31
View File
@@ -8,6 +8,7 @@ import (
"maps"
"os"
"path/filepath"
"slices"
"strings"
"sync"
"time"
@@ -38,6 +39,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"`
@@ -78,6 +80,8 @@ type App struct {
imeBridge *host.IMEBridge
trayMgr *tray.Manager
allowQuit bool
quitMode string
vmStarts sync.WaitGroup
lastVMs []reims.VMListItem
lastVMsAt time.Time // when pollVMs last refreshed lastVMs; zero = stale
pollWake chan struct{} // wakePoll: run pollVMs now instead of at its next tick
@@ -174,10 +178,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
@@ -653,7 +664,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,
@@ -741,28 +756,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.
}
}
@@ -778,9 +773,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
@@ -1357,6 +1350,10 @@ func stripLegacyManagedExtraArgs(extraArgs string) string {
}
func (a *App) StartVM(name string) error {
if err := a.beginVMStart(); err != nil {
return err
}
defer a.vmStarts.Done()
prep, err := a.prep(name)
if err != nil {
return err
@@ -1517,7 +1514,15 @@ func (a *App) StopVM(name string, force bool) error {
if err != nil {
return err
}
release, err := vmstart.LockVMForStop(a.baseCtx(), c, name, force)
if force {
return a.stopVM(a.baseCtx(), c, name, "--force")
}
return a.stopVM(a.baseCtx(), c, name)
}
func (a *App) stopVM(ctx context.Context, c *reims.Client, name string, flags ...string) error {
force := slices.Contains(flags, "--force")
release, err := vmstart.LockVMForStop(ctx, c, name, force)
if err != nil {
return err
}
@@ -1538,11 +1543,7 @@ func (a *App) StopVM(name string, force bool) error {
w := vmstart.LineWriter(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)
}
err = c.Stop(ctx, name, w, w, flags...)
if err != nil {
a.mu.Lock()
delete(a.transitions, name)
+119
View File
@@ -0,0 +1,119 @@
package app
import (
"context"
"errors"
"os"
"path/filepath"
"time"
"github.com/Nwflower/reims-go/internal/driver/reims"
"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 {
c, err := a.client()
if err != nil {
// A fresh installation can quit before its first runtime is installed.
a.mu.Lock()
cfg := *a.cfg
a.mu.Unlock()
_, 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
}
return err
}
return stopListedVMs(ctx, c.Locale, c.List, func(ctx context.Context, name string) error {
return a.stopVM(ctx, c, name, "--force")
})
}
const quitVMTimeout = 10 * time.Second
func stopListedVMs(ctx context.Context, loc i18n.Locale, list func(context.Context) ([]reims.VMListItem, error), stop func(context.Context, string) 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 string
for _, vm := range vms {
if vm.State == "running" {
if stopped[vm.Name] {
return errors.New(i18n.M(loc, "err.quit.stop_failed", i18n.Vars{"name": vm.Name}))
}
if next == "" {
next = vm.Name
}
}
}
if next == "" {
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}))
}
if err != nil {
return errors.New(i18n.M(loc, "err.quit.stop_failed", i18n.Vars{"name": next}))
}
stopped[next] = true
}
}
+153
View File
@@ -0,0 +1,153 @@
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/reims"
"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 := []reims.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) ([]reims.VMListItem, error) {
return vms, nil
}, func(ctx context.Context, name string) error {
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: []reims.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
@@ -89,6 +89,10 @@ func (a *App) SuspendVM(name string) error {
// ResumeVM restores a suspended VM with its original media and devices.
func (a *App) ResumeVM(name string) error {
if err := a.beginVMStart(); err != nil {
return err
}
defer a.vmStarts.Done()
prep, err := a.prep(name)
if err != nil {
return err
+4 -3
View File
@@ -756,12 +756,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 {
+13 -1
View File
@@ -130,6 +130,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": "恢复点名称包含不支持的控制字符或引号",
@@ -182,7 +184,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",
@@ -373,6 +375,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": "拖动调整日志高度",
@@ -402,6 +406,7 @@ var catalog = map[Locale]map[string]string{
"shortcutBarFullscreen": "切换全屏",
"shortcutBarRelease": "释放键盘和鼠标",
"showSidebar": "显示侧边栏",
"shutdownMode": "关机方式",
"sidebarHost": "内核",
"sidebarInstallers": "安装包",
"sidebarItemAria": "{label},{state}",
@@ -664,6 +669,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",
@@ -907,6 +914,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",
@@ -936,6 +945,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}",
@@ -1116,6 +1126,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"},
+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
@@ -1028,6 +1028,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
@@ -278,6 +278,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
@@ -1028,6 +1028,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
@@ -278,6 +278,10 @@
"gpuUnavailableHint": "没有找到能加速的显卡,可改用 VMware SVGA",
"minimizeToTray": "关闭窗口时最小化到系统托盘",
"minimizeToTraySub": "关闭窗口后剪贴板和共享文件夹继续工作,可从托盘启停虚拟机",
"forceQuitAppTitle": "强制退出 Reims-Go",
"forceQuitAppSub": "对所有运行中的虚拟机执行硬关机,未保存的数据可能丢失。",
"forceQuitAppButton": "强制退出",
"forceQuitInProgress": "正在强制退出…",
"hostDisplays": "物理显示器",
"hostDisplayPrimary": "主屏",
"multiDisplayHint": {