diff --git a/v3/internal/templates/_base/vanilla/frontend/index.html b/v3/internal/templates/_base/vanilla/frontend/index.html index c4eb3cc4..fd16cea8 100644 --- a/v3/internal/templates/_base/vanilla/frontend/index.html +++ b/v3/internal/templates/_base/vanilla/frontend/index.html @@ -7,7 +7,19 @@ Wails App -
+ + + + + + +

Hello Wails!

+
+ +
+

+ Click on the Wails logo to learn more +

diff --git a/v3/internal/templates/_common/Taskfile.tmpl.yml b/v3/internal/templates/_common/Taskfile.tmpl.yml index 1310e157..4ad78b1f 100644 --- a/v3/internal/templates/_common/Taskfile.tmpl.yml +++ b/v3/internal/templates/_common/Taskfile.tmpl.yml @@ -371,14 +371,25 @@ tasks: summary: Build the frontend project dir: frontend sources: - - "*" + - "**/*" generates: - dist/* deps: - install:frontend:deps + - generate:bindings cmds: - npm run build -q + generate:bindings: + summary: Generates bindings for the frontend + sources: + - "**/*.go" + generates: + - "frontend/bindings/**/*" + cmds: + - wails3 generate bindings + # - wails3 generate bindings -silent + go:mod:tidy: summary: Runs `go mod tidy` internal: true diff --git a/v3/internal/templates/_common/greetservice.go b/v3/internal/templates/_common/greetservice.go new file mode 100644 index 00000000..8972c39c --- /dev/null +++ b/v3/internal/templates/_common/greetservice.go @@ -0,0 +1,7 @@ +package main + +type GreetService struct{} + +func (g *GreetService) Greet(name string) string { + return "Hello " + name + "!" +} diff --git a/v3/internal/templates/_common/main.go.tmpl b/v3/internal/templates/_common/main.go.tmpl index c30a939d..edeb549c 100644 --- a/v3/internal/templates/_common/main.go.tmpl +++ b/v3/internal/templates/_common/main.go.tmpl @@ -15,6 +15,9 @@ func main() { app := application.New(application.Options{ Name: "{{.ProjectName}}", Description: "A demo of using raw HTML & CSS", + Bind: []any{ + &GreetService{}, + }, Assets: application.AssetOptions{ FS: assets, }, diff --git a/v3/internal/templates/vanilla/frontend/counter.js b/v3/internal/templates/vanilla/frontend/counter.js deleted file mode 100644 index 881e2d7a..00000000 --- a/v3/internal/templates/vanilla/frontend/counter.js +++ /dev/null @@ -1,9 +0,0 @@ -export function setupCounter(element) { - let counter = 0 - const setCounter = (count) => { - counter = count - element.innerHTML = `count is ${counter}` - } - element.addEventListener('click', () => setCounter(counter + 1)) - setCounter(0) -} diff --git a/v3/internal/templates/vanilla/frontend/index.html b/v3/internal/templates/vanilla/frontend/index.html index a13d6248..142c24f8 100644 --- a/v3/internal/templates/vanilla/frontend/index.html +++ b/v3/internal/templates/vanilla/frontend/index.html @@ -1,13 +1,30 @@ - - - - + + + + + Wails App - - -
+ + +
+
+ + + + + + +
+

Hello Wails!

+
+ +
+

+ 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 5a926e5b..949d013a 100644 --- a/v3/internal/templates/vanilla/frontend/main.js +++ b/v3/internal/templates/vanilla/frontend/main.js @@ -1,23 +1,9 @@ -import './style.css' -import javascriptLogo from './javascript.svg' -import { setupCounter } from './counter.js' +import {Greet} from "./bindings/main/GreetService.js"; -document.querySelector('#app').innerHTML = ` -
- - - - - - -

Hello Wails!

-
- -
-

- Click on the Wails logo to learn more -

-
-` - -setupCounter(document.querySelector('#counter')) +window.doGreet = () => { + Greet('test').then((result) => { + console.log(result); + }).catch((err) => { + console.log(err); + }); +} \ 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 63288c9e..7006177b 100644 --- a/v3/internal/templates/vanilla/frontend/package.json +++ b/v3/internal/templates/vanilla/frontend/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "devDependencies": { - "vite": "^4.0.0" + "vite": "^4.0.0", + "@wailsio/runtime": "^3.0.0-alpha.6" } } \ No newline at end of file diff --git a/v3/internal/templates/vanilla/frontend/javascript.svg b/v3/internal/templates/vanilla/frontend/public/javascript.svg similarity index 100% rename from v3/internal/templates/vanilla/frontend/javascript.svg rename to v3/internal/templates/vanilla/frontend/public/javascript.svg diff --git a/v3/internal/templates/vanilla/frontend/style.css b/v3/internal/templates/vanilla/frontend/public/style.css similarity index 92% rename from v3/internal/templates/vanilla/frontend/style.css rename to v3/internal/templates/vanilla/frontend/public/style.css index 12320801..51e4476c 100644 --- a/v3/internal/templates/vanilla/frontend/style.css +++ b/v3/internal/templates/vanilla/frontend/public/style.css @@ -28,10 +28,18 @@ body { margin: 0; display: flex; place-items: center; + place-content: center; min-width: 320px; min-height: 100vh; } +.container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + h1 { font-size: 3.2em; line-height: 1.1;