-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_menu.go
More file actions
40 lines (32 loc) · 956 Bytes
/
app_menu.go
File metadata and controls
40 lines (32 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"log"
"github.com/linhay/gettokens/internal/appmenu"
"github.com/wailsapp/wails/v2/pkg/menu"
)
const macOSCheckForUpdatesMenuLabel = "检查更新..."
func buildApplicationMenu(app *App) *menu.Menu {
return buildApplicationMenuWithUpdateAction(func() {})
}
func buildApplicationMenuWithUpdateAction(checkForUpdates func()) *menu.Menu {
_ = checkForUpdates
return menu.NewMenuFromItems(
menu.AppMenu(),
menu.EditMenu(),
menu.WindowMenu(),
)
}
func installNativeApplicationMenuUpdateItem(app *App) {
if err := appmenu.InstallCheckForUpdates(macOSCheckForUpdatesMenuLabel, appmenu.Callbacks{
CheckForUpdates: func() {
go app.checkForUpdatesFromMenu()
},
}); err != nil {
log.Printf("install macOS check for updates menu item failed: %v", err)
}
}
func (a *App) checkForUpdatesFromMenu() {
if _, err := a.CheckUpdate(); err != nil {
log.Printf("check for updates from macOS menu failed: %v", err)
}
}