-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.wails.go
74 lines (63 loc) · 1.87 KB
/
main.wails.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
package main
import (
"context"
"my-app/backend/app"
"my-app/backend/app/config"
"my-app/backend/service"
"my-app/backend/tray"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
// Wails Life Cycle
type wailsapp struct {
ctx context.Context
}
// get title from i18n translation
func (w *wailsapp) title() string {
return app.App().CurrentTranslation().AppName
}
// get current color theme from app config
func (w *wailsapp) windowTheme() (t windows.Theme) {
switch app.App().Config().ColorTheme {
default:
t = windows.SystemDefault
case config.ColorThemeLight:
t = windows.Light
case config.ColorThemeDark:
t = windows.Dark
}
return
}
// startup is called at application startup
func (w *wailsapp) startup(ctx context.Context) {
w.ctx = ctx
service.Service(ctx)
tray.Tray(ctx)
app.App().Log().Wails().Print("WAILS START UP")
}
// domReady is called after the front-end dom has been loaded
func (w *wailsapp) domReady(ctx context.Context) {
if app.App().Config().Web().IsAutoStart() {
tray.Tray().StartWebService()
}
app.App().Log().Wails().Print("WAILS DOM READY")
}
// beforeClose is called when the application is about to quit,
// either by clicking the window close button or calling runtime.Quit.
// Returning true will cause the application to continue,
// false will continue shutdown as normal.
func (w *wailsapp) beforeClose(ctx context.Context) (prevent bool) {
app.App().Log().Wails().Print("WAILS BEFORE CLOSE")
return false
}
// shutdown is called at application termination
func (w *wailsapp) shutdown(ctx context.Context) {
app.App().Log().Wails().Print("WAILS SHUTDOWN")
}
// suspend is called when Windows enters low power mode
func (w *wailsapp) suspend() {
app.App().Log().Wails().Print("WAILS SUSPEND")
}
// resume is called when Windows resumes from low power mode
func (w *wailsapp) resume() {
app.App().Log().Wails().Print("WAILS RESUME")
}