2021-09-08 08:58:58 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-09-09 22:13:06 +08:00
|
|
|
|
|
|
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
2021-09-08 08:58:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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-08 08:58:58 +08:00
|
|
|
func (b *App) startup(ctx context.Context) {
|
|
|
|
// Perform your setup here
|
2021-09-09 22:13:06 +08:00
|
|
|
// 在这里执行初始化设置
|
|
|
|
b.ctx = ctx
|
2021-09-08 08:58:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// shutdown is called at application termination
|
2021-09-09 05:17:10 +08:00
|
|
|
// 在应用程序终止时被调用
|
2021-09-08 08:58:58 +08:00
|
|
|
func (b *App) shutdown(ctx context.Context) {
|
|
|
|
// Perform your teardown here
|
2021-09-09 22:13:06 +08:00
|
|
|
// 在此处做一些资源释放的操作
|
2021-09-08 08:58:58 +08:00
|
|
|
}
|
|
|
|
|
2021-09-09 22:13:06 +08:00
|
|
|
// Quit Exit the application
|
|
|
|
// Quit 退出应用
|
|
|
|
func (b *App) Quit() {
|
|
|
|
runtime.Quit(b.ctx)
|
2021-09-08 08:58:58 +08:00
|
|
|
}
|