5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 16:51:16 +08:00
wails/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/troubleshooting.mdx
2022-03-15 20:13:32 +11:00

83 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 故障排除
各种故障排除技巧。
## 我的应用程序显示白色/空白屏幕
检查您的应用程序是否在正确目录中包含资源。在您的`main.go`文件中,您将拥有类似于以下代码的内容:
```go
//go:embed frontend/dist
var assets embed.FS
```
检查`frontend/dist`中是否包含您的应用程序资源。
## Mac 应用程序无效
如果您构建的应用程序在 finder 中如下所示:
<p className="text--center">
<img src="/img/troubleshooting/invalid_mac_app.png"></img>
</p>
您的应用程序的 `info.plist` 可能无效。更新 `build/<yourapp>.app/Contents/info.plist` 文件并检查数据是否有效,例如二进制文件名称是否正确。要保留更改,请将文件复制回 `build/darwin` 目录。
## 前端调用后端方法无法使用可变参数
如果您有使用可变参数定义的后端方法,例如:
```go
func (a *App) TestFunc(msg string, args ...interface{}) error {
// Code
}
```
像这样从前端调用此方法将失败:
```js
var msg = "Hello: ";
var args = ["Go", "JS"];
window.go.main.App.TestFunc(msg, ...args)
.then((result) => {
//do things here
})
.catch((error) => {
//handle error
});
```
解决办法:
```js
var msg = "Hello ";
var args = ["Go", "JS"];
window.go.main.App.TestFunc(msg, args)
.then((result) => {
// 不需要展开符
// do things here
})
.catch((error) => {
//handle error
});
```
归功于https://github.com/wailsapp/wails/issues/1186
## 尝试安装 Wails 时遇到代理错误
如果您遇到这样的错误:
```
"https://proxy.golang.org/github.com/wailsapp/wails/cmd/wails/@v/list": dial tcp 172.217.163.49:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
```
这可能是因为官方 Go Proxy 被阻止(中国用户反馈了这一点)。解决方案是手动设置代理,例如:
```
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
```
来源https://github.com/wailsapp/wails/issues/1233