-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
97 lines (85 loc) · 2.49 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"embed"
_ "embed"
"fmt"
"os"
"time"
"code.vegaprotocol.io/vegawallet-desktop/app"
"code.vegaprotocol.io/vegawallet-desktop/backend"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
//go:embed build/appicon.png
var icon []byte
//go:embed frontend/dist
var assets embed.FS
func main() {
log := startupLogger()
defer func() {
if r := recover(); r != nil {
log.Fatal(fmt.Sprintf("Recovered from a panic: %v", r))
}
}()
pid := os.Getpid()
date := time.Now().UTC().Format("2006-01-02-15-04-05")
// Create an instance of the handler structure
handler := backend.NewHandler(icon)
log.Info(fmt.Sprintf("Starting the application: OptmizedFor(%s), PID(%d), date(%v)", app.OptimizedFor, pid, date))
defer log.Info(fmt.Sprintf("The application exited: OptmizedFor(%s), PID(%d), date(%v)", app.OptimizedFor, pid, date))
// Create application with options
if err := wails.Run(&options.App{
Title: app.Name,
Width: 540,
Height: 540,
MinWidth: 540,
MinHeight: 540,
Menu: handler.AppMenu(),
BackgroundColour: options.NewRGBA(0, 0, 0, 255),
AssetServer: &assetserver.Options{
Assets: assets,
},
Logger: log,
LogLevel: logger.INFO,
OnStartup: handler.Startup,
OnDomReady: handler.DOMReady,
OnShutdown: handler.Shutdown,
Bind: []interface{}{
handler,
},
Windows: &windows.Options{
WebviewIsTransparent: false,
WindowIsTranslucent: false,
DisableWindowIcon: false,
},
Mac: &mac.Options{
TitleBar: mac.TitleBarHiddenInset(),
WebviewIsTransparent: true,
WindowIsTranslucent: true,
About: &mac.AboutInfo{
Title: app.Name,
Message: app.About,
Icon: icon,
},
},
Linux: &linux.Options{
Icon: icon,
},
}); err != nil {
log.Fatal(fmt.Sprintf("The application encountered an error while running: %v, OptmizedFor(%s), PID(%d), date(%v)", err, app.OptimizedFor, pid, date))
}
}
func startupLogger() logger.Logger {
startupLogFilePath, err := app.StartupLogFilePath()
if err != nil {
// There is not much we can do, except fallback on a basic standard output
// logger.
return logger.NewDefaultLogger()
}
return logger.NewFileLogger(startupLogFilePath)
}