2021-09-08 08:58:58 +08:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// App struct
|
|
|
|
|
type App struct {
|
2021-09-09 22:13:06 +08:00
|
|
|
|
ctx context.Context
|
2021-09-08 08:58:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewApp creates a new App application struct
|
2021-09-09 22:13:06 +08:00
|
|
|
|
// NewApp 创建一个新的 App 应用程序
|
2021-09-08 08:58:58 +08:00
|
|
|
|
func NewApp() *App {
|
|
|
|
|
return &App{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// startup is called at application startup
|
2021-09-09 22:13:06 +08:00
|
|
|
|
// startup 在应用程序启动时调用
|
2021-09-23 01:30:36 +08:00
|
|
|
|
func (a *App) startup(ctx context.Context) {
|
2021-09-08 08:58:58 +08:00
|
|
|
|
// Perform your setup here
|
2021-09-09 22:13:06 +08:00
|
|
|
|
// 在这里执行初始化设置
|
2021-09-23 01:30:36 +08:00
|
|
|
|
a.ctx = ctx
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// domReady is called after the front-end dom has been loaded
|
|
|
|
|
// domReady 在前端Dom加载完毕后调用
|
2021-11-14 03:03:49 +08:00
|
|
|
|
func (a *App) domReady(ctx context.Context) {
|
2021-09-23 01:30:36 +08:00
|
|
|
|
// Add your action here
|
|
|
|
|
// 在这里添加你的操作
|
2021-09-08 08:58:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-14 21:11:36 +08:00
|
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 08:58:58 +08:00
|
|
|
|
// shutdown is called at application termination
|
2021-09-09 05:17:10 +08:00
|
|
|
|
// 在应用程序终止时被调用
|
2021-09-23 01:30:36 +08:00
|
|
|
|
func (a *App) shutdown(ctx context.Context) {
|
2021-09-08 08:58:58 +08:00
|
|
|
|
// Perform your teardown here
|
2021-09-09 22:13:06 +08:00
|
|
|
|
// 在此处做一些资源释放的操作
|
2021-09-08 08:58:58 +08:00
|
|
|
|
}
|