mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-16 07:35:51 +01:00
* Add support for origin tracking in raw message handling - Implemented origin and top origin tracking for web messages from JavaScript. - Updated `RawMessageHandler` to include `originInfo`. - Added cross-platform support for retrieving the origin of messages in macOS, Windows, and Linux. * fix build * fix build * fix build * fix build * fix build * Fix nil checks and string handling for message origins across platforms - Ensure proper fallback to empty strings for `origin` and `topOrigin` when errors or nil values are encountered. - Normalize handling of `message.body` to account for non-NSString values in macOS. * add docs * Remove unused doc * update changelog * fix build --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
_ "embed"
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
)
|
|
|
|
//go:embed assets
|
|
var assets embed.FS
|
|
|
|
func main() {
|
|
|
|
app := application.New(application.Options{
|
|
Name: "Raw Message Demo",
|
|
Description: "A demo of sending raw messages from the frontend",
|
|
Assets: application.AssetOptions{
|
|
Handler: application.BundledAssetFileServer(assets),
|
|
},
|
|
Mac: application.MacOptions{
|
|
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
|
},
|
|
RawMessageHandler: func(window application.Window, message string, originInfo *application.OriginInfo) {
|
|
println(fmt.Sprintf("Raw message received from Window %s with message: %s, origin %s, topOrigin %s, isMainFrame %t", window.Name(), message, originInfo.Origin, originInfo.TopOrigin, originInfo.IsMainFrame))
|
|
},
|
|
})
|
|
|
|
app.Window.NewWithOptions(application.WebviewWindowOptions{
|
|
Title: "Window 1",
|
|
Name: "Window 1",
|
|
Mac: application.MacWindow{
|
|
Backdrop: application.MacBackdropTranslucent,
|
|
TitleBar: application.MacTitleBarHiddenInsetUnified,
|
|
InvisibleTitleBarHeight: 50,
|
|
},
|
|
})
|
|
|
|
err := app.Run()
|
|
|
|
if err != nil {
|
|
log.Fatal(err.Error())
|
|
}
|
|
}
|