mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 07:10:40 +08:00
28 lines
563 B
Go
28 lines
563 B
Go
//+build experimental
|
|
|
|
package runtime
|
|
|
|
import (
|
|
"context"
|
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
|
"log"
|
|
goruntime "runtime"
|
|
)
|
|
|
|
func getFrontend(ctx context.Context) frontend.Frontend {
|
|
result := ctx.Value("frontend")
|
|
if result != nil {
|
|
return result.(frontend.Frontend)
|
|
}
|
|
pc, _, _, _ := goruntime.Caller(1)
|
|
funcName := goruntime.FuncForPC(pc).Name()
|
|
log.Fatalf("cannot call '%s': Application not initialised", funcName)
|
|
return nil
|
|
}
|
|
|
|
// Quit the application
|
|
func Quit(ctx context.Context) {
|
|
frontend := getFrontend(ctx)
|
|
frontend.Quit()
|
|
}
|