feat(ui): 开机自启动 + 窗口大小记忆

- win32/autostart: SetAutoStart/IsAutoStartEnabled 操作 HKCU Run 键
- win32/window_size: GetWindowSize 通过 GetWindowRect 获取窗口尺寸
- config: 新增 AutoStart、WindowWidth、WindowHeight 字段
- store: Preferences/SetPreferences 扩展支持 autoStart + windowSize
- dialog_preferences: 新增"开机自启动"复选框
- app.go: 启动时恢复窗口大小,关闭时通过 SetWindowSize 保存
- i18n: label_auto_start / hint_auto_start 三语翻译
This commit is contained in:
2026-06-12 11:10:25 +08:00
parent cb4d88ebdd
commit 1605b5b7ae
11 changed files with 278 additions and 17 deletions
+13 -2
View File
@@ -13,7 +13,7 @@ import (
)
// preferencesDialog edits the persistent UI prefs: UI language, theme,
// auto-lock timeout, and minimize-to-tray behaviour.
// auto-lock timeout, minimize-to-tray, and auto-start behaviour.
type preferencesDialog struct {
lang string
theme themeMode
@@ -38,6 +38,10 @@ type preferencesDialog struct {
// system tray instead of exiting. Tray icon stays visible either way.
minToTray widget.Bool
// Auto-start: when on, the app is registered in the Windows Run key
// to launch at logon.
autoStart widget.Bool
okBt widget.Clickable
cancelBt widget.Clickable
}
@@ -50,6 +54,7 @@ type preferencesResult struct {
theme themeMode
autoLockMinutes int
minimizeToTray bool
autoStart bool
}
// supportedLanguages is the closed set the prefs dialog exposes. Keep
@@ -63,7 +68,7 @@ var supportedLanguages = []struct {
{"de", "Deutsch"},
}
func newPreferencesDialog(currentLang string, currentTheme themeMode, currentAutoLock int, currentMinToTray bool) *preferencesDialog {
func newPreferencesDialog(currentLang string, currentTheme themeMode, currentAutoLock int, currentMinToTray, currentAutoStart bool) *preferencesDialog {
if currentLang == "" {
currentLang = "en"
}
@@ -74,6 +79,7 @@ func newPreferencesDialog(currentLang string, currentTheme themeMode, currentAut
d.autoLockEd.SingleLine = true
d.autoLockEd.SetText(strconv.Itoa(currentAutoLock))
d.minToTray.Value = currentMinToTray
d.autoStart.Value = currentAutoStart
return d
}
@@ -98,6 +104,7 @@ func (d *preferencesDialog) Layout(
theme: d.theme,
autoLockMinutes: mins,
minimizeToTray: d.minToTray.Value,
autoStart: d.autoStart.Value,
})
return layout.Dimensions{Size: gtx.Constraints.Max}
}
@@ -164,6 +171,10 @@ func (d *preferencesDialog) Layout(
layout.Rigid(material.CheckBox(th, &d.minToTray, i18n.T("label_minimize_to_tray")).Layout),
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
layout.Rigid(material.Caption(th, i18n.T("hint_minimize_to_tray")).Layout),
layout.Rigid(layout.Spacer{Height: unit.Dp(12)}.Layout),
layout.Rigid(material.CheckBox(th, &d.autoStart, i18n.T("label_auto_start")).Layout),
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
layout.Rigid(material.Caption(th, i18n.T("hint_auto_start")).Layout),
)
}