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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
type App struct {
|
type App struct {
|
||||||
runtime context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApp creates a new App application struct
|
// NewApp creates a new App application struct
|
||||||
|
// NewApp 创建一个新的 App 应用程序
|
||||||
func NewApp() *App {
|
func NewApp() *App {
|
||||||
return &App{}
|
return &App{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// startup is called at application startup
|
// startup is called at application startup
|
||||||
|
// startup 在应用程序启动时调用
|
||||||
func (b *App) startup(ctx context.Context) {
|
func (b *App) startup(ctx context.Context) {
|
||||||
// Perform your setup here
|
// Perform your setup here
|
||||||
//TODO: move to new runtime layout
|
// 在这里执行初始化设置
|
||||||
|
b.ctx = ctx
|
||||||
//b.runtime = runtime
|
|
||||||
//runtime.Window.SetTitle("{{.ProjectName}}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// shutdown is called at application termination
|
// shutdown is called at application termination
|
||||||
// 在应用程序终止时被调用
|
// 在应用程序终止时被调用
|
||||||
func (b *App) shutdown(ctx context.Context) {
|
func (b *App) shutdown(ctx context.Context) {
|
||||||
// Perform your teardown here
|
// Perform your teardown here
|
||||||
|
// 在此处做一些资源释放的操作
|
||||||
}
|
}
|
||||||
|
|
||||||
// Greet returns a greeting for the given name
|
// Quit Exit the application
|
||||||
func (b *App) Greet(name string) string {
|
// Quit 退出应用
|
||||||
return fmt.Sprintf("Hello %s!", name)
|
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.
|
// it will be updated to be called directly when js is running.
|
||||||
// 由于当前js运行时还没有开发完成,所以先调用Go完成。后续会更新为js运行时直接调用。
|
// 由于当前js运行时还没有开发完成,所以先调用Go完成。后续会更新为js运行时直接调用。
|
||||||
const onclickMinimise = () => {
|
const onclickMinimise = () => {
|
||||||
alert(i18n.global.t("global.not-supported"))
|
window.runtime.WindowMinimise()
|
||||||
|
|
||||||
}
|
}
|
||||||
const onclickQuit = () => {
|
const onclickQuit = () => {
|
||||||
alert(i18n.global.t("global.not-supported"))
|
window.go.main.App.Quit()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ func main() {
|
|||||||
app,
|
app,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user