diff --git a/v3/internal/templates/_common/main.go.tmpl b/v3/internal/templates/_common/main.go.tmpl index edeb549c5..1d710c243 100644 --- a/v3/internal/templates/_common/main.go.tmpl +++ b/v3/internal/templates/_common/main.go.tmpl @@ -27,17 +27,27 @@ func main() { }) // Create window app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ - Title: "Plain Bundle", - CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`, + Title: "Window 1", Mac: application.MacWindow{ InvisibleTitleBarHeight: 50, Backdrop: application.MacBackdropTranslucent, TitleBar: application.MacTitleBarHiddenInset, }, - + BackgroundColour: application.NewRGB(36, 36, 36), URL: "/", }) + go func() { + for { + now := time.Now().Format(time.RFC1123) + app.Events.Emit(&application.WailsEvent{ + Name: "time", + Data: now, + }) + time.Sleep(time.Second) + } + }() + err := app.Run() if err != nil { diff --git a/v3/internal/templates/vanilla/frontend/index.html b/v3/internal/templates/vanilla/frontend/index.html index 142c24f8c..17eb8b3c3 100644 --- a/v3/internal/templates/vanilla/frontend/index.html +++ b/v3/internal/templates/vanilla/frontend/index.html @@ -8,23 +8,31 @@ Wails App -
-
- - - - - - -
-

Hello Wails!

-
- -
-

- Click on the Wails logo to learn more -

+
+
+ + + + + +
- +

Wails + Javascript

+
+

Listening for Time event...

+
+
+ + + +
+
+

 

+
+

+ Click on the Wails logo to learn more +

+
+ diff --git a/v3/internal/templates/vanilla/frontend/main.js b/v3/internal/templates/vanilla/frontend/main.js index 949d013ad..54ecd9a0b 100644 --- a/v3/internal/templates/vanilla/frontend/main.js +++ b/v3/internal/templates/vanilla/frontend/main.js @@ -1,9 +1,20 @@ import {Greet} from "./bindings/main/GreetService.js"; +import {Events} from "@wailsio/runtime"; window.doGreet = () => { - Greet('test').then((result) => { - console.log(result); + let name = document.getElementById('name').value; + if (!name) { + name = 'from Go'; + } + Greet(name).then((result) => { + let element = document.getElementById('greeting'); + element.innerText = result; }).catch((err) => { console.log(err); }); -} \ No newline at end of file +} + +Events.On('time', (time) => { + let element = document.getElementById('time'); + element.innerText = time.data; +}); \ No newline at end of file diff --git a/v3/internal/templates/vanilla/frontend/package.json b/v3/internal/templates/vanilla/frontend/package.json index 7006177b2..758dce5cc 100644 --- a/v3/internal/templates/vanilla/frontend/package.json +++ b/v3/internal/templates/vanilla/frontend/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "devDependencies": { - "vite": "^4.0.0", - "@wailsio/runtime": "^3.0.0-alpha.6" + "vite": "^5.0.0", + "@wailsio/runtime": "latest" } } \ No newline at end of file diff --git a/v3/pkg/application/messageprocessor_call.go b/v3/pkg/application/messageprocessor_call.go index 6fe7965de..b78d15e69 100644 --- a/v3/pkg/application/messageprocessor_call.go +++ b/v3/pkg/application/messageprocessor_call.go @@ -26,7 +26,6 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter, m.httpError(rw, "Unable to parse arguments: %s", err.Error()) return } - fmt.Println("processCallMethod", args) callID := args.String("call-id") if callID == nil { m.Error("call-id is required")