-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
104 lines (93 loc) · 2.04 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
98
99
100
101
102
103
104
package main
import (
"context"
"embed"
"log"
"time"
"flow-poc/backend/config"
"flow-poc/backend/db"
dirhandler "flow-poc/backend/filesystem/dir_handler"
"flow-poc/backend/filesystem/file_handler"
"flow-poc/backend/filesystem/node"
"flow-poc/backend/games"
"flow-poc/backend/topmenu"
"flow-poc/backend/watcher"
"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/runtime"
)
//go:embed all:frontend/dist
var assets embed.FS
type Bar struct {
Name string
}
func main() {
// Create an instance of the app structure
app := NewApp()
queries := db.ConnectToDb()
topmenu := topmenu.NewTopMenu()
config := config.NewAppConfig()
fh := file_handler.NewFileHandler(config)
dh := dirhandler.NewDirHandler(config, fh.RecentFiles)
w := watcher.New(config)
gr := games.NewGameRepository(queries)
go func() {
w.Wait()
}()
go func() {
if err := w.Start(time.Millisecond * 100); err != nil {
log.Fatalln(err)
}
}()
go func() {
for {
select {
case err := <-w.Error:
log.Fatalln(err)
case evt := <-w.Event:
evt.MarshalFrontend(config.ConfigFile.LabPath)
log.Printf("event reçu %s", evt)
runtime.EventsEmit(w.Ctx, "fsop", evt)
}
}
}()
// Create application with options
err := wails.Run(&options.App{
Title: "LabMonster",
Width: 1024,
Height: 768,
AlwaysOnTop: false,
WindowStartState: options.Maximised,
Frameless: true,
DisableResize: false,
AssetServer: &assetserver.Options{
Assets: assets,
},
OnStartup: func(ctx context.Context) {
app.SetContext(ctx)
topmenu.SetContext(ctx)
config.SetContext(ctx)
w.SetContext(ctx)
},
Bind: []interface{}{
app,
topmenu,
config,
fh,
dh,
gr,
},
EnumBind: []interface{}{
watcher.FsOps,
node.FTypes,
node.DTypes,
},
OnShutdown: func(ctx context.Context) {
fh.RecentFiles.SaveRecentlyOpended()
},
})
if err != nil {
println("Error:", err.Error())
}
}