-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
72 lines (64 loc) · 1.67 KB
/
main.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"embed"
"runtime"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/menu/keys"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/mac"
wr "github.com/wailsapp/wails/v2/pkg/runtime"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed build/appicon.png
var icon []byte
func main() {
// Create an instance of the app structure
app := NewApp()
AppMenu := menu.NewMenu()
ColckMenu := AppMenu.AddSubmenu("File")
ColckMenu.AddText("退出", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
wr.Quit(app.ctx)
})
if runtime.GOOS == "darwin" {
AppMenu.Append(menu.EditMenu()) // on macos platform, we should append EditMenu to enable Cmd+C,Cmd+V,Cmd+Z... shortcut
}
// Create application with options
err := wails.Run(&options.App{
Title: "clock",
Width: 450,
Height: 175,
Menu: AppMenu, // reference the menu above
AssetServer: &assetserver.Options{
Assets: assets,
},
Frameless: true,
DisableResize: true,
AlwaysOnTop: true,
BackgroundColour: &options.RGBA{R: 0, G: 0, B: 0, A: 0},
OnStartup: app.startup,
Bind: []interface{}{
app,
},
Mac: &mac.Options{
TitleBar: nil,
Appearance: "",
WebviewIsTransparent: true,
WindowIsTranslucent: true,
Preferences: nil,
DisableZoom: false,
About: &mac.AboutInfo{
Title: "PFClock",
Message: "PFinalClub Clock",
Icon: icon,
},
OnFileOpen: nil,
OnUrlOpen: nil,
},
})
if err != nil {
println("Error:", err.Error())
}
}