-
Notifications
You must be signed in to change notification settings - Fork 13
/
app.go
51 lines (43 loc) · 1.39 KB
/
app.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
package main
import (
"context"
"wailstemplate/application/wailshelper"
)
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
// NewApp 创建一个新的 App 应用程序
func NewApp() *App {
return &App{}
}
// startup is called at application startup
// startup 在应用程序启动时调用
func (a *App) startup(ctx context.Context) {
// Perform your setup here
// 在这里执行初始化设置
a.ctx = ctx
wailshelper.SetCtx(&a.ctx)
}
// domReady is called after the front-end dom has been loaded
// domReady 在前端Dom加载完毕后调用
func (a *App) domReady(ctx context.Context) {
// Add your action here
// 在这里添加你的操作
}
// 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.
// beforeClose在单击窗口关闭按钮或调用runtime.Quit即将退出应用程序时被调用.
// 返回 true 将导致应用程序继续,false 将继续正常关闭。
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
return false
}
// shutdown is called at application termination
// 在应用程序终止时被调用
func (a *App) shutdown(ctx context.Context) {
// Perform your teardown here
// 在此处做一些资源释放的操作
}