Added mermaid language support

This commit is contained in:
2025-11-04 22:58:36 +08:00
parent 689b0d5d14
commit e9b6fef3cd
87 changed files with 4359 additions and 27 deletions

View File

@@ -9,7 +9,7 @@ import (
)
// RegisterTrayEvents 注册与系统托盘相关的所有事件
func RegisterTrayEvents(app *application.App, systray *application.SystemTray, mainWindow *application.WebviewWindow, trayService *services.TrayService) {
func RegisterTrayEvents(systray *application.SystemTray, mainWindow *application.WebviewWindow, trayService *services.TrayService) {
// 不附加窗口到系统托盘,避免失去焦点自动缩小
// systray.AttachWindow(mainWindow)
@@ -18,7 +18,7 @@ func RegisterTrayEvents(app *application.App, systray *application.SystemTray, m
// 设置点击托盘图标显示主窗口
systray.OnClick(func() {
trayService.ShowWindow()
trayService.AutoShowHide()
})
// 处理窗口关闭事件 - 根据配置决定是隐藏到托盘还是直接退出

View File

@@ -59,3 +59,8 @@ func (ts *TrayService) ShowWindow() {
func (ts *TrayService) MinimizeButtonClicked() {
ts.windowHelper.MinimiseMainWindow()
}
// AutoShowHide 自动显示/隐藏主窗口
func (ts *TrayService) AutoShowHide() {
ts.windowHelper.AutoShowMainWindow()
}

View File

@@ -67,3 +67,13 @@ func (wh *WindowHelper) FocusMainWindow() bool {
}
return false
}
// AutoShowMainWindow 自动显示主窗口
func (wh *WindowHelper) AutoShowMainWindow() {
window := wh.MustGetMainWindow()
if window.IsVisible() {
window.Hide()
} else {
window.Show()
}
}

View File

@@ -3,6 +3,9 @@ package systray
import (
"embed"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/icons"
"runtime"
"time"
"voidraft/internal/events"
"voidraft/internal/services"
"voidraft/internal/version"
@@ -18,8 +21,19 @@ func SetupSystemTray(mainWindow *application.WebviewWindow, assets embed.FS, tra
// 设置标签
systray.SetLabel("voidraft")
// 设置图标
iconBytes, _ := assets.ReadFile("appicon.png")
iconBytes, err := assets.ReadFile("frontend/dist/appicon.png")
if err != nil {
panic(err)
}
systray.SetIcon(iconBytes)
systray.SetDarkModeIcon(iconBytes)
// Use the template icon on macOS so the clock respects light/dark modes.
if runtime.GOOS == "darwin" {
systray.SetTemplateIcon(icons.SystrayMacTemplate)
}
systray.WindowDebounce(300 * time.Millisecond)
// 创建托盘菜单
menu := app.NewMenu()
@@ -30,5 +44,5 @@ func SetupSystemTray(mainWindow *application.WebviewWindow, assets embed.FS, tra
systray.SetMenu(menu)
// 注册托盘相关事件
events.RegisterTrayEvents(app, systray, mainWindow, trayService)
events.RegisterTrayEvents(systray, mainWindow, trayService)
}