forked from anfragment/zen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (69 loc) · 1.7 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
73
74
75
76
77
78
79
package main
import (
"embed"
"fmt"
"log"
"os"
"runtime"
"github.com/anfragment/zen/internal/app"
"github.com/anfragment/zen/internal/autostart"
"github.com/anfragment/zen/internal/cfg"
"github.com/anfragment/zen/internal/logger"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
const (
appName = "Zen"
)
//go:embed all:frontend/dist
var assets embed.FS
func main() {
err := logger.SetupLogger()
if err != nil {
log.Printf("failed to setup logger: %v", err)
}
log.Printf("initializing the app; version=%q", cfg.Version)
config, err := cfg.NewConfig()
if err != nil {
log.Fatalf("failed to load config: %v", err)
}
var startOnDomReady bool
for _, arg := range os.Args[1:] {
if arg == "--start" {
startOnDomReady = true
}
}
app, err := app.NewApp(appName, config, startOnDomReady)
if err != nil {
log.Fatalf("failed to create app: %v", err)
}
autostart := &autostart.Manager{}
err = wails.Run(&options.App{
Title: appName,
Width: 420,
Height: 650,
DisableResize: true,
AssetServer: &assetserver.Options{
Assets: assets,
},
OnStartup: app.Startup,
OnBeforeClose: app.BeforeClose,
Bind: []interface{}{
app,
config,
autostart,
},
Mac: &mac.Options{
About: &mac.AboutInfo{
Title: appName,
Message: fmt.Sprintf("Your Comprehensive Ad-Blocker and Privacy Guard\nVersion: %s\n© 2024 Ansar Smagulov", cfg.Version),
},
},
HideWindowOnClose: runtime.GOOS == "darwin" || runtime.GOOS == "windows", // only macOS keeps closed windows in taskbar
})
if err != nil {
log.Fatal(err)
}
}