diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx index 6cd13c452..aa2c51f35 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx @@ -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 模块 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx index aad005810..a1052bf26 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx @@ -25,3 +25,7 @@ Wails 为拖动窗口提供了一个简单的解决方案:任何具有“data- ``` + +:::info 全屏 +如果您允许应用程序全屏显示,则此拖动功能将被禁用。 +::: diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx index 961227f8e..fbf47c06d 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx @@ -89,3 +89,4 @@ Renaming package-lock.json -> package-lock.tmpl.json... - 确保`template.json`完整,尤其是`helpurl` - 将文件推送到 GitHub - 在[社区模板](/docs/community/templates)页面上创建 PR +- 在[模板公告](https://github.com/wailsapp/wails/discussions/825)讨论板上发布模板 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx index 6a9068c37..48d65ec32 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx @@ -9,10 +9,10 @@ 通过在构建时使用`-webview2`标志,您可以决定在未检测到合适的运行时的时候(包括安装的运行时是否太旧)应用程序将执行的操作。四个选项是: -1. 下载 -2. 内嵌 -3. 浏览器 -4. 错误 +1. Download(下载) +2. Embed(内嵌) +3. Browser(浏览器) +4. Error(错误) ### 下载 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx index 47e22cb84..69494863b 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx @@ -98,7 +98,9 @@ var assets embed.FS 由于可用于生产的二进制文件使用包含在`embed.FS`中的文件,因此应用程序不需要附带任何外部文件。 当使用`wails dev`命令在”dev“模式下,资源从磁盘加载,任何更改都会导致“实时重新加载”。资源的位置需要使用`-assetdir`传递给`wails dev`命令,并且很可能与嵌入路径相同。 -希望将来我们可以从`embed.FS`本身计算出来。更多细节可以在[应用程序开发指南](/docs/guides/application-development)中找到。 +希望将来我们可以从`embed.FS`本身计算出来。 + +更多细节可以在[应用程序开发指南](/docs/guides/application-development)中找到。 #### 应用程序生命周期回调 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx index 3c27b5577..ea00656b5 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx @@ -243,7 +243,7 @@ func main() { 类型:bool -将此设置为 true 将使 webview 背景透明,其中没有其他颜色呈现。通常与[窗口半透明](#窗口半透明)结合使用 以制作外观现代的应用程序。 +当 alpha 值为 0 时,设置为 true 将使 WebView 背景透明。这意味着如果你使用`rgba(0,0,0,0)`,主窗口将显示。通常与[窗口半透明](#窗口半透明)结合使用以制作冰霜效果的应用程序。 ### 窗口半透明 @@ -251,7 +251,7 @@ func main() { 类型:bool -将此设置为 true 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作外观现代的应用程序。 +将此设置为 true 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作冰霜效果的应用程序。 ### 禁用窗口图标 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx index 78f082e8d..9264196f1 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx @@ -5,8 +5,6 @@ sidebar_position: 5 # 对话框 -TODO: 待同步 - ## 概述 运行时的这一部分提供对原生对话框的调用,例如文件选择器和消息框。上下文 @@ -17,44 +15,44 @@ JS 运行时当前不支持 Dialog。 ### 打开选择目录对话框 +打开一个对话框,提示用户选择目录。可以使用 [打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。 + Go 方法签名: `OpenDirectoryDialog(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 方法签名: `SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error)` 返回值: 所选文件(如果用户取消则为空白)或错误 -打开一个对话框,提示用户选择文件名以进行保存。可以使用[保存文件对话框参数选项](#保存文件对话框参数选项)自定义。 - ### 消息对话框 +使用消息对话框显示消息。可以使用[消息对话框参数选项](#消息对话框参数选项)进行自定义。 + Go 方法签名: `MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error)` 返回值: 所选按钮的文本或错误 -使用消息对话框显示消息。可以使用[消息对话框参数选项](#消息对话框参数选项)进行自定义。 - ## 参数选项 ### 打开选择文件对话框参数选项 @@ -65,15 +63,28 @@ type OpenDialogOptions struct { DefaultFilename string Title string Filters []FileFilter - AllowFiles bool // Mac Only - AllowDirectories bool // Mac Only - ShowHiddenFiles bool // Mac Only - CanCreateDirectories bool // Mac Only - ResolvesAliases bool // Mac Only - TreatPackagesAsDirectories bool // Mac Only + AllowFiles bool + AllowDirectories bool + ShowHiddenFiles bool + CanCreateDirectories bool + ResolvesAliases bool + TreatPackagesAsDirectories bool } ``` +| 字段 | 描述 | Win | Mac | +| -------------------------- | --------------------------------- | --- | --- | +| DefaultDirectory | 对话框打开时显示的目录 | ✅ | ✅ | +| DefaultFilename | 默认文件名 | ✅ | ✅ | +| Title | 对话框的标题 | ✅ | ✅ | +| [Filters](#文件过滤) | 文件过滤器列表 | ✅ | ✅ | +| AllowFiles | 允许选择文件 | | ✅ | +| AllowDirectories | 允许选择目录 | | ✅ | +| ShowHiddenFiles | 显示系统隐藏的文件 | | ✅ | +| CanCreateDirectories | 允许用户创建目录 | | ✅ | +| ResolvesAliases | 如果为 true,则返回文件而不是别名 | | ✅ | +| TreatPackagesAsDirectories | 允许导航到包 | | ✅ | + ### 保存文件对话框参数选项 ```go @@ -82,12 +93,22 @@ type SaveDialogOptions struct { DefaultFilename string Title string Filters []FileFilter - ShowHiddenFiles bool // Mac Only - CanCreateDirectories bool // Mac Only - TreatPackagesAsDirectories bool // Mac Only + ShowHiddenFiles bool + CanCreateDirectories bool + TreatPackagesAsDirectories bool } ``` +| 字段 | 描述 | Win | Mac | +| -------------------------- | ---------------------- | --- | --- | +| DefaultDirectory | 对话框打开时显示的目录 | ✅ | ✅ | +| DefaultFilename | 默认文件名 | ✅ | ✅ | +| Title | 对话框的标题 | ✅ | ✅ | +| [Filters](#文件过滤) | 文件过滤器列表 | ✅ | ✅ | +| ShowHiddenFiles | 显示系统隐藏的文件 | | ✅ | +| CanCreateDirectories | 允许用户创建目录 | | ✅ | +| TreatPackagesAsDirectories | 允许导航到包 | | ✅ | + ### 消息对话框参数选项 ```go @@ -96,30 +117,96 @@ type MessageDialogOptions struct { Title string Message string Buttons []string - DefaultButton string // Mac Only - CancelButton string // Mac Only - Icon string // Mac Only + DefaultButton string + CancelButton string } ``` -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; +| 字段 | 描述 | Win | Mac | +| ------------- | ---------------------------------------------------- | --- | --- | +| Type | 消息对话框的类型,例如问题、信息... | ✅ | ✅ | +| Title | 对话框的标题 | ✅ | ✅ | +| Message | 向用户显示的消息 | ✅ | ✅ | +| Buttons | 按钮标题列表 | | ✅ | +| DefaultButton | 带有此文本的按钮应被视为默认按钮。 Bound to `return` | | ✅ | +| CancelButton | 带有此文本的按钮应被视为取消。Bound to `escape` | | ✅ | - - - Windows - 具有标准对话框类型并且按钮不可定制。返回的值将是以下之一:“确定”、“取消”、“中止”、“重试”、“忽略”、“是”、“否”、“再试一次”或“继续” - - “DefaultButton”和“CancelButton”都应与“Buttons”中的值匹配。 - 即将推出... - +#### Windows + +Windows 具有标准对话框类型,其中的按钮不可自定义。 +返回的值将是以下之一:"Ok", "Cancel", "Abort", "Retry", "Ignore", "Yes", "No", "Try Again" or "Continue" + +#### Mac + +Mac 上的消息对话框最多可以指定 4 个按钮。如果没有`DefaultButton`或`CancelButton`给出,第一个按钮被认为是默认的并绑定到`return`键。 + +对于以下代码: + +```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”: + +```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”。 + +
+ +
+
+ +如果我们现在指定`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”: + +
+ +
+
+
+
#### 对话框类型 @@ -140,3 +227,41 @@ type FileFilter struct { Pattern string // semi-colon separated list of extensions, EG: "*.jpg;*.png" } ``` + +#### Windows + +Windows 允许您在对话框中使用多个文件过滤器。每个 FileFilter 将在对话框中显示为一个单独的条目: + +
+ +
+
+
+
+ +#### Mac + +Mac 对话框只有一组模式来过滤文件的概念。如果提供了多个 FileFilters,Wails 将使用所有定义的模式。 + +示例: + +```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`作为过滤器打开文件对话框。