diff --git a/internal/gui/app.go b/internal/gui/app.go index 9171cc7a3..b070eb537 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -230,6 +230,15 @@ func Run(version string, showMain bool, link string) error { } h.tray.SetMenu(menu) h.tray.AttachWindow(h.panel).WindowOffset(6) + // the quick panel by the icon, or the main window if the user would + // rather (Settings → Tray icon) + h.tray.OnClick(func() { + if settings.Load().Tray == "window" { + h.ShowMain("") + return + } + h.tray.ToggleWindow() + }) // Wails shows a Windows webview 3s after Show whether or not WebView2 // has made its controller yet, and a slow first start then crashes on diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 600e30d82..a9094dfdb 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -1759,11 +1759,13 @@ function renderUsage() { // ---------- settings ---------- // -// Two choices (palette, language) and the facts people come looking for: +// Three choices (palette, language, what the tray icon opens) and the facts +// people come looking for: // the version, where magpie keeps its files, the gateway's address. const THEMES = [["system", "System"], ["light", "Light"], ["dark", "Dark"]]; const LOCALES = [["system", "System"], ["en", "English"], ["zh", "中文"]]; +const TRAYS = [["panel", "Quick panel"], ["window", "Main window"]]; // applyPrefs paints and speaks as the saved settings say. A ?theme= or // ?locale= in the URL wins, so a forced look stays forced. @@ -1795,8 +1797,10 @@ async function loadSettings() { function renderSettings() { const s = prefs; - $("#themeSegs").replaceChildren(segs(THEMES.map(([id, name]) => [id, t(name)]), s.theme, (theme) => savePrefs({ theme, lang: s.lang }))); - $("#langSegs").replaceChildren(segs(LOCALES.map(([id, name]) => [id, t(name)]), s.lang, (lang) => savePrefs({ theme: s.theme, lang }))); + const keep = { theme: s.theme, lang: s.lang, tray: s.tray }; + $("#themeSegs").replaceChildren(segs(THEMES.map(([id, name]) => [id, t(name)]), s.theme, (theme) => savePrefs({ ...keep, theme }))); + $("#langSegs").replaceChildren(segs(LOCALES.map(([id, name]) => [id, t(name)]), s.lang, (lang) => savePrefs({ ...keep, lang }))); + $("#traySegs").replaceChildren(segs(TRAYS.map(([id, name]) => [id, t(name)]), s.tray || "panel", (tray) => savePrefs({ ...keep, tray }))); const about = $("#about"); about.replaceChildren(); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 766b94be6..a15de4faf 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -31,6 +31,10 @@ const I18N = { "{agent} stays signed in; magpie just stops offering it": "{agent} 仍保持登录,只是 magpie 不再提供它", "You removed it from magpie.": "你已把它从 magpie 中移除。", "Add it back": "加回来", + "Tray icon": "托盘图标", + "What clicking magpie’s icon in the menu bar or tray opens": "点击菜单栏或托盘里的 magpie 图标时打开什么", + "Quick panel": "快捷面板", + "Main window": "主窗口", "{name} added back": "已加回 {name}", "auth": "认证", "agent default": "Agent 默认值", diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index b31a9d2e9..327032169 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -88,6 +88,10 @@