mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:20:48 +08:00
Updated docs. Closes #1501
This commit is contained in:
parent
95082336cd
commit
7cc3652a39
@ -20,9 +20,9 @@ Wails has a number of common dependencies that are required before installation:
|
|||||||
|
|
||||||
### Go
|
### Go
|
||||||
|
|
||||||
Download Go from the [Go Downloads Page](https://golang.org/dl/).
|
Download Go from the [Go Downloads Page](https://go.dev/doc/install).
|
||||||
|
|
||||||
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:
|
Ensure that you follow the official [Go installation instructions](https://go.dev/doc/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 is installed correctly: `go version`
|
||||||
- Check "~/go/bin" is in your PATH variable: `echo $PATH | grep go/bin`
|
- Check "~/go/bin" is in your PATH variable: `echo $PATH | grep go/bin`
|
||||||
@ -37,6 +37,7 @@ Run `npm --version` to verify.
|
|||||||
|
|
||||||
You will also need to install platform specific dependencies:
|
You will also need to install platform specific dependencies:
|
||||||
|
|
||||||
|
|
||||||
import Tabs from "@theme/Tabs";
|
import Tabs from "@theme/Tabs";
|
||||||
import TabItem from "@theme/TabItem";
|
import TabItem from "@theme/TabItem";
|
||||||
|
|
||||||
@ -76,3 +77,10 @@ Run `go install github.com/wailsapp/wails/v2/cmd/wails@latest` to install the Wa
|
|||||||
## System Check
|
## System Check
|
||||||
|
|
||||||
Running `wails doctor` will check if you have the correct dependencies installed. If not, it will advise on what is missing and help on how to rectify any problems.
|
Running `wails doctor` will check if you have the correct dependencies installed. If not, it will advise on what is missing and help on how to rectify any problems.
|
||||||
|
|
||||||
|
## The `wails` command appears to be missing?
|
||||||
|
|
||||||
|
If your system is reporting that the `wails` command is missing, make sure you have followed the Go installation guide
|
||||||
|
correctly. Normally, it means that the `go/bin` directory in your User's home directory is not in the `PATH` environment
|
||||||
|
variable. You will also normally need to close and reopen any open command prompts so that changes to the environment
|
||||||
|
made by the installer are reflected at the command prompt.
|
@ -113,6 +113,40 @@ func main() {
|
|||||||
|
|
||||||
This will bind all public methods in our `App` struct (it will never bind the startup and shutdown methods).
|
This will bind all public methods in our `App` struct (it will never bind the startup and shutdown methods).
|
||||||
|
|
||||||
|
### Dealing with context when binding multiple structs
|
||||||
|
|
||||||
|
If you want to bind methods for multiple structs but want each struct to keep a reference to the context so that you
|
||||||
|
can use the runtime functions, a good pattern is to pass the context from the `OnStartup` method to your struct instances
|
||||||
|
:
|
||||||
|
|
||||||
|
```go
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
app := NewApp()
|
||||||
|
otherStruct := NewOtherStruct()
|
||||||
|
|
||||||
|
err := wails.Run(&options.App{
|
||||||
|
Title: "My App",
|
||||||
|
Width: 800,
|
||||||
|
Height: 600,
|
||||||
|
OnStartup: func(ctx context.Context){
|
||||||
|
app.SetContext(ctx)
|
||||||
|
otherStruct.SetContext(ctx)
|
||||||
|
},
|
||||||
|
OnShutdown: app.shutdown,
|
||||||
|
Bind: []interface{}{
|
||||||
|
app,
|
||||||
|
otherStruct
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
More information on Binding can be found [here](../howdoesitwork.mdx#method-binding).
|
More information on Binding can be found [here](../howdoesitwork.mdx#method-binding).
|
||||||
|
|
||||||
## Application Menu
|
## Application Menu
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
|
|
||||||
# Troubleshooting
|
# Troubleshooting
|
||||||
|
|
||||||
An assortment of troubleshooting tips.
|
An assortment of troubleshooting tips.
|
||||||
|
|
||||||
|
## The `wails` command appears to be missing?
|
||||||
|
|
||||||
|
If your system is reporting that the `wails` command is missing, make sure you have followed the Go installation guide
|
||||||
|
correctly. Normally, it means that the `go/bin` directory in your User's home directory is not in the `PATH` environment
|
||||||
|
variable. You will also normally need to close and reopen any open command prompts so that changes to the environment
|
||||||
|
made by the installer are reflected at the command prompt.
|
||||||
|
|
||||||
## My application is displaying a white/blank screen
|
## My application is displaying a white/blank screen
|
||||||
|
|
||||||
Check that your application includes the assets from the correct directory. In your `main.go` file, you will have
|
Check that your application includes the assets from the correct directory. In your `main.go` file, you will have
|
||||||
|
Loading…
Reference in New Issue
Block a user