-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
105 lines (92 loc) · 3.28 KB
/
Copy pathmain.go
File metadata and controls
105 lines (92 loc) · 3.28 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// catdb — a cross-platform database management tool built on Wails v3.
//
// IMPORTANT: per CLAUDE.md #1, this file is the ONLY place outside
// wailsbridge/ that may import github.com/wailsapp/wails/v3/pkg/application
// directly. Everything else routes through wailsbridge.
package main
import (
"context"
"embed"
"log"
"runtime"
"github.com/wailsapp/wails/v3/pkg/application"
"catdb/internal/core/session"
"catdb/internal/platform"
"catdb/internal/services"
"catdb/internal/storage"
_ "catdb/plugins"
"catdb/wailsbridge"
)
//go:embed all:frontend/dist
var assets embed.FS
func init() {
application.RegisterEvent[map[string]any]("transfer:progress")
application.RegisterEvent[map[string]any]("window:close-blocked")
application.RegisterEvent[map[string]any]("custom:switch-english-input")
application.RegisterEvent[map[string]any]("connection:saved")
application.RegisterEvent[map[string]any]("update:progress")
}
func main() {
store, err := storage.Open("")
if err != nil {
log.Fatalf("storage: %v", err)
}
defer store.Close()
secrets := storage.NewSecrets("catdb")
mgr := session.NewManager(store, secrets)
defer mgr.CloseAll()
settingsSvc := services.NewSettingsService(store)
app := application.New(application.Options{
Name: "catdb",
Description: "Cross-platform database management tool",
Services: []application.Service{
application.NewService(services.NewConnectionService(store, secrets, mgr)),
application.NewService(services.NewQueryService(mgr)),
application.NewService(services.NewMetadataService(mgr)),
application.NewService(services.NewEditService(mgr)),
application.NewService(services.NewTransferService(mgr)),
application.NewService(services.NewSystemService()),
application.NewService(services.NewSavedQueryService(store)),
application.NewService(services.NewUpdateService(store, "")),
application.NewService(settingsSvc),
},
Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets),
},
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
wailsbridge.SetApp(app)
// Listen for front-end focus events on the SQL editor — switch to English
// input source on macOS so SQL typing starts in the correct layout.
app.Event.On("custom:switch-english-input", func(_ *application.CustomEvent) {
platform.SwitchToEnglishInputSource()
})
// Seed the native-menu locale from the persisted preference so the app
// menu + context menus render in the right language from the first frame.
if loc, err := settingsSvc.GetLocale(context.Background()); err == nil {
wailsbridge.InitMenuLocale(loc)
}
app.Menu.SetApplicationMenu(wailsbridge.BuildApplicationMenu(app))
wailsbridge.RegisterContextMenus(app)
win := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "catdb",
Width: 1200,
Height: 760,
MinWidth: 600,
MinHeight: 500,
Frameless: runtime.GOOS == "windows",
Mac: application.MacWindow{
InvisibleTitleBarHeight: 30,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
BackgroundColour: application.NewRGB(245, 245, 247),
URL: "/",
})
wailsbridge.AttachCloseGuard(win)
if err := app.Run(); err != nil {
log.Fatal(err)
}
}