Files
winauth-go/internal/config/model.go
T
iceking2nd b483360778 feat(ui): 主题切换 + 语言持久化 + About 对话框
- 新增 light/dark 主题调色板与 Windows 注册表系统主题探测
- 偏好设置对话框:主题三选一 + 语言下拉(en/zh-CN/de),即时生效
- 持久化 Language/Theme/AutoLockMinutes/MinimizeToTray 至 YAML 顶层
- 启动时按 config 中保存的语言初始化 i18n
- About 对话框展示 version/runtime/项目地址/许可证
- 全部硬编码颜色迁移到 themePalette,为深色模式做准备
2026-06-12 03:38:13 +08:00

38 lines
2.1 KiB
Go

// Package config defines the persistent shape of a winauth-go config and
// provides loaders for both the new YAML format and the legacy WinAuth
// XML format produced by the original C# application.
package config
// Entry is a serialized authenticator inside the config file. Vendor
// determines how Data is interpreted by the authenticator package's
// SetSecretData method.
type Entry struct {
Name string `yaml:"name" json:"name"`
Vendor string `yaml:"vendor" json:"vendor"` // google|microsoft|okta|hotp|battlenet|steam
IconName string `yaml:"icon" json:"icon,omitempty"`
SecretRaw string `yaml:"secret" json:"secret"` // value returned by Authenticator.SecretData()
// Hotkey is a human-readable global hotkey like "Ctrl+Alt+G". Empty
// means no hotkey. Parsed by internal/hotkey.Parse — invalid strings
// log a warning at registration time and are otherwise ignored.
Hotkey string `yaml:"hotkey,omitempty" json:"hotkey,omitempty"`
}
// Config is the top-level file shape. Entries are stored unencrypted by
// default; if Encrypted is true, EncryptedBlob holds a WAGO1 base64 ciphertext
// produced by internal/crypto.EncryptModern and Entries is empty on disk.
type Config struct {
Version int `yaml:"version" json:"version"`
Language string `yaml:"language,omitempty" json:"language,omitempty"`
// Theme is one of "", "light", "dark", "system" (empty = system).
Theme string `yaml:"theme,omitempty" json:"theme,omitempty"`
// AutoLockMinutes locks the UI (hides codes, requires password) after
// this many minutes of inactivity. 0 disables auto-lock.
AutoLockMinutes int `yaml:"auto_lock_minutes,omitempty" json:"auto_lock_minutes,omitempty"`
// MinimizeToTray sends the window to the system tray instead of
// exiting when the close button is pressed.
MinimizeToTray bool `yaml:"minimize_to_tray,omitempty" json:"minimize_to_tray,omitempty"`
Encrypted bool `yaml:"encrypted" json:"encrypted"`
EncryptedBlob string `yaml:"encrypted_blob,omitempty" json:"encrypted_blob,omitempty"`
Entries []Entry `yaml:"entries,omitempty" json:"entries,omitempty"`
}