mirror of
https://github.com/misitebao/wails-template-vue
synced 2025-05-10 17:23:59 +08:00
feat: complete application minimization and exit functions
This commit is contained in:
parent
575c511c51
commit
87ffbfe791
21
app.tmpl.go
21
app.tmpl.go
@ -2,35 +2,38 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
// App struct
|
||||
type App struct {
|
||||
runtime context.Context
|
||||
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 (b *App) startup(ctx context.Context) {
|
||||
// Perform your setup here
|
||||
//TODO: move to new runtime layout
|
||||
|
||||
//b.runtime = runtime
|
||||
//runtime.Window.SetTitle("{{.ProjectName}}")
|
||||
// 在这里执行初始化设置
|
||||
b.ctx = ctx
|
||||
}
|
||||
|
||||
// shutdown is called at application termination
|
||||
// 在应用程序终止时被调用
|
||||
func (b *App) shutdown(ctx context.Context) {
|
||||
// Perform your teardown here
|
||||
// 在此处做一些资源释放的操作
|
||||
}
|
||||
|
||||
// Greet returns a greeting for the given name
|
||||
func (b *App) Greet(name string) string {
|
||||
return fmt.Sprintf("Hello %s!", name)
|
||||
// Quit Exit the application
|
||||
// Quit 退出应用
|
||||
func (b *App) Quit() {
|
||||
runtime.Quit(b.ctx)
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ export default {
|
||||
// it will be updated to be called directly when js is running.
|
||||
// 由于当前js运行时还没有开发完成,所以先调用Go完成。后续会更新为js运行时直接调用。
|
||||
const onclickMinimise = () => {
|
||||
alert(i18n.global.t("global.not-supported"))
|
||||
window.runtime.WindowMinimise()
|
||||
|
||||
}
|
||||
const onclickQuit = () => {
|
||||
alert(i18n.global.t("global.not-supported"))
|
||||
window.go.main.App.Quit()
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ func main() {
|
||||
app,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user