5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-18 09:59:31 +08:00
wails/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-v2.9.0/gettingstarted/installation.mdx
Lea Anthony 8b215a9b4c
v2.9.0
2024-06-16 10:34:01 +10:00

90 lines
3.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.

---
sidebar_position: 1
---
# 安装
## 支持的平台
- Windows 10/11 AMD64/ARM64
- MacOS 10.13+ AMD64
- MacOS 11.0+ ARM64
- Linux AMD64/ARM64
## 依赖
Wails 有许多安装前需要的常见依赖项:
- Go 1.18+
- NPM (Node 15+)
### Go
从 [Go 下载页面](https://go.dev/dl/) 下载 Go。
确保您遵守官方的 [Go 安装说明](https://golang.org/doc/install#install)。 您还需要确保您的 `PATH` 环境变量包含您的 `~/go/bin` 目录路径。 重启终端并执行以下命令检查:
- 检查 Go 是否安装正确: `go version`
- 检查 "~/go/bin" 是否在您的 PATH 变量中: `echo $PATH | grep go/bin`
### NPM
从 [Node 下载页面](https://nodejs.org/en/download/) 下载 NPM。 最好使用最新版本,因为这是我们通常会测试的版本。
运行 `npm --version` 进行验证。
## 平台特定依赖关系
您还需要安装平台特定的依赖项:
```mdx-code-block
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
<Tabs
defaultValue="Windows"
values={[
{ label: "Windows", value: "Windows" },
{ label: "MacOS", value: "MacOS" },
{ label: "Linux", value: "Linux" },
]}
>
<TabItem value="MacOS">
Wails 要求安装 xcode 命令行工具。 这可以通过运行 <code>xcode-select --install</code> 来完成。
</TabItem>
<TabItem value="Windows">
Wails 要求安装 <a href="https://developer.microsoft.com/en-us/microsoft-edge/webview2/">WebView2</a> 运行时。 一些 Windows 安装已经安装了这个。 您可以使用 <code>wails doctor</code> 命令进行检查。
</TabItem>
<TabItem value={"Linux"}>
Linux 需要标准的 <code>gcc</code> 构建工具以及 <code>libgtk3</code> 和 <code>libwebkit</code>。 与其为不同的发行版列出大量命令Wails 可以尝试确定针对您的特定发行版的安装命令。 安装后运行 <code>wails doctor</code> 以显示如何安装依赖项。 如果您的发行版/包管理器不受支持,请参阅 <a href={"/docs/guides/linux-distro-support"}>添加Linux发行版指南</a>。
</TabItem>
</Tabs>
```
## 可选依赖
- [UPX](https://upx.github.io/) 用于压缩您的应用程序。
- [NSIS](https://wails.io/docs/guides/windows-installer/) 用于生成 Windows 安装程序。
## 安装 Wails
运行 `go install github.com/wailsapp/wails/v2/cmd/wails@latest` 安装 Wails CLI。
注意:如果您遇到了类似于以下内容的错误:
```shell
....\Go\pkg\mod\github.com\wailsapp\wails\v2@v2.1.0\pkg\templates\templates.go:28:12: pattern all:ides/*: no matching files found
```
请检查您是否已安装 Go 1.18+
```shell
go version
```
## 系统检查
运行 `wails doctor` 将检查您是否安装了正确的依赖项。 如果没有,它会就缺少的内容提供建议以帮助纠正问题。
## `wails` 命令好像不见了?
如果您的系统报告缺少 `wails` 命令,请确保您已正确遵循 Go 安装指南。 通常,这意味着您的用户 home 目录中的 `go/bin` 目录不在 `PATH` 环境变量中。 通常情况下还需要关闭并重新打开任何已打开的命令提示符,以便安装程序对环境所做的更改反映在命令提示符中。