v2.0.0-beta.37

This commit is contained in:
Lea Anthony 2022-05-26 17:45:32 -10:00
commit 6a88568f0a
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
56 changed files with 611 additions and 296 deletions

View file

@ -1,3 +1,3 @@
package internal
var Version = "v2.0.0-beta.36"
var Version = "v2.0.0-beta.37"

View file

@ -1,54 +0,0 @@
---
sidebar_position: 2
---
# Creating a Project
## Project Generation
Now that the CLI is installed, you can generate a new project by using the `wails init` command.
To get up and running quickly, you can generate a default project by running `wails init -n myproject`. This will
create a directory called `myproject` and populate it with the default template.
Other project templates are available and can be listed using `wails init -l`.
There are also [community templates](../community/templates) available that offer different capabilities and frameworks.
To see the other options available, you can run `wails init -help`.
More details can be found in the [CLI Reference](../reference/cli#init).
## Project Layout
Wails projects have the following layout:
```
.
├── build/
│ ├── appicon.png
│ ├── darwin/
│ └── windows/
├── frontend/
├── go.mod
├── go.sum
├── main.go
└── wails.json
```
### Project structure rundown
- `/main.go` - The main application
- `/frontend/` - Frontend project files
- `/build/` - Project build directory
- `/build/appicon.png` - The application icon
- `/build/darwin/` - Mac specific project files
- `/build/windows/` - Windows specific project files
- `/wails.json` - The project configuration
- `/go.mod` - Go module file
- `/go.sum` - Go module checksum file
The `frontend` directory has nothing specific to Wails and can be any frontend project of your choosing.
The `build` directory is used during the build process. These files may be updated to customise your builds. If
files are removed from the build directory, default versions will be regenerated.
The default module name in `go.mod` is "changeme". You should change this to something more appropriate.

View file

@ -5,7 +5,7 @@ sidebar_position: 1
# Templates
This page serves as a list for community supported templates. Please submit a PR (click `Edit this page` at the bottom)
to include your templates. To build your own template, please see the [Templates](../guides/templates) guide.
to include your templates. To build your own template, please see the [Templates](../guides/templates.mdx) guide.
To use these templates, run `wails init -n "Your Project Name" -t [the link below[@version]]`
@ -35,10 +35,14 @@ If you are unsure about a template, inspect `package.json` and `wails.json` for
- [wails-react-template](https://github.com/AlienRecall/wails-react-template) - A template using reactjs
- [wails-react-template](https://github.com/flin7/wails-react-template) - A minimal template for React that supports live development
- [wails-vite-react-ts](https://github.com/lontten/wails-vite-react-ts) - A template with Vite + React + TypeScript
- [wails-template-nextjs](https://github.com/LGiki/wails-template-nextjs) - A template using Next.js and TypeScript
## Svelte
- [wails-svelte-template](https://github.com/raitonoberu/wails-svelte-template) - A template using Svelte
- [wails-vite-svelte-template](https://github.com/BillBuilt/wails-vite-svelte-template) - A template using Svelte and Vite
- [wails-vite-svelte-tailwind-template](https://github.com/BillBuilt/wails-vite-svelte-tailwind-template) - A template using Svelte and Vite with TailwindCSS v3
## Elm
- [wails-elm-template](https://github.com/benjamin-thomas/wails-elm-template) - Develop your GUI app with functional programming and a **snappy** hot-reload setup :tada: :rocket:

View file

@ -15,5 +15,5 @@ If you run the binary, you should see the default application:
<br/>
For more details on compilation options, please refer to the [CLI Reference](../reference/cli#build).
For more details on compilation options, please refer to the [CLI Reference](../reference/cli.mdx#build).

View file

@ -7,9 +7,10 @@ sidebar_position: 5
You can run your application in development mode by running `wails dev` from your project directory. This will do the following things:
- Build your application and run it
- Watch for modifications in your Go files and rebuild/re-run on change
- Sets up a [webserver](http://localhost:34115) that will serve your application over a browser. This allows you to use your favourite browser extensions. You can even call your Go code from the console.
- Bind your Go code to the frontend so it can be called from Javascript
- Using the power of [vite](https://vitejs.dev/), will watch for modifications in your Go files and rebuild/re-run on change
- Sets up a [webserver](http://localhost:34115) that will serve your application over a browser. This allows you to use your favourite browser extensions. You can even call your Go code from the console
To get started, run `wails dev` in the project directory. More information on this can be found [here](../reference/cli#dev).
To get started, run `wails dev` in the project directory. More information on this can be found [here](../reference/cli.mdx#dev).
Coming soon: Tutorial

View file

@ -0,0 +1,127 @@
---
sidebar_position: 2
---
# Creating a Project
## Project Generation
Now that the CLI is installed, you can generate a new project by using the `wails init` command.
Pick your favourite framework:
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
<Tabs
defaultValue="Svelte"
values={[
{label: "Svelte", value: "Svelte"},
{label: "React", value: "React"},
{label: "Vue", value: "Vue"},
{label: "Preact", value: "Preact"},
{label: "Lit", value: "Lit"},
{label: "Vanilla", value: "Vanilla"},
]}
>
<TabItem value="Svelte">
Generate a <a href="https://svelte.dev/">Svelte</a> project using Javascript with:<br/>
wails init -n myproject -t svelte
If you would rather use Typescript:
wails init -n myproject -t svelte-ts
</TabItem>
<TabItem value="React">
Generate a <a href="https://reactjs.org/">React</a> project using Javascript with:<br/>
wails init -n myproject -t react
If you would rather use Typescript:
wails init -n myproject -t react-ts
</TabItem>
<TabItem value="Vue">
Generate a <a href="https://vuejs.org/">Vue</a> project using Javascript with:<br/>
wails init -n myproject -t vue
If you would rather use Typescript:
wails init -n myproject -t vue-ts
</TabItem>
<TabItem value="Preact">
Generate a <a href="https://preactjs.com/">Preact</a> project using Javascript with:<br/>
wails init -n myproject -t preact
If you would rather use Typescript:
wails init -n myproject -t preact-ts
</TabItem>
<TabItem value="Lit">
Generate a <a href="https://lit.dev/">Lit</a> project using Javascript with:<br/>
wails init -n myproject -t lit
If you would rather use Typescript:
wails init -n myproject -t lit-ts
</TabItem>
<TabItem value="Vanilla">
Generate a Vanilla project using Javascript with:<br/>
wails init -n myproject -t vanilla
If you would rather use Typescript:
wails init -n myproject -t vanilla-ts
</TabItem>
</Tabs>
<hr/>
There are also [community templates](../community/templates.mdx) available that offer different capabilities and frameworks.
To see the other options available, you can run `wails init -help`.
More details can be found in the [CLI Reference](../reference/cli.mdx#init).
## Project Layout
Wails projects have the following layout:
```
.
├── build/
│ ├── appicon.png
│ ├── darwin/
│ └── windows/
├── frontend/
├── go.mod
├── go.sum
├── main.go
└── wails.json
```
### Project structure rundown
- `/main.go` - The main application
- `/frontend/` - Frontend project files
- `/build/` - Project build directory
- `/build/appicon.png` - The application icon
- `/build/darwin/` - Mac specific project files
- `/build/windows/` - Windows specific project files
- `/wails.json` - The project configuration
- `/go.mod` - Go module file
- `/go.sum` - Go module checksum file
The `frontend` directory has nothing specific to Wails and can be any frontend project of your choosing.
The `build` directory is used during the build process. These files may be updated to customise your builds. If
files are removed from the build directory, default versions will be regenerated.
The default module name in `go.mod` is "changeme". You should change this to something more appropriate.

View file

@ -22,7 +22,7 @@ Wails has a number of common dependencies that are required before installation:
Download Go from the [Go Downloads Page](https://golang.org/dl/).
Ensure that you follow the official [Go installation instructions](https://golang.org/doc/install#install). You will also need to ensure that your `PATH` environment variable also includes the path to your `~/go/bin` directory. Restart your terminal and do the following checks:
Ensure that you follow the official [Go installation instructions](https://golang.org/doc/install.mdx#install). You will also need to ensure that your `PATH` environment variable also includes the path to your `~/go/bin` directory. Restart your terminal and do the following checks:
- Check Go is installed correctly: `go version`
- Check "~/go/bin" is in your PATH variable: `echo $PATH | grep go/bin`

View file

@ -30,7 +30,7 @@ func (a *App) shutdown(ctx context.Context) {
- The startup method is called as soon as Wails allocates the resources it needs and is a good place for creating resources,
setting up event listeners and anything else the application needs at startup.
It is given a `context.Context` which is usually saved in a struct field. This context is needed for calling the
[runtime](../reference/runtime/intro). If this method returns an error, the application will terminate.
[runtime](../reference/runtime/intro.mdx). If this method returns an error, the application will terminate.
In dev mode, the error will be output to the console.
- The shutdown method will be called by Wails right at the end of the shutdown process. This is a good place to deallocate
@ -59,7 +59,7 @@ func main() {
```
More information on application lifecycle hooks can be found [here](../howdoesitwork#application-lifecycle-callbacks).
More information on application lifecycle hooks can be found [here](../howdoesitwork.mdx#application-lifecycle-callbacks).
## Binding Methods
@ -113,7 +113,7 @@ func main() {
This will bind all public methods in our `App` struct (it will never bind the startup and shutdown methods).
More information on Binding can be found [here](../howdoesitwork#method-binding).
More information on Binding can be found [here](../howdoesitwork.mdx#method-binding).
## Application Menu
@ -161,6 +161,15 @@ The second, if given, will be executed in the `frontend` directory to build the
If these 2 keys aren't given, then Wails does absolutely nothing with the frontend. It is only expecting that `embed.FS`.
### AssetsHandler
A Wails v2 app can optionally define a `http.Handler` in the `options.App`, which allows hooking into the AssetServer to
create files on the fly or process POST/PUT requests.
GET requests are always first handled by the `assets` FS. If the FS doesn't find the requested file the request will be
forwarded to the `http.Handler` for serving. Any requests other than GET will be directly processed by the `AssetsHandler`
if specified.
It's also possible to only use the `AssetsHandler` by specifiy `nil` as the `Assets` option.
## Built in Dev Server
Running `wails dev` will start the built in dev server which will start a file watcher in your project directory. By

View file

@ -35,7 +35,20 @@ To revert back to a stable version, run:
If you want to test a branch, follow the instructions above, but ensure you switch the branch you want to test before installing:
- `git clone https://github.com/wailsapp/wails`
- `cd wails`
- `git checkout -b branch-to-test --track origin/branch-to-test`
- `cd wails/v2/cmd/wails`
- `cd v2/cmd/wails`
- `go install`
## Testing a PR
If you want to test a PR, follow the instructions above, but ensure you fetch the PR and switch the branch before installing.
Please replace `[IDofThePR]` with the ID of the PR shown on github.com:
- `git clone https://github.com/wailsapp/wails`
- `cd wails`
- `git fetch -u origin pull/[IDofThePR]/head:test/pr-[IDofThePR]`
- `git checkout test/pr-[IDofThePR]`
- `git reset --hard HEAD`
- `cd v2/cmd/wails`
- `go install`

View file

@ -1,8 +1,8 @@
# Frameless Applications
Wails supports applications with no frame. This can be achieved by using the [frameless](../reference/options#frameless)
field in [Application Options](../reference/options#application-options).
Wails supports applications with no frame. This can be achieved by using the [frameless](../reference/options.mdx#frameless)
field in [Application Options](../reference/options.mdx#application-options).
Wails offers a simple solution for dragging the window: Any HTML element that has the attribute "data-wails-drag" will
act as a "drag handle". This property applies to all nested elements. If you need to indicate that a nested element

View file

@ -25,7 +25,7 @@ Example:
app.Run()
```
In v2, there is just a single method, `wails.Run()`, that accepts [application options](../reference/options#application-options).
In v2, there is just a single method, `wails.Run()`, that accepts [application options](../reference/options.mdx#application-options).
```go title="v2"
err := wails.Run(&options.App{
@ -43,7 +43,7 @@ In v2, there is just a single method, `wails.Run()`, that accepts [application o
In v1, it was possible to bind both arbitrary functions and structs. In v2, this has been simplified to only binding structs.
The struct instances that were previously passed to the `Bind()` method in v1, are now specified in the `Bind` field of
the [application options](../reference/options#application-options):
the [application options](../reference/options.mdx#application-options):
```go title="v1"
app := wails.CreateApp(/* options */)
@ -64,13 +64,13 @@ In v1, bound methods were available to the frontend at `window.backend`. This ha
### Application Lifecycle
In v1, there were 2 special methods in a bound struct: `WailsInit()` and `WailsShutdown()`. These have
been replaced with 3 lifecycle hooks as part of the [application options](../reference/options#application-options):
been replaced with 3 lifecycle hooks as part of the [application options](../reference/options.mdx#application-options):
- [OnStartup](../reference/options#onstartup)
- [OnShutdown](../reference/options#onshutdown)
- [OnDomReady](../reference/options#ondomready)
- [OnStartup](../reference/options.mdx#onstartup)
- [OnShutdown](../reference/options.mdx#onshutdown)
- [OnDomReady](../reference/options.mdx#ondomready)
Note: [OnDomReady](../reference/options#ondomready) replaces the `wails:ready` system event in v1.
Note: [OnDomReady](../reference/options.mdx#ondomready) replaces the `wails:ready` system event in v1.
These methods can be standard functions, but a common practice is to have them part of a struct:
@ -96,11 +96,11 @@ func (b *Basic) startup(ctx context.Context) {
The runtime in v2 is much richer than v1 with support for menus, window manipulation
and better dialogs. The signature of the methods has changed slightly - please refer
the the [Runtime Reference](../reference/runtime/intro).
the the [Runtime Reference](../reference/runtime/intro.mdx).
In v1, the [runtime](../reference/runtime/intro) was available via a struct passed to `WailsInit()`.
In v1, the [runtime](../reference/runtime/intro.mdx) was available via a struct passed to `WailsInit()`.
In v2, the runtime has been moved out to its own package. Each method in the runtime takes the
`context.Context` that is passed to the [OnStartup](../reference/options#onstartup) method.
`context.Context` that is passed to the [OnStartup](../reference/options.mdx#onstartup) method.
```go title="Runtime Example"
package main
@ -173,7 +173,7 @@ func main() {
Of course, bundlers can be used if you wish to. The only requirement is to pass
the final application assets directory to Wails using an `embed.FS` in the `Assets`
key of the [application options](../reference/options#application-options).
key of the [application options](../reference/options.mdx#application-options).
### Project Configuration

View file

@ -20,7 +20,7 @@ const router = createRouter({
## Angular
The recommended approach for routing in Angular is [HashLocationStrategy](https://codecraft.tv/courses/angular/routing/routing-strategies/#_hashlocationstrategy):
The recommended approach for routing in Angular is [HashLocationStrategy](https://codecraft.tv/courses/angular/routing/routing-strategies#_hashlocationstrategy):
```ts
RouterModule.forRoot(routes, {useHash: true})

View file

@ -4,7 +4,7 @@
Wails generates projects from pre-created templates. In v1, this was a difficult to maintain set of projects that were
subject to going out of date. In v2, to empower the community, a couple of new features have been added for templates:
- Ability to generate projects from [Remote Templates](../reference/cli#remote-templates)
- Ability to generate projects from [Remote Templates](../reference/cli.mdx#remote-templates)
- Tooling to help create your own templates
## Creating Templates
@ -91,5 +91,5 @@ Publishing a template is simply pushing the files to GitHub. The following best
- Remove any unwanted files and directories (such as `.git`) from your frontend directory
- Ensure that `template.json` is complete, especially `helpurl`
- Push the files to GitHub
- Create a PR on the [Community Templates](../community/templates) page
- Create a PR on the [Community Templates](../community/templates.mdx) page
- Announce the template on the [Template Announcement](https://github.com/wailsapp/wails/discussions/825) discussion board

View file

@ -83,7 +83,7 @@ This example has the following options set:
- `OnShutdown` - A callback for when the application is about to quit
- `Bind` - A slice of struct instances that we wish to expose to the frontend
A full list of application options can be found in the [Options Reference](./reference/options).
A full list of application options can be found in the [Options Reference](reference/options).
#### Assets
@ -108,24 +108,25 @@ the application.
When running in development mode using the `wails dev` command, the assets are loaded off disk, and any changes result
in a "live reload". The location of the assets will be inferred from the `embed.FS`.
More details can be found in the [Application Development Guide](./guides/application-development).
More details can be found in the [Application Development Guide](guides/application-development.mdx).
#### Application Lifecycle Callbacks
Just before the frontend is about to load `index.html`, a callback is made to the function provided in [OnStartup](./reference/options#OnStartup).
Just before the frontend is about to load `index.html`, a callback is made to the function provided in [OnStartup](reference/options.mdx#onstartup).
A standard Go context is passed to this method. This context is required when calling the runtime so a standard pattern is to save
a reference to in this method. Just before the application shuts down, the [OnShutdown](./reference/options#OnShutdown) callback is called in the same way,
again with the context. There is also an [OnDomReady](./reference/options#OnDomReady) callback for when the frontend
a reference to in this method. Just before the application shuts down, the [OnShutdown](reference/options.mdx#onshutdown) callback is called in the same way,
again with the context. There is also an [OnDomReady](reference/options.mdx#ondomready) callback for when the frontend
has completed loading all assets in `index.html` and is equivalent of the [`body onload`](https://www.w3schools.com/jsref/event_onload.asp) event in Javascript.
It is also possible to hook into the window close (or application quit) event by setting the
option [OnBeforeClose](./reference/options#OnBeforeClose).
option [OnBeforeClose](reference/options.mdx#onbeforeclose).
#### Method Binding
The `Bind` option is one of the most important options in a Wails application. It specifies which struct methods
to expose to the frontend. When the application starts, it examines the struct instances listed in the `Bind` field in
the options, determines which methods are public (starts with an uppercase letter) and will generate Javascript versions
of those methods that can be called by the frontend code.
to expose to the frontend. Think of structs like "controllers" in a traditional web application. When the application
starts, it examines the struct instances listed in the `Bind` field in the options, determines which methods are
public (starts with an uppercase letter) and will generate Javascript versions of those methods that can be called
by the frontend code.
:::info Note
@ -135,7 +136,7 @@ of those methods that can be called by the frontend code.
In this example, we create a new `App` instance and then add this instance to the `Bind` option in `wails.Run`:
```go {16,26} title="main.go"
```go {16,24} title="main.go"
package main
import (
@ -158,8 +159,6 @@ func main() {
Width: 1024,
Height: 768,
Assets: &assets,
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
@ -174,67 +173,41 @@ type App struct {
ctx context.Context
}
func (b *App) startup(ctx context.Context) {
b.ctx = ctx
}
func (b *App) shutdown(ctx context.Context) {}
func (b *App) Greet(name string) string {
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s!", name)
}
```
You may bind as many structs as you like. Just make sure you create an instance of it and pass it in `Bind`:
```go {10-12}
...
```go {8-10}
//...
err := wails.Run(&options.App{
Title: "Basic Demo",
Width: 1024,
Height: 768,
Assets: &assets,
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
&mystruct1{},
&mystruct2{},
},
})
...
```
The bound methods are located in the frontend at `window.go.<packagename>.<struct>.<method>`.
In the example above, we bind `app`, which has one public method `Greet`.
This can be called in Javascript by calling `window.go.main.App.Greet`.
These methods return a Promise. A successful call will result in the first return value from the Go call to be passed
to the `resolve` handler. An unsuccessful call is when a Go method that has an error type as it's second return value,
passes an error instance back to the caller. This is passed back via the `reject` handler.
In the example above, `Greet` only returns a `string` so the Javascript call will never reject - unless invalid data
is passed to it.
When you run `wails dev` (or `wails generate module`), a frontend module will be generated containing the following:
- Javascript bindings for all bound methods
- Typescript declarations for all bound methods
- Typescript definitions for all Go structs used as inputs or outputs by the bound methods
All data types are correctly translated between Go and Javascript. Even structs. If you return a struct from a Go call,
it will be returned to your frontend as a Javascript map. Note: If you wish to use structs, you **must** define `json` struct
tags for your fields!
:::info Note
Anonymous nested structs are not supported at this time.
:::
It is also possible to send structs back to Go. Any Javascript map passed as an argument that
is expecting a struct, will be converted to that struct type. To make this process a lot easier, in `dev` mode,
a TypeScript module is generated, defining all the struct types used in bound methods. Using this module, it's possible
to construct and send native Javascript objects to the Go code.
More information on Binding can be found in the [Binding Methods](./guides/application-development#binding-methods)
section of the [Application Development Guide](./guides/application-development).
This makes it incredibly simple to call Go code from the frontend, using the same strongly typed datastructures.
## The Frontend
### Overview
The frontend is a collection of files rendered by webkit. It's like a browser and webserver in one.
The frontend is a collection of files rendered by webkit. It''s like a browser and webserver in one.
There is virtually[^1] no limit to which frameworks or libraries you can use. The main points of interaction between
the frontend and your Go code are:
@ -247,48 +220,61 @@ the frontend and your Go code are:
### Calling bound Go methods
All bound Go methods are available at `window.go.<package>.<struct>.<method>`. As stated in
the previous section, these return a Promise where a successful call returns a value to the
resolve handler and an error returns a value to the reject handler.
When you run your application with `wails dev`, it will automatically generate Javascript bindings for your structs in a
directory called `wailsjs/go` (You can also do this by running `wails generate module`). The generated files mirror the
package names in your application. In the example above, we bind `app`, which has one public method `Greet`. This will
lead to the generation of the following files:
```go title="mycode.js"
window.go.main.App.Greet("Bill").then((result) => {
console.log("The greeting is: " + result);
})
```bash
wailsjs
└─go
└─main
├─App.d.ts
└─App.js
```
Here we can see that there is a `main` package that contains the Javascript bindings for the bound `App` struct, as well
as the Typescript declaration file for those methods. To call `Greet` from our frontend, we simply import the method and
call it like a regular Javascript function:
```javascript
// ...
import {Greet} from '../wailsjs/go/main/App'
function doGreeting(name) {
Greet(name).then((result) => {
// Do something with result
})
}
```
The Typescript declaration file gives you the correct types for the bound methods:
```ts
export function Greet(arg1:string):Promise<string>;
```
When running the application in `dev` mode, a javascript module is generated that wraps these
methods with JSDoc annotations. This really help with development, especially as most
IDEs will process JSDoc to provide code completion and type hinting. This module is called `go`
and is generated in the directory specified by the `wailsjsdir` flag. In this module is a file
called `bindings.js` containing these wrappers. For the above example, the file contains the
following code:
The generated methods return a Promise. A successful call will result in the first return value from the Go call to be passed
to the `resolve` handler. An unsuccessful call is when a Go method that has an error type as it''s second return value,
passes an error instance back to the caller. This is passed back via the `reject` handler.
In the example above, `Greet` only returns a `string` so the Javascript call will never reject - unless invalid data
is passed to it.
```js title="bindings.js"
const go = {
main: {
App: {
/**
* Greet
* @param {Person} arg1 - Go Type: string
* @returns {Promise<string>} - Go Type: string
*/
Greet: (arg1) => {
return window.go.main.App.Greet(arg1);
},
},
},
};
export default go;
```
All data types are correctly translated between Go and Javascript. Even structs. If you return a struct from a Go call,
it will be returned to your frontend as a Javascript class. Note: If you wish to use structs, you **must** define
`json` struct tags for your fields!
#### Support for structs
:::info Note
Anonymous nested structs are not supported at this time.
:::
There is also additional support for Go methods that use structs in their signature. All Go structs
specified by bound method (either as parameters or return types) will have Typescript versions auto
generated as part of the Go code wrapper module. Using these, it's possible to share the same data
model between Go and Javascript. These models align with the JSDoc annotations, empowering IDE code
completion.
It is possible to send structs back to Go. Any Javascript map/class passed as an argument that
is expecting a struct, will be converted to that struct type. To make this process a lot easier, in `dev` mode,
a TypeScript module is generated, defining all the struct types used in bound methods. Using this module, it''s possible
to construct and send native Javascript objects to the Go code.
There is also support for Go methods that use structs in their signature. All Go structs
specified by a bound method (either as parameters or return types) will have Typescript versions auto
generated as part of the Go code wrapper module. Using these, it''s possible to share the same data
model between Go and Javascript.
Example: We update our `Greet` method to accept a `Person` instead of a string:
@ -309,76 +295,77 @@ func (a *App) Greet(p Person) string {
}
```
Our `bindings.js` file has now been updated to reflect the change:
The `wailsjs/go/main/App.js` file will still have the following code:
```js title="bindings.js"
const go = {
main: {
App: {
/**
* Greet
* @param {Person} arg1 - Go Type: main.Person
* @returns {Promise<string>} - Go Type: string
*/
Greet: (arg1) => {
return window.go.main.App.Greet(arg1);
},
},
},
};
export default go;
```js title="App.js"
export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1);
}
```
Alongside `bindings.js`, there is a file called `models.ts`. This contains our Go structs in TypeScript form:
But the `wailsjs/go/main/App.d.ts` file will be updated with the following code:
```ts title="App.d.ts"
import {main} from '../models';
export function Greet(arg1:main.Person):Promise<string>;
```
As we can see, the "main" namespace is imported from a new "models.ts" file. This file contains all the struct definitions
used by our bound methods. In this example, this is a `Person` struct. If we look at `models.ts`, we can see how the models
are defined:
```ts title="models.ts"
export class Address {
street: string;
postcode: string;
export namespace main {
static createFrom(source: any = {}) {
return new Address(source);
}
export class Address {
street: string;
postcode: string;
constructor(source: any = {}) {
if ("string" === typeof source) source = JSON.parse(source);
this.street = source["street"];
this.postcode = source["postcode"];
}
}
export class Person {
name: string;
age: number;
address?: Address;
static createFrom(source: any = {}) {
return new Address(source);
}
static createFrom(source: any = {}) {
return new Person(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.street = source["street"];
this.postcode = source["postcode"];
}
}
export class Person {
name: string;
age: number;
address?: Address;
constructor(source: any = {}) {
if ("string" === typeof source) source = JSON.parse(source);
this.name = source["name"];
this.age = source["age"];
this.address = this.convertValues(source["address"], Address);
}
static createFrom(source: any = {}) {
return new Person(source);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice) {
return (a as any[]).map((elem) => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.name = source["name"];
this.age = source["age"];
this.address = this.convertValues(source["address"], Address);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
}
```
@ -386,22 +373,23 @@ So long as you have TypeScript as part of your frontend build configuration, you
the following way:
```js title="mycode.js"
import go from "./wailsjs/go/bindings";
import { Person } from "./wailsjs/go/models";
import {Greet} from '../wailsjs/go/main/App'
import {main} from '../wailsjs/go/models'
let name = "";
function greet(name) {
let p = new Person();
p.name = name;
p.age = 42;
go.main.App.Greet(p).then((result) => {
console.log(result);
});
}
function generate() {
let person = new main.Person()
person.name = "Peter"
person.age = 27
Greet(person).then((result) => {
console.log(result)
})
}
```
The combination of JSDoc and TypeScript generated models makes for a powerful development environment.
The combination of generated bindings and TypeScript models makes for a powerful development environment.
More information on Binding can be found in the [Binding Methods](guides/application-development.mdx#binding-methods)
section of the [Application Development Guide](guides/application-development.mdx).
### Calling runtime methods
@ -412,4 +400,4 @@ tasks such as emit an event or perform logging operations:
window.runtime.EventsEmit("my-event", 1);
```
More details about the JS runtime can be found in the [Runtime Reference](./reference/runtime/intro).
More details about the JS runtime can be found in the [Runtime Reference](reference/runtime/intro).

View file

@ -21,6 +21,12 @@ gives it that 'frosty' effect of a native app.
</a>
</p>
## Quick Start Templates
Wails comes with a number of pre-configured templates that allow you to get your application up and running quickly.
There are templates for the following frameworks: Svelte, React, Vue, Preact, Lit and Vanilla. There are both Javascript
and Typescript versions for each template.
## Native Elements
Wails uses a purpose built library for handling native elements such as Window, Menus, Dialogs, etc, so you can build

View file

@ -29,7 +29,7 @@ Example:
This will generate a a project called "test" in the "mytestproject" directory, initialise git,
generate vscode project files and do so silently.
More information on using IDEs with Wails can be found [here](/docs/guides/ides).
More information on using IDEs with Wails can be found [here](../guides/ides.mdx).
### Remote Templates
@ -38,7 +38,7 @@ Remote templates (hosted on GitHub) are supported and can be installed by using
Example:
`wails init -n test -t https://github.com/leaanthony/testtemplate[@v1.0.0]`
A list of community maintained templates can be found [here](/docs/community/templates)
A list of community maintained templates can be found [here](../community/templates.mdx)
:::warning Attention
@ -54,7 +54,7 @@ A list of community maintained templates can be found [here](/docs/community/tem
| Flag | Description | Default |
| :------------------- | :-------------------------------------- | :------------------------- |
| -platform | Build for the given (comma delimited) [platforms](/docs/reference/cli#platforms) eg. `windows/arm64`. Note, if you do not give the architecture, `runtime.GOARCH` is used. | runtime.GOOS/runtime.GOARCH |
| -platform | Build for the given (comma delimited) [platforms](../reference/cli.mdx#platforms) eg. `windows/arm64`. Note, if you do not give the architecture, `runtime.GOARCH` is used. | runtime.GOOS/runtime.GOARCH |
| -clean | Cleans the `build/bin` directory | |
| -compiler "compiler"| Use a different go compiler to build, eg go1.15beta1 | go |
| -ldflags "flags" | Additional ldflags to pass to the compiler | |
@ -69,10 +69,11 @@ A list of community maintained templates can be found [here](/docs/community/tem
| -webview2 | WebView2 installer strategy: download,embed,browser,error | download |
| -u | Updates your project's `go.mod` to use the same version of Wails as the CLI | |
| -debug | Retains debug information in the application | false |
| -trimpath | Remove all file system paths from the resulting executable. | false |
For a detailed description of the `webview2` flag, please refer to the [Windows](/docs/guides/windows) Guide.
For a detailed description of the `webview2` flag, please refer to the [Windows](../guides/windows.mdx) Guide.
If you prefer to build using standard Go tooling, please consult the [Manual Builds](/docs/guides/manual-builds)
If you prefer to build using standard Go tooling, please consult the [Manual Builds](../guides/manual-builds.mdx)
guide.
Example:
@ -169,12 +170,12 @@ Your system is ready for Wails development!
| -noreload | Disable automatic reload when assets change | |
| -v | Verbosity level (0 - silent, 1 - standard, 2 - verbose) | 1 |
| -wailsjsdir | The directory to generate the generated Wails JS modules | Value in `wails.json` |
| -debounce | The time to wait for reload after an asset change is detected | 100 (milliseconds) |
| -devserverurl "url" | Use 3rd party dev server url, EG Vite | "http://localhost:34115" |
| -debounce | The time to wait for reload after an asset change is detected | 100 (milliseconds) |
| -devserver "host:port" | The address to bind the wails dev server to | "localhost:34115" |
| -frontenddevserverurl "url" | Use 3rd party dev server url to serve assets, EG Vite | "" |
| -appargs "args" | Arguments passed to the application in shell style | |
| -platform "platform" | Platform/Arch to target | `runtime.GOOS` |
| -save | Saves the given `assetdir`, `reloaddirs`, `wailsjsdir`, `debounce` and `devserverurl` flags in
`wails.json` to become the defaults for subsequent invocations. | |
| -save | Saves the given `assetdir`, `reloaddirs`, `wailsjsdir`, `debounce`, `devserver` and `frontenddevserverurl` flags in `wails.json` to become the defaults for subsequent invocations. | |
Example:
@ -182,12 +183,12 @@ Example:
This command will do the following:
- Build the application and run it (more details [here](/docs/guides/manual-builds)
- Build the application and run it (more details [here](../guides/manual-builds.mdx)
- Generate the Wails JS modules in `./frontend/src`
- Watch for updates to files in `./frontend/dist` and reload on any change
- Open a browser and connect to the application
There is more information on using this feature with existing framework scripts [here](/docs/guides/application-development#live-reloading).
There is more information on using this feature with existing framework scripts [here](../guides/application-development.mdx#live-reloading).
## generate
@ -201,7 +202,7 @@ it may be used for generating projects.
| -name | The template name (Mandatory) |
| -frontend "path" | Path to frontend project to use in template |
For more details on creating templates, consult the [Templates guide](/docs/guides/templates).
For more details on creating templates, consult the [Templates guide](../guides/templates.mdx).
## update
@ -215,4 +216,4 @@ For more details on creating templates, consult the [Templates guide](/docs/guid
## version
`wails version` will simply output the current CLI version.
`wails version` will simply output the current CLI version.

View file

@ -5,27 +5,34 @@ sidebar_position: 4
# Menus
It is possible to add an application menu to Wails projects. This is achieved by defining a [Menu](#menu) struct and
setting the [`Menu`](../reference/options#menu) option, or by calling the runtime method [MenuSetApplicationMenu](../reference/runtime/menu#menusetapplicationmenu).
setting it in the [`Menu`](../reference/options.mdx#menu) application config, or by calling the runtime method
[MenuSetApplicationMenu](../reference/runtime/menu.mdx#menusetapplicationmenu).
It is also possible to dynamically update the menu, by updating the menu struct and calling
[MenuUpdateApplicationMenu](../reference/runtime/menu#menuupdateapplicationmenu).
Example:
An example of how to create a menu:
```go
myMenu := menu.NewMenuFromItems(
menu.SubMenu("File", menu.NewMenuFromItems(
menu.Text("&Open", keys.CmdOrCtrl("o"), openFile),
menu.Separator(),
menu.Text("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
runtime.Quit()
}),
)),
AppMenu := menu.NewMenu()
FileMenu := AppMenu.AddSubmenu("File")
FileMenu.AddText("&Open", keys.CmdOrCtrl("o"), openFile)
FileMenu.AddSeparator()
FileMenu.AddText("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
runtime.Quit()
})
err := wails.Run(&options.App{
Title: "Menus Demo",
Width: 800,
Height: 600,
Menu: AppMenu,
Bind: []interface{}{
app,
},
)
// ...
````
runtime.MenuSetApplicationMenu(myMenu)
```
It is also possible to dynamically update the menu, by updating the menu struct and calling
[MenuUpdateApplicationMenu](../reference/runtime/menu.mdx#menuupdateapplicationmenu).
The example above uses helper methods, however it's possible to build the menu structs manually.
@ -211,8 +218,18 @@ func Text(label string, accelerator *keys.Accelerator, click Callback) *MenuItem
func Separator() *MenuItem
func Radio(label string, selected bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func Checkbox(label string, checked bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func SubMenu(label string, menu *Menu) *MenuItem
func SubMenu(label string, menu *Menu) *Menu
```
You can also create menu items directly on a menu by using the "Add" helpers:
```go title="Package: github.com/wailsapp/wails/v2/pkg/menu"
func (m *Menu) AddText(label string, accelerator *keys.Accelerator, click Callback) *MenuItem
func (m *Menu) AddSeparator() *MenuItem
func (m *Menu) AddRadio(label string, selected bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func (m *Menu) AddCheckbox(label string, checked bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func (m *Menu) AddSubMenu(label string, menu *Menu) *MenuI
```
A note on radio groups: A radio group is defined as a number of radio menu items that are next to each other in the menu.
This means that you do not need to group items together as it is automatic. However, that also means you cannot have 2

View file

@ -30,6 +30,7 @@ func main() {
RGBA: &options.RGBA{R: 0, G: 0, B: 0, A: 255},
AlwaysOnTop: false,
Assets: assets,
AssetsHandler: assetsHandler,
Menu: app.applicationMenu(),
Logger: nil,
LogLevel: logger.DEBUG,
@ -56,6 +57,8 @@ func main() {
LightModeTitleText: windows.RGB(20, 20, 20),
LightModeBorder: windows.RGB(200, 200, 200),
},
// User messages that can be customised
Messages *windows.Messages
},
Mac: &mac.Options{
TitleBar: &mac.TitleBar{
@ -75,6 +78,9 @@ func main() {
Icon: icon,
},
},
Linux: &linux.Options{
Icon: icon,
},
})
if err != nil {
log.Fatal(err)
@ -134,7 +140,7 @@ Name: Frameless
Type: bool
When set to `true`, the window will have no borders or title bar.
Also see [Frameless Windows](../guides/frameless).
Also see [Frameless Windows](../guides/frameless.mdx).
### MinWidth
@ -178,7 +184,7 @@ Name: StartHidden
Type: bool
When set to `true`, the application will be hidden until [WindowShow](../reference/runtime/window#WindowShow)
When set to `true`, the application will be hidden until [WindowShow](../reference/runtime/window.mdx#windowshow)
is called.
### HideWindowOnClose
@ -212,17 +218,49 @@ Indicates that the window should stay above other windows when losing focus.
Name: Assets
Type: \*embed.FS
Type: embed.FS
The frontend assets to be used by the application. Requires an `index.html` file.
### AssetsHandler <img src="http://badges.github.io/stability-badges/dist/experimental.svg"/>
Name: AssetsHandler
Type: http.Handler
The assets handler is a generic `http.Handler` which will be called for any non GET request on the assets server
and for GET requests which can not be served from the `assets` because the file is not found.
| Value | Win | Mac | Lin |
| ----------------------------- | --- | --- | --- |
| GET | ✅ | ✅ | ✅ |
| POST | ✅ | ✅ | ❌ |
| PUT | ✅ | ✅ | ❌ |
| PATCH | ✅ | ✅ | ❌ |
| DELETE | ✅ | ✅ | ❌ |
| Request Headers | ✅ | ✅ | ❌ |
| Request Body | ✅ | ✅ | ❌ |
| Request Body Streaming | ❌ | ❌ | ❌ |
| Response StatusCodes | ✅ | ✅ | ❌ |
| Response Headers | ✅ | ✅ | ❌ |
| Response Body | ✅ | ✅ | ✅ |
| Response Body Streaming | ❌ | ❌ | ✅ |
NOTE: Linux is currently very limited due to targeting a WebKit2GTK Version < 2.36.0. In the future some features will be
supported by the introduction of WebKit2GTK 2.36.0+ support.
NOTE: When used in combination with a Frontend DevServer there might be limitations, eg. Vite serves the index.html
on every path, that does not contain a file extension.
### Menu
Name: Menu
Type: \*menu.Menu
The menu to be used by the application. More details about Menus in the [Menu Reference](../reference/runtime/menu).
The menu to be used by the application. More details about Menus in the [Menu Reference](../reference/runtime/menu.mdx).
NOTE: On Mac, if no menu is specified, a default menu will be created.
@ -234,7 +272,7 @@ Type: logger.Logger
Default: Logger to Stdout
The logger to be used by the application. More details about logging in the [Log Reference](../reference/runtime/log).
The logger to be used by the application. More details about logging in the [Log Reference](../reference/runtime/log.mdx).
### LogLevel
@ -244,7 +282,7 @@ Type: logger.LogLevel
Default: `Info` in dev mode, `Error` in production mode
The default log level. More details about logging in the [Log Reference](../reference/runtime/log).
The default log level. More details about logging in the [Log Reference](../reference/runtime/log.mdx).
### OnStartup
@ -311,7 +349,7 @@ Defines how the window should present itself at startup.
| --------------- | --- | --- | --- |
| Fullscreen | ✅ | ✅ | ✅ |
| Maximised | ✅ | ✅ | ✅ |
| Minimised | ✅ | | ✅ |
| Minimised | ✅ | | ✅ |
### Bind
@ -337,6 +375,14 @@ Type: \*mac.Options
This defines [Mac specific options](#mac-specific-options).
### Linux
Name: Linux
Type: \*linux.Options
This defines [Linux specific options](#linux-specific-options).
## Windows Specific Options
### WebviewIsTransparent
@ -384,6 +430,87 @@ Type: string
This defines the path where the WebView2 stores the user data. If empty `%APPDATA%\[BinaryName.exe]` will be used.
### Theme
Name: Theme
Type: `windows.Theme`
Minimum Windows Version: Windows 10 2004/20H1
This defines the theme that the application should use:
| Value | Description |
| --------------- | ----------- |
| SystemDefault | *Default*. The theme will be based on the system default. If the user changes their theme, the application will update to use the new setting |
| Dark | The application will use a dark theme exclusively |
| Light | The application will use a light theme exclusively |
### CustomTheme
Name: CustomTheme
Type: `windows.CustomTheme`
Minimum Windows Version: Windows 10/11 2009/21H2 Build 22000
Allows you to specify custom colours for TitleBar, TitleText and Border for both light and dark mode, as well as
when the window is active or inactive.
#### CustomTheme
The CustomTheme struct uses `int32` to specify the colour values. These are in the standard(!) Windows format of:
`0x00BBGGAA`. A helper function is provided to do RGB conversions into this format: `windows.RGB(r,g,b uint8)`.
NOTE: Any value not provided will default to black.
```go
type ThemeSettings struct {
DarkModeTitleBar int32
DarkModeTitleBarInactive int32
DarkModeTitleText int32
DarkModeTitleTextInactive int32
DarkModeBorder int32
DarkModeBorderInactive int32
LightModeTitleBar int32
LightModeTitleBarInactive int32
LightModeTitleText int32
LightModeTitleTextInactive int32
LightModeBorder int32
LightModeBorderInactive int32
}
```
Example:
```go
CustomTheme: &windows.ThemeSettings{
// Theme to use when window is active
DarkModeTitleBar: windows.RGB(255, 0, 0), // Red
DarkModeTitleText: windows.RGB(0, 255, 0), // Green
DarkModeBorder: windows.RGB(0, 0, 255), // Blue
LightModeTitleBar: windows.RGB(200, 200, 200),
LightModeTitleText: windows.RGB(20, 20, 20),
LightModeBorder: windows.RGB(200, 200, 200),
// Theme to use when window is inactive
DarkModeTitleBarInactive: windows.RGB(128, 0, 0),
DarkModeTitleTextInactive: windows.RGB(0, 128, 0),
DarkModeBorderInactive: windows.RGB(0, 0, 128),
LightModeTitleBarInactive: windows.RGB(100, 100, 100),
LightModeTitleTextInactive: windows.RGB(10, 10, 10),
LightModeBorderInactive: windows.RGB(100, 100, 100),
},
```
### Messages
Name: Messages
Type: `*windows.Messages`
A struct of strings used by the webview2 installer if a valid webview2 runtime is not found.
Customise this for any language you choose to support.
## Mac Specific Options
### TitleBar
@ -446,7 +573,7 @@ type TitleBar struct {
| Name | Description |
| ---- | ----------- |
| TitlebarAppearsTransparent | Makes the titlebar transparent. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) |
| TitlebarAppearsTransparent | Makes the titlebar transparent. This has the effect of hiding the titlebar and the content fill the window. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) |
| HideTitle | Hides the title of the window. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindowtitlevisibility?language=objc) |
| HideTitleBar | Removes [NSWindowStyleMaskTitled](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemasktitled/) from the style mask |
| FullSizeContent | Makes the webview fill the entire window. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemaskfullsizecontentview)|

View file

@ -14,12 +14,13 @@ The project config resides in the `wails.json` file in the project directory. Th
"frontend:install": "[The command to install node dependencies, run in the frontend directory - often `npm install`]",
"frontend:build": "[The command to build the assets, run in the frontend directory - often `npm run build`]",
"frontend:dev": "[This command is the dev equivalent of frontend:build. If not specified falls back to frontend:build]",
"frontend:dev:watcher": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers]",
"frontend:dev:watcher": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers or starting 3d party dev servers]",
"frontend:dev:serverUrl": "[URL to a 3rd party dev server to be used to serve assets, EG Vite",
"wailsjsdir": "[Relative path to the directory that the auto-generated JS modules will be created]",
"version": "[Project config version]",
"outputfilename": "[The name of the binary]",
"debounceMS": 100, // The default time the dev server waits to reload when it detects a vhange in assets
"devserverurl": "[URL to the dev server serving local assets. Default: http://localhost:34115]",
"debounceMS": 100, // The default time the dev server waits to reload when it detects a change in assets
"devServer": "[Address to bind the wails dev sever to. Default: localhost:34115]",
"appargs": "[Arguments passed to the application in shell style when in dev mode]",
"runNonNativeBuildHooks": false, // Defines if build hooks should be run though they are defined for an OS other than the host OS.
"postBuildHooks": {
@ -34,11 +35,11 @@ The project config resides in the `wails.json` file in the project directory. Th
"copyright": "[The copyright of the product. Default: 'Copyright.........']",
"comments": "[A short comment of the app. Default: 'Built using Wails (https://wails.app)']"
},
"nsisType": "['multiple': One installer per achitecture. 'single': Single universal installer for all architectures being built. Default: 'multiple']"
"nsisType": "['multiple': One installer per architecture. 'single': Single universal installer for all architectures being built. Default: 'multiple']"
}
```
This file is read by the Wails CLI when running `wails build` or `wails dev`.
The `assetdir`, `reloaddirs`, `wailsjsdir`, `debounceMS` and `devserverurl` flags in `wails build/dev` will update the project config
The `assetdir`, `reloaddirs`, `wailsjsdir`, `debounceMS`, `devserver` and `frontenddevserverurl` flags in `wails build/dev` will update the project config
and thus become defaults for subsequent runs.

View file

@ -8,15 +8,15 @@ The runtime is a library that provides utility methods for your application. The
and the aim is to try and keep them at parity where possible.
The Go Runtime is available through importing `github.com/wailsapp/wails/v2/pkg/runtime`. All methods in this package
take a context as the first parameter. This context should be obtained from the [OnStartup](../../reference/options#onstartup)
or [OnDomReady](../../reference/options#ondomready) hooks.
take a context as the first parameter. This context should be obtained from the [OnStartup](../options.mdx#onstartup)
or [OnDomReady](../options.mdx#ondomready) hooks.
:::info Note
Whilst the context will be provided to the
[OnStartup](../../reference/options#onstartup) method, there's no guarantee the runtime will work in this method as
[OnStartup](../options.mdx#onstartup) method, there's no guarantee the runtime will work in this method as
the window is initialising in a different thread. If
you wish to call runtime methods at startup, use [OnDomReady](../../reference/options#ondomready).
you wish to call runtime methods at startup, use [OnDomReady](../options.mdx#ondomready).
:::

View file

@ -27,6 +27,12 @@ JS Signature: `LogPrint(message: string)`
Logs the given message as a raw message.
### LogPrintf
Go Signature: `LogPrintf(ctx context.Context, format string, args ...interface{})`
Logs the given message as a raw message.
### LogTrace
Go Signature: `LogTrace(ctx context.Context, message string)`
@ -35,6 +41,12 @@ JS Signature: `LogTrace(message: string)`
Logs the given message at the `Trace` log level.
### LogTracef
Go Signature: `LogTracef(ctx context.Context, format string, args ...interface{})`
Logs the given message at the `Trace` log level.
### LogDebug
Go Signature: `LogDebug(ctx context.Context, message string)`
@ -43,6 +55,11 @@ JS Signature: `LogDebug(message: string)`
Logs the given message at the `Debug` log level.
### LogDebugf
Go Signature: `LogDebugf(ctx context.Context, format string, args ...interface{})`
Logs the given message at the `Debug` log level.
### LogInfo
@ -52,6 +69,11 @@ JS Signature: `LogInfo(message: string)`
Logs the given message at the `Info` log level.
### LogInfof
Go Signature: `LogInfof(ctx context.Context, format string, args ...interface{})`
Logs the given message at the `Info` log level.
### LogWarning
@ -61,6 +83,11 @@ JS Signature: `LogWarning(message: string)`
Logs the given message at the `Warning` log level.
### LogWarningf
Go Signature: `LogWarningf(ctx context.Context, format string, args ...interface{})`
Logs the given message at the `Warning` log level.
### LogError
@ -70,14 +97,26 @@ JS Signature: `LogError(message: string)`
Logs the given message at the `Error` log level.
### LogErrorf
Go Signature: `LogErrorf(ctx context.Context, format string, args ...interface{})`
Logs the given message at the `Error` log level.
### LogFatal
Go Signature: `LogFatal(ctx context.Context, message string)`
JS Signature: `LogFatal(message: string)`
Logs the given message at the `Fatal` log level.
### LogFatalf
Go Signature: `LogFatalf(ctx context.Context, format string, args ...interface{})`
Logs the given message at the `Fatal` log level.
### LogSetLogLevel
Go Signature: `LogSetLogLevel(ctx context.Context, level logger.LogLevel)`
@ -96,7 +135,7 @@ Sets the log level. In Javascript, the number relates to the following log level
## Using a Custom Logger
A custom logger may be used by providing it using the [Logger](../../reference/options#logger)
A custom logger may be used by providing it using the [Logger](../options.mdx#logger)
application option. The only requirement is that the logger implements the `logger.Logger` interface
defined in `github.com/wailsapp/wails/v2/pkg/logger`:

View file

@ -15,7 +15,7 @@ These methods are related to the application menu.
### MenuSetApplicationMenu
Go Signature: `MenuSetApplicationMenu(ctx context.Context, menu *menu.Menu)`
Sets the application menu to the given [menu](../../reference/menus) .
Sets the application menu to the given [menu](../menus.mdx) .
### MenuUpdateApplicationMenu
Go Signature: `MenuUpdateApplicationMenu(ctx context.Context)`

View file

@ -41,7 +41,43 @@ Go Signature: `WindowReload(ctx context.Context)`
JS Signature: `WindowReload()`
Performs a "reload" (Reloads index.html)
Performs a "reload" (Reloads current page).
### WindowReloadApp
Go Signature: `WindowReloadApp(ctx context.Context)`
JS Signature: `WindowReloadApp()`
Reloads the application frontend.
### WindowSetSy
### WindowSetSystemDefaultTheme
Go Signature: `WindowSetSystemDefaultTheme(ctx context.Context)`
JS Signature: `WindowSetSystemDefaultTheme()`
Windows only.
Sets window theme to system default (dark/light).
### WindowSetLightTheme
Go Signature: `WindowSetLightTheme(ctx context.Context)`
JS Signature: `WindowSetLightTheme()`
Windows only.
Sets window theme to light.
### WindowSetDarkTheme
Go Signature: `WindowSetDarkTheme(ctx context.Context)`
JS Signature: `WindowSetDarkTheme()`
Windows only.
Sets window theme to dark.
### WindowShow
Go Signature: `WindowShow(ctx context.Context)`

View file

@ -1,4 +1,4 @@
[
"v2.0.0-beta.35",
"v2.0.0-beta.34"
"v2.0.0-beta.37",
"v2.0.0-beta.35"
]