feat: add Wails desktop GUI and stage-0 UI redesign
Wails shell over the existing Go core (app.go, main.go, wails.json, build/), with a React frontend for the VM list, VM detail, host page, create wizard and settings, plus process helpers for the driver and runtime packages. UI redesign stage 0 (docs/ui-redesign.md): - VM actions live in the page header: one primary action per state, icon-only secondary actions with tooltips, the rest in a "..." menu - install guide is a single card with the only "eject installer" button - summary is an icon + value row; paths, ICD, CPU model and runtime hash moved to a collapsed "technical details" section - logs no longer auto-open; a status bar shows merged download progress and an error count; the log view sticks to the bottom - busy states on actions, toasts for results, custom delete dialog with "keep disk files" - design tokens, Windows font stack, integer type scale, no inline styles - keyboard: sidebar listbox navigation, focus rings, Ctrl+N / Ctrl+, / Ctrl+L - copy rewritten per the restraint rules in §4.5 - Radix primitives and lucide icons replace hand-rolled widgets Backend: OpenVMFolder binding to show a VM's directory in Explorer. Docs: shell-design.md revised for decisions D1 and D4. Vite dev server pinned to 127.0.0.1 so `wails dev` can reach it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46f274be09
commit
4bea654736
60 files changed
+7960
-67
No files matched your search
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.0.1",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "wails-dev",
|
||||
"runtimeExecutable": "wails",
|
||||
"runtimeArgs": ["dev", "-browser=false"],
|
||||
"port": 34115
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -41,5 +41,6 @@
|
||||
- [`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 里程碑与验收标准
|
||||
@@ -15,12 +15,13 @@
|
||||
- **免编译便携运行时**:通过 CI 预编译单套 `reims-runtime-win-x64`(仅含 `reims-ctl.exe` + `reims-util.exe` + 自包含 71 DLL 的 `qemu/`,**彻底脱离 MSYS2 / Rust / Git**),经本机冒烟测试后进入 `stable` 通道,用户端下载解压即用。
|
||||
- **把上游当内核**:不长期维护 fork。对上游的修改只放在 `patches/` 补丁队列里,同时向上游提 PR,合并后删掉,目标是补丁数清零。
|
||||
- **轻量单文件外壳**:Go + Wails(复用系统内置 WebView2),GUI 与 CLI 共用同一套 Go 核心包,不捆绑 Python / PowerShell 7。
|
||||
- **紧贴 `reims-ctl` 生态**:以子进程封装 `reims-ctl`(并通过 `XDG_*` 环境变量强制隔离到用户指定盘符),上游更新只需同步发布新版运行时包。
|
||||
- **工程化增值能力**:WHPX 一键体检与提权引导、自动锁定独显 Vulkan ICD、P-Core 绑核、CoW 派生与快照、QMP/SSH/截屏控制。
|
||||
- **紧贴 `reims-ctl` 生态**:以子进程封装 `reims-ctl` 与 `reims-util`(并通过 `XDG_*` 环境变量强制隔离到用户指定盘符),上游更新只需同步发布新版运行时包。
|
||||
- **GUI 宿主机断点续传离线下载**:通过 `reims-util --json` 在宿主机直接下载可复用的 **macOS 离线完整安装包**(结构化进度条 + 自动断点续传 + 缓存管理),规避 Recovery 内经 QEMU SLIRP 在线拉取 ~17 GB 易因 Apple CDN 断流失败的问题。
|
||||
- **工程化增值能力**:WHPX 与 Windows 提交内存(Commit Limit)一键体检、自动锁定独显 Vulkan ICD、P-Core 绑核、CoW 派生与快照、独立 QMP/SSH/截屏控制。
|
||||
|
||||
## 技术可行性基线(2026-11-28 本机实测)
|
||||
|
||||
- **Win10 19045 + RTX 4070 Ti 实测可用,但需要本地补丁**:本机已在 `Reims vGPU` 窗口内成功引导并进入 `Install macOS Tahoe` 图形安装界面。这次用的 QEMU 带着 [`patches/qemu-whpx-win10-compat.patch`](patches/qemu-whpx-win10-compat.patch)(修复 Win10 上 WHPX 建 vCPU 失败),不是纯上游构建。补丁的管理方式见 [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md) 第 5 节。
|
||||
- **Win10 19045 + RTX 4070 Ti 实测可用,但需要本地补丁**:本机已在 `Reims vGPU` 窗口内成功引导并进入 `Install macOS Tahoe` 图形安装界面。这次用的 QEMU 带着 [`patches/qemu-whpx-win10-compat.patch`](patches/qemu-whpx-win10-compat.patch)(修复 Win10 上 WHPX 建 vCPU `hr=80070057` 与 `WHvResetPartition` 空指针 `0xc0000005` 崩溃),不是纯上游构建。补丁的管理方式见 [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md) 第 5 节。
|
||||
- **上游没有 Release、变动很快**:2026-11-21 到 11-28 上游有 100 多个提交。所以 `reims-go` 只给用户发冒烟测试过的 `stable` 运行时(同上文档第 6 节)。
|
||||
- **目标宿主**:Win10 的扩展支持已在 2026 年 10 月结束,上游只在 Win11 上测过。对外以 Win11 为主,Win10 靠补丁保证本机可用。
|
||||
- **便携运行时剥离实测通过**:将 `reims-ctl.exe`(58 MB)、`reims-util.exe`(31.3 MB)与 `qemu/current/`(828.5 MB,含 71 个 DLL)置于纯净 `PATH`(无 MSYS2、无 Rust、无源码仓库)中运行,`reims-ctl doctor` 的 **9/9 运行时检查全部通过**(详情见 [`docs/portable-runtime-spec.md`](docs/portable-runtime-spec.md))。
|
||||
|
||||
@@ -0,0 +1,478 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"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"
|
||||
rt "github.com/Nwflower/reims-go/internal/runtime"
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
mu sync.Mutex
|
||||
cfg *config.Config
|
||||
transitions map[string]string
|
||||
pendingChanges map[string][]PendingChange
|
||||
stopPoll context.CancelFunc
|
||||
}
|
||||
|
||||
func NewApp() *App {
|
||||
cfg, err := config.Load("")
|
||||
if err != nil {
|
||||
cfg = config.Default()
|
||||
}
|
||||
return &App{
|
||||
cfg: cfg,
|
||||
transitions: make(map[string]string),
|
||||
pendingChanges: make(map[string][]PendingChange),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
pollCtx, cancel := context.WithCancel(ctx)
|
||||
a.stopPoll = cancel
|
||||
go a.pollVMs(pollCtx)
|
||||
}
|
||||
|
||||
func (a *App) shutdown(ctx context.Context) {
|
||||
if a.stopPoll != nil {
|
||||
a.stopPoll()
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
a.mu.Lock()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Auto-pin P-cores once per running QEMU PID.
|
||||
if a.cfg.AutoPinPCores && vm.State == "running" && vm.PID != nil && *vm.PID > 0 && !pinnedPIDs[*vm.PID] {
|
||||
if cachedHost.HasHybridCores && cachedHost.PCoreMask > 0 {
|
||||
if err := host.PinProcessToPCores(uint32(*vm.PID), cachedHost.PCoreMask); err == nil {
|
||||
pinnedPIDs[*vm.PID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(&b, "%s:%s:%s;", vm.Name, vm.State, a.transitions[vm.Name])
|
||||
}
|
||||
sig := b.String()
|
||||
a.mu.Unlock()
|
||||
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) {
|
||||
if a.ctx == nil {
|
||||
return
|
||||
}
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:log", map[string]string{
|
||||
"ts": time.Now().Format("15:04:05"),
|
||||
"source": source,
|
||||
"line": line,
|
||||
})
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
a.mu.Unlock()
|
||||
|
||||
rep := host.Inspect(cfgCopy.DataRoot)
|
||||
runtimes, _ := rt.List(&cfgCopy)
|
||||
active, _ := rt.ResolveActive(&cfgCopy)
|
||||
vms, _ := a.listVMsInternal(context.Background())
|
||||
|
||||
return AppState{
|
||||
Config: &cfgCopy,
|
||||
Host: rep,
|
||||
Runtimes: runtimes,
|
||||
ActiveRuntime: active,
|
||||
VMs: vms,
|
||||
Transitions: trCopy,
|
||||
PendingChanges: pcCopy,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) GetVMDetail(name string) (reims.VMDetail, error) {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return reims.VMDetail{}, err
|
||||
}
|
||||
return c.Show(context.Background(), name)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
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()
|
||||
return reims.ValidateCreate(opts, host.Inspect(root))
|
||||
}
|
||||
|
||||
func (a *App) PreviewCreate(opts reims.CreateOpts) (string, error) {
|
||||
return reims.PreviewCreateCommand(opts)
|
||||
}
|
||||
|
||||
func (a *App) CreateVM(opts reims.CreateOpts) error {
|
||||
if issues := a.ValidateCreate(opts); 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) }}
|
||||
a.emitLog(opts.Name, "Creating VM "+opts.Name+"...")
|
||||
err = c.Create(context.Background(), opts, w, w)
|
||||
if err != nil {
|
||||
a.emitLog(opts.Name, "Create error: "+err.Error())
|
||||
return err
|
||||
}
|
||||
a.emitLog(opts.Name, "VM "+opts.Name+" ready.")
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
return nil
|
||||
}
|
||||
|
||||
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) StartVM(name string) error {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.mu.Lock()
|
||||
a.transitions[name] = "starting"
|
||||
delete(a.pendingChanges, name)
|
||||
a.mu.Unlock()
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
||||
|
||||
w := &logWriter{emit: func(line string) { a.emitLog(name, line) }}
|
||||
a.emitLog(name, "Starting "+name+"...")
|
||||
if err := c.Start(context.Background(), name, w, w); 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
|
||||
}
|
||||
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.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.emitLog(name, fmt.Sprintf("Deleting VM %s (keepFiles=%v)...", name, keepFiles))
|
||||
if err := c.Delete(context.Background(), name, keepFiles, io.Discard, io.Discard); err != nil {
|
||||
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)
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"fixed": {
|
||||
"file_version": "{{.Info.ProductVersion}}"
|
||||
},
|
||||
"info": {
|
||||
"0000": {
|
||||
"ProductVersion": "{{.Info.ProductVersion}}",
|
||||
"CompanyName": "{{.Info.CompanyName}}",
|
||||
"FileDescription": "{{.Info.ProductName}}",
|
||||
"LegalCopyright": "{{.Info.Copyright}}",
|
||||
"ProductName": "{{.Info.ProductName}}",
|
||||
"Comments": "{{.Info.Comments}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<assemblyIdentity type="win32" name="com.wails.{{.Name}}" version="{{.Info.ProductVersion}}.0" processorArchitecture="*"/>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
||||
+40
-15
@@ -22,10 +22,11 @@ flowchart TB
|
||||
end
|
||||
|
||||
subgraph Core["Go 核心服务层 (internal/)"]
|
||||
Preflight["host/ 环境体检与调优\n(WHPX检测与一键提权、Vulkan ICD扫描、\nP/E核拓扑与进程亲和性绑核)"]
|
||||
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截屏与状态监控)"]
|
||||
Control["control/ 带外控制\n(独立QMP客户端、SSH执行、\n截屏与状态监控)"]
|
||||
end
|
||||
|
||||
subgraph External["外部运行时(独立子进程,全部在 DataRoot 下)"]
|
||||
@@ -33,8 +34,9 @@ flowchart TB
|
||||
QEMU["qemu-system-x86_64.exe + qemu-img.exe\n(含 reims-graphics-pci + 71 DLLs)"]
|
||||
end
|
||||
|
||||
GUI --> Preflight & RuntimeMgr & VMMgr & Control
|
||||
CLI --> Preflight & RuntimeMgr & VMMgr & Control
|
||||
GUI --> Preflight & RuntimeMgr & InstallerMgr & VMMgr & Control
|
||||
CLI --> Preflight & RuntimeMgr & InstallerMgr & VMMgr & Control
|
||||
InstallerMgr --> ReimsCtl
|
||||
VMMgr --> ReimsCtl
|
||||
VMMgr --> QEMU
|
||||
Control --> QEMU
|
||||
@@ -47,6 +49,9 @@ flowchart TB
|
||||
- **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 绑核**:
|
||||
@@ -57,15 +62,25 @@ flowchart TB
|
||||
- 维护 `<DataRoot>\runtimes\` 下的多版本便携运行时包:
|
||||
- 支持从 GitHub Releases(含可选国内加速镜像)拉取,也支持「导入本地 `.tar.zst` 包」离线安装;
|
||||
- 校验 `manifest.json` 与 SHA256 后解压至 `<commit>.tmp` 再原子重命名,失败不破坏现有版本;
|
||||
- 统一构造子进程环境(`XDG_*`、`REIMS_CTL_QEMU`、`PATH`),彻底消除对用户全局环境变量与 C 盘的依赖。
|
||||
- 统一构造子进程环境(`XDG_*`、`REIMS_CTL_QEMU`、`PATH`),彻底消除对用户全局环境变量与 C 盘的依赖;
|
||||
- **可承接上游未来官方发布**:运行时源采用清单化拉取协议,若上游 `steelbrain/reims-vgpu` 日后提供官方 Windows 预编译包,可直接切换源承接。
|
||||
|
||||
### 3.3 `internal/driver/reims` — `reims-ctl` 受控包装器
|
||||
- 包装 `list --json`、`show`、`create`、`start`、`stop`、`set`、`eject`、`delete`、`logs`、`command`、`doctor`。
|
||||
- 流式捕获 stdout/stderr 与串口日志,实时推送到 Wails 前端事件总线(`runtime.EventsEmit`),让用户在安装 macOS Tahoe 期间直观看到下载进度与内核启动日志。
|
||||
### 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.1`),供 GUI 下拉选择(同时保留在线恢复模式作为备选)。
|
||||
2. **宿主机直连下载 + 结构化进度条**:调用 `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` 推送进度百分比、已下载字节、速率与断流重试状态,无需脆弱正则匹配。
|
||||
3. **暂停 / 断点续传与空间预警**:`reims-util` 原生支持中断后重跑同命令自动断点续传;GUI 提供「暂停/取消」与「继续下载」按钮,并在目标盘剩余空间不足 40 GB 时前置预警。
|
||||
4. **缓存复用与可视化清理**:已下载的离线镜像常驻 `<DataRoot>\data\reims-ctl\installers\`,GUI 包装 `reims-ctl downloads` 与 `reims-ctl downloads delete <NAME>` 展示体积并支持一键清理;后续新建 VM 直接通过 `--installer <path>` 复用本地镜像,零重复下载。
|
||||
5. **离线装机 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 期间直观看到进度与内核启动日志。
|
||||
- **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)。
|
||||
|
||||
### 3.4 `internal/vm` 与 `internal/control` — 开发者进阶能力(M3)
|
||||
### 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` 提供命令执行通道。
|
||||
|
||||
@@ -78,13 +93,15 @@ reims-go/
|
||||
├── 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)
|
||||
│ ├── host/ # WHPX、提交内存预检、Vulkan ICD、P/E 核拓扑、进程亲和性(*_windows.go + *_other.go)
|
||||
│ ├── runtime/ # 便携运行时下载/导入、校验、解压、环境构造
|
||||
│ ├── installer/ # reims-util --json 离线安装包下载、断点续传、缓存管理
|
||||
│ ├── driver/
|
||||
│ │ └── reims/ # reims-ctl 子进程包装与 JSON/日志解析
|
||||
│ ├── qmp/ # QMP TCP 客户端
|
||||
│ ├── 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/
|
||||
@@ -96,7 +113,15 @@ reims-go/
|
||||
|
||||
| 维度 | `Reims-GUI-Win`(社区参考) | `reims-go`(本设计) |
|
||||
| :--- | :--- | :--- |
|
||||
| 外壳与体积 | Python + PySide6 + PowerShell 7 + 双套 QEMU(Release ~1.68 GB) | Go + Wails(WebView2 原生)+ 单套 `zstd` 便携运行时(预计总下载 ~250–320 MB) |
|
||||
| 上游耦合方式 | 手写 PowerShell 拼 QEMU 参数与 `fatsync` 改 OpenCore | 直接包装 `reims-ctl`,上游升级只需替换运行时包 |
|
||||
| 硬件调优 | CPU 预设 + SMBIOS 伪装 | 自动体检 WHPX + 过滤虚拟显卡锁定独显 ICD + 异构大小核 P-Core 绑核 |
|
||||
| 开发者能力 | 基础创建/启停,`taskkill` 强杀 | GUI + CLI 双模、串口日志流、CoW 派生、QMP/SSH 自动化接口 |
|
||||
| 外壳与体积 | 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 自动化接口 |
|
||||
|
||||
## 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 工程工作流。 |
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
**结论**:`reims-vgpu` 的 Windows 运行时在二进制层面**已经自包含,可以脱离 MSYS2 与编译环境独立运行**。
|
||||
|
||||
**限定条件**:这次实测的 `qemu/` 带着第 5 节的 Win10 补丁。纯上游构建在 Win10 上能否启动 VM,没有单独测过(**待验证**)。所以运行时包必须说明自己带了哪些补丁,不能写成「纯上游 `3731afd`」。
|
||||
**限定条件**:这次实测的 `qemu/` 带着第 5 节的 Win10 补丁。纯上游构建在 Win10 19045 上已于 2026-11-28 实测必现两处崩溃(见第 5 节证据)。所以运行时包必须说明自己带了哪些补丁,不能写成「纯上游 `3731afd`」。
|
||||
|
||||
## 2. 上游源码关键发现(`3731afd`)
|
||||
|
||||
@@ -98,7 +98,16 @@ reims-runtime-<commit>/
|
||||
|
||||
| 补丁 | 作用对象 | 解决的问题 | 状态 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `qemu-whpx-win10-compat.patch` | `vendor/qemu` 的 `target/i386/whpx/whpx-all.c` | ① `WHvResetPartition` 在 Win10 上不存在时跳过调用;② `whpx_tsc_deadline_refused()` 改在一个临时分区上探测。原实现在真实分区上建、删 vCPU 0,Win10 19045 上之后再建 vCPU 0 会返回 `E_INVALIDARG`(`0x80070057`) | 本机已用,未提交上游。提 PR 由人来做 |
|
||||
| `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(由人操作) |
|
||||
|
||||
### 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。
|
||||
- 本机 `WinHvPlatform.dll` 导出表已确认包含 `WHvSetVirtualProcessorInterruptControllerState2` 与 `WHvRequestInterrupt`,后续在 M3.1 实测强制 `-accel whpx,kernel-irqchip=on` 的稳定性;若稳定则优先向上游提 PR。
|
||||
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 节)。
|
||||
|
||||
规则:
|
||||
1. 补丁原文的权威副本放在 `reims-go/patches/`。macos-vm-lab 的那份是研究时的原始记录。
|
||||
|
||||
+14
-13
@@ -31,13 +31,14 @@ flowchart LR
|
||||
|
||||
**目标**:先用纯 Go 打通所有底层能力与单元测试,确保 CLI 单独就能跑完整个生命周期。
|
||||
|
||||
- [ ] **M1.1**:`internal/config` + `internal/i18n` — 实现配置持久化(`locale: zh-CN | en-US`、`data_root`)与双语消息字典;`internal/host` 实现 Windows 原生体检(`*_windows.go`)与非 Windows 桩(`*_other.go`,确保 macOS 开发环境可直接 `go test ./...`)。
|
||||
- [ ] **M1.1**:`internal/config` + `internal/i18n` — 实现配置持久化(`locale: zh-CN | en-US`、`data_root`)与双语消息字典;`internal/host` 实现 Windows 原生体检(`*_windows.go`:含 WHPX、**物理内存与可用提交内存 `FreeVirtualMemory` 安全档位推荐**、Vulkan ICD、P/E 核拓扑)与非 Windows 桩(`*_other.go`,确保 macOS 开发环境可直接 `go test ./...`)。
|
||||
- [ ] **M1.2**:`internal/runtime` — 实现便携运行时导入(本地 `.tar.zst` 与 HTTP 下载)、SHA256 校验、原子解压、版本切换与子进程环境变量构造(`XDG_*` + `REIMS_CTL_QEMU`)。
|
||||
- [ ] **M1.3**:`internal/driver/reims` — 封装 `reims-ctl` 的 `list --json`、`show`、`create`、`start`、`stop`、`set`、`eject`、`delete`、`logs`,带 Fake CLI 单元测试。
|
||||
- [ ] **M1.4**:`cmd/reims-go` — 提供 `doctor`、`runtime install/list/use`、`vm list/create/start/stop/eject/logs` 子命令,支持 `--lang zh|en` 与中英双语输出。
|
||||
- [ ] **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 进度流解析、取消/断点续传与缓存清理。
|
||||
- [ ] **M1.4**:`internal/driver/reims` — 封装 `reims-ctl` 的 `list --json`、`show`、`create`、`start`、`stop`、`set`、`eject`、`delete`、`logs`、`downloads`,带 Fake CLI 单元测试。
|
||||
- [ ] **M1.5**:`cmd/reims-go` — 提供 `doctor`、`runtime install/list/use`、`installer list/download/delete`、`vm list/create/start/stop/eject/logs` 子命令,支持 `--lang zh|en` 与中英双语输出。
|
||||
|
||||
**DoD**:
|
||||
- 在一个从未 dot-source `reims-env.ps1` 的全新 PowerShell 中,仅运行 `reims-go` CLI 即可完成体检、导入运行时、启动/查看 VM;
|
||||
- 在一个从未 dot-source `reims-env.ps1` 的全新 PowerShell 中,仅运行 `reims-go` CLI 即可完成体检、导入运行时、断点续传下载离线包、启动/查看 VM;
|
||||
- `go test ./...` 全通过。
|
||||
|
||||
---
|
||||
@@ -46,18 +47,18 @@ flowchart LR
|
||||
|
||||
**目标**:做成真正给普通开发者/自己点几下就能用的轻量桌面应用。
|
||||
|
||||
- [ ] **M2.1**:**首次启动向导(中英双语实时切换)** — 自动识别系统语言(支持顶部一键切换 `中文 / English`);展示环境体检卡片(WHPX、显卡、内存、磁盘);WHPX 未开时提供「一键提权启用并重启」按钮;引导选择非 C 盘数据目录并一键安装/导入便携运行时。
|
||||
- [ ] **M2.2**:**VM 主面板** — 实例列表、实时状态、一键启停、实时输出下载进度与串口/图形日志抽屉。
|
||||
- [ ] **M2.3**:**创建与装机引导(贴合简体中文 / 英文 macOS 界面术语)** — 选版本(macOS Tahoe)、存放目录、核数、内存、磁盘上限、目标 GPU(默认锁定独显 ICD),安装完毕后突出提示一键 **弹出安装盘(Eject)**。
|
||||
- [ ] **M2.1**:**首次启动向导(中英双语实时切换)** — 自动识别系统语言(支持顶部一键切换 `中文 / English`);展示环境体检卡片(WHPX、**提交内存与推荐 RAM**、显卡、磁盘);WHPX 未开时提供「一键提权启用并重启」按钮;引导选择非 C 盘数据目录并一键安装/导入便携运行时。
|
||||
- [ ] **M2.2**:**离线安装包下载管理器(核心体验)** — 调用 `reims-util --json` 展示可选 macOS Tahoe 精确版本,在 GUI 内直接触发宿主机直连下载、实时显示进度条 / 速率 / 已下体积 / 自动重试状态、支持「暂停/取消」与「断点续传」,并可视化管理 `<DataRoot>\data\reims-ctl\installers` 缓存。
|
||||
- [ ] **M2.3**:**VM 主面板与创建/装机引导(贴合简体中文 / 英文 macOS 界面术语)** — 实例列表、实时状态、一键启停与串口/图形日志抽屉;新建默认推荐复用本地离线包(附 `--network false`,启动前校验提交内存),装机侧边栏展示离线安装 3 步引导(抹盘 APFS → `sh /Volumes/Installer/install-macos.sh` → 一键 **弹出安装盘并恢复网络**)。
|
||||
- [ ] **M2.4**:打包为单文件 `reims-go.exe`(验证体积与冷启动速度)。
|
||||
- [ ] **M2.5**:**设置面板(对齐 macOS)** — 按 [`shell-design.md`](shell-design.md) 第 3 节的类别分页(平台、引导、CPU、内存、存储、网络、图形与显示器、音频、键盘与指针、串口与日志、高级);VM 运行中也能打开、能改,每个字段标出生效时机;保存前先在 Go 里校验,再调用 `reims-ctl set` 写入;平台类字段只读且脱敏。
|
||||
- [ ] **M2.5**:**设置面板(对齐 macOS)** — 按 [`shell-design.md`](shell-design.md) 第 3 节的类别分页(平台、引导、CPU、内存、存储、网络、图形与显示器、音频、键盘与指针、串口与日志、高级);VM 运行中也能打开、能改,每个字段标出生效时机;保存前先在 Go 里校验(含提交内存与 ICD 检查),再调用 `reims-ctl set` 写入;平台类字段只读且脱敏。
|
||||
- [ ] **M2.6**:**待生效修改** — 详情页列出「已保存、下次启动才生效」的修改(例如 `cpus 8→12`),提供「重启以应用」按钮;状态模型按 `shell-design.md` 第 4 节实现。
|
||||
- [ ] **M2.7**:**主窗口结构** — 侧边栏 + 详情 + 工具栏,新建用分步助手,最后一步显示将执行的 `reims-ctl create` 命令(`shell-design.md` 第 5 节)。
|
||||
|
||||
**DoD**:
|
||||
- 双击 `reims-go.exe` 即可走完「体检 → 导入运行时 → 创建/启动 VM → 查看日志 → 弹出安装盘」全流程,无需打开命令行。
|
||||
- VM 运行中修改 CPU / 内存 / 显示器数量并保存,重启后 `reims-ctl show` 显示新值;非法输入(如内存超过宿主物理内存、ICD 文件不存在)在保存前被拦下。
|
||||
- **可测量的时间目标**:从首次双击到出现 macOS 安装界面 ≤ 10 分钟。不计入:开启 WHPX 后的重启、运行时下载、从 Apple 下载恢复镜像。macOS 图形安装本身的耗时单独实测记录(**待验证**,预计几十分钟),不作为 DoD。
|
||||
- 双击 `reims-go.exe` 即可走完「体检 → 导入运行时 → GUI 断点续传下载离线安装包 → 创建/启动 VM → 离线装完并弹出安装盘」全流程,无需打开命令行。
|
||||
- VM 运行中修改 CPU / 内存 / 显示器数量并保存,重启后 `reims-ctl show` 显示新值;非法输入(如内存超过宿主可用提交内存、ICD 文件不存在)在保存前被拦下。
|
||||
- **可测量的时间目标**:从首次双击到出现 macOS 安装界面 ≤ 10 分钟。不计入:开启 WHPX 后的重启、运行时下载、从 Apple 下载离线安装包。macOS 离线安装本身的耗时单独实测记录(**待验证**),不作为 DoD。
|
||||
|
||||
---
|
||||
|
||||
@@ -65,8 +66,8 @@ flowchart LR
|
||||
|
||||
**目标**:补齐现有社区 GUI 的空白,对接 `macos-vm-lab` 的工程化需求。
|
||||
|
||||
- [ ] **M3.1**:**P-Core 自动绑核** — 启动 VM 后自动定位对应 `qemu-system-x86_64.exe` PID 并应用 P-Core 亲和性掩码,界面显示当前绑核状态。
|
||||
- [ ] **M3.2**:**QMP 与优雅关机** — 通过 `--extra-args` 接入 QMP,实现运行态监控、优雅关机与截屏(实测验证不与上游内置参数冲突)。
|
||||
- [ ] **M3.1**:**P-Core 自动绑核与 Win10 `kernel-irqchip=on` 验证** — 启动 VM 后自动定位对应 `qemu-system-x86_64.exe` PID 并应用 P-Core 亲和性掩码,界面显示当前绑核状态;实测 Win10 下强制开启 `kernel-irqchip=on` 的稳定性与 I/O CPU 收益(稳定则优先向上游提 PR)。
|
||||
- [ ] **M3.2**:**独立 QMP 与优雅关机** — 通过 `--extra-args` 接入独立 TCP QMP 通道(不抢占 `reims-ctl` 自带的 `qmp.sock`),实现运行态监控、优雅关机与截屏(实测验证不与上游内置参数冲突)。
|
||||
- [ ] **M3.3**:**Golden Image 与 CoW 秒级派生** — 支持将已装好系统的 VM 标记为模板,用 `qemu-img` 秒级派生临时测试实例,销毁后模板哈希不变。
|
||||
- [ ] **M3.4**:**一键打包排障日志** — 收集体检报告、QEMU/串口日志(自动脱敏序列号/MAC/OSK),一键导出 `.zip`。
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
- 创建:用分步助手;
|
||||
- 修改:设置面板按类别分页,像 macOS 的「系统设置」。
|
||||
|
||||
外壳跑在 Windows 上,但视觉和交互按 macOS 来做,用户进 VM 前后体验一致。Windows 特有的部分(UAC、WHPX、Vulkan ICD)集中放在「宿主」页,不混进 VM 设置。
|
||||
外壳跑在 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. 三条原语
|
||||
|
||||
@@ -66,10 +66,10 @@
|
||||
## 5. 界面结构
|
||||
|
||||
```text
|
||||
┌ 工具栏:[▶ 启动] [■ 关机] [⏏ 弹出安装盘] [📷 截屏] [⚙ 设置] [+ 新建] ┐
|
||||
┌ 标题栏:reims-go ─ □ ✕ ┐
|
||||
├──────────────┬───────────────────────────────────────────────────────────────┤
|
||||
│ 侧边栏 │ 详情 │
|
||||
│ ● m0 运行中 │ 概览:系统版本、CPU / 内存 / 磁盘、GPU、SSH 端口 │
|
||||
│ 虚拟机 [+] │ m0 ● 运行中 [主操作] ■ ⚙ ⋯ │
|
||||
│ ● m0 │ 概览:CPU / 内存 / 磁盘、GPU、SSH 端口 │
|
||||
│ ○ golden │ 待生效的修改(有才显示):cpus 8→12 [重启以应用] │
|
||||
│ ○ run-01 │ 日志抽屉:QEMU 输出 / 串口 │
|
||||
│ ───────── │ │
|
||||
@@ -77,6 +77,7 @@
|
||||
└──────────────┴───────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- **VM 操作放在详情页页头,不放顶部工具栏**:操作离对象近,切到宿主页时也不会出现整排按钮消失、布局跳动的问题。主操作随状态切换,其余操作是纯图标按钮或收进「⋯」菜单(2026-11-28 按 `ui-redesign.md` D1 修订)。
|
||||
- **新建助手**(弹出式分步):① 系统来源 → ② CPU 与内存 → ③ 存储 → ④ 图形与 GPU → ⑤ 摘要与校验 → 创建。每一步都能返回,最后一步列出将要执行的 `reims-ctl create` 命令。
|
||||
- **设置面板**:左边是第 3 节的类别列表,右边是表单。顶部显示 VM 当前状态,以及这一页修改的生效时机。
|
||||
- **宿主页**:WHPX 状态和启用按钮(UAC)、GPU 与 ICD 列表、P/E 核拓扑、数据目录与空间、运行时版本和通道。
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
# 前端改版方案(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 和行号后再写解析器 | 否 |
|
||||
| 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 上线后删掉这段兼容代码。
|
||||
|
||||
## 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 |
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>reims-go</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "reims-go-frontend",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc --noEmit && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-alert-dialog": "^1.2.1",
|
||||
"@radix-ui/react-dialog": "^1.3.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.2.1",
|
||||
"@radix-ui/react-toast": "^1.3.1",
|
||||
"@radix-ui/react-tooltip": "^1.4.1",
|
||||
"lucide-react": "^1.82.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"typescript": "^5.7.3",
|
||||
"vite": "^6.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
17717fba491cc661ca1f25a060babeba
|
||||
Generated
+1985
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
||||
allowBuilds:
|
||||
esbuild: true
|
||||
@@ -0,0 +1,304 @@
|
||||
import { Minus, Square, X } from 'lucide-react'
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { CreateWizard } from './components/CreateWizard'
|
||||
import { DeleteDialog } from './components/DeleteDialog'
|
||||
import { HostView } from './components/HostView'
|
||||
import { LogPanel, LogTab } from './components/LogPanel'
|
||||
import { SettingsModal } from './components/SettingsModal'
|
||||
import { HOST_ID, Sidebar } from './components/Sidebar'
|
||||
import { VMAction, VMPage } from './components/VMPage'
|
||||
import { I18nKey, t } from './i18n'
|
||||
import { LogLine, appendLog } from './lib/logs'
|
||||
import { AppState, Locale, VMDetail } from './types'
|
||||
import { TooltipProvider } from './ui/controls'
|
||||
import { Toaster, useToasts } from './ui/toast'
|
||||
import { backend } from './wails'
|
||||
|
||||
const errText = (e: unknown) => String(e).replace(/^Error:\s*/, '')
|
||||
|
||||
const failKey: Record<VMAction, I18nKey> = {
|
||||
start: 'failStart',
|
||||
stop: 'failStop',
|
||||
forceStop: 'failStop',
|
||||
restart: 'failRestart',
|
||||
eject: 'failEject',
|
||||
delete: 'failDelete',
|
||||
openFolder: 'failOpenFolder',
|
||||
}
|
||||
|
||||
export const App: React.FC = () => {
|
||||
const [state, setState] = useState<AppState | null>(null)
|
||||
const [selected, setSelected] = useState<string>(HOST_ID)
|
||||
const [detail, setDetail] = useState<VMDetail | null>(null)
|
||||
const [showWizard, setShowWizard] = useState(false)
|
||||
const [showSettings, setShowSettings] = useState(false)
|
||||
const [deleteTarget, setDeleteTarget] = useState<string | null>(null)
|
||||
const [busy, setBusy] = useState<Record<string, VMAction>>({})
|
||||
const [loadError, setLoadError] = useState('')
|
||||
|
||||
const [logsOpen, setLogsOpen] = useState(false)
|
||||
const [logTab, setLogTab] = useState<LogTab>('app')
|
||||
const [logLines, setLogLines] = useState<LogLine[]>([])
|
||||
const [serialLog, setSerialLog] = useState('')
|
||||
const [unseenErrors, setUnseenErrors] = useState(0)
|
||||
const logsOpenRef = useRef(logsOpen)
|
||||
logsOpenRef.current = logsOpen
|
||||
|
||||
const toasts = useToasts()
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
try {
|
||||
const s = await backend.getState()
|
||||
setState(s)
|
||||
setLoadError('')
|
||||
setSelected((cur) => {
|
||||
if (cur === HOST_ID) return cur
|
||||
if ((s.vms ?? []).some((v) => v.name === cur)) return cur
|
||||
return s.vms && s.vms.length > 0 ? s.vms[0].name : HOST_ID
|
||||
})
|
||||
} catch (e) {
|
||||
setLoadError(errText(e))
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
refresh()
|
||||
const offState = backend.onStateChanged(() => { refresh() })
|
||||
// Logs never pop the panel open (docs/ui-redesign.md §5.2); errors only bump a badge.
|
||||
const offLog = backend.onLog((entry) => {
|
||||
setLogLines((prev) => {
|
||||
const next = appendLog(prev, entry)
|
||||
const last = next[next.length - 1]
|
||||
if (!logsOpenRef.current && last.level === 'error' && last !== prev[prev.length - 1]) {
|
||||
setUnseenErrors((n) => n + 1)
|
||||
}
|
||||
return next
|
||||
})
|
||||
})
|
||||
return () => { offState(); offLog() }
|
||||
}, [refresh])
|
||||
|
||||
const vms = state?.vms ?? []
|
||||
const selectedVM = selected !== HOST_ID ? vms.find((v) => v.name === selected) : undefined
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedVM) { setDetail(null); return }
|
||||
backend.getVMDetail(selectedVM.name).then(setDetail).catch(() => setDetail(null))
|
||||
}, [selectedVM?.name, state])
|
||||
|
||||
const locale: Locale = state?.config.locale ?? 'zh-CN'
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const effectiveState = selectedVM ? (state?.transitions[selectedVM.name] ?? selectedVM.state) : ''
|
||||
const pending = selectedVM ? (state?.pending_changes[selectedVM.name] ?? []) : []
|
||||
const hostReady = !!state && state.host.whpx === 'ready' && !!state.active_runtime
|
||||
|
||||
const openLogs = (tab: LogTab = 'app') => {
|
||||
setLogTab(tab)
|
||||
setLogsOpen(true)
|
||||
setUnseenErrors(0)
|
||||
}
|
||||
|
||||
const toggleLogs = () => {
|
||||
setLogsOpen((o) => !o)
|
||||
setUnseenErrors(0)
|
||||
}
|
||||
|
||||
const loadSerial = async (name = selectedVM?.name) => {
|
||||
if (!name) return
|
||||
try {
|
||||
setSerialLog(await backend.readVMLogs(name, true))
|
||||
} catch (e) {
|
||||
setSerialLog(errText(e))
|
||||
}
|
||||
}
|
||||
|
||||
const fail = (title: string, e: unknown) =>
|
||||
toasts.push({ kind: 'error', title, description: errText(e), action: { label: tr('viewLogs'), onClick: () => openLogs('app') } })
|
||||
|
||||
const runVMAction = async (name: string, action: VMAction, fn: () => Promise<void>, okTitle?: string) => {
|
||||
setBusy((b) => ({ ...b, [name]: action }))
|
||||
try {
|
||||
await fn()
|
||||
if (okTitle) toasts.push({ kind: 'ok', title: okTitle })
|
||||
await refresh()
|
||||
} catch (e) {
|
||||
fail(tr(failKey[action]), e)
|
||||
} finally {
|
||||
setBusy((b) => {
|
||||
const { [name]: _, ...rest } = b
|
||||
return rest
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onVMAction = (action: VMAction) => {
|
||||
if (!selectedVM) return
|
||||
const name = selectedVM.name
|
||||
switch (action) {
|
||||
case 'start': return runVMAction(name, action, () => backend.startVM(name))
|
||||
case 'stop': return runVMAction(name, action, () => backend.stopVM(name, false), tr('toastStopped', { name }))
|
||||
case 'forceStop': return runVMAction(name, action, () => backend.stopVM(name, true), tr('toastStopped', { name }))
|
||||
case 'restart': return runVMAction(name, action, () => backend.restartVM(name))
|
||||
case 'eject': return runVMAction(name, action, () => backend.ejectInstaller(name), tr('toastEjected'))
|
||||
case 'openFolder':
|
||||
return backend.openVMFolder(name).catch((e) => fail(tr('failOpenFolder'), e))
|
||||
case 'delete': return setDeleteTarget(name)
|
||||
}
|
||||
}
|
||||
|
||||
const confirmDelete = (keepFiles: boolean) => {
|
||||
const name = deleteTarget
|
||||
setDeleteTarget(null)
|
||||
if (name) runVMAction(name, 'delete', () => backend.deleteVM(name, keepFiles), tr('toastDeleted', { name }))
|
||||
}
|
||||
|
||||
const openWizard = () => {
|
||||
if (!state?.active_runtime) {
|
||||
setSelected(HOST_ID)
|
||||
toasts.push({ kind: 'error', title: tr('noRuntimeAlert') })
|
||||
return
|
||||
}
|
||||
setShowWizard(true)
|
||||
}
|
||||
|
||||
const copy = async (text: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
toasts.push({ kind: 'ok', title: tr('toastCopied') })
|
||||
} catch (e) {
|
||||
fail(tr('failGeneric'), e)
|
||||
}
|
||||
}
|
||||
|
||||
const setLang = async (l: Locale) => {
|
||||
await backend.setLocale(l)
|
||||
refresh()
|
||||
}
|
||||
|
||||
// Global shortcuts (docs/ui-redesign.md §7.3). Dialogs own the keyboard while open.
|
||||
const shortcutRef = useRef<(e: KeyboardEvent) => void>(() => {})
|
||||
shortcutRef.current = (e: KeyboardEvent) => {
|
||||
if (!e.ctrlKey || e.altKey || e.metaKey) return
|
||||
if (showWizard || showSettings || deleteTarget) return
|
||||
const k = e.key.toLowerCase()
|
||||
if (k === 'n') { e.preventDefault(); openWizard() }
|
||||
else if (k === ',' && detail) { e.preventDefault(); setShowSettings(true) }
|
||||
else if (k === 'l') { e.preventDefault(); toggleLogs() }
|
||||
}
|
||||
useEffect(() => {
|
||||
const h = (e: KeyboardEvent) => shortcutRef.current(e)
|
||||
window.addEventListener('keydown', h)
|
||||
return () => window.removeEventListener('keydown', h)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<div className="app-shell">
|
||||
<header className="titlebar" onDoubleClick={() => backend.winToggleMaximise()}>
|
||||
<div className="brand">
|
||||
<span className="brand-mark" aria-hidden="true">R</span>
|
||||
reims-go
|
||||
</div>
|
||||
<div className="win-controls" onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<button type="button" className="win-btn" aria-label={tr('minimize')} onClick={() => backend.winMinimise()}><Minus size={14} /></button>
|
||||
<button type="button" className="win-btn" aria-label={tr('maximize')} onClick={() => backend.winToggleMaximise()}><Square size={12} /></button>
|
||||
<button type="button" className="win-btn close" aria-label={tr('closeWindow')} onClick={() => backend.winQuit()}><X size={15} /></button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="workspace">
|
||||
<Sidebar
|
||||
locale={locale}
|
||||
vms={vms}
|
||||
transitions={state?.transitions ?? {}}
|
||||
selected={selected}
|
||||
hostReady={hostReady}
|
||||
onSelect={setSelected}
|
||||
onNew={openWizard}
|
||||
/>
|
||||
|
||||
<main className="main">
|
||||
<div className="scroll">
|
||||
{!state ? (
|
||||
<div className="page">
|
||||
{loadError ? <div className="notice notice-error">{loadError}</div> : <span className="muted">…</span>}
|
||||
</div>
|
||||
) : selectedVM ? (
|
||||
<VMPage
|
||||
locale={locale}
|
||||
name={selectedVM.name}
|
||||
state={effectiveState}
|
||||
detail={detail}
|
||||
host={state.host}
|
||||
pending={pending}
|
||||
busyAction={busy[selectedVM.name]}
|
||||
onAction={onVMAction}
|
||||
onSettings={() => setShowSettings(true)}
|
||||
onDelete={() => setDeleteTarget(selectedVM.name)}
|
||||
onViewLogs={() => { openLogs('serial'); loadSerial() }}
|
||||
onCopy={copy}
|
||||
/>
|
||||
) : (
|
||||
<HostView
|
||||
state={state}
|
||||
locale={locale}
|
||||
onRefresh={refresh}
|
||||
onError={fail}
|
||||
onSetLocale={setLang}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<LogPanel
|
||||
locale={locale}
|
||||
open={logsOpen}
|
||||
onToggle={toggleLogs}
|
||||
tab={selectedVM ? logTab : 'app'}
|
||||
onTab={(tab) => { setLogTab(tab); if (tab === 'serial') loadSerial() }}
|
||||
lines={logLines}
|
||||
unseenErrors={unseenErrors}
|
||||
onClear={() => setLogLines([])}
|
||||
serialText={serialLog}
|
||||
showSerial={!!selectedVM}
|
||||
onRefreshSerial={() => loadSerial()}
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{showWizard && state && (
|
||||
<CreateWizard
|
||||
locale={locale}
|
||||
host={state.host}
|
||||
onClose={() => setShowWizard(false)}
|
||||
onCreated={(name) => {
|
||||
setShowWizard(false)
|
||||
setSelected(name)
|
||||
refresh()
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showSettings && state && detail && (
|
||||
<SettingsModal
|
||||
locale={locale}
|
||||
detail={detail}
|
||||
host={state.host}
|
||||
running={effectiveState === 'running'}
|
||||
onClose={() => setShowSettings(false)}
|
||||
onSaved={() => {
|
||||
setShowSettings(false)
|
||||
toasts.push({ kind: 'ok', title: tr(effectiveState === 'running' ? 'toastSavedNextStart' : 'toastSaved') })
|
||||
refresh()
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{deleteTarget && (
|
||||
<DeleteDialog locale={locale} name={deleteTarget} onCancel={() => setDeleteTarget(null)} onConfirm={confirmDelete} />
|
||||
)}
|
||||
|
||||
<Toaster items={toasts.items} onRemove={toasts.remove} closeLabel={tr('close')} />
|
||||
</div>
|
||||
</TooltipProvider>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
import { Check } from 'lucide-react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { shortGPUName } from '../lib/format'
|
||||
import { CreateOpts, HostReport, Locale, ValidationIssue } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { backend } from '../wails'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
host: HostReport
|
||||
onClose: () => void
|
||||
onCreated: (name: string) => void
|
||||
}
|
||||
|
||||
export const CreateWizard: React.FC<Props> = ({ locale, host, onClose, onCreated }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [step, setStep] = useState(1)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [err, setErr] = useState('')
|
||||
const [issues, setIssues] = useState<ValidationIssue[]>([])
|
||||
const [cmdPreview, setCmdPreview] = useState('')
|
||||
|
||||
const [opts, setOpts] = useState<CreateOpts>({
|
||||
name: 'macos-tahoe',
|
||||
dir: '',
|
||||
source_mode: 'apple',
|
||||
macos: 'tahoe',
|
||||
installer: '',
|
||||
cpus: host.logical_cpus >= 12 ? 8 : 4,
|
||||
memory: host.total_ram_gb >= 24 ? '16G' : '8G',
|
||||
disk_size: '128G',
|
||||
disk: '',
|
||||
disk_mode: 'copy',
|
||||
graphics: 'reims-vgpu',
|
||||
gpu: host.recommended_gpu?.vulkan_icd ?? 'auto',
|
||||
resolution: '1920x1080',
|
||||
displays: 1,
|
||||
borderless: false,
|
||||
audio: true,
|
||||
network: true,
|
||||
ssh_port: 0,
|
||||
logs: true,
|
||||
start: true,
|
||||
})
|
||||
const set = (patch: Partial<CreateOpts>) => setOpts((o) => ({ ...o, ...patch }))
|
||||
|
||||
const buildPayload = (): CreateOpts => {
|
||||
const p: CreateOpts = { ...opts }
|
||||
if (p.source_mode === 'apple') {
|
||||
p.installer = ''
|
||||
p.disk = ''
|
||||
} else if (p.source_mode === 'installer') {
|
||||
p.macos = ''
|
||||
p.disk = ''
|
||||
} else {
|
||||
p.macos = ''
|
||||
p.installer = ''
|
||||
p.disk_size = ''
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (step !== 5) return
|
||||
const payload = buildPayload()
|
||||
Promise.all([backend.validateCreate(payload), backend.previewCreate(payload)])
|
||||
.then(([iss, cmd]) => {
|
||||
setIssues(iss ?? [])
|
||||
setCmdPreview(cmd)
|
||||
})
|
||||
.catch((e) => setErr(String(e)))
|
||||
}, [step, opts])
|
||||
|
||||
const pickDir = async () => {
|
||||
const dir = await backend.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)
|
||||
if (f) set({ [field]: f })
|
||||
}
|
||||
|
||||
const handleCreate = async () => {
|
||||
setErr('')
|
||||
setBusy(true)
|
||||
try {
|
||||
const payload = buildPayload()
|
||||
await backend.createVM(payload)
|
||||
onCreated(payload.name)
|
||||
} catch (e) {
|
||||
setErr(String(e).replace(/^Error:\s*/, ''))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const realGPUs = (host.gpus ?? []).filter((g) => g.kind !== 'virtual')
|
||||
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')} dismissable={!busy} onClose={onClose}>
|
||||
<nav className="wizard-steps" aria-label={tr('wizardTitle')}>
|
||||
{steps.map((key, idx) => {
|
||||
const n = idx + 1
|
||||
return (
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
className={`wizard-step${step > n ? ' done' : ''}`}
|
||||
aria-current={step === n ? 'step' : undefined}
|
||||
disabled={busy}
|
||||
onClick={() => setStep(n)}
|
||||
>
|
||||
{step > n && <Check size={12} />}
|
||||
{tr(key)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</nav>
|
||||
|
||||
<div className="dialog-body">
|
||||
{err && <div className="notice notice-error">{err}</div>}
|
||||
|
||||
{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>
|
||||
{(['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, ...(mode === 'apple' ? { macos: opts.macos || 'tahoe' } : {}) })}
|
||||
/>
|
||||
{tr(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>
|
||||
)}
|
||||
|
||||
{opts.source_mode !== 'apple' && (
|
||||
<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 })}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => (opts.source_mode === 'installer'
|
||||
? pickFile('installer', '*.img;*.dmg')
|
||||
: pickFile('disk', '*.qcow2;*.img'))}
|
||||
>
|
||||
{tr('choose')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{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">{tr('memHint')}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{step === 3 && (
|
||||
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>
|
||||
) : (
|
||||
<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>
|
||||
)
|
||||
)}
|
||||
|
||||
{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'],
|
||||
['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 })} />
|
||||
{tr(label)}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{step === 5 && (
|
||||
<>
|
||||
{issues.length > 0 ? (
|
||||
<div className="notice notice-error">
|
||||
<ul>{issues.map((i) => <li key={i.field + i.code}>{i.message}</li>)}</ul>
|
||||
</div>
|
||||
) : (
|
||||
<span className="hint">{tr('validationPassed')}</span>
|
||||
)}
|
||||
<div className="field">
|
||||
<span className="field-label">{tr('commandPreview')}</span>
|
||||
<div className="code">{cmdPreview}</div>
|
||||
</div>
|
||||
{busy && <span className="hint">{tr('creating')}</span>}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="dialog-foot">
|
||||
<Button variant="ghost" disabled={step === 1 || busy} onClick={() => setStep(step - 1)}>{tr('back')}</Button>
|
||||
{step < 5 ? (
|
||||
<Button variant="primary" onClick={() => setStep(step + 1)}>{tr('next')}</Button>
|
||||
) : (
|
||||
<Button variant="primary" busy={busy} disabled={issues.length > 0} onClick={handleCreate}>{tr('createNow')}</Button>
|
||||
)}
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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
|
||||
name: string
|
||||
onCancel: () => void
|
||||
onConfirm: (keepFiles: boolean) => void
|
||||
}
|
||||
|
||||
export const DeleteDialog: React.FC<Props> = ({ locale, name, onCancel, onConfirm }) => {
|
||||
const [keepFiles, setKeepFiles] = useState(false)
|
||||
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, 'deleteTitle', { name })}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">
|
||||
{t(locale, keepFiles ? 'deleteDescKeep' : 'deleteDesc')}
|
||||
</Alert.Description>
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={keepFiles} onChange={(e) => setKeepFiles(e.target.checked)} />
|
||||
{t(locale, 'deleteKeepFiles')}
|
||||
</label>
|
||||
</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-danger" onClick={() => onConfirm(keepFiles)}>
|
||||
{t(locale, 'deleteConfirm')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
import { Cpu, HardDrive, MemoryStick, RefreshCw, ShieldCheck } from 'lucide-react'
|
||||
import React, { useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { AppState, Locale } from '../types'
|
||||
import { Button, IconButton } from '../ui/controls'
|
||||
import { backend } from '../wails'
|
||||
|
||||
interface Props {
|
||||
state: AppState
|
||||
locale: Locale
|
||||
onRefresh: () => void
|
||||
onError: (title: string, e: unknown) => void
|
||||
onSetLocale: (l: Locale) => void
|
||||
}
|
||||
|
||||
export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, onSetLocale }) => {
|
||||
const [importing, setImporting] = useState(false)
|
||||
const [enabling, setEnabling] = useState(false)
|
||||
const { host, config, runtimes } = state
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
|
||||
const whpx = {
|
||||
ready: { short: tr('whpxReady'), hint: '', tone: 'ok' },
|
||||
no_hypervisor: { short: tr('whpxNoHvShort'), hint: tr('whpxNoHv'), tone: 'warn' },
|
||||
missing: { short: tr('whpxMissingShort'), hint: tr('whpxMissing'), tone: 'warn' },
|
||||
unsupported: { short: tr('whpxUnsupportedShort'), hint: tr('whpxUnsupported'), tone: 'warn' },
|
||||
}[host.whpx] ?? { short: host.whpx, hint: '', tone: 'warn' }
|
||||
|
||||
const guard = (fn: () => Promise<unknown>) => async () => {
|
||||
try {
|
||||
await fn()
|
||||
onRefresh()
|
||||
} catch (e) {
|
||||
onError(tr('failGeneric'), e)
|
||||
}
|
||||
}
|
||||
|
||||
const enableWHPX = async () => {
|
||||
setEnabling(true)
|
||||
await guard(() => backend.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)
|
||||
})()
|
||||
setImporting(false)
|
||||
}
|
||||
|
||||
const gpuKind = (k: string) =>
|
||||
tr(k === 'discrete' ? 'gpuDiscrete' : k === 'integrated' ? 'gpuIntegrated' : k === 'virtual' ? 'gpuVirtual' : 'gpuUnknown')
|
||||
|
||||
const realGPUs = (host.gpus ?? []).filter((g) => g.kind !== 'virtual')
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<header className="page-head">
|
||||
<div className="page-title"><h1>{tr('sidebarHost')}</h1></div>
|
||||
<div className="actions">
|
||||
<IconButton label={tr('refresh')} icon={<RefreshCw size={16} />} onClick={onRefresh} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="tiles">
|
||||
<div className="tile">
|
||||
<div className="tile-head"><ShieldCheck size={14} /> {tr('whpxTitle')}</div>
|
||||
<div className={`tile-value ${whpx.tone}`}>{whpx.short}</div>
|
||||
<div className="tile-sub">{host.os}/{host.arch}</div>
|
||||
</div>
|
||||
<div className="tile">
|
||||
<div className="tile-head"><Cpu size={14} /> {tr('hostCPU')}</div>
|
||||
<div className="tile-value">{tr('hostCoresThreads', { c: host.physical_cores, t: host.logical_cpus })}</div>
|
||||
<div className="tile-sub">
|
||||
{host.has_hybrid_cores ? tr('hostHybrid', { p: host.p_core_count, e: host.e_core_count }) : tr('hostSymmetric')}
|
||||
</div>
|
||||
</div>
|
||||
<div className="tile">
|
||||
<div className="tile-head"><MemoryStick size={14} /> {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-value">{host.free_disk_gb.toFixed(0)} GB</div>
|
||||
<div className="tile-sub mono">{config.data_root}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">
|
||||
{tr('hostRuntime')}
|
||||
<Button variant={runtimes && runtimes.length > 0 ? 'secondary' : 'primary'} busy={importing} onClick={importRuntime}>
|
||||
{tr('importRuntime')}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="list">
|
||||
{!runtimes || runtimes.length === 0 ? (
|
||||
<div className="row"><span className="row-sub">{tr('noRuntime')}</span></div>
|
||||
) : (
|
||||
runtimes.map((rt) => (
|
||||
<div className="row" key={rt.commit}>
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className="mono">{rt.commit}</span>
|
||||
<span className="muted">{rt.manifest.qemu_version}</span>
|
||||
{rt.active && <span className="badge badge-ok">{tr('activeBadge')}</span>}
|
||||
</div>
|
||||
<div className="row-sub mono">{rt.dir}</div>
|
||||
</div>
|
||||
{!rt.active && (
|
||||
<div className="row-right">
|
||||
<Button onClick={guard(() => backend.useRuntime(rt.commit))}>{tr('activate')}</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('hostSystem')}</div>
|
||||
<div className="list">
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('hostWHPX')}</div>
|
||||
{whpx.hint && <div className="row-sub">{whpx.hint}</div>}
|
||||
</div>
|
||||
<div className="row-right">
|
||||
{host.whpx === 'missing' ? (
|
||||
<Button variant="primary" busy={enabling} onClick={enableWHPX}>{tr('enableWHPX')}</Button>
|
||||
) : (
|
||||
<span className={`badge ${whpx.tone === 'ok' ? 'badge-ok' : 'badge-warn'}`}>{whpx.short}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
{host.has_hybrid_cores && (
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">{tr('autoPinPCores')}</div>
|
||||
<div className="row-sub mono">{host.p_core_mask_hex}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<label className="switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={tr('autoPinPCores')}
|
||||
checked={config.auto_pin_pcores}
|
||||
onChange={(e) => guard(() => backend.setAutoPinPCores(e.target.checked))()}
|
||||
/>
|
||||
<span className="slider" />
|
||||
</label>
|
||||
</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">
|
||||
{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>}
|
||||
</div>
|
||||
<div className="row-sub mono">{g.vulkan_icd}</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section">
|
||||
<div className="section-title">{tr('hostPrefs')}</div>
|
||||
<div className="list">
|
||||
<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>
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import { ArrowDown, ChevronDown, ChevronUp, Eraser, LoaderCircle, RefreshCw } from 'lucide-react'
|
||||
import React, { useLayoutEffect, useRef, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { LogLine, activeProgress } from '../lib/logs'
|
||||
import { Locale } from '../types'
|
||||
import { Button, IconButton, Tip } from '../ui/controls'
|
||||
|
||||
export type LogTab = 'app' | 'serial'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
open: boolean
|
||||
onToggle: () => void
|
||||
tab: LogTab
|
||||
onTab: (tab: LogTab) => void
|
||||
lines: LogLine[]
|
||||
unseenErrors: number
|
||||
onClear: () => void
|
||||
serialText: string
|
||||
showSerial: boolean
|
||||
onRefreshSerial: () => void
|
||||
}
|
||||
|
||||
/** Sticks to the bottom until the user scrolls up; offers "jump to latest" then. */
|
||||
function useStickToBottom(dep: unknown, active: boolean) {
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const [stuck, setStuck] = useState(true)
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const el = ref.current
|
||||
if (el && active && stuck) el.scrollTop = el.scrollHeight
|
||||
}, [dep, active, stuck])
|
||||
|
||||
const onScroll = () => {
|
||||
const el = ref.current
|
||||
if (!el) return
|
||||
setStuck(el.scrollHeight - el.scrollTop - el.clientHeight < 24)
|
||||
}
|
||||
const jump = () => {
|
||||
const el = ref.current
|
||||
if (el) el.scrollTop = el.scrollHeight
|
||||
setStuck(true)
|
||||
}
|
||||
return { ref, stuck, onScroll, jump }
|
||||
}
|
||||
|
||||
export const LogPanel: React.FC<Props> = ({
|
||||
locale, open, onToggle, tab, onTab, lines, unseenErrors, onClear, serialText, showSerial, onRefreshSerial,
|
||||
}) => {
|
||||
const tr = (k: Parameters<typeof t>[1]) => t(locale, k)
|
||||
const content = tab === 'app' ? lines : serialText
|
||||
const { ref, stuck, onScroll, jump } = useStickToBottom(content, open)
|
||||
const progress = activeProgress(lines)
|
||||
|
||||
return (
|
||||
<div className="logs">
|
||||
<div className="logbar">
|
||||
{progress && (
|
||||
<Tip label={`${progress.source} · ${progress.label}`} side="top">
|
||||
<span className="task" tabIndex={0}>
|
||||
<LoaderCircle size={14} className="spin" />
|
||||
<span className="task-label">{progress.label}</span>
|
||||
<span className="progress" aria-hidden="true"><div style={{ width: `${progress.percent}%` }} /></span>
|
||||
<span>{Math.round(progress.percent)}%</span>
|
||||
</span>
|
||||
</Tip>
|
||||
)}
|
||||
<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')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{open && tab === 'app' && lines.length > 0 && (
|
||||
<IconButton small tipSide="top" label={tr('clear')} icon={<Eraser size={14} />} onClick={onClear} />
|
||||
)}
|
||||
{open && tab === 'serial' && (
|
||||
<IconButton small tipSide="top" label={tr('refresh')} icon={<RefreshCw size={14} />} onClick={onRefreshSerial} />
|
||||
)}
|
||||
{!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}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{open && (
|
||||
<div className="logs-body-wrap">
|
||||
<div className="logs-body" ref={ref} onScroll={onScroll} role="log" aria-live="off">
|
||||
{tab === 'app'
|
||||
? (lines.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>
|
||||
)))
|
||||
: (serialText || <span className="muted">{tr('logsEmpty')}</span>)}
|
||||
</div>
|
||||
{!stuck && (
|
||||
<Button className="jump-latest" icon={<ArrowDown size={14} />} onClick={jump}>
|
||||
{tr('jumpLatest')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
import React, { useState } from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { shortGPUName } from '../lib/format'
|
||||
import { HostReport, Locale, SetOpts, ValidationIssue, VMDetail } from '../types'
|
||||
import { Button } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { backend } from '../wails'
|
||||
|
||||
type Cat = 'platform' | 'cpu' | 'memory' | 'storage' | 'network' | 'graphics' | 'audio' | 'input' | 'logs' | 'advanced'
|
||||
|
||||
const CATS: { id: Cat; label: I18nKey }[] = [
|
||||
{ id: 'platform', label: 'catPlatform' },
|
||||
{ id: 'cpu', label: 'catCPU' },
|
||||
{ id: 'memory', label: 'catMemory' },
|
||||
{ id: 'storage', label: 'catStorage' },
|
||||
{ id: 'network', label: 'catNetwork' },
|
||||
{ id: 'graphics', label: 'catGraphics' },
|
||||
{ id: 'audio', label: 'catAudio' },
|
||||
{ id: 'input', label: 'catInput' },
|
||||
{ id: 'logs', label: 'catLogs' },
|
||||
{ id: 'advanced', label: 'catAdvanced' },
|
||||
]
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
detail: VMDetail
|
||||
host: HostReport
|
||||
running: boolean
|
||||
onClose: () => void
|
||||
onSaved: () => void
|
||||
}
|
||||
|
||||
export const SettingsModal: React.FC<Props> = ({ locale, detail, host, running, onClose, onSaved }) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [cat, setCat] = useState<Cat>('cpu')
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [issues, setIssues] = useState<ValidationIssue[]>([])
|
||||
const [err, setErr] = useState('')
|
||||
|
||||
const [form, setForm] = useState<SetOpts>({
|
||||
name: detail.name,
|
||||
cpus: detail.cpus,
|
||||
memory: detail.memory,
|
||||
graphics: detail.graphics,
|
||||
displays: detail.displays,
|
||||
disk_controller: detail.disk_controller,
|
||||
resolution: detail.resolution,
|
||||
borderless: detail.borderless,
|
||||
capture: detail.capture,
|
||||
gpu: detail.gpu,
|
||||
logs: detail.logs,
|
||||
log_level: detail.log_level,
|
||||
audio: detail.audio,
|
||||
network: detail.network,
|
||||
ssh_port: detail.ssh_port,
|
||||
stop_timeout: detail.stop_timeout,
|
||||
extra_args: detail.extra_args,
|
||||
})
|
||||
const set = (patch: Partial<SetOpts>) => setForm((f) => ({ ...f, ...patch }))
|
||||
|
||||
const buildDiff = (): SetOpts => {
|
||||
const out: SetOpts = { name: detail.name }
|
||||
if (form.cpus && form.cpus !== detail.cpus) out.cpus = form.cpus
|
||||
if (form.memory && form.memory !== detail.memory) out.memory = form.memory
|
||||
if (form.graphics && form.graphics !== detail.graphics) out.graphics = form.graphics
|
||||
if (form.displays && form.displays !== detail.displays) out.displays = form.displays
|
||||
if (form.disk_controller && form.disk_controller !== detail.disk_controller) out.disk_controller = form.disk_controller
|
||||
if (form.resolution && form.resolution !== detail.resolution) out.resolution = form.resolution
|
||||
if (form.borderless !== detail.borderless) out.borderless = form.borderless
|
||||
if (form.capture !== detail.capture) out.capture = form.capture
|
||||
if (form.gpu && form.gpu !== detail.gpu) out.gpu = form.gpu
|
||||
if (form.logs !== detail.logs) out.logs = form.logs
|
||||
if (form.log_level && form.log_level !== detail.log_level) out.log_level = form.log_level
|
||||
if (form.audio !== detail.audio) out.audio = form.audio
|
||||
if (form.network !== detail.network) out.network = form.network
|
||||
if (form.ssh_port !== detail.ssh_port) out.ssh_port = form.ssh_port
|
||||
if (form.stop_timeout !== detail.stop_timeout) out.stop_timeout = form.stop_timeout
|
||||
if (form.extra_args !== detail.extra_args) out.extra_args = form.extra_args
|
||||
return out
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
setErr('')
|
||||
setIssues([])
|
||||
setBusy(true)
|
||||
try {
|
||||
const diff = buildDiff()
|
||||
const iss = await backend.validateSet(diff)
|
||||
if (iss && iss.length > 0) {
|
||||
setIssues(iss)
|
||||
return
|
||||
}
|
||||
await backend.applyVMSettings(diff)
|
||||
onSaved()
|
||||
} catch (e) {
|
||||
setErr(String(e).replace(/^Error:\s*/, ''))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const realGPUs = (host.gpus ?? []).filter((g) => g.kind !== 'virtual')
|
||||
|
||||
const check = (key: 'network' | 'borderless' | 'audio' | 'capture' | 'logs', label: I18nKey) => (
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={!!form[key]} onChange={(e) => set({ [key]: e.target.checked })} />
|
||||
{tr(label)}
|
||||
</label>
|
||||
)
|
||||
|
||||
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('settingsTitle', { name: detail.name })}
|
||||
subtitle={tr(running ? 'appliesNextStart' : 'requiresStop')}
|
||||
closeLabel={tr('close')}
|
||||
dismissable={!busy}
|
||||
onClose={onClose}
|
||||
>
|
||||
<div className="settings-split">
|
||||
<nav className="settings-nav" aria-label={tr('settings')}>
|
||||
{CATS.map((c) => (
|
||||
<button
|
||||
key={c.id}
|
||||
type="button"
|
||||
className="nav-item"
|
||||
aria-selected={cat === c.id}
|
||||
aria-current={cat === c.id ? 'page' : undefined}
|
||||
onClick={() => setCat(c.id)}
|
||||
>
|
||||
<span className="nav-label">{tr(c.label)}</span>
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<div className="settings-pane">
|
||||
{err && <div className="notice notice-error">{err}</div>}
|
||||
{issues.length > 0 && (
|
||||
<div className="notice notice-error">
|
||||
<ul>{issues.map((i) => <li key={i.field + i.code}>{i.message}</li>)}</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{cat === 'platform' && (
|
||||
<>
|
||||
<span className="hint">{tr('platformReadonly')}</span>
|
||||
<dl className="kv-list">
|
||||
<dt>{tr('fieldKind')}</dt><dd>{detail.kind || '—'}</dd>
|
||||
<dt>{tr('fieldCPUModel')}</dt><dd className="mono">{detail.cpu_model || '—'}</dd>
|
||||
<dt>{tr('opencore')}</dt><dd>{detail.has_opencore ? tr('configured') : '—'}</dd>
|
||||
<dt>{tr('fieldDir')}</dt><dd className="mono">{detail.directory}</dd>
|
||||
</dl>
|
||||
</>
|
||||
)}
|
||||
|
||||
{cat === 'cpu' && (
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-cpus">{tr('factCPU')} · {tr('hostThreads', { n: host.logical_cpus })}</label>
|
||||
{presets([4, 6, 8, 12].filter((n) => n <= Math.max(host.logical_cpus, 4)), form.cpus, (n) => tr('cores', { n }), (cpus) => set({ cpus }))}
|
||||
<input id="set-cpus" className="input" type="number" min={1} max={host.logical_cpus || 64} value={form.cpus ?? 8} onChange={(e) => set({ cpus: Number(e.target.value) })} />
|
||||
<span className="hint">{tr('cpuHint')}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{cat === 'memory' && (
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-mem">{tr('factMemory')} · {tr('hostMemory', { n: host.total_ram_gb.toFixed(0) })}</label>
|
||||
{presets(['4G', '8G', '12G', '16G', '24G'], form.memory, (m) => m, (memory) => set({ memory }))}
|
||||
<input id="set-mem" className="input" value={form.memory ?? ''} onChange={(e) => set({ memory: e.target.value })} />
|
||||
<span className="hint">{tr('memHint')}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{cat === 'storage' && (
|
||||
<>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-disk">{tr('fieldDisk')}</label>
|
||||
<input id="set-disk" className="input mono" value={detail.disk} readOnly />
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-ctl">{tr('diskController')}</label>
|
||||
<select id="set-ctl" className="select" value={form.disk_controller} onChange={(e) => set({ disk_controller: e.target.value })}>
|
||||
<option value="ahci">SATA</option>
|
||||
<option value="nvme">NVMe</option>
|
||||
<option value="virtio">VirtIO</option>
|
||||
</select>
|
||||
{detail.has_installer && <span className="hint warn">{tr('diskControllerWarn')}</span>}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{cat === 'network' && (
|
||||
<>
|
||||
{check('network', 'enableNetwork')}
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-ssh">{tr('sshPort')}</label>
|
||||
<input id="set-ssh" className="input" type="number" min={0} max={65535} value={form.ssh_port ?? 0} onChange={(e) => set({ ssh_port: Number(e.target.value) })} />
|
||||
<span className="hint">{tr('sshPortHint')}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{cat === 'graphics' && (
|
||||
<>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-gfx">{tr('graphicsBackend')}</label>
|
||||
<select id="set-gfx" className="select" value={form.graphics} onChange={(e) => set({ graphics: e.target.value })}>
|
||||
<option value="reims-vgpu">{tr('graphicsReims')}</option>
|
||||
<option value="vmware-svga">{tr('graphicsSvga')}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-gpu">{tr('gpuSelect')}</label>
|
||||
<select id="set-gpu" className="select" value={form.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="set-res">{tr('resolution')}</label>
|
||||
<input id="set-res" className="input" value={form.resolution ?? ''} onChange={(e) => set({ resolution: e.target.value })} />
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-displays">{tr('displays')}</label>
|
||||
<input id="set-displays" className="input" type="number" min={1} max={4} value={form.displays ?? 1} onChange={(e) => set({ displays: Number(e.target.value) })} />
|
||||
</div>
|
||||
</div>
|
||||
{check('borderless', 'borderless')}
|
||||
</>
|
||||
)}
|
||||
|
||||
{cat === 'audio' && check('audio', 'enableAudio')}
|
||||
{cat === 'input' && check('capture', 'captureInput')}
|
||||
|
||||
{cat === 'logs' && (
|
||||
<>
|
||||
{check('logs', 'enableLogs')}
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-loglevel">{tr('logLevel')}</label>
|
||||
<input id="set-loglevel" className="input mono" value={form.log_level ?? ''} onChange={(e) => set({ log_level: e.target.value })} placeholder="info" />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{cat === 'advanced' && (
|
||||
<>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-timeout">{tr('stopTimeout')}</label>
|
||||
<input id="set-timeout" className="input" type="number" min={0} value={form.stop_timeout ?? 90} onChange={(e) => set({ stop_timeout: Number(e.target.value) })} />
|
||||
<span className="hint">{tr('stopTimeoutHint')}</span>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="field-label" htmlFor="set-extra">{tr('extraArgs')}</label>
|
||||
<input id="set-extra" className="input mono" value={form.extra_args ?? ''} onChange={(e) => set({ extra_args: e.target.value })} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="dialog-foot">
|
||||
<span className="spacer" />
|
||||
<Button variant="ghost" disabled={busy} onClick={onClose}>{tr('cancel')}</Button>
|
||||
<Button variant="primary" busy={busy} onClick={handleSave}>{tr('save')}</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import { Cpu, Monitor, Plus } 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'
|
||||
|
||||
export const HOST_ID = '__host__'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
vms: VMListItem[]
|
||||
transitions: Record<string, string>
|
||||
selected: string
|
||||
hostReady: boolean
|
||||
onSelect: (id: string) => void
|
||||
onNew: () => void
|
||||
}
|
||||
|
||||
export const Sidebar: React.FC<Props> = ({ locale, vms, transitions, selected, hostReady, onSelect, onNew }) => {
|
||||
const listRef = useRef<HTMLDivElement>(null)
|
||||
const ids = [...vms.map((v) => v.name), HOST_ID]
|
||||
|
||||
// Listbox keyboard model: ↑/↓/Home/End move selection and focus together.
|
||||
const onKeyDown = (e: React.KeyboardEvent) => {
|
||||
const idx = ids.indexOf(selected)
|
||||
let next = -1
|
||||
if (e.key === 'ArrowDown') next = Math.min(ids.length - 1, idx + 1)
|
||||
else if (e.key === 'ArrowUp') next = Math.max(0, idx - 1)
|
||||
else if (e.key === 'Home') next = 0
|
||||
else if (e.key === 'End') next = ids.length - 1
|
||||
if (next < 0) return
|
||||
e.preventDefault()
|
||||
onSelect(ids[next])
|
||||
listRef.current?.querySelector<HTMLElement>(`[data-id="${CSS.escape(ids[next])}"]`)?.focus()
|
||||
}
|
||||
|
||||
const item = (id: string, label: string, icon: React.ReactNode, stateLabel: string, kind: ReturnType<typeof statusKind>) => (
|
||||
<button
|
||||
key={id}
|
||||
type="button"
|
||||
role="option"
|
||||
data-id={id}
|
||||
className="nav-item"
|
||||
aria-selected={selected === id}
|
||||
aria-label={`${label},${stateLabel}`}
|
||||
tabIndex={selected === id ? 0 : -1}
|
||||
onClick={() => onSelect(id)}
|
||||
>
|
||||
{icon}
|
||||
<span className="nav-label">{label}</span>
|
||||
<Tip label={stateLabel} side="right">
|
||||
<span className="hstack"><StatusShape kind={kind} /></span>
|
||||
</Tip>
|
||||
</button>
|
||||
)
|
||||
|
||||
return (
|
||||
<aside className="sidebar">
|
||||
<div className="sidebar-head">
|
||||
<span>{t(locale, 'sidebarVMs')}</span>
|
||||
<IconButton small label={t(locale, 'newVM')} shortcut="Ctrl+N" icon={<Plus size={16} />} onClick={onNew} tipSide="right" />
|
||||
</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>}
|
||||
{vms.map((vm) => {
|
||||
const st = transitions[vm.name] ?? vm.state
|
||||
return item(vm.name, vm.name, <Monitor size={16} />, t(locale, `state_${st}` as I18nKey), statusKind(st))
|
||||
})}
|
||||
<div className="sidebar-sep" role="presentation" />
|
||||
{item(
|
||||
HOST_ID,
|
||||
t(locale, 'sidebarHost'),
|
||||
<Cpu size={16} />,
|
||||
t(locale, hostReady ? 'hostReady' : 'hostNeedsAction'),
|
||||
hostReady ? 'running' : 'warn',
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
import * as Menu from '@radix-ui/react-dropdown-menu'
|
||||
import {
|
||||
ChevronRight,
|
||||
Copy,
|
||||
Cpu,
|
||||
Ellipsis,
|
||||
FolderOpen,
|
||||
Gpu,
|
||||
HardDrive,
|
||||
MemoryStick,
|
||||
Play,
|
||||
Power,
|
||||
RotateCw,
|
||||
Settings,
|
||||
Square,
|
||||
Terminal,
|
||||
Trash,
|
||||
} from 'lucide-react'
|
||||
import React from 'react'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { controllerLabel, formatMemory, graphicsLabel, sshCommand } from '../lib/format'
|
||||
import { HostReport, Locale, PendingChange, VMDetail } from '../types'
|
||||
import { Button, IconButton, StatusShape, Tip, statusKind } from '../ui/controls'
|
||||
|
||||
export type VMAction = 'start' | 'stop' | 'forceStop' | 'restart' | 'eject' | 'delete' | 'openFolder'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
name: string
|
||||
state: string
|
||||
detail: VMDetail | null
|
||||
host: HostReport
|
||||
pending: PendingChange[]
|
||||
busyAction?: VMAction
|
||||
onAction: (action: VMAction) => void
|
||||
onSettings: () => void
|
||||
onDelete: () => void
|
||||
onViewLogs: () => void
|
||||
onCopy: (text: string) => void
|
||||
}
|
||||
|
||||
export const VMPage: React.FC<Props> = ({
|
||||
locale, name, state, detail, host, pending, busyAction, onAction, onSettings, onDelete, onViewLogs, onCopy,
|
||||
}) => {
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const busy = busyAction !== undefined
|
||||
const running = state === 'running'
|
||||
const transitioning = state === 'starting' || state === 'stopping'
|
||||
|
||||
// One primary action per state (docs/ui-redesign.md §3.2). Running has none
|
||||
// until "Show VM window" (B5) exists.
|
||||
let primary: React.ReactNode = null
|
||||
if (state === 'stopped') {
|
||||
primary = (
|
||||
<Button variant="primary" icon={<Play size={14} />} busy={busyAction === 'start'} disabled={busy} onClick={() => onAction('start')}>
|
||||
{tr('start')}
|
||||
</Button>
|
||||
)
|
||||
} else if (state === 'starting') {
|
||||
primary = <Button variant="primary" busy>{tr('starting')}</Button>
|
||||
} else if (state === 'broken') {
|
||||
primary = <Button variant="primary" icon={<Terminal size={14} />} onClick={onViewLogs}>{tr('viewLogs')}</Button>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<header className="page-head">
|
||||
<div className="page-title">
|
||||
<h1>{name}</h1>
|
||||
<span className="state-text">
|
||||
<StatusShape kind={statusKind(state)} />
|
||||
{tr(`state_${state}` as I18nKey)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="actions">
|
||||
{primary}
|
||||
{running && (
|
||||
<IconButton label={tr('stop')} icon={<Square size={15} />} busy={busyAction === 'stop'} disabled={busy} onClick={() => onAction('stop')} />
|
||||
)}
|
||||
<IconButton label={tr('settings')} shortcut="Ctrl+," icon={<Settings size={16} />} disabled={!detail} onClick={onSettings} />
|
||||
<Menu.Root>
|
||||
<Tip label={tr('more')}>
|
||||
<Menu.Trigger asChild>
|
||||
<button type="button" className="icon-btn" aria-label={tr('more')}>
|
||||
<Ellipsis size={16} />
|
||||
</button>
|
||||
</Menu.Trigger>
|
||||
</Tip>
|
||||
<Menu.Portal>
|
||||
<Menu.Content className="menu" align="end" sideOffset={4} collisionPadding={8}>
|
||||
{running && (
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('restart')}>
|
||||
<RotateCw size={14} /> {tr('restart')}
|
||||
</Menu.Item>
|
||||
)}
|
||||
{(running || transitioning) && (
|
||||
<Menu.Item className="menu-item danger" disabled={busyAction === 'forceStop'} onSelect={() => onAction('forceStop')}>
|
||||
<Power size={14} /> {tr('forceStop')}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.Item className="menu-item" onSelect={() => onAction('openFolder')}>
|
||||
<FolderOpen size={14} /> {tr('openFolder')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className="menu-item" onSelect={onViewLogs}>
|
||||
<Terminal size={14} /> {tr('viewLogs')}
|
||||
</Menu.Item>
|
||||
<Menu.Separator className="menu-sep" />
|
||||
<Menu.Item className="menu-item danger" disabled={running || transitioning || busy} onSelect={onDelete}>
|
||||
<Trash size={14} /> {tr('delete')}
|
||||
</Menu.Item>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu.Root>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{state === 'broken' && <div className="notice notice-error">{tr('brokenHint')}</div>}
|
||||
|
||||
{pending.length > 0 && (
|
||||
<div className="notice">
|
||||
<span>
|
||||
{tr('pendingTitle')}:
|
||||
<span className="mono">{pending.map((p) => `${p.field} ${p.from}→${p.to}`).join(' · ')}</span>
|
||||
</span>
|
||||
{running && (
|
||||
<Button busy={busyAction === 'restart'} disabled={busy} onClick={() => onAction('restart')}>
|
||||
{tr('restartToApply')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{detail?.has_installer && (
|
||||
<section className="card" aria-labelledby="guide-title">
|
||||
<h2 className="card-title" id="guide-title">{tr('guideTitle')}</h2>
|
||||
<ol className="steps">
|
||||
<li>{tr('guideStep1')}</li>
|
||||
<li>{tr('guideStep2')}</li>
|
||||
<li>{tr('guideStep3')}</li>
|
||||
</ol>
|
||||
<div className="card-foot">
|
||||
<Button
|
||||
variant={running ? 'primary' : 'secondary'}
|
||||
busy={busyAction === 'eject'}
|
||||
disabled={busy}
|
||||
onClick={() => onAction('eject')}
|
||||
>
|
||||
{tr('eject')}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{detail && detail.ssh_port > 0 && (
|
||||
<div className="cmd-line">
|
||||
<Terminal size={16} aria-hidden="true" />
|
||||
<code>{sshCommand(detail.ssh_port)}</code>
|
||||
<IconButton small label={tr('copy')} icon={<Copy size={14} />} onClick={() => onCopy(sshCommand(detail.ssh_port))} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{detail && (
|
||||
<div className="facts">
|
||||
<Fact label={tr('factCPU')} icon={<Cpu size={16} />} value={tr('cores', { n: detail.cpus })} />
|
||||
<Fact label={tr('factMemory')} icon={<MemoryStick size={16} />} value={formatMemory(detail.memory)} />
|
||||
<Fact label={tr('factDisk')} icon={<HardDrive size={16} />} value={controllerLabel(detail.disk_controller)} />
|
||||
<Fact label={tr('factGraphics')} icon={<Gpu size={16} />} value={graphicsLabel(locale, detail, host)} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{detail && (
|
||||
<details className="tech">
|
||||
<summary><ChevronRight size={14} /> {tr('techInfo')}</summary>
|
||||
<dl className="kv-list">
|
||||
<dt>{tr('fieldKind')}</dt><dd>{detail.kind || '—'}</dd>
|
||||
<dt>{tr('fieldCPUModel')}</dt><dd className="mono">{detail.cpu_model || 'auto'}</dd>
|
||||
<dt>{tr('fieldDisk')}</dt><dd className="mono">{detail.disk}</dd>
|
||||
<dt>{tr('fieldController')}</dt><dd>{detail.disk_controller}</dd>
|
||||
<dt>{tr('fieldGraphicsBackend')}</dt><dd>{detail.graphics}</dd>
|
||||
{detail.gpu && detail.gpu !== 'auto' && (<><dt>{tr('fieldICD')}</dt><dd className="mono">{detail.gpu}</dd></>)}
|
||||
<dt>{tr('fieldDisplays')}</dt><dd>{detail.displays} × {detail.resolution}</dd>
|
||||
<dt>{tr('fieldNetwork')}</dt><dd>{detail.network_summary || tr('off')}</dd>
|
||||
<dt>{tr('fieldAudio')}</dt><dd>{detail.audio_raw || tr('off')}</dd>
|
||||
<dt>{tr('fieldDir')}</dt><dd className="mono">{detail.directory}</dd>
|
||||
</dl>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const Fact: React.FC<{ label: string; icon: React.ReactNode; value: string }> = ({ label, icon, value }) => (
|
||||
<Tip label={label}>
|
||||
<span className="fact" tabIndex={0} aria-label={`${label}:${value}`}>
|
||||
{icon}
|
||||
{value}
|
||||
</span>
|
||||
</Tip>
|
||||
)
|
||||
@@ -0,0 +1,414 @@
|
||||
import { Locale } from './types'
|
||||
|
||||
// Copy rules: docs/ui-redesign.md §4.5 — verbs on buttons, one short sentence
|
||||
// per hint, no 请/您/成功, no full stop on buttons or short hints.
|
||||
const dict = {
|
||||
'zh-CN': {
|
||||
// Shell
|
||||
sidebarVMs: '虚拟机',
|
||||
sidebarHost: '宿主与运行时',
|
||||
emptyVMs: '还没有虚拟机',
|
||||
hostReady: '就绪',
|
||||
hostNeedsAction: '需要处理',
|
||||
minimize: '最小化',
|
||||
maximize: '最大化',
|
||||
closeWindow: '关闭',
|
||||
|
||||
// Actions
|
||||
newVM: '新建虚拟机',
|
||||
start: '启动',
|
||||
starting: '启动中',
|
||||
stop: '关机',
|
||||
restart: '重启',
|
||||
forceStop: '强制关机',
|
||||
eject: '弹出安装盘',
|
||||
settings: '设置',
|
||||
more: '更多',
|
||||
openFolder: '打开所在文件夹',
|
||||
delete: '删除…',
|
||||
viewLogs: '查看日志',
|
||||
refresh: '刷新',
|
||||
copy: '复制',
|
||||
clear: '清空',
|
||||
cancel: '取消',
|
||||
close: '关闭',
|
||||
back: '上一步',
|
||||
next: '下一步',
|
||||
save: '保存',
|
||||
choose: '浏览…',
|
||||
jumpLatest: '跳到最新',
|
||||
expandLogs: '展开日志',
|
||||
collapseLogs: '收起日志',
|
||||
|
||||
// States
|
||||
state_running: '运行中',
|
||||
state_stopped: '已停止',
|
||||
state_starting: '启动中',
|
||||
state_stopping: '停止中',
|
||||
state_broken: '出错',
|
||||
|
||||
// VM page
|
||||
pendingTitle: '下次启动生效',
|
||||
restartToApply: '重启以应用',
|
||||
guideTitle: '安装 macOS',
|
||||
guideStep1: '在「磁盘工具」中抹掉「QEMU HARDDISK Media」,格式选 APFS',
|
||||
guideStep2: '退出磁盘工具,选择「重新安装 macOS」',
|
||||
guideStep3: '进入桌面后,弹出安装盘',
|
||||
brokenHint: '这台虚拟机的配置无法读取',
|
||||
techInfo: '技术信息',
|
||||
factCPU: '处理器',
|
||||
factMemory: '内存',
|
||||
factDisk: '存储',
|
||||
factGraphics: '图形',
|
||||
cores: '{n} 核',
|
||||
gpuAuto: '自动选择 GPU',
|
||||
softwareGraphics: '软件渲染',
|
||||
fieldKind: '类型',
|
||||
fieldCPUModel: 'CPU 型号',
|
||||
fieldDisk: '磁盘',
|
||||
fieldController: '磁盘控制器',
|
||||
fieldGraphicsBackend: '图形后端',
|
||||
fieldICD: 'Vulkan ICD',
|
||||
fieldDisplays: '显示器',
|
||||
fieldNetwork: '网络',
|
||||
fieldAudio: '音频',
|
||||
fieldDir: '目录',
|
||||
off: '关闭',
|
||||
|
||||
// Logs
|
||||
logActivity: '活动',
|
||||
logSerial: '串口',
|
||||
logsEmpty: '暂无日志',
|
||||
|
||||
// Toasts & dialogs
|
||||
toastStopped: '{name} 已关机',
|
||||
toastEjected: '已弹出安装盘',
|
||||
toastDeleted: '已删除 {name}',
|
||||
toastSaved: '已保存',
|
||||
toastSavedNextStart: '已保存,下次启动生效',
|
||||
toastCopied: '已复制',
|
||||
failStart: '启动失败',
|
||||
failStop: '关机失败',
|
||||
failRestart: '重启失败',
|
||||
failEject: '弹出安装盘失败',
|
||||
failDelete: '删除失败',
|
||||
failOpenFolder: '无法打开文件夹',
|
||||
failGeneric: '操作失败',
|
||||
deleteTitle: '删除「{name}」?',
|
||||
deleteDesc: '配置和虚拟磁盘会被移除,无法撤销',
|
||||
deleteDescKeep: '只移除配置,磁盘文件留在原目录',
|
||||
deleteKeepFiles: '保留磁盘文件',
|
||||
deleteConfirm: '删除',
|
||||
noRuntimeAlert: '先在「宿主与运行时」导入运行时包',
|
||||
|
||||
// Host
|
||||
hostRuntime: '运行时',
|
||||
hostSystem: '系统',
|
||||
hostGPUs: '显卡',
|
||||
hostPrefs: '偏好设置',
|
||||
language: '语言',
|
||||
whpxTitle: 'WHPX',
|
||||
whpxReady: '就绪',
|
||||
whpxNoHvShort: '未激活',
|
||||
whpxMissingShort: '未启用',
|
||||
whpxUnsupportedShort: '不支持',
|
||||
whpxNoHv: '在 BIOS 中开启 Intel VT-x / AMD-V',
|
||||
whpxMissing: '启用后需要重启 Windows',
|
||||
whpxUnsupported: '当前不是 Windows 宿主',
|
||||
hostWHPX: 'Windows 虚拟机监控程序平台',
|
||||
enableWHPX: '启用',
|
||||
hostCPU: '处理器',
|
||||
hostCoresThreads: '{c} 核 · {t} 线程',
|
||||
hostHybrid: '{p} 性能核 + {e} 能效核',
|
||||
hostSymmetric: '同构核心',
|
||||
autoPinPCores: '启动后绑定到性能核',
|
||||
hostRAM: '内存',
|
||||
hostRAMAvail: '可用 {n} GB',
|
||||
hostRAMTotal: '共 {n} GB',
|
||||
hostDisk: '可用空间',
|
||||
hostDataRoot: '数据目录',
|
||||
noRuntime: '还没有运行时,导入 reims-runtime-win-x64-*.tar.zst 即可',
|
||||
importRuntime: '导入运行时包',
|
||||
activeBadge: '使用中',
|
||||
activate: '使用',
|
||||
gpuRecommended: '推荐',
|
||||
gpuDiscrete: '独显',
|
||||
gpuIntegrated: '核显',
|
||||
gpuVirtual: '虚拟',
|
||||
gpuUnknown: '未知',
|
||||
|
||||
// Wizard
|
||||
wizardTitle: '新建虚拟机',
|
||||
step1: '系统来源',
|
||||
step2: 'CPU 与内存',
|
||||
step3: '存储',
|
||||
step4: '图形与外设',
|
||||
step5: '确认',
|
||||
vmName: '名称',
|
||||
vmDir: '存放目录',
|
||||
vmDirHint: '留空则使用数据目录',
|
||||
sourceApple: '从 Apple 下载恢复镜像',
|
||||
sourceInstaller: '本地安装器镜像(.img / .dmg)',
|
||||
sourceDisk: '已有虚拟磁盘(.qcow2)',
|
||||
macosVersion: 'macOS 版本',
|
||||
macosTahoe: 'macOS 26 Tahoe(硬件加速需要 26.4 及以上)',
|
||||
diskSize: '磁盘上限',
|
||||
diskSizeHint: '按实际占用增长,推荐 128G',
|
||||
diskMode: '使用方式',
|
||||
diskModeCopy: '复制一份,不改动原盘',
|
||||
diskModeInPlace: '直接使用原盘',
|
||||
hostThreads: '宿主 {n} 线程',
|
||||
hostMemory: '宿主 {n} GB',
|
||||
cpuHint: '推荐 4 或 8 核',
|
||||
memHint: '建议不超过宿主内存的 75%',
|
||||
graphicsBackend: '图形后端',
|
||||
graphicsReims: 'reims-vgpu(硬件加速,推荐)',
|
||||
graphicsSvga: 'vmware-svga(无加速,用于排障)',
|
||||
gpuSelect: '宿主 GPU',
|
||||
gpuAutoOption: '自动(优先独显)',
|
||||
resolution: '分辨率',
|
||||
displays: '显示器数量',
|
||||
borderless: '无边框全屏',
|
||||
enableAudio: '音频',
|
||||
enableNetwork: '网络(NAT)',
|
||||
sshPort: 'SSH 转发端口',
|
||||
sshPortHint: '0 表示关闭',
|
||||
enableLogs: '记录图形与串口日志',
|
||||
startAfterCreate: '创建后立即启动',
|
||||
commandPreview: '将执行的命令',
|
||||
validationPassed: '检查通过',
|
||||
createNow: '创建',
|
||||
creating: '正在创建,进度见底部状态栏',
|
||||
|
||||
// Settings
|
||||
settingsTitle: '{name} 设置',
|
||||
appliesNextStart: '下次启动生效',
|
||||
requiresStop: '部分修改需要先关机',
|
||||
catPlatform: '平台',
|
||||
catCPU: 'CPU',
|
||||
catMemory: '内存',
|
||||
catStorage: '存储',
|
||||
catNetwork: '网络',
|
||||
catGraphics: '图形与显示器',
|
||||
catAudio: '音频',
|
||||
catInput: '键盘与指针',
|
||||
catLogs: '串口与日志',
|
||||
catAdvanced: '高级',
|
||||
platformReadonly: '机型、序列号等平台身份信息不在界面显示',
|
||||
opencore: 'OpenCore',
|
||||
configured: '已配置',
|
||||
diskController: '磁盘控制器',
|
||||
diskControllerWarn: '切换前先弹出安装盘',
|
||||
captureInput: '点击窗口时捕获键鼠',
|
||||
stopTimeout: '关机等待时间(秒)',
|
||||
stopTimeoutHint: '0 表示一直等待',
|
||||
extraArgs: '额外 QEMU 参数',
|
||||
logLevel: '日志级别(REIMS_VGPU_LOG)',
|
||||
},
|
||||
'en-US': {
|
||||
sidebarVMs: 'Virtual machines',
|
||||
sidebarHost: 'Host & runtime',
|
||||
emptyVMs: 'No virtual machines',
|
||||
hostReady: 'Ready',
|
||||
hostNeedsAction: 'Needs attention',
|
||||
minimize: 'Minimize',
|
||||
maximize: 'Maximize',
|
||||
closeWindow: 'Close',
|
||||
|
||||
newVM: 'New virtual machine',
|
||||
start: 'Start',
|
||||
starting: 'Starting',
|
||||
stop: 'Shut down',
|
||||
restart: 'Restart',
|
||||
forceStop: 'Force shut down',
|
||||
eject: 'Eject installer',
|
||||
settings: 'Settings',
|
||||
more: 'More',
|
||||
openFolder: 'Show in folder',
|
||||
delete: 'Delete…',
|
||||
viewLogs: 'View logs',
|
||||
refresh: 'Refresh',
|
||||
copy: 'Copy',
|
||||
clear: 'Clear',
|
||||
cancel: 'Cancel',
|
||||
close: 'Close',
|
||||
back: 'Back',
|
||||
next: 'Next',
|
||||
save: 'Save',
|
||||
choose: 'Browse…',
|
||||
jumpLatest: 'Jump to latest',
|
||||
expandLogs: 'Show logs',
|
||||
collapseLogs: 'Hide logs',
|
||||
|
||||
state_running: 'Running',
|
||||
state_stopped: 'Stopped',
|
||||
state_starting: 'Starting',
|
||||
state_stopping: 'Stopping',
|
||||
state_broken: 'Error',
|
||||
|
||||
pendingTitle: 'Applies on next start',
|
||||
restartToApply: 'Restart to apply',
|
||||
guideTitle: 'Install macOS',
|
||||
guideStep1: 'In Disk Utility, erase "QEMU HARDDISK Media" as APFS',
|
||||
guideStep2: 'Quit Disk Utility and choose "Reinstall macOS"',
|
||||
guideStep3: 'Once on the desktop, eject the installer',
|
||||
brokenHint: 'This VM’s configuration can’t be read',
|
||||
techInfo: 'Technical details',
|
||||
factCPU: 'CPU',
|
||||
factMemory: 'Memory',
|
||||
factDisk: 'Storage',
|
||||
factGraphics: 'Graphics',
|
||||
cores: '{n} cores',
|
||||
gpuAuto: 'Automatic GPU',
|
||||
softwareGraphics: 'Software rendering',
|
||||
fieldKind: 'Kind',
|
||||
fieldCPUModel: 'CPU model',
|
||||
fieldDisk: 'Disk',
|
||||
fieldController: 'Disk controller',
|
||||
fieldGraphicsBackend: 'Graphics backend',
|
||||
fieldICD: 'Vulkan ICD',
|
||||
fieldDisplays: 'Displays',
|
||||
fieldNetwork: 'Network',
|
||||
fieldAudio: 'Audio',
|
||||
fieldDir: 'Directory',
|
||||
off: 'Off',
|
||||
|
||||
logActivity: 'Activity',
|
||||
logSerial: 'Serial',
|
||||
logsEmpty: 'No logs yet',
|
||||
|
||||
toastStopped: '{name} shut down',
|
||||
toastEjected: 'Installer ejected',
|
||||
toastDeleted: '{name} deleted',
|
||||
toastSaved: 'Saved',
|
||||
toastSavedNextStart: 'Saved — applies on next start',
|
||||
toastCopied: 'Copied',
|
||||
failStart: 'Couldn’t start',
|
||||
failStop: 'Couldn’t shut down',
|
||||
failRestart: 'Couldn’t restart',
|
||||
failEject: 'Couldn’t eject the installer',
|
||||
failDelete: 'Couldn’t delete',
|
||||
failOpenFolder: 'Couldn’t open the folder',
|
||||
failGeneric: 'Something went wrong',
|
||||
deleteTitle: 'Delete "{name}"?',
|
||||
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',
|
||||
deleteConfirm: 'Delete',
|
||||
noRuntimeAlert: 'Import a runtime under Host & runtime first',
|
||||
|
||||
hostRuntime: 'Runtime',
|
||||
hostSystem: 'System',
|
||||
hostGPUs: 'Graphics cards',
|
||||
hostPrefs: 'Preferences',
|
||||
language: 'Language',
|
||||
whpxTitle: 'WHPX',
|
||||
whpxReady: 'Ready',
|
||||
whpxNoHvShort: 'Inactive',
|
||||
whpxMissingShort: 'Off',
|
||||
whpxUnsupportedShort: 'Unsupported',
|
||||
whpxNoHv: 'Turn on Intel VT-x / AMD-V in BIOS',
|
||||
whpxMissing: 'Windows restarts after enabling',
|
||||
whpxUnsupported: 'This host isn’t Windows',
|
||||
hostWHPX: 'Windows Hypervisor Platform',
|
||||
enableWHPX: 'Enable',
|
||||
hostCPU: 'CPU',
|
||||
hostCoresThreads: '{c} cores · {t} threads',
|
||||
hostHybrid: '{p} performance + {e} efficiency',
|
||||
hostSymmetric: 'Uniform cores',
|
||||
autoPinPCores: 'Pin to performance cores on start',
|
||||
hostRAM: 'Memory',
|
||||
hostRAMAvail: '{n} GB free',
|
||||
hostRAMTotal: '{n} GB total',
|
||||
hostDisk: 'Free space',
|
||||
hostDataRoot: 'Data folder',
|
||||
noRuntime: 'No runtime yet — import reims-runtime-win-x64-*.tar.zst',
|
||||
importRuntime: 'Import runtime',
|
||||
activeBadge: 'In use',
|
||||
activate: 'Use',
|
||||
gpuRecommended: 'Recommended',
|
||||
gpuDiscrete: 'Discrete',
|
||||
gpuIntegrated: 'Integrated',
|
||||
gpuVirtual: 'Virtual',
|
||||
gpuUnknown: 'Unknown',
|
||||
|
||||
wizardTitle: 'New virtual machine',
|
||||
step1: 'Source',
|
||||
step2: 'CPU & memory',
|
||||
step3: 'Storage',
|
||||
step4: 'Graphics & devices',
|
||||
step5: 'Review',
|
||||
vmName: 'Name',
|
||||
vmDir: 'Folder',
|
||||
vmDirHint: 'Leave empty to use the data folder',
|
||||
sourceApple: 'Download recovery image from Apple',
|
||||
sourceInstaller: 'Local installer image (.img / .dmg)',
|
||||
sourceDisk: 'Existing virtual disk (.qcow2)',
|
||||
macosVersion: 'macOS version',
|
||||
macosTahoe: 'macOS 26 Tahoe (acceleration needs 26.4 or later)',
|
||||
diskSize: 'Disk size',
|
||||
diskSizeHint: 'Grows with use; 128G recommended',
|
||||
diskMode: 'Use disk as',
|
||||
diskModeCopy: 'A copy — original untouched',
|
||||
diskModeInPlace: 'In place',
|
||||
hostThreads: 'Host has {n} threads',
|
||||
hostMemory: 'Host has {n} GB',
|
||||
cpuHint: '4 or 8 cores recommended',
|
||||
memHint: 'Keep under 75% of host memory',
|
||||
graphicsBackend: 'Graphics backend',
|
||||
graphicsReims: 'reims-vgpu (accelerated, recommended)',
|
||||
graphicsSvga: 'vmware-svga (no acceleration, for troubleshooting)',
|
||||
gpuSelect: 'Host GPU',
|
||||
gpuAutoOption: 'Automatic (prefers discrete)',
|
||||
resolution: 'Resolution',
|
||||
displays: 'Displays',
|
||||
borderless: 'Borderless full screen',
|
||||
enableAudio: 'Audio',
|
||||
enableNetwork: 'Network (NAT)',
|
||||
sshPort: 'SSH forward port',
|
||||
sshPortHint: '0 turns it off',
|
||||
enableLogs: 'Keep graphics and serial logs',
|
||||
startAfterCreate: 'Start after creating',
|
||||
commandPreview: 'Command to run',
|
||||
validationPassed: 'All checks passed',
|
||||
createNow: 'Create',
|
||||
creating: 'Creating — progress is in the status bar',
|
||||
|
||||
settingsTitle: '{name} settings',
|
||||
appliesNextStart: 'Applies on next start',
|
||||
requiresStop: 'Some changes need the VM shut down',
|
||||
catPlatform: 'Platform',
|
||||
catCPU: 'CPU',
|
||||
catMemory: 'Memory',
|
||||
catStorage: 'Storage',
|
||||
catNetwork: 'Network',
|
||||
catGraphics: 'Graphics & displays',
|
||||
catAudio: 'Audio',
|
||||
catInput: 'Keyboard & pointer',
|
||||
catLogs: 'Serial & logs',
|
||||
catAdvanced: 'Advanced',
|
||||
platformReadonly: 'Model, serial number and other platform identity are never shown',
|
||||
opencore: 'OpenCore',
|
||||
configured: 'Configured',
|
||||
diskController: 'Disk controller',
|
||||
diskControllerWarn: 'Eject the installer before switching',
|
||||
captureInput: 'Capture keyboard and mouse on click',
|
||||
stopTimeout: 'Shutdown timeout (seconds)',
|
||||
stopTimeoutHint: '0 waits indefinitely',
|
||||
extraArgs: 'Extra QEMU arguments',
|
||||
logLevel: 'Log level (REIMS_VGPU_LOG)',
|
||||
},
|
||||
} as const
|
||||
|
||||
export type I18nKey = keyof (typeof dict)['zh-CN']
|
||||
|
||||
export function t(locale: Locale, key: I18nKey, vars?: Record<string, string | number>): string {
|
||||
const table = dict[locale] ?? dict['zh-CN']
|
||||
let s: string = table[key] ?? dict['en-US'][key] ?? key
|
||||
if (vars) {
|
||||
for (const [k, v] of Object.entries(vars)) {
|
||||
s = s.replace(`{${k}}`, String(v))
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { t } from '../i18n'
|
||||
import { GPUInfo, HostReport, Locale, VMDetail } from '../types'
|
||||
|
||||
// Human-readable values for the main view (docs/ui-redesign.md §4.3).
|
||||
// Raw values stay available under "Technical details".
|
||||
|
||||
/** "16G" / "16384M" / "16GiB" → "16 GB". Unknown shapes pass through. */
|
||||
export function formatMemory(raw: string): string {
|
||||
const m = /^\s*(\d+(?:\.\d+)?)\s*([KMGT])?(?:i?B)?\s*$/i.exec(raw ?? '')
|
||||
if (!m) return raw
|
||||
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
|
||||
const rounded = gb >= 10 ? Math.round(gb) : Math.round(gb * 10) / 10
|
||||
return `${rounded} GB`
|
||||
}
|
||||
|
||||
export function controllerLabel(raw: string): string {
|
||||
switch ((raw ?? '').toLowerCase()) {
|
||||
case 'ahci': case 'sata': return 'SATA'
|
||||
case 'nvme': return 'NVMe'
|
||||
case 'virtio': return 'VirtIO'
|
||||
default: return raw ? raw.toUpperCase() : '—'
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
/** Drop vendor boilerplate: "NVIDIA GeForce RTX 4070 Ti" → "RTX 4070 Ti". */
|
||||
export function shortGPUName(name: string): string {
|
||||
return name
|
||||
.replace(/^NVIDIA\s+(GeForce\s+)?/i, '')
|
||||
.replace(/^AMD\s+(Radeon\s+)?(?=RX|Pro)/i, 'Radeon ')
|
||||
.replace(/^Intel\(R\)\s+/i, 'Intel ')
|
||||
.trim()
|
||||
}
|
||||
|
||||
/** "1920x1080" → "1080p"; non-16:9 sizes keep "W×H". */
|
||||
export function resolutionLabel(raw: string): string {
|
||||
const m = /^(\d+)\s*[x×]\s*(\d+)$/i.exec(raw ?? '')
|
||||
if (!m) return raw
|
||||
const w = Number(m[1]), h = Number(m[2])
|
||||
return Math.abs(w / h - 16 / 9) < 0.01 ? `${h}p` : `${w}×${h}`
|
||||
}
|
||||
|
||||
export function graphicsLabel(locale: Locale, d: VMDetail, host: HostReport): string {
|
||||
if (d.graphics && d.graphics !== 'reims-vgpu') return t(locale, 'softwareGraphics')
|
||||
let gpu: string
|
||||
if (!d.gpu || d.gpu === 'auto') {
|
||||
gpu = host.recommended_gpu ? shortGPUName(host.recommended_gpu.name) : t(locale, 'gpuAuto')
|
||||
} else {
|
||||
const found = findGPU(host, d.gpu)
|
||||
gpu = found ? shortGPUName(found.name) : t(locale, 'gpuAuto')
|
||||
}
|
||||
const res = resolutionLabel(d.resolution)
|
||||
const screens = d.displays > 1 ? `${d.displays} × ${res}` : res
|
||||
return res ? `${gpu} · ${screens}` : gpu
|
||||
}
|
||||
|
||||
export function sshCommand(port: number): string {
|
||||
return `ssh -p ${port} 127.0.0.1`
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { LogEntry } from '../types'
|
||||
|
||||
export type LogLevel = 'info' | 'warn' | 'error'
|
||||
|
||||
export interface LogLine extends LogEntry {
|
||||
id: number
|
||||
level: LogLevel
|
||||
/** Set on progress lines ("… 45% of 11 MB"); lines with the same key collapse into one. */
|
||||
progressKey?: string
|
||||
percent?: number
|
||||
}
|
||||
|
||||
export const MAX_LOG_LINES = 2000
|
||||
|
||||
// Upstream reims-ctl prints download progress as "<label>: N% of <size>" — one
|
||||
// line per percent. The exact source line upstream is unverified
|
||||
// (docs/ui-redesign.md §6 B1); until structured task events exist, collapse
|
||||
// those lines client-side.
|
||||
const PROGRESS_RE = /^(.*?)[:\s]\s*(\d{1,3}(?:\.\d+)?)%\s+of\s+.+$/i
|
||||
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 line: LogLine = { ...entry, id: nextId++, level: 'info' }
|
||||
if (ERROR_RE.test(entry.line)) line.level = 'error'
|
||||
else if (WARN_RE.test(entry.line)) line.level = 'warn'
|
||||
const m = PROGRESS_RE.exec(entry.line)
|
||||
if (m) {
|
||||
line.progressKey = `${entry.source}|${m[1].trim()}`
|
||||
line.percent = Math.min(100, Number(m[2]))
|
||||
}
|
||||
return line
|
||||
}
|
||||
|
||||
/** Append, collapsing consecutive progress lines for the same task into one. */
|
||||
export function appendLog(prev: LogLine[], entry: LogEntry): LogLine[] {
|
||||
const line = classify(entry)
|
||||
const last = prev[prev.length - 1]
|
||||
if (line.progressKey && last?.progressKey === line.progressKey) {
|
||||
return [...prev.slice(0, -1), { ...line, id: last.id }]
|
||||
}
|
||||
const next = [...prev, line]
|
||||
return next.length > MAX_LOG_LINES ? next.slice(next.length - MAX_LOG_LINES) : next
|
||||
}
|
||||
|
||||
/** The task in flight, if the newest line is unfinished progress. */
|
||||
export function activeProgress(lines: LogLine[]): { label: string; percent: number; source: string } | null {
|
||||
const last = lines[lines.length - 1]
|
||||
if (!last?.progressKey || last.percent === undefined || last.percent >= 100) return null
|
||||
const label = last.progressKey.slice(last.progressKey.indexOf('|') + 1)
|
||||
// Drop a leading "<vm>:" that duplicates the source.
|
||||
const clean = label.startsWith(`${last.source}:`) ? label.slice(last.source.length + 1).trim() : label
|
||||
return { label: clean, percent: last.percent, source: last.source }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import { App } from './App'
|
||||
import './styles/app.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
)
|
||||
@@ -0,0 +1,336 @@
|
||||
@import "./tokens.css";
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body, #root {
|
||||
margin: 0; padding: 0; height: 100%; overflow: hidden;
|
||||
background: var(--surface-0); color: var(--text);
|
||||
font-family: var(--font-sans); font-size: var(--fs-14); line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
button { font: inherit; color: inherit; }
|
||||
h1, h2, h3, p { margin: 0; }
|
||||
|
||||
:focus { outline: none; }
|
||||
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-md); }
|
||||
|
||||
::-webkit-scrollbar { width: 8px; height: 8px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb { background: var(--surface-active); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
|
||||
::-webkit-scrollbar-thumb:hover { background-color: var(--border-strong); }
|
||||
|
||||
.mono { font-family: var(--font-mono); font-size: var(--fs-12); }
|
||||
.muted { color: var(--text-3); }
|
||||
.selectable { user-select: text; }
|
||||
.hstack { display: flex; align-items: center; gap: var(--sp-2); }
|
||||
.spacer { flex: 1; }
|
||||
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
.spin { animation: spin 0.9s linear infinite; }
|
||||
@keyframes pulse { 50% { opacity: 0.35; } }
|
||||
|
||||
/* ── Shell ─────────────────────────────────────────────── */
|
||||
.app-shell { display: flex; flex-direction: column; height: 100%; border: 1px solid var(--border); }
|
||||
|
||||
.titlebar {
|
||||
height: var(--titlebar-h); flex-shrink: 0;
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding-left: var(--sp-4);
|
||||
background: var(--surface-chrome); border-bottom: 1px solid var(--border);
|
||||
user-select: none; --wails-draggable: drag;
|
||||
}
|
||||
.brand { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); font-weight: var(--fw-strong); }
|
||||
.brand-mark {
|
||||
width: 18px; height: 18px; border-radius: var(--r-sm);
|
||||
background: var(--accent); color: var(--accent-text);
|
||||
display: grid; place-items: center; font-size: var(--fs-12); font-weight: var(--fw-strong);
|
||||
}
|
||||
.win-controls { display: flex; height: 100%; --wails-draggable: no-drag; }
|
||||
.win-btn {
|
||||
width: 46px; height: 100%; border: none; background: transparent; color: var(--text-2);
|
||||
display: grid; place-items: center; cursor: pointer; transition: background var(--dur-fast);
|
||||
}
|
||||
.win-btn:hover { background: var(--surface-hover); color: var(--text); }
|
||||
.win-btn.close:hover { background: #c42b1c; color: #fff; }
|
||||
.win-btn:focus-visible { border-radius: 0; }
|
||||
|
||||
.workspace { display: flex; flex: 1; min-height: 0; }
|
||||
|
||||
/* ── Sidebar ───────────────────────────────────────────── */
|
||||
.sidebar {
|
||||
width: var(--sidebar-w); flex-shrink: 0;
|
||||
display: flex; flex-direction: column; gap: var(--sp-1);
|
||||
padding: var(--sp-2); overflow-y: auto;
|
||||
background: var(--surface-sidebar); border-right: 1px solid var(--border);
|
||||
}
|
||||
.sidebar-head {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: var(--sp-2) var(--sp-1) var(--sp-1) var(--sp-2);
|
||||
font-size: var(--fs-12); font-weight: var(--fw-strong); color: var(--text-3);
|
||||
}
|
||||
.sidebar-sep { height: 1px; background: var(--border); margin: var(--sp-2); }
|
||||
.nav { display: flex; flex-direction: column; gap: 2px; }
|
||||
.nav-empty { padding: var(--sp-1) var(--sp-2); font-size: var(--fs-13); color: var(--text-3); }
|
||||
.nav-item {
|
||||
width: 100%; height: 34px; padding: 0 var(--sp-2);
|
||||
display: flex; align-items: center; gap: var(--sp-2);
|
||||
border: none; border-radius: var(--r-md); background: transparent; color: var(--text-2);
|
||||
text-align: left; cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast);
|
||||
}
|
||||
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
|
||||
.nav-item[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
|
||||
.nav-item[aria-selected="true"] > svg { color: var(--accent-soft-text); }
|
||||
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-13); }
|
||||
|
||||
/* Status shapes: shape + colour, never colour alone */
|
||||
.status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
|
||||
.status-running { background: var(--status-running); }
|
||||
.status-stopped { border: 1.5px solid var(--status-idle); }
|
||||
.status-busy { background: conic-gradient(var(--status-busy) 0 50%, transparent 50% 100%); border: 1.5px solid var(--status-busy); animation: pulse 1.4s ease-in-out infinite; }
|
||||
.status-warn { background: var(--status-busy); }
|
||||
.status-broken { background: var(--status-error); border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; }
|
||||
|
||||
/* ── Main column ───────────────────────────────────────── */
|
||||
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
||||
.scroll { flex: 1; overflow-y: auto; padding: var(--sp-6) var(--sp-8); }
|
||||
.page { max-width: var(--page-max); margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-6); }
|
||||
|
||||
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); min-height: 32px; }
|
||||
.page-title { display: flex; align-items: baseline; gap: var(--sp-3); min-width: 0; }
|
||||
.page-title h1 { font-size: var(--fs-20); font-weight: var(--fw-strong); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.state-text { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); color: var(--text-2); white-space: nowrap; }
|
||||
.actions { display: flex; align-items: center; gap: var(--sp-1); flex-shrink: 0; }
|
||||
.actions .btn + .icon-btn, .actions .btn + .btn { margin-left: var(--sp-1); }
|
||||
|
||||
.section { display: flex; flex-direction: column; gap: var(--sp-2); }
|
||||
.section-title { font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 28px; }
|
||||
|
||||
/* ── Buttons ───────────────────────────────────────────── */
|
||||
.btn {
|
||||
height: 30px; padding: 0 var(--sp-3);
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
|
||||
border-radius: var(--r-md); border: 1px solid var(--border-strong);
|
||||
background: var(--surface-1); color: var(--text);
|
||||
font-size: var(--fs-13); font-weight: var(--fw-regular); white-space: nowrap; flex-shrink: 0;
|
||||
cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast);
|
||||
}
|
||||
.btn:hover:not(:disabled) { background: var(--surface-hover); }
|
||||
.btn:disabled { opacity: 0.45; cursor: default; }
|
||||
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-text); font-weight: var(--fw-strong); }
|
||||
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
|
||||
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; font-weight: var(--fw-strong); }
|
||||
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); background: var(--danger); }
|
||||
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
|
||||
.btn-ghost:hover:not(:disabled) { color: var(--text); }
|
||||
|
||||
.icon-btn {
|
||||
width: 30px; height: 30px; flex-shrink: 0;
|
||||
display: inline-grid; place-items: center;
|
||||
border: none; border-radius: var(--r-md); background: transparent; color: var(--text-2);
|
||||
cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast);
|
||||
}
|
||||
.icon-btn:hover:not(:disabled), .icon-btn[data-state="open"] { background: var(--surface-hover); color: var(--text); }
|
||||
.icon-btn:disabled { opacity: 0.4; cursor: default; }
|
||||
.icon-btn.sm { width: 26px; height: 26px; }
|
||||
|
||||
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-md); background: var(--surface-input); border: 1px solid var(--border); }
|
||||
.segmented button { height: 24px; padding: 0 var(--sp-3); border: none; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: var(--fs-13); cursor: pointer; }
|
||||
.segmented button[aria-pressed="true"] { background: var(--surface-active); color: var(--text); font-weight: var(--fw-strong); }
|
||||
|
||||
/* ── Cards & notices ───────────────────────────────────── */
|
||||
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
|
||||
.card-title { font-size: var(--fs-14); font-weight: var(--fw-strong); }
|
||||
.card-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); }
|
||||
|
||||
.notice {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
|
||||
padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
|
||||
border-radius: var(--r-lg); background: var(--notice-soft); border: 1px solid var(--notice-border);
|
||||
font-size: var(--fs-13);
|
||||
}
|
||||
.notice-error { background: var(--danger-soft); border-color: rgba(240, 98, 90, 0.3); color: #ff9c95; padding: var(--sp-2) var(--sp-4); }
|
||||
.notice-error ul { margin: 0; padding-left: var(--sp-4); }
|
||||
|
||||
.steps { margin: 0; padding-left: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-1); color: var(--text-2); font-size: var(--fs-13); }
|
||||
|
||||
/* ── Facts row (icon + value) ──────────────────────────── */
|
||||
.facts { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); }
|
||||
.fact { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-14); color: var(--text); border-radius: var(--r-sm); }
|
||||
.fact > svg { color: var(--text-3); }
|
||||
|
||||
.cmd-line {
|
||||
display: flex; align-items: center; gap: var(--sp-3);
|
||||
padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3);
|
||||
border-radius: var(--r-lg); background: var(--surface-input); border: 1px solid var(--border);
|
||||
}
|
||||
.cmd-line > svg { color: var(--text-3); }
|
||||
.cmd-line code { flex: 1; font-family: var(--font-mono); font-size: var(--fs-13); color: var(--text-code); user-select: text; }
|
||||
|
||||
/* ── Disclosure: technical details ─────────────────────── */
|
||||
.tech > summary {
|
||||
list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--sp-1);
|
||||
font-size: var(--fs-13); color: var(--text-2); border-radius: var(--r-sm);
|
||||
}
|
||||
.tech > summary::-webkit-details-marker { display: none; }
|
||||
.tech > summary svg { transition: transform var(--dur-fast); }
|
||||
.tech[open] > summary svg { transform: rotate(90deg); }
|
||||
.tech > summary:hover { color: var(--text); }
|
||||
.kv-list { margin: var(--sp-3) 0 0; display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-6); font-size: var(--fs-13); }
|
||||
.kv-list dt { color: var(--text-3); }
|
||||
.kv-list dd { margin: 0; color: var(--text-2); word-break: break-all; user-select: text; }
|
||||
|
||||
/* ── Grouped list (host page, settings) ────────────────── */
|
||||
.list { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
|
||||
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) var(--sp-4); position: relative; }
|
||||
.row + .row::before { content: ""; position: absolute; top: 0; left: var(--sp-4); right: var(--sp-4); height: 1px; background: var(--border); }
|
||||
.row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
|
||||
.row-title { font-size: var(--fs-14); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
|
||||
.row-sub { font-size: var(--fs-12); color: var(--text-3); word-break: break-all; }
|
||||
.row-right { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
|
||||
|
||||
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-12); white-space: nowrap; background: var(--surface-active); color: var(--text-2); }
|
||||
.badge-accent { background: var(--accent-soft); color: var(--accent-soft-text); }
|
||||
.badge-ok { background: rgba(63, 185, 80, 0.15); color: var(--status-running); }
|
||||
.badge-warn { background: rgba(212, 167, 44, 0.15); color: var(--status-busy); }
|
||||
.badge-error { background: var(--danger); color: #fff; min-width: 18px; height: 18px; padding: 0 var(--sp-1); justify-content: center; border-radius: 999px; }
|
||||
|
||||
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-3); }
|
||||
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
|
||||
.tile-head { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-12); color: var(--text-3); }
|
||||
.tile-value { font-size: var(--fs-16); font-weight: var(--fw-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.tile-value.ok { color: var(--status-running); }
|
||||
.tile-value.warn { color: var(--status-busy); }
|
||||
.tile-sub { font-size: var(--fs-12); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
|
||||
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; cursor: pointer; }
|
||||
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
|
||||
.slider { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-active); border: 1px solid var(--border-strong); transition: background var(--dur); pointer-events: none; }
|
||||
.slider::before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur), background var(--dur); }
|
||||
.switch input:checked + .slider { background: var(--accent); border-color: transparent; }
|
||||
.switch input:checked + .slider::before { transform: translateX(16px); background: #fff; }
|
||||
.switch input:focus-visible + .slider { box-shadow: var(--focus-ring); }
|
||||
|
||||
/* ── Log bar & panel ───────────────────────────────────── */
|
||||
.logs { flex-shrink: 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); background: var(--surface-chrome); }
|
||||
.logbar { height: var(--logbar-h); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-2) 0 var(--sp-3); }
|
||||
.tabs { display: flex; gap: 2px; }
|
||||
.tab { height: 24px; padding: 0 var(--sp-2); border: none; border-radius: var(--r-sm); background: transparent; color: var(--text-3); font-size: var(--fs-12); cursor: pointer; }
|
||||
.tab:hover { color: var(--text); }
|
||||
.tab[aria-selected="true"] { background: var(--surface-active); color: var(--text); }
|
||||
.task { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-12); color: var(--text-2); }
|
||||
.task-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.progress { width: 96px; height: 4px; border-radius: 999px; background: var(--surface-active); overflow: hidden; flex-shrink: 0; }
|
||||
.progress > div { height: 100%; background: var(--accent); transition: width var(--dur); }
|
||||
.logs-body-wrap { position: relative; border-top: 1px solid var(--border); }
|
||||
.logs-body {
|
||||
height: 220px; overflow-y: auto; padding: var(--sp-2) var(--sp-4);
|
||||
font-family: var(--font-mono); font-size: var(--fs-12); line-height: 1.6; color: var(--text-code);
|
||||
white-space: pre-wrap; word-break: break-word; user-select: text;
|
||||
}
|
||||
.log-line { display: flex; gap: var(--sp-3); }
|
||||
.log-ts { color: var(--text-3); flex-shrink: 0; }
|
||||
.log-src { color: var(--accent-soft-text); flex-shrink: 0; }
|
||||
.log-line.warn .log-msg { color: var(--status-busy); }
|
||||
.log-line.error .log-msg { color: var(--status-error); }
|
||||
.jump-latest { position: absolute; right: var(--sp-4); bottom: var(--sp-3); }
|
||||
|
||||
/* ── Overlays: dialog, menu, tooltip, toast ────────────── */
|
||||
.overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
|
||||
.dialog {
|
||||
position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%);
|
||||
width: 720px; max-width: calc(100vw - 48px); max-height: calc(100vh - 80px);
|
||||
display: flex; flex-direction: column; overflow: hidden;
|
||||
background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
|
||||
box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.dialog.sm { width: 420px; }
|
||||
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-6); border-bottom: 1px solid var(--border); }
|
||||
.dialog-title { font-size: var(--fs-16); font-weight: var(--fw-strong); }
|
||||
.dialog-desc { font-size: var(--fs-13); color: var(--text-2); }
|
||||
.dialog-body { padding: var(--sp-6); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--sp-4); }
|
||||
.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) var(--sp-6); border-top: 1px solid var(--border); }
|
||||
.dialog.sm .dialog-body { padding: var(--sp-6) var(--sp-6) var(--sp-4); gap: var(--sp-3); }
|
||||
.dialog.sm .dialog-foot { border-top: none; justify-content: flex-end; padding-top: 0; padding-bottom: var(--sp-6); }
|
||||
|
||||
.menu {
|
||||
min-width: 180px; padding: var(--sp-1); z-index: 50;
|
||||
background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
.menu-item {
|
||||
height: 30px; padding: 0 var(--sp-2); display: flex; align-items: center; gap: var(--sp-2);
|
||||
border-radius: var(--r-sm); font-size: var(--fs-13); cursor: pointer; user-select: none; outline: none;
|
||||
}
|
||||
.menu-item > svg { color: var(--text-3); }
|
||||
.menu-item[data-highlighted] { background: var(--accent); color: var(--accent-text); }
|
||||
.menu-item[data-highlighted] > svg { color: var(--accent-text); }
|
||||
.menu-item[data-disabled] { opacity: 0.4; cursor: default; }
|
||||
.menu-item.danger { color: var(--danger); }
|
||||
.menu-item.danger > svg { color: var(--danger); }
|
||||
.menu-item.danger[data-highlighted] { background: var(--danger); color: #fff; }
|
||||
.menu-item.danger[data-highlighted] > svg { color: #fff; }
|
||||
.menu-sep { height: 1px; margin: var(--sp-1) var(--sp-2); background: var(--border); }
|
||||
|
||||
.tooltip {
|
||||
z-index: 60; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm);
|
||||
background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
|
||||
font-size: var(--fs-12); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
|
||||
display: flex; gap: var(--sp-2); align-items: center;
|
||||
}
|
||||
.tooltip kbd { font-family: var(--font-sans); color: var(--text-3); }
|
||||
|
||||
.toast-viewport { position: fixed; right: var(--sp-4); bottom: calc(var(--logbar-h) + var(--sp-4)); z-index: 70; display: flex; flex-direction: column; gap: var(--sp-2); width: 340px; max-width: calc(100vw - 32px); margin: 0; padding: 0; list-style: none; outline: none; }
|
||||
.toast {
|
||||
display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3);
|
||||
background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
.toast > svg { margin-top: 2px; flex-shrink: 0; }
|
||||
.toast.ok > svg { color: var(--status-running); }
|
||||
.toast.error > svg { color: var(--status-error); }
|
||||
.toast-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.toast-title { font-size: var(--fs-13); font-weight: var(--fw-strong); }
|
||||
.toast-desc { font-size: var(--fs-12); color: var(--text-2); word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.toast .btn { height: 26px; }
|
||||
|
||||
/* ── Forms (wizard, settings) ──────────────────────────── */
|
||||
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
|
||||
.field-label { font-size: var(--fs-13); color: var(--text-2); }
|
||||
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
|
||||
.input, .select {
|
||||
width: 100%; height: 32px; padding: 0 var(--sp-3);
|
||||
border-radius: var(--r-md); border: 1px solid var(--border-strong);
|
||||
background: var(--surface-input); color: var(--text); font: inherit; font-size: var(--fs-13);
|
||||
}
|
||||
.input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
|
||||
.input[readonly] { color: var(--text-2); }
|
||||
.input.mono { font-family: var(--font-mono); font-size: var(--fs-12); }
|
||||
.input-group { display: flex; gap: var(--sp-2); align-items: center; }
|
||||
.hint { font-size: var(--fs-12); color: var(--text-3); }
|
||||
.hint.warn { color: var(--status-busy); }
|
||||
.choices { display: flex; flex-direction: column; gap: var(--sp-2); }
|
||||
.choice { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); cursor: pointer; }
|
||||
.choice input { accent-color: var(--accent); margin: 0; }
|
||||
.presets { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
|
||||
.preset {
|
||||
height: 28px; padding: 0 var(--sp-3); border-radius: var(--r-md);
|
||||
border: 1px solid var(--border-strong); background: transparent; color: var(--text-2);
|
||||
font-size: var(--fs-13); cursor: pointer;
|
||||
}
|
||||
.preset:hover { background: var(--surface-hover); color: var(--text); }
|
||||
.preset[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: var(--accent-text); }
|
||||
|
||||
.wizard-steps { display: flex; gap: var(--sp-1); padding: var(--sp-2) var(--sp-6); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
|
||||
.wizard-step { height: 26px; padding: 0 var(--sp-2); border: none; border-radius: var(--r-sm); background: transparent; color: var(--text-3); font-size: var(--fs-12); cursor: pointer; display: inline-flex; align-items: center; gap: var(--sp-1); }
|
||||
.wizard-step[aria-current="step"] { background: var(--accent-soft); color: var(--accent-soft-text); font-weight: var(--fw-strong); }
|
||||
.wizard-step.done { color: var(--text-2); }
|
||||
.wizard-step.done svg { color: var(--status-running); }
|
||||
|
||||
.settings-split { display: flex; height: 460px; min-height: 0; }
|
||||
.settings-nav { width: 180px; flex-shrink: 0; padding: var(--sp-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
|
||||
.settings-pane { flex: 1; padding: var(--sp-6); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-4); }
|
||||
|
||||
.code { padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-input); border: 1px solid var(--border); font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-code); word-break: break-all; user-select: text; }
|
||||
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
|
||||
.fieldset legend { padding: 0; margin-bottom: var(--sp-2); }
|
||||
@@ -0,0 +1,85 @@
|
||||
/* Design tokens. Components reference these only — no raw colours, sizes or
|
||||
spacing in component CSS or inline styles. See docs/ui-redesign.md §4.1. */
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
|
||||
/* Type */
|
||||
--font-sans: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
|
||||
--font-mono: "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
|
||||
--fs-12: 12px; /* captions, badges, log text */
|
||||
--fs-13: 13px; /* secondary text, controls */
|
||||
--fs-14: 14px; /* body */
|
||||
--fs-16: 16px; /* subtitles */
|
||||
--fs-20: 20px; /* page titles */
|
||||
--fs-24: 24px; /* empty-state titles */
|
||||
--fw-regular: 400;
|
||||
--fw-strong: 600;
|
||||
|
||||
/* Spacing (4px grid) */
|
||||
--sp-1: 4px;
|
||||
--sp-2: 8px;
|
||||
--sp-3: 12px;
|
||||
--sp-4: 16px;
|
||||
--sp-6: 24px;
|
||||
--sp-8: 32px;
|
||||
|
||||
/* Radius */
|
||||
--r-sm: 4px;
|
||||
--r-md: 6px;
|
||||
--r-lg: 8px;
|
||||
--r-xl: 12px;
|
||||
|
||||
/* Surfaces */
|
||||
--surface-0: #1c1c1f; /* window */
|
||||
--surface-sidebar: #171719;
|
||||
--surface-chrome: #141416; /* title bar, log bar */
|
||||
--surface-1: rgba(255, 255, 255, 0.04); /* cards */
|
||||
--surface-2: #26262b; /* menus, dialogs, tooltips */
|
||||
--surface-input: rgba(0, 0, 0, 0.25);
|
||||
--surface-hover: rgba(255, 255, 255, 0.06);
|
||||
--surface-active: rgba(255, 255, 255, 0.10);
|
||||
--border: rgba(255, 255, 255, 0.08);
|
||||
--border-strong: rgba(255, 255, 255, 0.14);
|
||||
--scrim: rgba(0, 0, 0, 0.55);
|
||||
|
||||
/* Text */
|
||||
--text: #f2f2f4;
|
||||
--text-2: #a8a8b0;
|
||||
--text-3: #74747e;
|
||||
--text-code: #c9ccd6;
|
||||
|
||||
/* Semantics */
|
||||
--accent: #3b8cf6;
|
||||
--accent-hover: #5299f7;
|
||||
--accent-text: #ffffff;
|
||||
--accent-soft: rgba(59, 140, 246, 0.18);
|
||||
--accent-soft-text: #8dbcfb;
|
||||
--focus-ring: 0 0 0 2px rgba(59, 140, 246, 0.55);
|
||||
|
||||
--status-running: #3fb950;
|
||||
--status-busy: #d4a72c;
|
||||
--status-error: #f0625a;
|
||||
--status-idle: #74747e;
|
||||
|
||||
--danger: #f0625a;
|
||||
--danger-soft: rgba(240, 98, 90, 0.14);
|
||||
--notice-soft: rgba(212, 167, 44, 0.10);
|
||||
--notice-border: rgba(212, 167, 44, 0.32);
|
||||
|
||||
/* Motion */
|
||||
--dur-fast: 120ms;
|
||||
--dur: 200ms;
|
||||
|
||||
/* Layout */
|
||||
--titlebar-h: 40px;
|
||||
--logbar-h: 32px;
|
||||
--sidebar-w: 232px;
|
||||
--page-max: 960px;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
:root {
|
||||
--dur-fast: 0ms;
|
||||
--dur: 0ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
export type Locale = 'zh-CN' | 'en-US'
|
||||
|
||||
export interface Config {
|
||||
data_root: string
|
||||
locale: Locale
|
||||
active_runtime?: string
|
||||
auto_pin_pcores: boolean
|
||||
default_gpu?: string
|
||||
}
|
||||
|
||||
export interface GPUInfo {
|
||||
name: string
|
||||
vulkan_icd: string
|
||||
kind: 'discrete' | 'integrated' | 'virtual' | 'unknown'
|
||||
}
|
||||
|
||||
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[]
|
||||
total_ram_gb: number
|
||||
avail_ram_gb: number
|
||||
data_root: string
|
||||
free_disk_gb: number
|
||||
whpx: 'ready' | 'no_hypervisor' | 'missing' | 'unsupported'
|
||||
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 interface InstalledRuntime {
|
||||
commit: string
|
||||
dir: string
|
||||
active: boolean
|
||||
manifest: RuntimeManifest
|
||||
}
|
||||
|
||||
export interface VMListItem {
|
||||
name: string
|
||||
dir: string
|
||||
pid: number | null
|
||||
state: 'running' | 'stopped' | 'broken'
|
||||
}
|
||||
|
||||
export interface PendingChange {
|
||||
field: string
|
||||
from: string
|
||||
to: string
|
||||
}
|
||||
|
||||
export interface AppState {
|
||||
config: Config
|
||||
host: HostReport
|
||||
runtimes: InstalledRuntime[] | null
|
||||
active_runtime?: InstalledRuntime
|
||||
vms: VMListItem[] | null
|
||||
transitions: Record<string, string>
|
||||
pending_changes: Record<string, PendingChange[]>
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
export interface ValidationIssue {
|
||||
field: string
|
||||
code: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface CreateOpts {
|
||||
name: string
|
||||
dir?: string
|
||||
source_mode?: 'apple' | 'installer' | 'disk'
|
||||
macos?: string
|
||||
installer?: string
|
||||
cpus: number
|
||||
memory: string
|
||||
disk_size?: string
|
||||
disk?: string
|
||||
disk_mode?: 'copy' | 'in-place'
|
||||
graphics: 'reims-vgpu' | 'vmware-svga'
|
||||
gpu: string
|
||||
resolution: string
|
||||
displays: number
|
||||
borderless?: 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 interface LogEntry {
|
||||
ts: string
|
||||
source: string
|
||||
line: string
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import * as RTooltip from '@radix-ui/react-tooltip'
|
||||
import { LoaderCircle } from 'lucide-react'
|
||||
import React from 'react'
|
||||
|
||||
export const TooltipProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
||||
<RTooltip.Provider delayDuration={400} skipDelayDuration={200}>{children}</RTooltip.Provider>
|
||||
)
|
||||
|
||||
interface TipProps {
|
||||
label: string
|
||||
shortcut?: string
|
||||
side?: 'top' | 'bottom' | 'left' | 'right'
|
||||
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>
|
||||
)
|
||||
|
||||
type ButtonVariant = 'secondary' | 'primary' | 'danger' | 'ghost'
|
||||
|
||||
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: ButtonVariant
|
||||
busy?: boolean
|
||||
icon?: React.ReactNode
|
||||
}
|
||||
|
||||
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ variant = 'secondary', busy, icon, children, disabled, className, ...rest }, ref) => (
|
||||
<button
|
||||
ref={ref}
|
||||
type="button"
|
||||
className={`btn${variant === 'secondary' ? '' : ` btn-${variant}`}${className ? ` ${className}` : ''}`}
|
||||
disabled={disabled || busy}
|
||||
aria-busy={busy || undefined}
|
||||
{...rest}
|
||||
>
|
||||
{busy ? <LoaderCircle size={14} className="spin" /> : icon}
|
||||
{children}
|
||||
</button>
|
||||
),
|
||||
)
|
||||
Button.displayName = 'Button'
|
||||
|
||||
interface IconButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
||||
label: string
|
||||
shortcut?: string
|
||||
icon: React.ReactNode
|
||||
busy?: boolean
|
||||
small?: boolean
|
||||
tipSide?: TipProps['side']
|
||||
}
|
||||
|
||||
/** Icon-only button: always carries a tooltip and an accessible name (§4.5). */
|
||||
export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
||||
({ label, shortcut, icon, busy, small, disabled, className, tipSide, ...rest }, ref) => (
|
||||
<Tip label={label} shortcut={shortcut} side={tipSide}>
|
||||
<button
|
||||
ref={ref}
|
||||
type="button"
|
||||
aria-label={label}
|
||||
className={`icon-btn${small ? ' sm' : ''}${className ? ` ${className}` : ''}`}
|
||||
disabled={disabled || busy}
|
||||
aria-busy={busy || undefined}
|
||||
{...rest}
|
||||
>
|
||||
{busy ? <LoaderCircle size={16} className="spin" /> : icon}
|
||||
</button>
|
||||
</Tip>
|
||||
),
|
||||
)
|
||||
IconButton.displayName = 'IconButton'
|
||||
|
||||
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 === 'broken') return 'broken'
|
||||
return 'stopped'
|
||||
}
|
||||
|
||||
/** Status shape: differs by shape as well as colour. */
|
||||
export const StatusShape: React.FC<{ kind: StatusKind }> = ({ kind }) => (
|
||||
<span className={`status status-${kind}`} aria-hidden="true" />
|
||||
)
|
||||
@@ -0,0 +1,43 @@
|
||||
import * as RDialog from '@radix-ui/react-dialog'
|
||||
import { X } from 'lucide-react'
|
||||
import React from 'react'
|
||||
import { IconButton } from './controls'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
subtitle?: string
|
||||
closeLabel: string
|
||||
/** While false, Esc / outside click / ✕ are ignored (e.g. during a create). */
|
||||
dismissable?: boolean
|
||||
onClose: () => void
|
||||
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 }) => (
|
||||
<RDialog.Root open onOpenChange={(open) => { if (!open && dismissable) onClose() }}>
|
||||
<RDialog.Portal>
|
||||
<RDialog.Overlay className="overlay" />
|
||||
<RDialog.Content
|
||||
className="dialog"
|
||||
onInteractOutside={(e) => e.preventDefault()}
|
||||
// Focus the first form field rather than ✕, so the close tooltip doesn't pop on open.
|
||||
onOpenAutoFocus={(e) => {
|
||||
const first = (e.currentTarget as HTMLElement | null)?.querySelector<HTMLElement>('input, select, textarea')
|
||||
if (first) { e.preventDefault(); first.focus() }
|
||||
}}
|
||||
>
|
||||
<div className="dialog-head">
|
||||
<div>
|
||||
<RDialog.Title className="dialog-title">{title}</RDialog.Title>
|
||||
{subtitle ? <RDialog.Description className="dialog-desc">{subtitle}</RDialog.Description> : <RDialog.Description />}
|
||||
</div>
|
||||
<RDialog.Close asChild>
|
||||
<IconButton label={closeLabel} icon={<X size={16} />} disabled={!dismissable} />
|
||||
</RDialog.Close>
|
||||
</div>
|
||||
{children}
|
||||
</RDialog.Content>
|
||||
</RDialog.Portal>
|
||||
</RDialog.Root>
|
||||
)
|
||||
@@ -0,0 +1,60 @@
|
||||
import * as RToast from '@radix-ui/react-toast'
|
||||
import { CircleCheck, CircleX, X } from 'lucide-react'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { IconButton } from './controls'
|
||||
|
||||
export interface ToastInput {
|
||||
kind: 'ok' | 'error'
|
||||
title: string
|
||||
description?: string
|
||||
action?: { label: string; onClick: () => void }
|
||||
}
|
||||
|
||||
export interface ToastItem extends ToastInput {
|
||||
id: number
|
||||
}
|
||||
|
||||
let seq = 1
|
||||
|
||||
export function useToasts() {
|
||||
const [items, setItems] = useState<ToastItem[]>([])
|
||||
const push = useCallback((input: ToastInput) => {
|
||||
setItems((prev) => [...prev.slice(-3), { ...input, id: seq++ }])
|
||||
}, [])
|
||||
const remove = useCallback((id: number) => setItems((prev) => prev.filter((i) => i.id !== id)), [])
|
||||
return { items, push, remove }
|
||||
}
|
||||
|
||||
interface ToasterProps {
|
||||
items: 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} />}
|
||||
<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>
|
||||
{item.action && (
|
||||
<RToast.Action asChild altText={item.action.label}>
|
||||
<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" />
|
||||
</RToast.Close>
|
||||
</RToast.Root>
|
||||
))}
|
||||
<RToast.Viewport className="toast-viewport" />
|
||||
</RToast.Provider>
|
||||
)
|
||||
@@ -0,0 +1,86 @@
|
||||
import {
|
||||
AppState,
|
||||
CreateOpts,
|
||||
InstalledRuntime,
|
||||
LogEntry,
|
||||
SetOpts,
|
||||
ValidationIssue,
|
||||
VMDetail,
|
||||
} 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>
|
||||
}
|
||||
}
|
||||
}
|
||||
runtime?: {
|
||||
EventsOn(event: string, cb: (...args: any[]) => void): () => void
|
||||
WindowMinimise(): void
|
||||
WindowToggleMaximise(): void
|
||||
Quit(): void
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function app() {
|
||||
const api = window.go?.main?.App
|
||||
if (!api) {
|
||||
throw new Error('Wails backend not attached')
|
||||
}
|
||||
return api
|
||||
}
|
||||
|
||||
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),
|
||||
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(),
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
// `wails dev` probes 127.0.0.1:5173; Vite's default "localhost" can bind ::1 only.
|
||||
server: {
|
||||
host: '127.0.0.1',
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
})
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
import {reims} from '../models';
|
||||
import {main} from '../models';
|
||||
import {runtime} from '../models';
|
||||
|
||||
export function ApplyVMSettings(arg1:reims.SetOpts):Promise<void>;
|
||||
|
||||
export function CreateVM(arg1:reims.CreateOpts):Promise<void>;
|
||||
|
||||
export function DeleteVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function EjectInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function EnableWHPX():Promise<void>;
|
||||
|
||||
export function GetState():Promise<main.AppState>;
|
||||
|
||||
export function GetVMDetail(arg1:string):Promise<reims.VMDetail>;
|
||||
|
||||
export function InstallRuntimeArchive(arg1:string):Promise<runtime.Installed>;
|
||||
|
||||
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 StartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function StopVM(arg1:string,arg2:boolean):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>>;
|
||||
@@ -0,0 +1,91 @@
|
||||
// @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']['main']['App']['ApplyVMSettings'](arg1);
|
||||
}
|
||||
|
||||
export function CreateVM(arg1) {
|
||||
return window['go']['main']['App']['CreateVM'](arg1);
|
||||
}
|
||||
|
||||
export function DeleteVM(arg1, arg2) {
|
||||
return window['go']['main']['App']['DeleteVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function EjectInstaller(arg1) {
|
||||
return window['go']['main']['App']['EjectInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function EnableWHPX() {
|
||||
return window['go']['main']['App']['EnableWHPX']();
|
||||
}
|
||||
|
||||
export function GetState() {
|
||||
return window['go']['main']['App']['GetState']();
|
||||
}
|
||||
|
||||
export function GetVMDetail(arg1) {
|
||||
return window['go']['main']['App']['GetVMDetail'](arg1);
|
||||
}
|
||||
|
||||
export function InstallRuntimeArchive(arg1) {
|
||||
return window['go']['main']['App']['InstallRuntimeArchive'](arg1);
|
||||
}
|
||||
|
||||
export function OpenVMFolder(arg1) {
|
||||
return window['go']['main']['App']['OpenVMFolder'](arg1);
|
||||
}
|
||||
|
||||
export function PickDirectory(arg1) {
|
||||
return window['go']['main']['App']['PickDirectory'](arg1);
|
||||
}
|
||||
|
||||
export function PickFile(arg1, arg2) {
|
||||
return window['go']['main']['App']['PickFile'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function PreviewCreate(arg1) {
|
||||
return window['go']['main']['App']['PreviewCreate'](arg1);
|
||||
}
|
||||
|
||||
export function ReadVMLogs(arg1, arg2) {
|
||||
return window['go']['main']['App']['ReadVMLogs'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RestartVM(arg1) {
|
||||
return window['go']['main']['App']['RestartVM'](arg1);
|
||||
}
|
||||
|
||||
export function SetAutoPinPCores(arg1) {
|
||||
return window['go']['main']['App']['SetAutoPinPCores'](arg1);
|
||||
}
|
||||
|
||||
export function SetDataRoot(arg1) {
|
||||
return window['go']['main']['App']['SetDataRoot'](arg1);
|
||||
}
|
||||
|
||||
export function SetLocale(arg1) {
|
||||
return window['go']['main']['App']['SetLocale'](arg1);
|
||||
}
|
||||
|
||||
export function StartVM(arg1) {
|
||||
return window['go']['main']['App']['StartVM'](arg1);
|
||||
}
|
||||
|
||||
export function StopVM(arg1, arg2) {
|
||||
return window['go']['main']['App']['StopVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function UseRuntime(arg1) {
|
||||
return window['go']['main']['App']['UseRuntime'](arg1);
|
||||
}
|
||||
|
||||
export function ValidateCreate(arg1) {
|
||||
return window['go']['main']['App']['ValidateCreate'](arg1);
|
||||
}
|
||||
|
||||
export function ValidateSet(arg1) {
|
||||
return window['go']['main']['App']['ValidateSet'](arg1);
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
export namespace config {
|
||||
|
||||
export class Config {
|
||||
data_root: string;
|
||||
locale: string;
|
||||
active_runtime?: string;
|
||||
auto_pin_pcores: boolean;
|
||||
default_gpu?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Config(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.data_root = source["data_root"];
|
||||
this.locale = source["locale"];
|
||||
this.active_runtime = source["active_runtime"];
|
||||
this.auto_pin_pcores = source["auto_pin_pcores"];
|
||||
this.default_gpu = source["default_gpu"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace host {
|
||||
|
||||
export class GPUInfo {
|
||||
name: string;
|
||||
vulkan_icd: string;
|
||||
kind: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new GPUInfo(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.name = source["name"];
|
||||
this.vulkan_icd = source["vulkan_icd"];
|
||||
this.kind = source["kind"];
|
||||
}
|
||||
}
|
||||
export class Report {
|
||||
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[];
|
||||
total_ram_gb: number;
|
||||
avail_ram_gb: number;
|
||||
data_root: string;
|
||||
free_disk_gb: number;
|
||||
whpx: string;
|
||||
gpus: GPUInfo[];
|
||||
recommended_gpu?: GPUInfo;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Report(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.os = source["os"];
|
||||
this.arch = source["arch"];
|
||||
this.logical_cpus = source["logical_cpus"];
|
||||
this.physical_cores = source["physical_cores"];
|
||||
this.has_hybrid_cores = source["has_hybrid_cores"];
|
||||
this.p_core_count = source["p_core_count"];
|
||||
this.e_core_count = source["e_core_count"];
|
||||
this.p_core_mask = source["p_core_mask"];
|
||||
this.p_core_mask_hex = source["p_core_mask_hex"];
|
||||
this.p_core_logical_cpus = source["p_core_logical_cpus"];
|
||||
this.e_core_logical_cpus = source["e_core_logical_cpus"];
|
||||
this.total_ram_gb = source["total_ram_gb"];
|
||||
this.avail_ram_gb = source["avail_ram_gb"];
|
||||
this.data_root = source["data_root"];
|
||||
this.free_disk_gb = source["free_disk_gb"];
|
||||
this.whpx = source["whpx"];
|
||||
this.gpus = this.convertValues(source["gpus"], GPUInfo);
|
||||
this.recommended_gpu = this.convertValues(source["recommended_gpu"], GPUInfo);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace main {
|
||||
|
||||
export class AppState {
|
||||
config?: config.Config;
|
||||
host: host.Report;
|
||||
runtimes: runtime.Installed[];
|
||||
active_runtime?: runtime.Installed;
|
||||
vms: reims.VMListItem[];
|
||||
transitions: Record<string, string>;
|
||||
pending_changes: Record<string, Array<PendingChange>>;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new AppState(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.config = this.convertValues(source["config"], config.Config);
|
||||
this.host = this.convertValues(source["host"], host.Report);
|
||||
this.runtimes = this.convertValues(source["runtimes"], runtime.Installed);
|
||||
this.active_runtime = this.convertValues(source["active_runtime"], runtime.Installed);
|
||||
this.vms = this.convertValues(source["vms"], reims.VMListItem);
|
||||
this.transitions = source["transitions"];
|
||||
this.pending_changes = this.convertValues(source["pending_changes"], Array<PendingChange>, true);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class PendingChange {
|
||||
field: string;
|
||||
from: string;
|
||||
to: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new PendingChange(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.field = source["field"];
|
||||
this.from = source["from"];
|
||||
this.to = source["to"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace reims {
|
||||
|
||||
export class CreateOpts {
|
||||
name: string;
|
||||
dir?: string;
|
||||
source_mode?: string;
|
||||
macos?: string;
|
||||
installer?: string;
|
||||
cpus?: number;
|
||||
memory?: string;
|
||||
disk_size?: string;
|
||||
disk?: string;
|
||||
disk_mode?: string;
|
||||
graphics?: string;
|
||||
gpu?: string;
|
||||
resolution?: string;
|
||||
displays?: number;
|
||||
borderless?: boolean;
|
||||
audio?: boolean;
|
||||
network?: boolean;
|
||||
ssh_port?: number;
|
||||
logs?: boolean;
|
||||
start?: boolean;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new CreateOpts(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.name = source["name"];
|
||||
this.dir = source["dir"];
|
||||
this.source_mode = source["source_mode"];
|
||||
this.macos = source["macos"];
|
||||
this.installer = source["installer"];
|
||||
this.cpus = source["cpus"];
|
||||
this.memory = source["memory"];
|
||||
this.disk_size = source["disk_size"];
|
||||
this.disk = source["disk"];
|
||||
this.disk_mode = source["disk_mode"];
|
||||
this.graphics = source["graphics"];
|
||||
this.gpu = source["gpu"];
|
||||
this.resolution = source["resolution"];
|
||||
this.displays = source["displays"];
|
||||
this.borderless = source["borderless"];
|
||||
this.audio = source["audio"];
|
||||
this.network = source["network"];
|
||||
this.ssh_port = source["ssh_port"];
|
||||
this.logs = source["logs"];
|
||||
this.start = source["start"];
|
||||
}
|
||||
}
|
||||
export class 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;
|
||||
env?: string[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new SetOpts(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.name = source["name"];
|
||||
this.cpus = source["cpus"];
|
||||
this.memory = source["memory"];
|
||||
this.graphics = source["graphics"];
|
||||
this.displays = source["displays"];
|
||||
this.disk_controller = source["disk_controller"];
|
||||
this.resolution = source["resolution"];
|
||||
this.borderless = source["borderless"];
|
||||
this.capture = source["capture"];
|
||||
this.gpu = source["gpu"];
|
||||
this.logs = source["logs"];
|
||||
this.log_level = source["log_level"];
|
||||
this.audio = source["audio"];
|
||||
this.audio_backend = source["audio_backend"];
|
||||
this.network = source["network"];
|
||||
this.ssh_port = source["ssh_port"];
|
||||
this.stop_timeout = source["stop_timeout"];
|
||||
this.extra_args = source["extra_args"];
|
||||
this.env = source["env"];
|
||||
}
|
||||
}
|
||||
export class 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;
|
||||
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;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new VMDetail(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.name = source["name"];
|
||||
this.state = source["state"];
|
||||
this.kind = source["kind"];
|
||||
this.directory = source["directory"];
|
||||
this.cpus = source["cpus"];
|
||||
this.memory = source["memory"];
|
||||
this.disk = source["disk"];
|
||||
this.disk_controller = source["disk_controller"];
|
||||
this.graphics = source["graphics"];
|
||||
this.display = source["display"];
|
||||
this.displays = source["displays"];
|
||||
this.resolution = source["resolution"];
|
||||
this.gpu = source["gpu"];
|
||||
this.has_opencore = source["has_opencore"];
|
||||
this.has_installer = source["has_installer"];
|
||||
this.installer_path = source["installer_path"];
|
||||
this.cpu_model = source["cpu_model"];
|
||||
this.audio = source["audio"];
|
||||
this.audio_raw = source["audio_raw"];
|
||||
this.network = source["network"];
|
||||
this.network_summary = source["network_summary"];
|
||||
this.ssh_port = source["ssh_port"];
|
||||
this.logs = source["logs"];
|
||||
this.log_level = source["log_level"];
|
||||
this.stop_timeout = source["stop_timeout"];
|
||||
this.capture = source["capture"];
|
||||
this.borderless = source["borderless"];
|
||||
this.extra_args = source["extra_args"];
|
||||
}
|
||||
}
|
||||
export class VMListItem {
|
||||
name: string;
|
||||
dir: string;
|
||||
pid?: number;
|
||||
state: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new VMListItem(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.name = source["name"];
|
||||
this.dir = source["dir"];
|
||||
this.pid = source["pid"];
|
||||
this.state = source["state"];
|
||||
}
|
||||
}
|
||||
export class ValidationIssue {
|
||||
field: string;
|
||||
code: string;
|
||||
message: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new ValidationIssue(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.field = source["field"];
|
||||
this.code = source["code"];
|
||||
this.message = source["message"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace runtime {
|
||||
|
||||
export class Manifest {
|
||||
schema_version: number;
|
||||
name: string;
|
||||
platform: string;
|
||||
upstream_repo: string;
|
||||
commit: string;
|
||||
full_commit: string;
|
||||
qemu_version: string;
|
||||
util_version: string;
|
||||
built_at: string;
|
||||
file_count: number;
|
||||
dll_count: number;
|
||||
raw_bytes: number;
|
||||
sha256: Record<string, string>;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Manifest(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.schema_version = source["schema_version"];
|
||||
this.name = source["name"];
|
||||
this.platform = source["platform"];
|
||||
this.upstream_repo = source["upstream_repo"];
|
||||
this.commit = source["commit"];
|
||||
this.full_commit = source["full_commit"];
|
||||
this.qemu_version = source["qemu_version"];
|
||||
this.util_version = source["util_version"];
|
||||
this.built_at = source["built_at"];
|
||||
this.file_count = source["file_count"];
|
||||
this.dll_count = source["dll_count"];
|
||||
this.raw_bytes = source["raw_bytes"];
|
||||
this.sha256 = source["sha256"];
|
||||
}
|
||||
}
|
||||
export class Installed {
|
||||
commit: string;
|
||||
dir: string;
|
||||
active: boolean;
|
||||
manifest: Manifest;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Installed(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.commit = source["commit"];
|
||||
this.dir = source["dir"];
|
||||
this.active = source["active"];
|
||||
this.manifest = this.convertValues(source["manifest"], Manifest);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@wailsapp/runtime",
|
||||
"version": "2.0.0",
|
||||
"description": "Wails Javascript runtime library",
|
||||
"main": "runtime.js",
|
||||
"types": "runtime.d.ts",
|
||||
"scripts": {
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/wailsapp/wails.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Wails",
|
||||
"Javascript",
|
||||
"Go"
|
||||
],
|
||||
"author": "Lea Anthony <lea.anthony@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/wailsapp/wails/issues"
|
||||
},
|
||||
"homepage": "https://github.com/wailsapp/wails#readme"
|
||||
}
|
||||
+330
@@ -0,0 +1,330 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
export interface Position {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Size {
|
||||
w: number;
|
||||
h: number;
|
||||
}
|
||||
|
||||
export interface Screen {
|
||||
isCurrent: boolean;
|
||||
isPrimary: boolean;
|
||||
width : number
|
||||
height : number
|
||||
}
|
||||
|
||||
// Environment information such as platform, buildtype, ...
|
||||
export interface EnvironmentInfo {
|
||||
buildType: string;
|
||||
platform: string;
|
||||
arch: string;
|
||||
}
|
||||
|
||||
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
|
||||
// emits the given event. Optional data may be passed with the event.
|
||||
// This will trigger any event listeners.
|
||||
export function EventsEmit(eventName: string, ...data: any): void;
|
||||
|
||||
// [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name.
|
||||
export function EventsOn(eventName: string, callback: (...data: any) => void): () => void;
|
||||
|
||||
// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple)
|
||||
// sets up a listener for the given event name, but will only trigger a given number times.
|
||||
export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void;
|
||||
|
||||
// [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce)
|
||||
// sets up a listener for the given event name, but will only trigger once.
|
||||
export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void;
|
||||
|
||||
// [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff)
|
||||
// unregisters the listener for the given event name.
|
||||
export function EventsOff(eventName: string, ...additionalEventNames: string[]): void;
|
||||
|
||||
// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall)
|
||||
// unregisters all listeners.
|
||||
export function EventsOffAll(): void;
|
||||
|
||||
// [LogPrint](https://wails.io/docs/reference/runtime/log#logprint)
|
||||
// logs the given message as a raw message
|
||||
export function LogPrint(message: string): void;
|
||||
|
||||
// [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace)
|
||||
// logs the given message at the `trace` log level.
|
||||
export function LogTrace(message: string): void;
|
||||
|
||||
// [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug)
|
||||
// logs the given message at the `debug` log level.
|
||||
export function LogDebug(message: string): void;
|
||||
|
||||
// [LogError](https://wails.io/docs/reference/runtime/log#logerror)
|
||||
// logs the given message at the `error` log level.
|
||||
export function LogError(message: string): void;
|
||||
|
||||
// [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal)
|
||||
// logs the given message at the `fatal` log level.
|
||||
// The application will quit after calling this method.
|
||||
export function LogFatal(message: string): void;
|
||||
|
||||
// [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo)
|
||||
// logs the given message at the `info` log level.
|
||||
export function LogInfo(message: string): void;
|
||||
|
||||
// [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning)
|
||||
// logs the given message at the `warning` log level.
|
||||
export function LogWarning(message: string): void;
|
||||
|
||||
// [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload)
|
||||
// Forces a reload by the main application as well as connected browsers.
|
||||
export function WindowReload(): void;
|
||||
|
||||
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
|
||||
// Reloads the application frontend.
|
||||
export function WindowReloadApp(): void;
|
||||
|
||||
// [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop)
|
||||
// Sets the window AlwaysOnTop or not on top.
|
||||
export function WindowSetAlwaysOnTop(b: boolean): void;
|
||||
|
||||
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
|
||||
// *Windows only*
|
||||
// Sets window theme to system default (dark/light).
|
||||
export function WindowSetSystemDefaultTheme(): void;
|
||||
|
||||
// [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme)
|
||||
// *Windows only*
|
||||
// Sets window to light theme.
|
||||
export function WindowSetLightTheme(): void;
|
||||
|
||||
// [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme)
|
||||
// *Windows only*
|
||||
// Sets window to dark theme.
|
||||
export function WindowSetDarkTheme(): void;
|
||||
|
||||
// [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter)
|
||||
// Centers the window on the monitor the window is currently on.
|
||||
export function WindowCenter(): void;
|
||||
|
||||
// [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle)
|
||||
// Sets the text in the window title bar.
|
||||
export function WindowSetTitle(title: string): void;
|
||||
|
||||
// [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen)
|
||||
// Makes the window full screen.
|
||||
export function WindowFullscreen(): void;
|
||||
|
||||
// [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen)
|
||||
// Restores the previous window dimensions and position prior to full screen.
|
||||
export function WindowUnfullscreen(): void;
|
||||
|
||||
// [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen)
|
||||
// Returns the state of the window, i.e. whether the window is in full screen mode or not.
|
||||
export function WindowIsFullscreen(): Promise<boolean>;
|
||||
|
||||
// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
|
||||
// Sets the width and height of the window.
|
||||
export function WindowSetSize(width: number, height: number): void;
|
||||
|
||||
// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
|
||||
// Gets the width and height of the window.
|
||||
export function WindowGetSize(): Promise<Size>;
|
||||
|
||||
// [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize)
|
||||
// Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions.
|
||||
// Setting a size of 0,0 will disable this constraint.
|
||||
export function WindowSetMaxSize(width: number, height: number): void;
|
||||
|
||||
// [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize)
|
||||
// Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions.
|
||||
// Setting a size of 0,0 will disable this constraint.
|
||||
export function WindowSetMinSize(width: number, height: number): void;
|
||||
|
||||
// [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition)
|
||||
// Sets the window position relative to the monitor the window is currently on.
|
||||
export function WindowSetPosition(x: number, y: number): void;
|
||||
|
||||
// [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition)
|
||||
// Gets the window position relative to the monitor the window is currently on.
|
||||
export function WindowGetPosition(): Promise<Position>;
|
||||
|
||||
// [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide)
|
||||
// Hides the window.
|
||||
export function WindowHide(): void;
|
||||
|
||||
// [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow)
|
||||
// Shows the window, if it is currently hidden.
|
||||
export function WindowShow(): void;
|
||||
|
||||
// [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise)
|
||||
// Maximises the window to fill the screen.
|
||||
export function WindowMaximise(): void;
|
||||
|
||||
// [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise)
|
||||
// Toggles between Maximised and UnMaximised.
|
||||
export function WindowToggleMaximise(): void;
|
||||
|
||||
// [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise)
|
||||
// Restores the window to the dimensions and position prior to maximising.
|
||||
export function WindowUnmaximise(): void;
|
||||
|
||||
// [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised)
|
||||
// Returns the state of the window, i.e. whether the window is maximised or not.
|
||||
export function WindowIsMaximised(): Promise<boolean>;
|
||||
|
||||
// [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise)
|
||||
// Minimises the window.
|
||||
export function WindowMinimise(): void;
|
||||
|
||||
// [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise)
|
||||
// Restores the window to the dimensions and position prior to minimising.
|
||||
export function WindowUnminimise(): void;
|
||||
|
||||
// [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised)
|
||||
// Returns the state of the window, i.e. whether the window is minimised or not.
|
||||
export function WindowIsMinimised(): Promise<boolean>;
|
||||
|
||||
// [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal)
|
||||
// Returns the state of the window, i.e. whether the window is normal or not.
|
||||
export function WindowIsNormal(): Promise<boolean>;
|
||||
|
||||
// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour)
|
||||
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
|
||||
export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void;
|
||||
|
||||
// [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall)
|
||||
// Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system.
|
||||
export function ScreenGetAll(): Promise<Screen[]>;
|
||||
|
||||
// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl)
|
||||
// Opens the given URL in the system browser.
|
||||
export function BrowserOpenURL(url: string): void;
|
||||
|
||||
// [Environment](https://wails.io/docs/reference/runtime/intro#environment)
|
||||
// Returns information about the environment
|
||||
export function Environment(): Promise<EnvironmentInfo>;
|
||||
|
||||
// [Quit](https://wails.io/docs/reference/runtime/intro#quit)
|
||||
// Quits the application.
|
||||
export function Quit(): void;
|
||||
|
||||
// [Hide](https://wails.io/docs/reference/runtime/intro#hide)
|
||||
// Hides the application.
|
||||
export function Hide(): void;
|
||||
|
||||
// [Show](https://wails.io/docs/reference/runtime/intro#show)
|
||||
// Shows the application.
|
||||
export function Show(): void;
|
||||
|
||||
// [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext)
|
||||
// Returns the current text stored on clipboard
|
||||
export function ClipboardGetText(): Promise<string>;
|
||||
|
||||
// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext)
|
||||
// Sets a text on the clipboard
|
||||
export function ClipboardSetText(text: string): Promise<boolean>;
|
||||
|
||||
// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop)
|
||||
// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
||||
export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void
|
||||
|
||||
// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff)
|
||||
// OnFileDropOff removes the drag and drop listeners and handlers.
|
||||
export function OnFileDropOff() :void
|
||||
|
||||
// Check if the file path resolver is available
|
||||
export function CanResolveFilePaths(): boolean;
|
||||
|
||||
// Resolves file paths for an array of files
|
||||
export function ResolveFilePaths(files: File[]): void
|
||||
|
||||
// Notification types
|
||||
export interface NotificationOptions {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle?: string; // macOS and Linux only
|
||||
body?: string;
|
||||
categoryId?: string;
|
||||
data?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface NotificationAction {
|
||||
id?: string;
|
||||
title?: string;
|
||||
destructive?: boolean; // macOS-specific
|
||||
}
|
||||
|
||||
export interface NotificationCategory {
|
||||
id?: string;
|
||||
actions?: NotificationAction[];
|
||||
hasReplyField?: boolean;
|
||||
replyPlaceholder?: string;
|
||||
replyButtonTitle?: string;
|
||||
}
|
||||
|
||||
// [InitializeNotifications](https://wails.io/docs/reference/runtime/notification#initializenotifications)
|
||||
// Initializes the notification service for the application.
|
||||
// This must be called before sending any notifications.
|
||||
export function InitializeNotifications(): Promise<void>;
|
||||
|
||||
// [CleanupNotifications](https://wails.io/docs/reference/runtime/notification#cleanupnotifications)
|
||||
// Cleans up notification resources and releases any held connections.
|
||||
export function CleanupNotifications(): Promise<void>;
|
||||
|
||||
// [IsNotificationAvailable](https://wails.io/docs/reference/runtime/notification#isnotificationavailable)
|
||||
// Checks if notifications are available on the current platform.
|
||||
export function IsNotificationAvailable(): Promise<boolean>;
|
||||
|
||||
// [RequestNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#requestnotificationauthorization)
|
||||
// Requests notification authorization from the user (macOS only).
|
||||
export function RequestNotificationAuthorization(): Promise<boolean>;
|
||||
|
||||
// [CheckNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#checknotificationauthorization)
|
||||
// Checks the current notification authorization status (macOS only).
|
||||
export function CheckNotificationAuthorization(): Promise<boolean>;
|
||||
|
||||
// [SendNotification](https://wails.io/docs/reference/runtime/notification#sendnotification)
|
||||
// Sends a basic notification with the given options.
|
||||
export function SendNotification(options: NotificationOptions): Promise<void>;
|
||||
|
||||
// [SendNotificationWithActions](https://wails.io/docs/reference/runtime/notification#sendnotificationwithactions)
|
||||
// Sends a notification with action buttons. Requires a registered category.
|
||||
export function SendNotificationWithActions(options: NotificationOptions): Promise<void>;
|
||||
|
||||
// [RegisterNotificationCategory](https://wails.io/docs/reference/runtime/notification#registernotificationcategory)
|
||||
// Registers a notification category that can be used with SendNotificationWithActions.
|
||||
export function RegisterNotificationCategory(category: NotificationCategory): Promise<void>;
|
||||
|
||||
// [RemoveNotificationCategory](https://wails.io/docs/reference/runtime/notification#removenotificationcategory)
|
||||
// Removes a previously registered notification category.
|
||||
export function RemoveNotificationCategory(categoryId: string): Promise<void>;
|
||||
|
||||
// [RemoveAllPendingNotifications](https://wails.io/docs/reference/runtime/notification#removeallpendingnotifications)
|
||||
// Removes all pending notifications from the notification center.
|
||||
export function RemoveAllPendingNotifications(): Promise<void>;
|
||||
|
||||
// [RemovePendingNotification](https://wails.io/docs/reference/runtime/notification#removependingnotification)
|
||||
// Removes a specific pending notification by its identifier.
|
||||
export function RemovePendingNotification(identifier: string): Promise<void>;
|
||||
|
||||
// [RemoveAllDeliveredNotifications](https://wails.io/docs/reference/runtime/notification#removealldeliverednotifications)
|
||||
// Removes all delivered notifications from the notification center.
|
||||
export function RemoveAllDeliveredNotifications(): Promise<void>;
|
||||
|
||||
// [RemoveDeliveredNotification](https://wails.io/docs/reference/runtime/notification#removedeliverednotification)
|
||||
// Removes a specific delivered notification by its identifier.
|
||||
export function RemoveDeliveredNotification(identifier: string): Promise<void>;
|
||||
|
||||
// [RemoveNotification](https://wails.io/docs/reference/runtime/notification#removenotification)
|
||||
// Removes a notification by its identifier (cross-platform convenience function).
|
||||
export function RemoveNotification(identifier: string): Promise<void>;
|
||||
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
export function LogPrint(message) {
|
||||
window.runtime.LogPrint(message);
|
||||
}
|
||||
|
||||
export function LogTrace(message) {
|
||||
window.runtime.LogTrace(message);
|
||||
}
|
||||
|
||||
export function LogDebug(message) {
|
||||
window.runtime.LogDebug(message);
|
||||
}
|
||||
|
||||
export function LogInfo(message) {
|
||||
window.runtime.LogInfo(message);
|
||||
}
|
||||
|
||||
export function LogWarning(message) {
|
||||
window.runtime.LogWarning(message);
|
||||
}
|
||||
|
||||
export function LogError(message) {
|
||||
window.runtime.LogError(message);
|
||||
}
|
||||
|
||||
export function LogFatal(message) {
|
||||
window.runtime.LogFatal(message);
|
||||
}
|
||||
|
||||
export function EventsOnMultiple(eventName, callback, maxCallbacks) {
|
||||
return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
|
||||
}
|
||||
|
||||
export function EventsOn(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, -1);
|
||||
}
|
||||
|
||||
export function EventsOff(eventName, ...additionalEventNames) {
|
||||
return window.runtime.EventsOff(eventName, ...additionalEventNames);
|
||||
}
|
||||
|
||||
export function EventsOffAll() {
|
||||
return window.runtime.EventsOffAll();
|
||||
}
|
||||
|
||||
export function EventsOnce(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, 1);
|
||||
}
|
||||
|
||||
export function EventsEmit(eventName) {
|
||||
let args = [eventName].slice.call(arguments);
|
||||
return window.runtime.EventsEmit.apply(null, args);
|
||||
}
|
||||
|
||||
export function WindowReload() {
|
||||
window.runtime.WindowReload();
|
||||
}
|
||||
|
||||
export function WindowReloadApp() {
|
||||
window.runtime.WindowReloadApp();
|
||||
}
|
||||
|
||||
export function WindowSetAlwaysOnTop(b) {
|
||||
window.runtime.WindowSetAlwaysOnTop(b);
|
||||
}
|
||||
|
||||
export function WindowSetSystemDefaultTheme() {
|
||||
window.runtime.WindowSetSystemDefaultTheme();
|
||||
}
|
||||
|
||||
export function WindowSetLightTheme() {
|
||||
window.runtime.WindowSetLightTheme();
|
||||
}
|
||||
|
||||
export function WindowSetDarkTheme() {
|
||||
window.runtime.WindowSetDarkTheme();
|
||||
}
|
||||
|
||||
export function WindowCenter() {
|
||||
window.runtime.WindowCenter();
|
||||
}
|
||||
|
||||
export function WindowSetTitle(title) {
|
||||
window.runtime.WindowSetTitle(title);
|
||||
}
|
||||
|
||||
export function WindowFullscreen() {
|
||||
window.runtime.WindowFullscreen();
|
||||
}
|
||||
|
||||
export function WindowUnfullscreen() {
|
||||
window.runtime.WindowUnfullscreen();
|
||||
}
|
||||
|
||||
export function WindowIsFullscreen() {
|
||||
return window.runtime.WindowIsFullscreen();
|
||||
}
|
||||
|
||||
export function WindowGetSize() {
|
||||
return window.runtime.WindowGetSize();
|
||||
}
|
||||
|
||||
export function WindowSetSize(width, height) {
|
||||
window.runtime.WindowSetSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetMaxSize(width, height) {
|
||||
window.runtime.WindowSetMaxSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetMinSize(width, height) {
|
||||
window.runtime.WindowSetMinSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetPosition(x, y) {
|
||||
window.runtime.WindowSetPosition(x, y);
|
||||
}
|
||||
|
||||
export function WindowGetPosition() {
|
||||
return window.runtime.WindowGetPosition();
|
||||
}
|
||||
|
||||
export function WindowHide() {
|
||||
window.runtime.WindowHide();
|
||||
}
|
||||
|
||||
export function WindowShow() {
|
||||
window.runtime.WindowShow();
|
||||
}
|
||||
|
||||
export function WindowMaximise() {
|
||||
window.runtime.WindowMaximise();
|
||||
}
|
||||
|
||||
export function WindowToggleMaximise() {
|
||||
window.runtime.WindowToggleMaximise();
|
||||
}
|
||||
|
||||
export function WindowUnmaximise() {
|
||||
window.runtime.WindowUnmaximise();
|
||||
}
|
||||
|
||||
export function WindowIsMaximised() {
|
||||
return window.runtime.WindowIsMaximised();
|
||||
}
|
||||
|
||||
export function WindowMinimise() {
|
||||
window.runtime.WindowMinimise();
|
||||
}
|
||||
|
||||
export function WindowUnminimise() {
|
||||
window.runtime.WindowUnminimise();
|
||||
}
|
||||
|
||||
export function WindowSetBackgroundColour(R, G, B, A) {
|
||||
window.runtime.WindowSetBackgroundColour(R, G, B, A);
|
||||
}
|
||||
|
||||
export function ScreenGetAll() {
|
||||
return window.runtime.ScreenGetAll();
|
||||
}
|
||||
|
||||
export function WindowIsMinimised() {
|
||||
return window.runtime.WindowIsMinimised();
|
||||
}
|
||||
|
||||
export function WindowIsNormal() {
|
||||
return window.runtime.WindowIsNormal();
|
||||
}
|
||||
|
||||
export function BrowserOpenURL(url) {
|
||||
window.runtime.BrowserOpenURL(url);
|
||||
}
|
||||
|
||||
export function Environment() {
|
||||
return window.runtime.Environment();
|
||||
}
|
||||
|
||||
export function Quit() {
|
||||
window.runtime.Quit();
|
||||
}
|
||||
|
||||
export function Hide() {
|
||||
window.runtime.Hide();
|
||||
}
|
||||
|
||||
export function Show() {
|
||||
window.runtime.Show();
|
||||
}
|
||||
|
||||
export function ClipboardGetText() {
|
||||
return window.runtime.ClipboardGetText();
|
||||
}
|
||||
|
||||
export function ClipboardSetText(text) {
|
||||
return window.runtime.ClipboardSetText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
||||
*
|
||||
* @export
|
||||
* @callback OnFileDropCallback
|
||||
* @param {number} x - x coordinate of the drop
|
||||
* @param {number} y - y coordinate of the drop
|
||||
* @param {string[]} paths - A list of file paths.
|
||||
*/
|
||||
|
||||
/**
|
||||
* OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
||||
*
|
||||
* @export
|
||||
* @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
||||
* @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
|
||||
*/
|
||||
export function OnFileDrop(callback, useDropTarget) {
|
||||
return window.runtime.OnFileDrop(callback, useDropTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* OnFileDropOff removes the drag and drop listeners and handlers.
|
||||
*/
|
||||
export function OnFileDropOff() {
|
||||
return window.runtime.OnFileDropOff();
|
||||
}
|
||||
|
||||
export function CanResolveFilePaths() {
|
||||
return window.runtime.CanResolveFilePaths();
|
||||
}
|
||||
|
||||
export function ResolveFilePaths(files) {
|
||||
return window.runtime.ResolveFilePaths(files);
|
||||
}
|
||||
|
||||
export function InitializeNotifications() {
|
||||
return window.runtime.InitializeNotifications();
|
||||
}
|
||||
|
||||
export function CleanupNotifications() {
|
||||
return window.runtime.CleanupNotifications();
|
||||
}
|
||||
|
||||
export function IsNotificationAvailable() {
|
||||
return window.runtime.IsNotificationAvailable();
|
||||
}
|
||||
|
||||
export function RequestNotificationAuthorization() {
|
||||
return window.runtime.RequestNotificationAuthorization();
|
||||
}
|
||||
|
||||
export function CheckNotificationAuthorization() {
|
||||
return window.runtime.CheckNotificationAuthorization();
|
||||
}
|
||||
|
||||
export function SendNotification(options) {
|
||||
return window.runtime.SendNotification(options);
|
||||
}
|
||||
|
||||
export function SendNotificationWithActions(options) {
|
||||
return window.runtime.SendNotificationWithActions(options);
|
||||
}
|
||||
|
||||
export function RegisterNotificationCategory(category) {
|
||||
return window.runtime.RegisterNotificationCategory(category);
|
||||
}
|
||||
|
||||
export function RemoveNotificationCategory(categoryId) {
|
||||
return window.runtime.RemoveNotificationCategory(categoryId);
|
||||
}
|
||||
|
||||
export function RemoveAllPendingNotifications() {
|
||||
return window.runtime.RemoveAllPendingNotifications();
|
||||
}
|
||||
|
||||
export function RemovePendingNotification(identifier) {
|
||||
return window.runtime.RemovePendingNotification(identifier);
|
||||
}
|
||||
|
||||
export function RemoveAllDeliveredNotifications() {
|
||||
return window.runtime.RemoveAllDeliveredNotifications();
|
||||
}
|
||||
|
||||
export function RemoveDeliveredNotification(identifier) {
|
||||
return window.runtime.RemoveDeliveredNotification(identifier);
|
||||
}
|
||||
|
||||
export function RemoveNotification(identifier) {
|
||||
return window.runtime.RemoveNotification(identifier);
|
||||
}
|
||||
@@ -1,3 +1,36 @@
|
||||
module github.com/Nwflower/reims-go
|
||||
|
||||
go 1.22
|
||||
go 1.26.0
|
||||
|
||||
require github.com/wailsapp/wails/v2 v2.17.1
|
||||
|
||||
require (
|
||||
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 // indirect
|
||||
github.com/bep/debounce v1.2.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||
github.com/labstack/echo/v4 v4.16.1 // indirect
|
||||
github.com/labstack/gommon v0.5.0 // indirect
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
||||
github.com/leaanthony/gosod v1.0.4 // indirect
|
||||
github.com/leaanthony/slicer v1.6.0 // indirect
|
||||
github.com/leaanthony/u v1.1.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.15 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/samber/lo v1.49.1 // indirect
|
||||
github.com/tkrajina/go-reflector v0.5.8 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.22 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/net v0.60.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
golang.org/x/text v0.42.0 // indirect
|
||||
)
|
||||
@@ -0,0 +1,74 @@
|
||||
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 h1:N3IGoHHp9pb6mj1cbXbuaSXV/UMKwmbKLf53nQmtqMA=
|
||||
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3/go.mod h1:QtOLZGz8olr4qH2vWK0QH0w0O4T9fEIjMuWpKUsH7nc=
|
||||
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
||||
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||
github.com/labstack/echo/v4 v4.16.1 h1:h05NuF1GvNu6jSAZxOv++AdjD/NJK+mZdGy0thiiuns=
|
||||
github.com/labstack/echo/v4 v4.16.1/go.mod h1:V/EQaTVHYJH92QhbQe7kFQ4mjgcjxLQQUQtAN87zZdw=
|
||||
github.com/labstack/gommon v0.5.0 h1:6VSQ2NOzsnEJ5W6+84E0RbcaDDmgB6NIAzWCczTEe6c=
|
||||
github.com/labstack/gommon v0.5.0/go.mod h1:Rzlg7HHy1maLfzBYGg9NZcVuz1sA68HHhLjhcEllYE0=
|
||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1 h1:xd8bzARK3dErqkPFtoF9F3/HgN8UQk0ed1YDKpEz01A=
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU=
|
||||
github.com/leaanthony/gosod v1.0.4 h1:YLAbVyd591MRffDgxUOU1NwLhT9T1/YiwjKZpkNFeaI=
|
||||
github.com/leaanthony/gosod v1.0.4/go.mod h1:GKuIL0zzPj3O1SdWQOdgURSuhkF+Urizzxh26t9f1cw=
|
||||
github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js=
|
||||
github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8=
|
||||
github.com/leaanthony/u v1.1.1 h1:TUFjwDGlNX+WuwVEzDqQwC2lOv0P4uhTQw7CMFdiK7M=
|
||||
github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
|
||||
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ=
|
||||
github.com/tkrajina/go-reflector v0.5.8/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/wailsapp/go-webview2 v1.0.22 h1:YT61F5lj+GGaat5OB96Aa3b4QA+mybD0Ggq6NZijQ58=
|
||||
github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||
github.com/wailsapp/wails/v2 v2.17.1 h1:RyswsftvVwjBcZy/ccfM2FuSeWRH/2WTTJUet4jlKUU=
|
||||
github.com/wailsapp/wails/v2 v2.17.1/go.mod h1:oj2ZhYZ3ob7KKOtmYtfm6v5pmacg8IKdA+qY2J1/iWQ=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
|
||||
golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -0,0 +1,7 @@
|
||||
//go:build !windows
|
||||
|
||||
package reims
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func configureCmd(cmd *exec.Cmd) {}
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build windows
|
||||
|
||||
package reims
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const createNoWindow = 0x08000000
|
||||
|
||||
func configureCmd(cmd *exec.Cmd) {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
HideWindow: true,
|
||||
CreationFlags: createNoWindow,
|
||||
}
|
||||
}
|
||||
+389
-26
@@ -6,11 +6,14 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/config"
|
||||
"github.com/Nwflower/reims-go/internal/host"
|
||||
rt "github.com/Nwflower/reims-go/internal/runtime"
|
||||
)
|
||||
|
||||
@@ -27,10 +30,56 @@ func NewClient(cfg *config.Config, installed rt.Installed) *Client {
|
||||
}
|
||||
}
|
||||
|
||||
type VMListItem struct {
|
||||
Name string `json:"name"`
|
||||
Dir string `json:"dir"`
|
||||
PID *int `json:"pid"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
type VMDetail struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
Kind string `json:"kind"`
|
||||
Directory string `json:"directory"`
|
||||
CPUs int `json:"cpus"`
|
||||
Memory string `json:"memory"`
|
||||
Disk string `json:"disk"`
|
||||
DiskController string `json:"disk_controller"`
|
||||
Graphics string `json:"graphics"`
|
||||
Display string `json:"display"`
|
||||
Displays int `json:"displays"`
|
||||
Resolution string `json:"resolution"`
|
||||
GPU string `json:"gpu"`
|
||||
HasOpenCore bool `json:"has_opencore"`
|
||||
HasInstaller bool `json:"has_installer"`
|
||||
InstallerPath string `json:"installer_path,omitempty"`
|
||||
CPUModel string `json:"cpu_model"`
|
||||
Audio bool `json:"audio"`
|
||||
AudioRaw string `json:"audio_raw"`
|
||||
Network bool `json:"network"`
|
||||
NetworkSummary string `json:"network_summary"`
|
||||
SSHPort int `json:"ssh_port"`
|
||||
Logs bool `json:"logs"`
|
||||
LogLevel string `json:"log_level"`
|
||||
StopTimeout int `json:"stop_timeout"`
|
||||
Capture bool `json:"capture"`
|
||||
Borderless bool `json:"borderless"`
|
||||
ExtraArgs string `json:"extra_args"`
|
||||
}
|
||||
|
||||
type ValidationIssue struct {
|
||||
Field string `json:"field"`
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type CreateOpts struct {
|
||||
Name string `json:"name"`
|
||||
Dir string `json:"dir,omitempty"`
|
||||
SourceMode string `json:"source_mode,omitempty"` // "apple" | "installer" | "disk"
|
||||
MacOS string `json:"macos,omitempty"`
|
||||
Installer string `json:"installer,omitempty"`
|
||||
CPUs int `json:"cpus,omitempty"`
|
||||
Memory string `json:"memory,omitempty"`
|
||||
DiskSize string `json:"disk_size,omitempty"`
|
||||
@@ -49,19 +98,139 @@ type CreateOpts struct {
|
||||
}
|
||||
|
||||
type SetOpts struct {
|
||||
Name string `json:"name"`
|
||||
CPUs int `json:"cpus,omitempty"`
|
||||
Memory string `json:"memory,omitempty"`
|
||||
Graphics string `json:"graphics,omitempty"`
|
||||
GPU string `json:"gpu,omitempty"`
|
||||
Resolution string `json:"resolution,omitempty"`
|
||||
Displays int `json:"displays,omitempty"`
|
||||
Borderless *bool `json:"borderless,omitempty"`
|
||||
Audio *bool `json:"audio,omitempty"`
|
||||
Network *bool `json:"network,omitempty"`
|
||||
SSHPort *int `json:"ssh_port,omitempty"`
|
||||
Logs *bool `json:"logs,omitempty"`
|
||||
ExtraArgs string `json:"extra_args,omitempty"`
|
||||
Name string `json:"name"`
|
||||
CPUs int `json:"cpus,omitempty"`
|
||||
Memory string `json:"memory,omitempty"`
|
||||
Graphics string `json:"graphics,omitempty"`
|
||||
Displays int `json:"displays,omitempty"`
|
||||
DiskController string `json:"disk_controller,omitempty"`
|
||||
Resolution string `json:"resolution,omitempty"`
|
||||
Borderless *bool `json:"borderless,omitempty"`
|
||||
Capture *bool `json:"capture,omitempty"`
|
||||
GPU string `json:"gpu,omitempty"`
|
||||
Logs *bool `json:"logs,omitempty"`
|
||||
LogLevel string `json:"log_level,omitempty"`
|
||||
Audio *bool `json:"audio,omitempty"`
|
||||
AudioBackend string `json:"audio_backend,omitempty"`
|
||||
Network *bool `json:"network,omitempty"`
|
||||
SSHPort *int `json:"ssh_port,omitempty"`
|
||||
StopTimeout *int `json:"stop_timeout,omitempty"`
|
||||
ExtraArgs *string `json:"extra_args,omitempty"`
|
||||
Env []string `json:"env,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
reVMName = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$`)
|
||||
reSizeG = regexp.MustCompile(`(?i)^(\d+)\s*([GM])$`)
|
||||
reRes = regexp.MustCompile(`^(\d{3,5})x(\d{3,5})$`)
|
||||
reMac = regexp.MustCompile(`(?i),?\s*mac\s+[0-9a-f]{2}(:[0-9a-f]{2}){5}`)
|
||||
)
|
||||
|
||||
// ParseSizeGB parses "16G" or "4096M" into gigabytes.
|
||||
func ParseSizeGB(raw string) (float64, bool) {
|
||||
m := reSizeG.FindStringSubmatch(strings.TrimSpace(raw))
|
||||
if len(m) != 3 {
|
||||
return 0, false
|
||||
}
|
||||
v, err := strconv.ParseFloat(m[1], 64)
|
||||
if err != nil || v <= 0 {
|
||||
return 0, false
|
||||
}
|
||||
if strings.EqualFold(m[2], "M") {
|
||||
return v / 1024.0, true
|
||||
}
|
||||
return v, true
|
||||
}
|
||||
|
||||
// ValidateCreate performs pre-save validation aligned with VZVirtualMachineConfiguration.validate().
|
||||
func ValidateCreate(o CreateOpts, rep host.Report) []ValidationIssue {
|
||||
var issues []ValidationIssue
|
||||
name := strings.TrimSpace(o.Name)
|
||||
if !reVMName.MatchString(name) {
|
||||
issues = append(issues, ValidationIssue{Field: "name", Code: "invalid_name", Message: "VM name must start with a letter/digit and use only A-Z, 0-9, ., _, -"})
|
||||
}
|
||||
if o.CPUs < 1 || (rep.LogicalCPUs > 0 && o.CPUs > rep.LogicalCPUs) {
|
||||
issues = append(issues, ValidationIssue{Field: "cpus", Code: "invalid_cpus", Message: fmt.Sprintf("vCPUs must be between 1 and %d", max(rep.LogicalCPUs, 1))})
|
||||
}
|
||||
if o.Memory != "" {
|
||||
memGB, ok := ParseSizeGB(o.Memory)
|
||||
if !ok || memGB < 2 {
|
||||
issues = append(issues, ValidationIssue{Field: "memory", Code: "invalid_memory", Message: "Memory must be at least 2G (e.g. 8G, 16G)"})
|
||||
} else if rep.TotalRAMGB > 0 && memGB > rep.TotalRAMGB*0.85 {
|
||||
issues = append(issues, ValidationIssue{Field: "memory", Code: "memory_exceeds_host", Message: fmt.Sprintf("Memory %.0fG exceeds safe host limit (host total %.1f GB)", memGB, rep.TotalRAMGB)})
|
||||
}
|
||||
}
|
||||
if o.Disk == "" && o.DiskSize != "" {
|
||||
diskGB, ok := ParseSizeGB(o.DiskSize)
|
||||
if !ok || diskGB < 32 {
|
||||
issues = append(issues, ValidationIssue{Field: "disk_size", Code: "invalid_disk_size", Message: "New disk size must be at least 32G (recommended 128G)"})
|
||||
}
|
||||
}
|
||||
if o.Disk != "" {
|
||||
if _, err := os.Stat(o.Disk); err != nil {
|
||||
issues = append(issues, ValidationIssue{Field: "disk", Code: "disk_not_found", Message: "Selected disk image file does not exist"})
|
||||
}
|
||||
}
|
||||
if o.Installer != "" {
|
||||
if _, err := os.Stat(o.Installer); err != nil {
|
||||
issues = append(issues, ValidationIssue{Field: "installer", Code: "installer_not_found", Message: "Selected installer image file does not exist"})
|
||||
}
|
||||
}
|
||||
if o.GPU != "" && o.GPU != "auto" && strings.HasSuffix(strings.ToLower(o.GPU), ".json") {
|
||||
if _, err := os.Stat(o.GPU); err != nil {
|
||||
issues = append(issues, ValidationIssue{Field: "gpu", Code: "gpu_icd_not_found", Message: "Selected Vulkan ICD JSON file does not exist"})
|
||||
}
|
||||
}
|
||||
if o.Resolution != "" && !reRes.MatchString(strings.TrimSpace(o.Resolution)) {
|
||||
issues = append(issues, ValidationIssue{Field: "resolution", Code: "invalid_resolution", Message: "Resolution must match WIDTHxHEIGHT (e.g. 1920x1080)"})
|
||||
}
|
||||
if o.Displays != 0 && (o.Displays < 1 || o.Displays > 4) {
|
||||
issues = append(issues, ValidationIssue{Field: "displays", Code: "invalid_displays", Message: "Displays must be between 1 and 4"})
|
||||
}
|
||||
if o.SSHPort < 0 || o.SSHPort > 65535 {
|
||||
issues = append(issues, ValidationIssue{Field: "ssh_port", Code: "invalid_ssh_port", Message: "SSH port must be 0..65535"})
|
||||
}
|
||||
return issues
|
||||
}
|
||||
|
||||
// ValidateSet validates configuration edits before invoking `reims-ctl set`.
|
||||
func ValidateSet(o SetOpts, current VMDetail, rep host.Report) []ValidationIssue {
|
||||
var issues []ValidationIssue
|
||||
if strings.TrimSpace(o.Name) == "" {
|
||||
issues = append(issues, ValidationIssue{Field: "name", Code: "missing_name", Message: "VM name is required"})
|
||||
}
|
||||
if o.CPUs != 0 && (o.CPUs < 1 || (rep.LogicalCPUs > 0 && o.CPUs > rep.LogicalCPUs)) {
|
||||
issues = append(issues, ValidationIssue{Field: "cpus", Code: "invalid_cpus", Message: fmt.Sprintf("vCPUs must be between 1 and %d", max(rep.LogicalCPUs, 1))})
|
||||
}
|
||||
if o.Memory != "" {
|
||||
memGB, ok := ParseSizeGB(o.Memory)
|
||||
if !ok || memGB < 2 {
|
||||
issues = append(issues, ValidationIssue{Field: "memory", Code: "invalid_memory", Message: "Memory must be at least 2G"})
|
||||
} else if rep.TotalRAMGB > 0 && memGB > rep.TotalRAMGB*0.85 {
|
||||
issues = append(issues, ValidationIssue{Field: "memory", Code: "memory_exceeds_host", Message: fmt.Sprintf("Memory %.0fG exceeds safe host limit (%.1f GB total)", memGB, rep.TotalRAMGB)})
|
||||
}
|
||||
}
|
||||
if o.Graphics != "" && current.Graphics != "" && o.Graphics != current.Graphics && current.State == "running" {
|
||||
issues = append(issues, ValidationIssue{Field: "graphics", Code: "graphics_requires_stop", Message: "Stop the VM before switching graphics type (OpenCore must be rebuilt)"})
|
||||
}
|
||||
if o.DiskController != "" && current.HasInstaller {
|
||||
issues = append(issues, ValidationIssue{Field: "disk_controller", Code: "eject_before_controller_change", Message: "Eject the macOS installer before changing disk controller"})
|
||||
}
|
||||
if o.GPU != "" && o.GPU != "auto" && strings.HasSuffix(strings.ToLower(o.GPU), ".json") {
|
||||
if _, err := os.Stat(o.GPU); err != nil {
|
||||
issues = append(issues, ValidationIssue{Field: "gpu", Code: "gpu_icd_not_found", Message: "Selected Vulkan ICD JSON file does not exist"})
|
||||
}
|
||||
}
|
||||
if o.Resolution != "" && !reRes.MatchString(strings.TrimSpace(o.Resolution)) {
|
||||
issues = append(issues, ValidationIssue{Field: "resolution", Code: "invalid_resolution", Message: "Resolution must match WIDTHxHEIGHT"})
|
||||
}
|
||||
if o.Displays != 0 && (o.Displays < 1 || o.Displays > 4) {
|
||||
issues = append(issues, ValidationIssue{Field: "displays", Code: "invalid_displays", Message: "Displays must be between 1 and 4"})
|
||||
}
|
||||
if o.SSHPort != nil && (*o.SSHPort < 0 || *o.SSHPort > 65535) {
|
||||
issues = append(issues, ValidationIssue{Field: "ssh_port", Code: "invalid_ssh_port", Message: "SSH port must be 0..65535"})
|
||||
}
|
||||
return issues
|
||||
}
|
||||
|
||||
// BuildCreateArgs converts CreateOpts into deterministic reims-ctl CLI arguments.
|
||||
@@ -76,20 +245,23 @@ func BuildCreateArgs(o CreateOpts) ([]string, error) {
|
||||
if o.MacOS != "" {
|
||||
args = append(args, "--macos", o.MacOS)
|
||||
}
|
||||
if o.Installer != "" {
|
||||
args = append(args, "--installer", o.Installer)
|
||||
}
|
||||
if o.CPUs > 0 {
|
||||
args = append(args, "--cpus", strconv.Itoa(o.CPUs))
|
||||
}
|
||||
if o.Memory != "" {
|
||||
args = append(args, "--memory", o.Memory)
|
||||
}
|
||||
if o.DiskSize != "" {
|
||||
if o.DiskSize != "" && o.Disk == "" {
|
||||
args = append(args, "--disk-size", o.DiskSize)
|
||||
}
|
||||
if o.Disk != "" {
|
||||
args = append(args, "--disk", o.Disk)
|
||||
}
|
||||
if o.DiskMode != "" {
|
||||
args = append(args, "--disk-mode", o.DiskMode)
|
||||
if o.DiskMode != "" {
|
||||
args = append(args, "--disk-mode", o.DiskMode)
|
||||
}
|
||||
}
|
||||
if o.Graphics != "" {
|
||||
args = append(args, "--graphics", o.Graphics)
|
||||
@@ -124,6 +296,24 @@ func BuildCreateArgs(o CreateOpts) ([]string, error) {
|
||||
return args, nil
|
||||
}
|
||||
|
||||
// PreviewCreateCommand formats the exact CLI command shown on Step 5 of the wizard.
|
||||
func PreviewCreateCommand(o CreateOpts) (string, error) {
|
||||
args, err := BuildCreateArgs(o)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
quoted := make([]string, 0, len(args)+1)
|
||||
quoted = append(quoted, "reims-ctl")
|
||||
for _, a := range args {
|
||||
if strings.ContainsAny(a, " \t\"") {
|
||||
quoted = append(quoted, strconv.Quote(a))
|
||||
} else {
|
||||
quoted = append(quoted, a)
|
||||
}
|
||||
}
|
||||
return strings.Join(quoted, " "), nil
|
||||
}
|
||||
|
||||
// BuildSetArgs converts SetOpts into reims-ctl set CLI arguments.
|
||||
func BuildSetArgs(o SetOpts) ([]string, error) {
|
||||
if strings.TrimSpace(o.Name) == "" {
|
||||
@@ -139,38 +329,171 @@ func BuildSetArgs(o SetOpts) ([]string, error) {
|
||||
if o.Graphics != "" {
|
||||
args = append(args, "--graphics", o.Graphics)
|
||||
}
|
||||
if o.GPU != "" {
|
||||
args = append(args, "--gpu", o.GPU)
|
||||
if o.Displays > 0 {
|
||||
args = append(args, "--displays", strconv.Itoa(o.Displays))
|
||||
}
|
||||
if o.DiskController != "" {
|
||||
args = append(args, "--disk-controller", o.DiskController)
|
||||
}
|
||||
if o.Resolution != "" {
|
||||
args = append(args, "--resolution", o.Resolution)
|
||||
}
|
||||
if o.Displays > 0 {
|
||||
args = append(args, "--displays", strconv.Itoa(o.Displays))
|
||||
}
|
||||
if o.Borderless != nil {
|
||||
args = append(args, "--borderless", strconv.FormatBool(*o.Borderless))
|
||||
}
|
||||
if o.Capture != nil {
|
||||
args = append(args, "--capture", strconv.FormatBool(*o.Capture))
|
||||
}
|
||||
if o.GPU != "" {
|
||||
args = append(args, "--gpu", o.GPU)
|
||||
}
|
||||
if o.Logs != nil {
|
||||
args = append(args, "--logs", strconv.FormatBool(*o.Logs))
|
||||
}
|
||||
if o.LogLevel != "" {
|
||||
args = append(args, "--log-level", o.LogLevel)
|
||||
}
|
||||
if o.Audio != nil {
|
||||
args = append(args, "--audio", strconv.FormatBool(*o.Audio))
|
||||
}
|
||||
if o.AudioBackend != "" {
|
||||
args = append(args, "--audio-backend", o.AudioBackend)
|
||||
}
|
||||
if o.Network != nil {
|
||||
args = append(args, "--network", strconv.FormatBool(*o.Network))
|
||||
}
|
||||
if o.SSHPort != nil {
|
||||
args = append(args, "--ssh-port", strconv.Itoa(*o.SSHPort))
|
||||
}
|
||||
if o.Logs != nil {
|
||||
args = append(args, "--logs", strconv.FormatBool(*o.Logs))
|
||||
if o.StopTimeout != nil {
|
||||
args = append(args, "--stop-timeout", strconv.Itoa(*o.StopTimeout))
|
||||
}
|
||||
if o.ExtraArgs != "" {
|
||||
args = append(args, "--extra-args", o.ExtraArgs)
|
||||
if o.ExtraArgs != nil {
|
||||
args = append(args, "--extra-args", *o.ExtraArgs)
|
||||
}
|
||||
for _, kv := range o.Env {
|
||||
if strings.TrimSpace(kv) != "" {
|
||||
args = append(args, "--env", kv)
|
||||
}
|
||||
}
|
||||
return args, nil
|
||||
}
|
||||
|
||||
// ParseShow parses the text output of `reims-ctl show <name>` while redacting MAC addresses.
|
||||
func ParseShow(name, text string) VMDetail {
|
||||
d := VMDetail{
|
||||
Name: name,
|
||||
Displays: 1,
|
||||
Resolution: "1920x1080",
|
||||
DiskController: "ahci",
|
||||
Graphics: "reims-vgpu",
|
||||
GPU: "auto",
|
||||
Capture: true,
|
||||
StopTimeout: 90,
|
||||
}
|
||||
for _, rawLine := range strings.Split(text, "\n") {
|
||||
line := strings.TrimSpace(rawLine)
|
||||
if line == "" || line == name {
|
||||
continue
|
||||
}
|
||||
// Keys are separated from values by 2+ spaces in `reims-ctl show`.
|
||||
parts := regexp.MustCompile(`\s{2,}`).Split(line, 2)
|
||||
if len(parts) != 2 {
|
||||
continue
|
||||
}
|
||||
k := strings.ToLower(strings.TrimSpace(parts[0]))
|
||||
v := strings.TrimSpace(parts[1])
|
||||
switch k {
|
||||
case "state":
|
||||
d.State = v
|
||||
case "kind":
|
||||
d.Kind = v
|
||||
case "directory":
|
||||
d.Directory = v
|
||||
case "cpus":
|
||||
d.CPUs, _ = strconv.Atoi(v)
|
||||
case "memory":
|
||||
d.Memory = v
|
||||
case "disk":
|
||||
d.Disk = v
|
||||
low := strings.ToLower(v)
|
||||
switch {
|
||||
case strings.Contains(low, "nvme"):
|
||||
d.DiskController = "nvme"
|
||||
case strings.Contains(low, "virtio"):
|
||||
d.DiskController = "virtio"
|
||||
default:
|
||||
d.DiskController = "ahci"
|
||||
}
|
||||
case "graphics":
|
||||
if strings.HasPrefix(v, "vmware-svga") {
|
||||
d.Graphics = "vmware-svga"
|
||||
} else {
|
||||
d.Graphics = "reims-vgpu"
|
||||
}
|
||||
case "display":
|
||||
d.Display = v
|
||||
if m := reRes.FindString(v); m != "" {
|
||||
d.Resolution = m
|
||||
}
|
||||
if strings.Contains(strings.ToLower(v), "borderless") {
|
||||
d.Borderless = true
|
||||
}
|
||||
switch {
|
||||
case strings.HasPrefix(v, "two"):
|
||||
d.Displays = 2
|
||||
case strings.HasPrefix(v, "three"):
|
||||
d.Displays = 3
|
||||
case strings.HasPrefix(v, "four"):
|
||||
d.Displays = 4
|
||||
default:
|
||||
d.Displays = 1
|
||||
}
|
||||
case "gpu":
|
||||
if strings.HasPrefix(strings.ToLower(v), "automatic") {
|
||||
d.GPU = "auto"
|
||||
} else {
|
||||
d.GPU = v
|
||||
}
|
||||
case "opencore":
|
||||
d.HasOpenCore = v != ""
|
||||
case "installer":
|
||||
d.HasInstaller = v != "" && !strings.EqualFold(v, "none")
|
||||
d.InstallerPath = v
|
||||
case "cpu model":
|
||||
d.CPUModel = v
|
||||
case "audio":
|
||||
d.AudioRaw = v
|
||||
d.Audio = strings.HasPrefix(strings.ToLower(v), "on")
|
||||
case "network":
|
||||
// Redact MAC per docs/shell-design.md §3.
|
||||
d.NetworkSummary = strings.TrimSpace(reMac.ReplaceAllString(v, " (MAC configured)"))
|
||||
d.Network = !strings.EqualFold(v, "off") && !strings.EqualFold(v, "none")
|
||||
case "ssh":
|
||||
if m := regexp.MustCompile(`(\d+)`).FindString(v); m != "" {
|
||||
d.SSHPort, _ = strconv.Atoi(m)
|
||||
}
|
||||
case "logs":
|
||||
d.Logs = strings.HasPrefix(strings.ToLower(v), "on")
|
||||
if m := regexp.MustCompile(`\(([^)]+)\)`).FindStringSubmatch(v); len(m) == 2 {
|
||||
d.LogLevel = m[1]
|
||||
}
|
||||
case "stop timeout":
|
||||
if m := regexp.MustCompile(`(\d+)`).FindString(v); m != "" {
|
||||
d.StopTimeout, _ = strconv.Atoi(m)
|
||||
}
|
||||
case "capture":
|
||||
d.Capture = !strings.EqualFold(v, "off") && !strings.EqualFold(v, "false")
|
||||
case "extra args":
|
||||
d.ExtraArgs = v
|
||||
}
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (c *Client) run(ctx context.Context, stdout, stderr io.Writer, args ...string) error {
|
||||
cmd := exec.CommandContext(ctx, c.Binary, args...)
|
||||
configureCmd(cmd)
|
||||
cmd.Env = c.Env
|
||||
if stdout != nil {
|
||||
cmd.Stdout = stdout
|
||||
@@ -181,6 +504,18 @@ func (c *Client) run(ctx context.Context, stdout, stderr io.Writer, args ...stri
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (c *Client) List(ctx context.Context) ([]VMListItem, error) {
|
||||
var out, errBuf bytes.Buffer
|
||||
if err := c.run(ctx, &out, &errBuf, "list", "--json"); err != nil {
|
||||
return nil, fmt.Errorf("reims-ctl list: %w (%s)", err, strings.TrimSpace(errBuf.String()))
|
||||
}
|
||||
var list []VMListItem
|
||||
if err := json.Unmarshal(bytes.TrimSpace(out.Bytes()), &list); err != nil {
|
||||
return nil, fmt.Errorf("parse list --json: %w", err)
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (c *Client) ListRaw(ctx context.Context) ([]map[string]any, error) {
|
||||
var out, errBuf bytes.Buffer
|
||||
if err := c.run(ctx, &out, &errBuf, "list", "--json"); err != nil {
|
||||
@@ -193,6 +528,30 @@ func (c *Client) ListRaw(ctx context.Context) ([]map[string]any, error) {
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (c *Client) Show(ctx context.Context, name string) (VMDetail, error) {
|
||||
var out, errBuf bytes.Buffer
|
||||
if err := c.run(ctx, &out, &errBuf, "show", name); err != nil {
|
||||
return VMDetail{}, fmt.Errorf("reims-ctl show %s: %w (%s)", name, err, strings.TrimSpace(errBuf.String()))
|
||||
}
|
||||
return ParseShow(name, out.String()), nil
|
||||
}
|
||||
|
||||
func (c *Client) ReadLogs(ctx context.Context, name string, serial bool) (string, error) {
|
||||
args := []string{"logs", name}
|
||||
if serial {
|
||||
args = append(args, "--serial")
|
||||
}
|
||||
var out, errBuf bytes.Buffer
|
||||
if err := c.run(ctx, &out, &errBuf, args...); err != nil {
|
||||
msg := strings.TrimSpace(errBuf.String())
|
||||
if msg == "" {
|
||||
msg = err.Error()
|
||||
}
|
||||
return out.String(), fmt.Errorf("%s", msg)
|
||||
}
|
||||
return out.String(), nil
|
||||
}
|
||||
|
||||
func (c *Client) Create(ctx context.Context, o CreateOpts, stdout, stderr io.Writer) error {
|
||||
args, err := BuildCreateArgs(o)
|
||||
if err != nil {
|
||||
@@ -217,6 +576,10 @@ func (c *Client) Stop(ctx context.Context, name string, stdout, stderr io.Writer
|
||||
return c.run(ctx, stdout, stderr, "stop", name)
|
||||
}
|
||||
|
||||
func (c *Client) StopForce(ctx context.Context, name string, stdout, stderr io.Writer) error {
|
||||
return c.run(ctx, stdout, stderr, "stop", "--force", name)
|
||||
}
|
||||
|
||||
func (c *Client) Eject(ctx context.Context, name string, stdout, stderr io.Writer) error {
|
||||
return c.run(ctx, stdout, stderr, "eject", name)
|
||||
}
|
||||
|
||||
@@ -34,3 +34,30 @@ func TestBuildCreateArgs(t *testing.T) {
|
||||
t.Fatalf("args mismatch:\n got: %v\nwant: %v", args, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseShowRedactsMACAndDetectsInstaller(t *testing.T) {
|
||||
sample := `m0
|
||||
state stopped
|
||||
kind x86-64 macOS guest (q35 and OpenCore, WHPX)
|
||||
directory D:\Data\vms\m0
|
||||
cpus 8
|
||||
memory 12G
|
||||
disk disk.qcow2 (qcow2, SATA)
|
||||
graphics reims-vgpu, its own GPU device and macOS drivers
|
||||
display one, in a window opening at 1920x1080, whose size the guest follows
|
||||
gpu automatic: the only GPU, or a discrete one before an integrated one
|
||||
opencore D:\Data\vms\m0\opencore.qcow2
|
||||
installer D:\Data\vms\m0\installer.img
|
||||
cpu model Skylake-Client-noTSX-IBRS
|
||||
audio on
|
||||
network user, mac 52:54:00:12:34:56
|
||||
logs on (info)
|
||||
stop timeout 90 s`
|
||||
d := ParseShow("m0", sample)
|
||||
if d.CPUs != 8 || d.Memory != "12G" || d.Resolution != "1920x1080" || !d.HasInstaller {
|
||||
t.Fatalf("unexpected parsed detail: %+v", d)
|
||||
}
|
||||
if d.NetworkSummary == "" || d.NetworkSummary == "user, mac 52:54:00:12:34:56" {
|
||||
t.Fatalf("expected MAC to be redacted, got %q", d.NetworkSummary)
|
||||
}
|
||||
}
|
||||
@@ -21,3 +21,7 @@ func Inspect(dataRoot string) Report {
|
||||
func PinProcessToPCores(pid uint32, mask uint64) error {
|
||||
return fmt.Errorf("P-core affinity pinning is only supported on Windows (current OS: %s)", runtime.GOOS)
|
||||
}
|
||||
|
||||
func EnableWHPXElevated() error {
|
||||
return fmt.Errorf("WHPX elevation is only supported on Windows (current OS: %s)", runtime.GOOS)
|
||||
}
|
||||
@@ -21,10 +21,13 @@ var (
|
||||
procSetProcessAffinityMask = kernel32.NewProc("SetProcessAffinityMask")
|
||||
procCloseHandle = kernel32.NewProc("CloseHandle")
|
||||
|
||||
advapi32 = syscall.NewLazyDLL("advapi32.dll")
|
||||
procRegOpenKeyExW = advapi32.NewProc("RegOpenKeyExW")
|
||||
advapi32 = syscall.NewLazyDLL("advapi32.dll")
|
||||
procRegOpenKeyExW = advapi32.NewProc("RegOpenKeyExW")
|
||||
procRegQueryValueExW = advapi32.NewProc("RegQueryValueExW")
|
||||
procRegCloseKey = advapi32.NewProc("RegCloseKey")
|
||||
procRegCloseKey = advapi32.NewProc("RegCloseKey")
|
||||
|
||||
shell32 = syscall.NewLazyDLL("shell32.dll")
|
||||
procShellExecuteW = shell32.NewProc("ShellExecuteW")
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -98,6 +101,25 @@ func PinProcessToPCores(pid uint32, mask uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// EnableWHPXElevated invokes a standard Windows UAC prompt to enable Windows Hypervisor Platform.
|
||||
func EnableWHPXElevated() error {
|
||||
verb, _ := syscall.UTF16PtrFromString("runas")
|
||||
file, _ := syscall.UTF16PtrFromString("powershell.exe")
|
||||
params, _ := syscall.UTF16PtrFromString(`-NoProfile -Command "Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All -NoRestart; Write-Host 'Done. Please restart Windows.'; Start-Sleep -Seconds 3"`)
|
||||
r, _, err := procShellExecuteW.Call(
|
||||
0,
|
||||
uintptr(unsafe.Pointer(verb)),
|
||||
uintptr(unsafe.Pointer(file)),
|
||||
uintptr(unsafe.Pointer(params)),
|
||||
0,
|
||||
1, // SW_SHOWNORMAL
|
||||
)
|
||||
if r <= 32 {
|
||||
return fmt.Errorf("ShellExecuteW runas failed (code %d): %w", r, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func probeWHPX() WHPXState {
|
||||
mod := syscall.NewLazyDLL("WinHvPlatform.dll")
|
||||
if err := mod.Load(); err != nil {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//go:build !windows
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// OpenFolder shows dir in the platform file manager (dev/preview hosts only).
|
||||
func OpenFolder(dir string) error {
|
||||
info, err := os.Stat(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return fmt.Errorf("not a directory: %s", dir)
|
||||
}
|
||||
opener := "xdg-open"
|
||||
if runtime.GOOS == "darwin" {
|
||||
opener = "open"
|
||||
}
|
||||
return exec.Command(opener, dir).Start()
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//go:build windows
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// OpenFolder shows dir in File Explorer. explorer.exe exits non-zero even on
|
||||
// success, so the process is started and not waited on.
|
||||
func OpenFolder(dir string) error {
|
||||
info, err := os.Stat(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return fmt.Errorf("not a directory: %s", dir)
|
||||
}
|
||||
return exec.Command("explorer.exe", dir).Start()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//go:build !windows
|
||||
|
||||
package runtime
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func configureCmd(cmd *exec.Cmd) {}
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build windows
|
||||
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const createNoWindow = 0x08000000
|
||||
|
||||
func configureCmd(cmd *exec.Cmd) {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
HideWindow: true,
|
||||
CreationFlags: createNoWindow,
|
||||
}
|
||||
}
|
||||
@@ -305,6 +305,7 @@ func extractTarZst(archivePath, destDir string) error {
|
||||
// Windows 10/11 built-in bsdtar supports .tar.zst natively on modern builds;
|
||||
// fall back to zstd -dc | tar -xf if needed.
|
||||
cmd := exec.Command("tar", "-xf", archivePath, "-C", destDir)
|
||||
configureCmd(cmd)
|
||||
if out, err := cmd.CombinedOutput(); err == nil {
|
||||
return nil
|
||||
} else {
|
||||
@@ -314,6 +315,8 @@ func extractTarZst(archivePath, destDir string) error {
|
||||
}
|
||||
z := exec.Command(zstdBin, "-dc", archivePath)
|
||||
t := exec.Command("tar", "-xf", "-", "-C", destDir)
|
||||
configureCmd(z)
|
||||
configureCmd(t)
|
||||
pipe, err := z.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
func main() {
|
||||
app := NewApp()
|
||||
err := wails.Run(&options.App{
|
||||
Title: "reims-go",
|
||||
Width: 1120,
|
||||
Height: 740,
|
||||
MinWidth: 920,
|
||||
MinHeight: 600,
|
||||
Frameless: true,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 28, G: 28, B: 30, A: 255},
|
||||
Windows: &windows.Options{
|
||||
Theme: windows.Dark,
|
||||
WebviewIsTransparent: false,
|
||||
WindowIsTranslucent: false,
|
||||
CustomTheme: &windows.ThemeSettings{
|
||||
DarkModeTitleBar: windows.RGB(28, 28, 30),
|
||||
DarkModeTitleText: windows.RGB(245, 245, 247),
|
||||
DarkModeBorder: windows.RGB(58, 58, 62),
|
||||
},
|
||||
},
|
||||
OnStartup: app.startup,
|
||||
OnShutdown: app.shutdown,
|
||||
Bind: []any{
|
||||
app,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"$schema": "https://wails.io/schemas/config.v2.json",
|
||||
"name": "reims-go",
|
||||
"outputfilename": "reims-go",
|
||||
"frontend:install": "pnpm install",
|
||||
"frontend:build": "pnpm run build",
|
||||
"frontend:dev:watcher": "pnpm run dev",
|
||||
"frontend:dev:serverUrl": "auto",
|
||||
"author": {
|
||||
"name": "reims-go"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user