-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
72 lines (62 loc) · 1.4 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 (
"context"
"embed"
"github.com/jsawo/renfield/beam"
"github.com/jsawo/renfield/config"
"github.com/jsawo/renfield/json"
"github.com/jsawo/renfield/tinker"
"github.com/jsawo/renfield/wasm"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/linux"
)
var (
appAPI *App
tinkerAPI *tinker.Tinker
jsonToolsAPI *json.JSONTools
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed build/appicon.png
var icon []byte
func main() {
config.Load()
appAPI = NewApp()
wasm.InitializeService()
tinkerAPI = tinker.NewTinker()
jsonToolsAPI = json.NewJSONTools()
err := wails.Run(&options.App{
Title: "Renfield",
Width: 1324,
Height: 1024,
Assets: assets,
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: appStartup,
Bind: []any{
appAPI,
tinkerAPI,
jsonToolsAPI,
},
Linux: &linux.Options{
Icon: icon,
WindowIsTranslucent: false,
},
// WindowStartState: options.Minimised,
// Debug: options.Debug{
// OpenInspectorOnStartup: true,
// },
})
if err != nil {
println("Error:", err.Error())
}
}
func appStartup(ctx context.Context) {
propagateContext(ctx)
beam.StartServer(ctx)
}
func propagateContext(ctx context.Context) {
appAPI.ctx = ctx
tinkerAPI.Ctx = ctx
jsonToolsAPI.Ctx = ctx
}