-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (56 loc) · 1.38 KB
/
Copy pathmain.go
File metadata and controls
60 lines (56 loc) · 1.38 KB
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
package main
import (
"context"
"fmt"
"io/fs"
"time"
"github.com/sbol/sbazeroth/internal/storage"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
func main() {
assets, err := fs.Sub(embeddedAssets, embeddedAssetsRoot)
if err != nil {
panic(fmt.Errorf("prepare embedded assets: %w", err))
}
database := applicationDataPath("sbazeroth.db")
if database == "" {
panic("resolve application database path")
}
store, err := storage.Open(database)
if err != nil {
panic(err)
}
defer store.Close()
migrationContext, cancelMigration := context.WithTimeout(context.Background(), 5*time.Second)
if err := store.ImportLegacyRuntimeSettings(migrationContext, applicationDataPath("settings.json")); err != nil {
cancelMigration()
panic(err)
}
cancelMigration()
app, err := NewApp(store)
if err != nil {
panic(err)
}
err = wails.Run(&options.App{
Title: "SBAzeroth",
Width: 1280,
Height: 800,
MinWidth: 1100,
MinHeight: 700,
BackgroundColour: &options.RGBA{R: 9, G: 11, B: 11, A: 1},
AssetServer: &assetserver.Options{
Assets: assets,
},
OnStartup: app.startup,
OnShutdown: app.shutdown,
OnBeforeClose: app.beforeClose,
Bind: []interface{}{
app,
},
})
if err != nil {
panic(fmt.Errorf("run SBAzeroth: %w", err))
}
}