5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 03:40:45 +08:00

Merge pull request #901 from misitebao/synchronize-chinese-documents

docs: synchronize chinese documents
This commit is contained in:
Lea Anthony 2021-10-31 08:55:22 +11:00 committed by GitHub
commit 43c29abb23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 313 additions and 149 deletions

105
README.md
View File

@ -18,42 +18,57 @@
## Internationalization ## Internationalization
English | [简体中文](README.zh-Hans.md) [English](README.md) | [简体中文](README.zh-Hans.md)
<span id="nav-2"></span>
## Table of Contents
<details>
<summary>Click me to Open/Close the directory listing</summary>
- [1. Internationalization](#nav-1)
- [2. Table of Contents](#nav-2)
- [3. Introductions](#nav-3)
- [3.1 Official Website](#nav-3-1)
- [4. Features](#nav-4)
- [5. Sponsors](#nav-5)
- [6. Installation](#nav-6)
- [6.1 MacOS](#nav-6-1)
- [6.2 Linux](#nav-6-2)
- [6.2.1 Debian/Ubuntu](#nav-6-2-1)
- [6.2.2 Arch Linux / ArchLabs / Ctlos Linux](#nav-6-2-2)
- [6.2.3 Centos](#nav-6-2-3)
- [6.2.4 Fedora](#nav-6-2-4)
- [6.2.5 VoidLinux & VoidLinux-musl](#nav-6-2-5)
- [6.2.6 Gentoo](#nav-6-2-6)
- [6.3 Windows](#nav-6-3)
- [7. Usage](#nav-7)
- [7.1 Next Steps](#nav-7-1)
- [8. FAQ](#nav-8)
- [9. Contributors](#nav-9)
- [10. Special Mentions](#nav-10)
- [12. Special Thanks](#nav-11)
</details>
<span id="nav-3"></span>
## Introductions
The traditional method of providing web interfaces to Go programs is via a built-in web server. Wails offers a different The traditional method of providing web interfaces to Go programs is via a built-in web server. Wails offers a different
approach: it provides the ability to wrap both Go code and a web frontend into a single binary. Tools are provided to approach: it provides the ability to wrap both Go code and a web frontend into a single binary. Tools are provided to
make this easy for you by handling project creation, compilation and bundling. All you have to do is get creative! make this easy for you by handling project creation, compilation and bundling. All you have to do is get creative!
<span id="nav-3-1"></span>
### Official Website
The official docs can be found at [https://wails.app](https://wails.app). The official docs can be found at [https://wails.app](https://wails.app).
Click [here](https://wails.io) if you are interested in trying out v2 Beta for Windows. Click [here](https://wails.io) if you are interested in trying out v2 Beta for Windows.
<span id="nav-2"></span> <span id="nav-4"></span>
## Contents
- [1. Internationalization](#nav-1)
- [2. Contents](#nav-2)
- [3. Features](#nav-3)
- [4. Sponsors](#nav-4)
- [5. Installation](#nav-5)
- [5.1 MacOS](#nav-5-1)
- [5.2 Linux](#nav-5-2)
- [5.2.1 Debian/Ubuntu](#nav-5-2-1)
- [5.2.2 Arch Linux / ArchLabs / Ctlos Linux](#nav-5-2-2)
- [5.2.3 Centos](#nav-5-2-3)
- [5.2.4 Fedora](#nav-5-2-4)
- [5.2.5 VoidLinux & VoidLinux-musl](#nav-5-2-5)
- [5.2.6 Gentoo](#nav-5-2-6)
- [5.3 Windows](#nav-5-3)
- [6. Installation](#nav-6)
- [7. Next Steps](#nav-7)
- [8. FAQ](#nav-8)
- [9. Contributors](#nav-9)
- [10. Special Mentions](#nav-10)
- [11. Special Thanks](#nav-11)
<span id="nav-3"></span>
## Features ## Features
@ -67,7 +82,7 @@ Click [here](https://wails.io) if you are interested in trying out v2 Beta for W
- Powerful cli tool - Powerful cli tool
- Multiplatform - Multiplatform
<span id="nav-4"></span> <span id="nav-5"></span>
## Sponsors ## Sponsors
@ -142,7 +157,7 @@ This project is supported by these kind people / companies:
<img src="https://github.com/DonTomato.png?size=45" width="45"/> <img src="https://github.com/DonTomato.png?size=45" width="45"/>
</a> </a>
<span id="nav-5"></span> <span id="nav-6"></span>
## Installation ## Installation
@ -152,7 +167,7 @@ an installation of Go. The basic requirements are:
- Go 1.16 - Go 1.16
- npm - npm
<span id="nav-5-1"></span> <span id="nav-6-1"></span>
### MacOS ### MacOS
@ -160,11 +175,11 @@ Make sure you have the xcode command line tools installed. This can be done by r
`xcode-select --install` `xcode-select --install`
<span id="nav-5-2"></span> <span id="nav-6-2"></span>
### Linux ### Linux
<span id="nav-5-2-1"></span> <span id="nav-6-2-1"></span>
#### Debian/Ubuntu #### Debian/Ubuntu
@ -176,7 +191,7 @@ _Ubuntu: 16.04, 18.04, 19.04_
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_, Pop!\_OS _Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_, Pop!\_OS
<span id="nav-5-2-2"></span> <span id="nav-6-2-2"></span>
#### Arch Linux / ArchLabs / Ctlos Linux #### Arch Linux / ArchLabs / Ctlos Linux
@ -184,7 +199,7 @@ _Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, K
_Also succesfully test on: Manjaro & ArcoLinux_ _Also succesfully test on: Manjaro & ArcoLinux_
<span id="nav-5-2-3"></span> <span id="nav-6-2-3"></span>
#### Centos #### Centos
@ -192,7 +207,7 @@ _Also succesfully test on: Manjaro & ArcoLinux_
_CentOS 6, 7_ _CentOS 6, 7_
<span id="nav-5-2-4"></span> <span id="nav-6-2-4"></span>
#### Fedora #### Fedora
@ -200,19 +215,19 @@ _CentOS 6, 7_
_Fedora 29, 30_ _Fedora 29, 30_
<span id="nav-5-2-5"></span> <span id="nav-6-2-5"></span>
#### VoidLinux & VoidLinux-musl #### VoidLinux & VoidLinux-musl
`xbps-install gtk+3-devel webkit2gtk-devel` `xbps-install gtk+3-devel webkit2gtk-devel`
<span id="nav-5-2-6"></span> <span id="nav-6-2-6"></span>
#### Gentoo #### Gentoo
`sudo emerge gtk+:3 webkit-gtk` `sudo emerge gtk+:3 webkit-gtk`
<span id="nav-5-3"></span> <span id="nav-6-3"></span>
### Windows ### Windows
@ -220,21 +235,21 @@ Windows requires gcc and related tooling. The recommended download is
from [http://tdm-gcc.tdragon.net/download](http://tdm-gcc.tdragon.net/download). Once this is installed, you are good to from [http://tdm-gcc.tdragon.net/download](http://tdm-gcc.tdragon.net/download). Once this is installed, you are good to
go. go.
<span id="nav-6"></span> <span id="nav-7"></span>
## Installation ## Usage
**Ensure Go modules are enabled: GO111MODULE=on and go/bin is in your PATH variable.** **Ensure Go modules are enabled: GO111MODULE=on and go/bin is in your PATH variable.**
Installation is as simple as running the following command: Installation is as simple as running the following command:
<pre style='color:white'> ```
go get -u github.com/wailsapp/wails/cmd/wails go get -u github.com/wailsapp/wails/cmd/wails
</pre> ```
<span id="nav-7"></span> <span id="nav-7-1"></span>
## Next Steps ### Next Steps
It is recommended at this stage to read the comprehensive documentation at [https://wails.app](https://wails.app). It is recommended at this stage to read the comprehensive documentation at [https://wails.app](https://wails.app).
@ -345,7 +360,7 @@ This project was mainly coded to the following albums:
<p align="center" style="text-align: center"> <p align="center" style="text-align: center">
<a href="https://pace.dev"><img src="pace.jpeg"/></a><br/> <a href="https://pace.dev"><img src="pace.jpeg"/></a><br/>
A <i>huge<i/> thanks to <a href="https://pace.dev">Pace</a> for sponsoring the project and helping the efforts to get Wails ported to Apple Silicon!<br/><br/> A <i>huge</i> thanks to <a href="https://pace.dev">Pace</a> for sponsoring the project and helping the efforts to get Wails ported to Apple Silicon!<br/><br/>
If you are looking for a Project Management tool that's powerful but quick and easy to use, check them out!<br/><br/> If you are looking for a Project Management tool that's powerful but quick and easy to use, check them out!<br/><br/>
</p> </p>

View File

@ -1,5 +1,5 @@
<p align="center" style="text-align: center"> <p align="center" style="text-align: center">
<img src="logo.png" width="40%"><br/> <img src="logo.png" width="55%"><br/>
</p> </p>
<p align="center"> <p align="center">
使用 Go 和 Web 技术构建桌面应用程序。<br/><br/> 使用 Go 和 Web 技术构建桌面应用程序。<br/><br/>
@ -18,44 +18,62 @@
## 国际化 ## 国际化
[English](README.md) | 简体中文 [English](README.md) | [简体中文](README.zh-Hans.md)
向 Go 程序提供 Web 接口的传统方法是通过内置 Web 服务器。Wails 提供了一种不同的方法:它提供了将 Go 代码和 Web
前端都包装成单个二进制文件的能力。通过提供工具,可以很轻松的完成项目的创建、编译和打包。你所要做的就是发挥创意!
官方文档可以在 [https://wails.app](https://wails.app) 中找到。
国内镜像站点 [https://wails.top](https://wails.top)。
<span id="nav-2"></span> <span id="nav-2"></span>
## 内容目录 ## 内容目录
<details>
<summary>点我 打开/关闭 目录列表</summary>
- [1. 国际化](#nav-1) - [1. 国际化](#nav-1)
- [2. 内容目录](#nav-2) - [2. 内容目录](#nav-2)
- [3. 特征](#nav-3) - [3. 项目介绍](#nav-3)
- [4. 赞助商](#nav-4) - [3.1 官方网站](#nav-3-1)
- [5. 安装](#nav-5) - [4. 功能](#nav-4)
- [5.1 MacOS](#nav-5-1) - [5. 赞助商](#nav-5)
- [5.2 Linux](#nav-5-2)
- [5.2.1 Debian/Ubuntu](#nav-5-2-1)
- [5.2.2 Arch Linux / ArchLabs / Ctlos Linux](#nav-5-2-2)
- [5.2.3 Centos](#nav-5-2-3)
- [5.2.4 Fedora](#nav-5-2-4)
- [5.2.5 VoidLinux & VoidLinux-musl](#nav-5-2-5)
- [5.2.6 Gentoo](#nav-5-2-6)
- [5.3 Windows](#nav-5-3)
- [6. 安装](#nav-6) - [6. 安装](#nav-6)
- [7. 下一步](#nav-7) - [6.1 MacOS](#nav-6-1)
- [6.2 Linux](#nav-6-2)
- [6.2.1 Debian/Ubuntu](#nav-6-2-1)
- [6.2.2 Arch Linux / ArchLabs / Ctlos Linux](#nav-6-2-2)
- [6.2.3 Centos](#nav-6-2-3)
- [6.2.4 Fedora](#nav-6-2-4)
- [6.2.5 VoidLinux & VoidLinux-musl](#nav-6-2-5)
- [6.2.6 Gentoo](#nav-6-2-6)
- [6.3 Windows](#nav-6-3)
- [7. 使用方法](#nav-7)
- [7.1 下一步](#nav-7-1)
- [8. 常见问题](#nav-8) - [8. 常见问题](#nav-8)
- [9. 贡献者](#nav-9) - [9. 贡献者](#nav-9)
- [10. 特别提及](#nav-10) - [10. 特别提及](#nav-10)
- [11. 许可协议](#nav-11) - [12. 特别感谢](#nav-11)
- [12. 特别感谢](#nav-12)
</details>
<span id="nav-3"></span> <span id="nav-3"></span>
## 特征 ## 项目介绍
为 Go 程序提供 Web 界面的传统方法是通过内置 Web 服务器。Wails 提供了一种不同的方法:它提供了将 Go 代码和 Web
前端一起打包成单个二进制文件的能力。通过提供的工具,可以很轻松的完成项目的创建、编译和打包。你所要做的就是发挥想象力!
<span id="nav-3-1"></span>
### 官方网站
官方文档可以在 [https://wails.app](https://wails.app) 中找到。
如果您对适用于 Windows 的 v2 测试版感兴趣,可以点击[此处](https://wails.io)查看。
镜像网站:
- [中国大陆镜像站点 - https://wails.top](https://wails.top)
<span id="nav-4"></span>
## 功能
- 后端使用标准 Go - 后端使用标准 Go
- 使用任意前端技术构建 UI 界面 - 使用任意前端技术构建 UI 界面
@ -67,13 +85,12 @@
- 强大的命令行工具 - 强大的命令行工具
- 跨多个平台 - 跨多个平台
<span id="nav-4"></span> <span id="nav-5"></span>
## 赞助商 ## 赞助商
这个项目由以下这些人或者公司支持: 这个项目由以下这些人或者公司支持:
<a href="https://github.com/sponsors/leaanthony" style="width:100px;"> <a href="https://github.com/sponsors/leaanthony" style="width:100px;">
<img src="sponsors/bronze%20sponsor.png" width="100"/> <img src="sponsors/bronze%20sponsor.png" width="100"/>
</a> </a>
@ -143,7 +160,7 @@
<img src="https://github.com/DonTomato.png?size=45" width="45"/> <img src="https://github.com/DonTomato.png?size=45" width="45"/>
</a> </a>
<span id="nav-5"></span> <span id="nav-6"></span>
## 安装 ## 安装
@ -152,7 +169,7 @@ Wails 使用 cgo 与原生渲染引擎结合,因此需要依赖一些平台的
- Go 1.16 - Go 1.16
- npm - npm
<span id="nav-5-1"></span> <span id="nav-6-1"></span>
### MacOS ### MacOS
@ -160,11 +177,11 @@ Wails 使用 cgo 与原生渲染引擎结合,因此需要依赖一些平台的
`xcode-select --install` `xcode-select --install`
<span id="nav-5-2"></span> <span id="nav-6-2"></span>
### Linux ### Linux
<span id="nav-5-2-1"></span> <span id="nav-6-2-1"></span>
#### Debian/Ubuntu #### Debian/Ubuntu
@ -176,7 +193,7 @@ _Ubuntu: 16.04, 18.04, 19.04_
_也成功测试了: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_, Pop!\_OS _也成功测试了: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_, Pop!\_OS
<span id="nav-5-2-2"></span> <span id="nav-6-2-2"></span>
#### Arch Linux / ArchLabs / Ctlos Linux #### Arch Linux / ArchLabs / Ctlos Linux
@ -184,7 +201,7 @@ _也成功测试了: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neo
_也成功测试了: Manjaro & ArcoLinux_ _也成功测试了: Manjaro & ArcoLinux_
<span id="nav-5-2-3"></span> <span id="nav-6-2-3"></span>
#### Centos #### Centos
@ -192,7 +209,7 @@ _也成功测试了: Manjaro & ArcoLinux_
_CentOS 6, 7_ _CentOS 6, 7_
<span id="nav-5-2-4"></span> <span id="nav-6-2-4"></span>
#### Fedora #### Fedora
@ -200,39 +217,39 @@ _CentOS 6, 7_
_Fedora 29, 30_ _Fedora 29, 30_
<span id="nav-5-2-5"></span> <span id="nav-6-2-5"></span>
#### VoidLinux & VoidLinux-musl #### VoidLinux & VoidLinux-musl
`xbps-install gtk+3-devel webkit2gtk-devel` `xbps-install gtk+3-devel webkit2gtk-devel`
<span id="nav-5-2-6"></span> <span id="nav-6-2-6"></span>
#### Gentoo #### Gentoo
`sudo emerge gtk+:3 webkit-gtk` `sudo emerge gtk+:3 webkit-gtk`
<span id="nav-5-3"></span> <span id="nav-6-3"></span>
### Windows ### Windows
Windows 需要 GCC 和相关工具。 建议从 [http://tdm-gcc.tdragon.net/download](http://tdm-gcc.tdragon.net/download) 下载, 安装完成,您就可以开始了。 Windows 需要 GCC 和相关工具。 建议从 [http://tdm-gcc.tdragon.net/download](http://tdm-gcc.tdragon.net/download) 下载, 安装完成,您就可以开始了。
<span id="nav-6"></span> <span id="nav-7"></span>
## 安装 ## 使用方法
**确保 Go modules 是开启的GO111MODULE=on 并且 go/bin 在您的 PATH 变量中。** **确保 Go modules 是开启的GO111MODULE=on 并且 go/bin 在您的 PATH 变量中。**
安装很简单,运行以下命令: 安装很简单,运行以下命令:
<pre style='color:white'> ```
go get -u github.com/wailsapp/wails/cmd/wails go get -u github.com/wailsapp/wails/cmd/wails
</pre> ```
<span id="nav-7"></span> <span id="nav-7-1"></span>
## 下一步 ### 下一步
建议在此时阅读 [https://wails.app](https://wails.app) 上面的文档. 建议在此时阅读 [https://wails.app](https://wails.app) 上面的文档.
@ -244,14 +261,14 @@ go get -u github.com/wailsapp/wails/cmd/wails
取决于您的要求。它旨在使 Go 程序员可以轻松制作轻量级桌面应用程序或在其现有应用程序中添加前端。尽管 Wails 当前不提供对诸如菜单之类的原生元素的钩子,但将来可能会改变。 取决于您的要求。它旨在使 Go 程序员可以轻松制作轻量级桌面应用程序或在其现有应用程序中添加前端。尽管 Wails 当前不提供对诸如菜单之类的原生元素的钩子,但将来可能会改变。
- 这个项目针对的是? - 这个项目针对的是哪些人?
希望将 HTML / JS / CSS 前端与其应用程序捆绑在一起的程序员,而不是借助创建服务并打开浏览器进行查看的方式。 希望将 HTML / JS / CSS 前端与其应用程序捆绑在一起的程序员,而不是借助创建服务并打开浏览器进行查看的方式。
- 名字怎么来的? - 名字怎么来的?
当我看到 WebView 时,我想"我真正想要的是围绕构建 WebView 应用程序工作,有点像 Rails 对于 Ruby"。因此最初它是一个文字游戏Webview on 当我看到 WebView 时,我想"我真正想要的是围绕构建 WebView 应用程序工作,有点像 Rails 对于 Ruby"。因此最初它是一个文字游戏Webview on
Rails。碰巧也是我来自的 [国家](https://en.wikipedia.org/wiki/Wales) 的英文名字的同音。所以就是了。 Rails。碰巧也是我来自的 [国家](https://en.wikipedia.org/wiki/Wales) 的英文名字的同音。所以就是了。
<span id="nav-9"></span> <span id="nav-9"></span>
@ -302,6 +319,7 @@ go get -u github.com/wailsapp/wails/cmd/wails
<a href="https://github.com/Igogrek"><img src="https://github.com/Igogrek.png?size=40" width="40"/></a></a> <a href="https://github.com/Igogrek"><img src="https://github.com/Igogrek.png?size=40" width="40"/></a></a>
<a href="https://github.com/aschey"><img src="https://github.com/aschey.png?size=40" width="40"/></a></a> <a href="https://github.com/aschey"><img src="https://github.com/aschey.png?size=40" width="40"/></a></a>
<a href="https://github.com/akhudek"><img src="https://github.com/akhudek.png?size=40" width="40"/></a></a> <a href="https://github.com/akhudek"><img src="https://github.com/akhudek.png?size=40" width="40"/></a></a>
<a href="https://github.com/s12chung"><img src="https://github.com/s12chung.png?size=40" width="40"/></a></a>
<span id="nav-10"></span> <span id="nav-10"></span>
@ -311,9 +329,9 @@ go get -u github.com/wailsapp/wails/cmd/wails
- [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot) - 他的支持和反馈是巨大的。 - [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot) - 他的支持和反馈是巨大的。
- [Serge Zaitsev](https://github.com/zserge) - Wails 窗口所使用的 [Webview](https://github.com/zserge/webview) 的作者。 - [Serge Zaitsev](https://github.com/zserge) - Wails 窗口所使用的 [Webview](https://github.com/zserge/webview) 的作者。
- [Byron](https://github.com/bh90210) - 有时Byron 单枪匹马地保持这个项目活着。没有他令人难以置信的投入,我们永远不会得到 v1 。 - [Byron](https://github.com/bh90210) - 有时Byron 一个人保持这个项目活跃着。没有他令人难以置信的投入,我们永远不会得到 v1 。
This project was mainly coded to the following albums: 编写项目代码时伴随着以下专辑:
- [Manic Street Preachers - Resistance Is Futile](https://open.spotify.com/album/1R2rsEUqXjIvAbzM0yHrxA) - [Manic Street Preachers - Resistance Is Futile](https://open.spotify.com/album/1R2rsEUqXjIvAbzM0yHrxA)
- [Manic Street Preachers - This Is My Truth, Tell Me Yours](https://open.spotify.com/album/4VzCL9kjhgGQeKCiojK1YN) - [Manic Street Preachers - This Is My Truth, Tell Me Yours](https://open.spotify.com/album/4VzCL9kjhgGQeKCiojK1YN)
@ -331,17 +349,11 @@ This project was mainly coded to the following albums:
<span id="nav-11"></span> <span id="nav-11"></span>
## 许可协议
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwailsapp%2Fwails.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)
<span id="nav-12"></span>
## 特别感谢 ## 特别感谢
<p align="center" style="text-align: center"> <p align="center" style="text-align: center">
<a href="https://pace.dev"><img src="pace.jpeg"/></a><br/> <a href="https://pace.dev"><img src="pace.jpeg"/></a><br/>
<i>非常<i/>感谢<a href="https://pace.dev">Pace</a>对项目的赞助,并帮助将 Wails 移植到 Apple Silicon !<br/><br/> <i>非常</i> 感谢<a href="https://pace.dev">Pace</a>对项目的赞助,并帮助将 Wails 移植到 Apple Silicon !<br/><br/>
如果您正在寻找一个强大并且快速和易于使用的项目管理工具,可以看看他们!<br/><br/> 如果您正在寻找一个强大并且快速和易于使用的项目管理工具,可以看看他们!<br/><br/>
</p> </p>

View File

@ -149,11 +149,16 @@ Wails v2 处理资源的方式的伟大之处在于它没有!您唯一需要
## 内置开发服务器 ## 内置开发服务器
TODO: 待同步 运行`wails dev`将启动内置的开发服务器,它将在您的项目目录中启动一个文件监听器。
默认情况下如果有任何文件更改wails 会检查它是否是应用程序文件(默认:.go可使用`-e`标志配置)。如果是,那么它将重新构建您的应用程序并重新启动它。如果更改的文件在`assetdir`目录中,它会在很短的时间后重新加载。
开发服务器使用一种称为“防抖”的技术,这意味着它不会立即重新加载,因为可能会在短时间内更改多个文件。当触发发生时,它会在发出重新加载之前等待一定的时间。
如果发生另一个触发,它会再次重置为等待时间。默认情况下,此值为 100ms。如果此值不适用于您的项目则可以使用`-debounce`标志进行配置。如果使用,此值将保存到您的项目配置中并成为默认值。
## 外部开发服务器 ## 外部开发服务器
TODO: 待同步 一些框架带有自己的实时重新加载服务器,但是它们将无法利用 Wails Go 绑定。在这种情况下最好运行一个监听脚本将项目重新构建到构建目录中Wails 将监视该目录。
有关示例,请参阅使用[rollup](https://rollupjs.org/guide/en/)的默认 svelte 模板。对于[create-react-app](https://create-react-app.dev/),可以使用[此脚本](https://gist.github.com/int128/e0cdec598c5b3db728ff35758abdbafd)来实现类似的结果。
## Go 模块 ## Go 模块

View File

@ -25,3 +25,7 @@ Wails 为拖动窗口提供了一个简单的解决方案任何具有“data-
</body> </body>
</html> </html>
``` ```
:::info 全屏
如果您允许应用程序全屏显示,则此拖动功能将被禁用。
:::

View File

@ -89,3 +89,4 @@ Renaming package-lock.json -> package-lock.tmpl.json...
- 确保`template.json`完整,尤其是`helpurl` - 确保`template.json`完整,尤其是`helpurl`
- 将文件推送到 GitHub - 将文件推送到 GitHub
- 在[社区模板](/docs/community/templates)页面上创建 PR - 在[社区模板](/docs/community/templates)页面上创建 PR
- 在[模板公告](https://github.com/wailsapp/wails/discussions/825)讨论板上发布模板

View File

@ -9,10 +9,10 @@
通过在构建时使用`-webview2`标志,您可以决定在未检测到合适的运行时的时候(包括安装的运行时是否太旧)应用程序将执行的操作。四个选项是: 通过在构建时使用`-webview2`标志,您可以决定在未检测到合适的运行时的时候(包括安装的运行时是否太旧)应用程序将执行的操作。四个选项是:
1. 下载 1. Download下载
2. 内嵌 2. Embed内嵌
3. 浏览器 3. Browser浏览器
4. 错误 4. Error错误
### 下载 ### 下载

View File

@ -98,7 +98,9 @@ var assets embed.FS
由于可用于生产的二进制文件使用包含在`embed.FS`中的文件,因此应用程序不需要附带任何外部文件。 由于可用于生产的二进制文件使用包含在`embed.FS`中的文件,因此应用程序不需要附带任何外部文件。
当使用`wails dev`命令在”dev“模式下资源从磁盘加载任何更改都会导致“实时重新加载”。资源的位置需要使用`-assetdir`传递给`wails dev`命令,并且很可能与嵌入路径相同。 当使用`wails dev`命令在”dev“模式下资源从磁盘加载任何更改都会导致“实时重新加载”。资源的位置需要使用`-assetdir`传递给`wails dev`命令,并且很可能与嵌入路径相同。
希望将来我们可以从`embed.FS`本身计算出来。更多细节可以在[应用程序开发指南](/docs/guides/application-development)中找到。 希望将来我们可以从`embed.FS`本身计算出来。
更多细节可以在[应用程序开发指南](/docs/guides/application-development)中找到。
#### 应用程序生命周期回调 #### 应用程序生命周期回调

View File

@ -243,7 +243,7 @@ func main() {
类型bool 类型bool
将此设置为 true 将使 webview 背景透明,其中没有其他颜色呈现。通常与[窗口半透明](#窗口半透明)结合使用 以制作外观现代的应用程序。 当 alpha 值为 0 时,设置为 true 将使 WebView 背景透明。这意味着如果你使用`rgba(0,0,0,0)`,主窗口将显示。通常与[窗口半透明](#窗口半透明)结合使用以制作冰霜效果的应用程序。
### 窗口半透明 ### 窗口半透明
@ -251,7 +251,7 @@ func main() {
类型bool 类型bool
将此设置为 true 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作外观现代的应用程序。 将此设置为 true 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作冰霜效果的应用程序。
### 禁用窗口图标 ### 禁用窗口图标

View File

@ -5,8 +5,6 @@ sidebar_position: 5
# 对话框 # 对话框
TODO: 待同步
## 概述 ## 概述
运行时的这一部分提供对原生对话框的调用,例如文件选择器和消息框。上下文 运行时的这一部分提供对原生对话框的调用,例如文件选择器和消息框。上下文
@ -17,44 +15,44 @@ JS 运行时当前不支持 Dialog。
### 打开选择目录对话框 ### 打开选择目录对话框
打开一个对话框,提示用户选择目录。可以使用 [打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。
Go 方法签名: `OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)` Go 方法签名: `OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)`
返回值: 所选目录(如果用户取消则为空白)或错误 返回值: 所选目录(如果用户取消则为空白)或错误
打开一个对话框,提示用户选择目录。可以使用 [打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。
### 打开选择文件对话框 ### 打开选择文件对话框
打开一个对话框,提示用户选择文件。可以使用[打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。
Go 方法签名: `OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)` Go 方法签名: `OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)`
返回值: 所选文件(如果用户取消则为空白)或错误 返回值: 所选文件(如果用户取消则为空白)或错误
打开一个对话框,提示用户选择文件。可以使用[打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。
### 打开选择多个文件对话框 ### 打开选择多个文件对话框
打开一个对话框,提示用户选择多个文件。可以使用[打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。
Go 方法签名: `OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error)` Go 方法签名: `OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error)`
返回值: 选定的文件(如果用户取消则为零)或错误 返回值: 选定的文件(如果用户取消则为零)或错误
打开一个对话框,提示用户选择多个文件。可以使用[打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。
### 保存文件对话框 ### 保存文件对话框
打开一个对话框,提示用户选择文件名以进行保存。可以使用[保存文件对话框参数选项](#保存文件对话框参数选项)自定义。
Go 方法签名: `SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error)` Go 方法签名: `SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error)`
返回值: 所选文件(如果用户取消则为空白)或错误 返回值: 所选文件(如果用户取消则为空白)或错误
打开一个对话框,提示用户选择文件名以进行保存。可以使用[保存文件对话框参数选项](#保存文件对话框参数选项)自定义。
### 消息对话框 ### 消息对话框
使用消息对话框显示消息。可以使用[消息对话框参数选项](#消息对话框参数选项)进行自定义。
Go 方法签名: `MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error)` Go 方法签名: `MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error)`
返回值: 所选按钮的文本或错误 返回值: 所选按钮的文本或错误
使用消息对话框显示消息。可以使用[消息对话框参数选项](#消息对话框参数选项)进行自定义。
## 参数选项 ## 参数选项
### 打开选择文件对话框参数选项 ### 打开选择文件对话框参数选项
@ -65,15 +63,28 @@ type OpenDialogOptions struct {
DefaultFilename string DefaultFilename string
Title string Title string
Filters []FileFilter Filters []FileFilter
AllowFiles bool // Mac Only AllowFiles bool
AllowDirectories bool // Mac Only AllowDirectories bool
ShowHiddenFiles bool // Mac Only ShowHiddenFiles bool
CanCreateDirectories bool // Mac Only CanCreateDirectories bool
ResolvesAliases bool // Mac Only ResolvesAliases bool
TreatPackagesAsDirectories bool // Mac Only TreatPackagesAsDirectories bool
} }
``` ```
| 字段 | 描述 | Win | Mac |
| -------------------------- | --------------------------------- | --- | --- |
| DefaultDirectory | 对话框打开时显示的目录 | ✅ | ✅ |
| DefaultFilename | 默认文件名 | ✅ | ✅ |
| Title | 对话框的标题 | ✅ | ✅ |
| [Filters](#文件过滤) | 文件过滤器列表 | ✅ | ✅ |
| AllowFiles | 允许选择文件 | | ✅ |
| AllowDirectories | 允许选择目录 | | ✅ |
| ShowHiddenFiles | 显示系统隐藏的文件 | | ✅ |
| CanCreateDirectories | 允许用户创建目录 | | ✅ |
| ResolvesAliases | 如果为 true则返回文件而不是别名 | | ✅ |
| TreatPackagesAsDirectories | 允许导航到包 | | ✅ |
### 保存文件对话框参数选项 ### 保存文件对话框参数选项
```go ```go
@ -82,12 +93,22 @@ type SaveDialogOptions struct {
DefaultFilename string DefaultFilename string
Title string Title string
Filters []FileFilter Filters []FileFilter
ShowHiddenFiles bool // Mac Only ShowHiddenFiles bool
CanCreateDirectories bool // Mac Only CanCreateDirectories bool
TreatPackagesAsDirectories bool // Mac Only TreatPackagesAsDirectories bool
} }
``` ```
| 字段 | 描述 | Win | Mac |
| -------------------------- | ---------------------- | --- | --- |
| DefaultDirectory | 对话框打开时显示的目录 | ✅ | ✅ |
| DefaultFilename | 默认文件名 | ✅ | ✅ |
| Title | 对话框的标题 | ✅ | ✅ |
| [Filters](#文件过滤) | 文件过滤器列表 | ✅ | ✅ |
| ShowHiddenFiles | 显示系统隐藏的文件 | | ✅ |
| CanCreateDirectories | 允许用户创建目录 | | ✅ |
| TreatPackagesAsDirectories | 允许导航到包 | | ✅ |
### 消息对话框参数选项 ### 消息对话框参数选项
```go ```go
@ -96,30 +117,96 @@ type MessageDialogOptions struct {
Title string Title string
Message string Message string
Buttons []string Buttons []string
DefaultButton string // Mac Only DefaultButton string
CancelButton string // Mac Only CancelButton string
Icon string // Mac Only
} }
``` ```
import Tabs from "@theme/Tabs"; | 字段 | 描述 | Win | Mac |
import TabItem from "@theme/TabItem"; | ------------- | ---------------------------------------------------- | --- | --- |
| Type | 消息对话框的类型,例如问题、信息... | ✅ | ✅ |
| Title | 对话框的标题 | ✅ | ✅ |
| Message | 向用户显示的消息 | ✅ | ✅ |
| Buttons | 按钮标题列表 | | ✅ |
| DefaultButton | 带有此文本的按钮应被视为默认按钮。 Bound to `return` | | ✅ |
| CancelButton | 带有此文本的按钮应被视为取消。Bound to `escape` | | ✅ |
<Tabs #### Windows
defaultValue="Windows"
values={[ Windows 具有标准对话框类型,其中的按钮不可自定义。
{ label: "Windows", value: "Windows" }, 返回的值将是以下之一:"Ok", "Cancel", "Abort", "Retry", "Ignore", "Yes", "No", "Try Again" or "Continue"
{ label: "MacOS", value: "MacOS" },
{ label: "Linux", value: "Linux" }, #### Mac
]}
> Mac 上的消息对话框最多可以指定 4 个按钮。如果没有`DefaultButton`或`CancelButton`给出,第一个按钮被认为是默认的并绑定到`return`键。
<TabItem value="Windows">
Windows 对于以下代码:
具有标准对话框类型并且按钮不可定制。返回的值将是以下之一:“确定”、“取消”、“中止”、“重试”、“忽略”、“是”、“否”、“再试一次”或“继续”
</TabItem> ```go
<TabItem value="MacOS">“DefaultButton”和“CancelButton”都应与“Buttons”中的值匹配。</TabItem> selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{
<TabItem value="Linux">即将推出...</TabItem> Title: "It's your turn!",
</Tabs> Message: "Select a number",
Buttons: []string{"one", "two", "three", "four"},
})
```
第一个按钮显示为默认值:
<div class="text--center">
<img
src="/img/runtime/dialog_no_defaults.png"
width="30%"
style={{ "box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px" }}
/>
</div>
<br />
如果我们指定`DefaultButton`为“two”
```go
selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{
Title: "It's your turn!",
Message: "Select a number",
Buttons: []string{"one", "two", "three", "four"},
DefaultButton: "two",
})
```
第二个按钮显示为默认值。当 `return` 被按下时则返回数值“two”。
<div class="text--center">
<img
src="/img/runtime/dialog_default_button.png"
width="30%"
style={{ "box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px" }}
/>
</div>
<br />
如果我们现在指定`CancelButton`为“three”
```go
selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{
Title: "It's your turn!",
Message: "Select a number",
Buttons: []string{"one", "two", "three", "four"},
DefaultButton: "two",
CancelButton: "three",
})
```
带有“three”的按钮显示在对话框的底部。当`escape`被按下时则返回值“three”
<div class="text--center">
<img
src="/img/runtime/dialog_default_cancel.png"
width="30%"
style={{ "box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px" }}
/>
</div>
<br />
<br />
<br />
#### 对话框类型 #### 对话框类型
@ -140,3 +227,41 @@ type FileFilter struct {
Pattern string // semi-colon separated list of extensions, EG: "*.jpg;*.png" Pattern string // semi-colon separated list of extensions, EG: "*.jpg;*.png"
} }
``` ```
#### Windows
Windows 允许您在对话框中使用多个文件过滤器。每个 FileFilter 将在对话框中显示为一个单独的条目:
<div class="text--center">
<img
src="/img/runtime/dialog_win_filters.png"
width="50%"
style={{ "box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px" }}
/>
</div>
<br />
<br />
<br />
#### Mac
Mac 对话框只有一组模式来过滤文件的概念。如果提供了多个 FileFiltersWails 将使用所有定义的模式。
示例:
```go
selection, err := runtime.OpenFileDialog(b.ctx, runtime.OpenDialogOptions{
Title: "Select File",
Filters: []runtime.FileFilter{
{
DisplayName: "Images (*.png;*.jpg)",
Pattern: "*.png;*.jpg",
}, {
DisplayName: "Videos (*.mov;*.mp4)",
Pattern: "*.mov;*.mp4",
},
},
})
```
这将导致使用`*.png,*.jpg,*.mov,*.mp4`作为过滤器打开文件对话框。