-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
87 lines (79 loc) · 2.21 KB
/
main.go
File metadata and controls
87 lines (79 loc) · 2.21 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
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
package main
import (
"context"
"embed"
"fmt"
"time"
"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/windows"
)
//go:embed all:frontend/dist
var assets embed.FS
func main() {
start := time.Now()
// 1. Create service instances (Fast: just memory allocation)
app := NewApp()
storage := NewStorage()
engine := NewEngine(storage)
triggerManager := NewTriggerManager(engine, storage)
actionService := NewActionService(app, storage)
excelService := NewExcelService()
// 2. Launch Wails window immediately
err := wails.Run(&options.App{
Title: "ForgeFlow",
Width: 1280,
Height: 800,
MinWidth: 1024,
MinHeight: 600,
DisableResize: false,
Fullscreen: false,
Frameless: true,
StartHidden: false,
HideWindowOnClose: false,
BackgroundColour: &options.RGBA{R: 30, G: 30, B: 30, A: 255},
AssetServer: &assetserver.Options{
Assets: assets,
},
OnStartup: func(ctx context.Context) {
// Initialize app context for binding
app.startup(ctx)
// 3. Move disk-heavy initialization to a background goroutine
// This allows the splash screen to show UP instantly.
go func() {
storage.Init()
triggerManager.StartAllTriggers()
fmt.Printf("✅ ForgeFlow Engine ready in %v\n", time.Since(start))
}()
},
OnShutdown: func(ctx context.Context) {
triggerManager.Shutdown()
app.shutdown(ctx)
},
Bind: []interface{}{
app,
engine,
storage,
triggerManager,
actionService,
excelService,
},
Windows: &windows.Options{
WebviewIsTransparent: false,
WindowIsTranslucent: false,
Theme: windows.Dark,
CustomTheme: &windows.ThemeSettings{
DarkModeTitleBar: windows.RGB(30, 30, 30), // #1e1e1e
DarkModeTitleText: windows.RGB(212, 212, 212), // #d4d4d4
DarkModeBorder: windows.RGB(62, 62, 66), // #3e3e42
LightModeTitleBar: windows.RGB(30, 30, 30),
LightModeTitleText: windows.RGB(212, 212, 212),
LightModeBorder: windows.RGB(62, 62, 66),
},
},
})
if err != nil {
fmt.Printf("Startup Error: %v\n", err)
}
}