diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/about.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/about.md index 43a272fc..bd3d3fae 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/about.md +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/about.md @@ -10,10 +10,9 @@ sidebar_position: 1 Wails 是一个可让您使用 Go 和 Web 技术编写桌面应用的项目。 -将它看作为 Go 的轻量级和快速的 Electron 替代品。 您可以使用 Go 的灵活性和强大功能,结合丰富的现代前端,轻松的构建应用程序。 +将它看作为 Go 的快并且轻量的 Electron 替代品。 您可以使用 Go 的灵活性和强大功能,结合丰富的现代前端,轻松的构建应用程序。 -Wails 一点也不弱!这是 [xbar](https://xbarapp.com) - 一个使用 Wails 编写的 MacOS 桌面应用。它使用 Mac 的系统原生菜单,支持浅色和深色桌面主题,主窗口使用半透明,使其具有原生应用的 -“冰霜” 效果。 +Wails 一点也不弱!这是 [xbar](https://xbarapp.com) - 一个使用 Wails 编写的 MacOS 桌面应用。它使用 Mac 的系统原生菜单,支持浅色和深色桌面主题,主窗口使用半透明,使其具有原生应用的“冰霜” 效果。
@@ -21,7 +20,7 @@ Wails 一点也不弱!这是 [xbar](https://xbarapp.com) - 一个使用 Wails ## 原生元素 -Wails 使用专门的库来处理原生元素,例如窗口、菜单、对话框等,因此您可以构建美观、功能丰富的桌面应用程序。 +Wails 使用专门构建的库来处理原生元素,例如窗口、菜单、对话框等,因此您可以构建美观、功能丰富的桌面应用程序。 **它不嵌入浏览器**,因此性能高。相反,它使用平台的原生渲染引擎。在 Windows 上,是基于 Chromium 构建的新 Microsoft Webview2 库。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/credits.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/credits.mdx index c1464e52..958df5c5 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/credits.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/credits.mdx @@ -5,7 +5,7 @@ sidebar_position: 99 # 荣誉墙 - [Lea Anthony](https://github.com/leaanthony) - 项目所有者,首席开发人员 -- [Misitebao](https://github.com/misitebao) - 中文文档,Windows 测试,漏洞发现者 +- [Misitebao](https://github.com/misitebao) - 中文文档,Windows 平台测试,漏洞发现者 - [Travis McLane](https://github.com/tmclane) - 处理交叉编译相关工作, MacOS 平台的测试 - [Byron Chris](https://github.com/bh90210) - Linux 发行版指导,Linux 平台的测试 @@ -31,6 +31,9 @@ sidebar_position: 99 + + +

diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx index e0f1f60d..4d58cee9 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx @@ -7,8 +7,9 @@ sidebar_position: 1 ## 支持的平台 - Windows 10 -- MacOS x64 & arm64 (due October '21) -- Linux (due December '21) +- MacOS 10.13+ (amd64) +- MacOS 11.0+ (arm64) +- Linux (截至时间 12 月 22 日) ## 依赖 @@ -49,11 +50,18 @@ import TabItem from "@theme/TabItem"; > Wails 要求安装 - WebView2 - 运行时。一些 Windows 已经默认安装了这个。您可以使用 wails doctor + + WebView2 + + 运行时。一些 Windows 已经默认安装了这个。您可以使用{" "} + wails doctor 命令进行检查(见下文)。 - 即将推出... + + Wails 要求安装 xcode 命令行工具。这可以通过运行以下命令来完成: +
+ xcode-select --install +
即将推出... 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 aa2c51f3..4c58de9c 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 @@ -6,7 +6,7 @@ 默认模板使用 `main.go` 配置和运行应用程序, 同时`app.go`用于定义应用程序逻辑. -该`app.go`文件将定义一个结构体,该结构体有 2 个方法作为主应用程序的回调: +`app.go`文件将定义一个结构体,该结构体有 2 个方法作为主应用程序的回调: ```go title="app.go" type App struct { diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/developing-wails.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/developing-wails.mdx index 64158c4b..777491c4 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/developing-wails.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/developing-wails.mdx @@ -6,7 +6,7 @@ ## 漏洞 -对于提出漏洞,请在 GitHub 上打开一个 Issue 并给出[v2]标签。wails doctor 在 Issue 中包含`wails doctor`的输出以帮助我们了解您的环境。 +对于提出漏洞,请在 GitHub 上打开一个 Issue 并给出[v2]标签。在 Issue 中包含`wails doctor`的输出以帮助我们了解您的环境。 对于修复漏洞,请在您想要接受的 Issue 上发表评论,我们将在 Issue 上贴上标签。最好使用 Windows,因为它是使用纯 Go 中完成的,调试更容易。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx index d5119208..3c8fbe3f 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx @@ -13,16 +13,16 @@ Wails CLI 有许多用于管理项目的命令。所有命令都以此方式运 `wails init` 用于生成项目。 -| 标志 | 描述 | 默认 | -| :----------------- | :---------------------------------------------------------------------------------- | :------ | -| -n "project name" | 项目名. **强制必填**. | | -| -d "project dir" | 要创建的项目目录 | 项目名 | -| -g | 初始化 git 存储库 | | -| -l | 可用项目模板列表 | | -| -q | 禁止输出到控制台 | | -| -t "template name" | 要使用的项目模板。这可能是默认模板的名称或在 github 上托管的远程模板的 URL 的名称。 | vanilla | -| -ide | 生成 IDE 项目文件 | | -| -f | 强制构建应用 | false | +| 标志 | 描述 | 默认 | +| :------------ | :---------------------------------------------------------------------------- | :------ | +| -n "项目名称" | 项目名称。 **强制必填** | | +| -d "项目目录" | 要创建的项目目录 | 项目名 | +| -g | 初始化 git 存储库 | | +| -l | 可用项目模板列表 | | +| -q | 禁止输出到控制台 | | +| -t "模板名称" | 要使用的项目模板。这可能是默认模板的名称或在 github 上托管的远程模板的 URL 。 | vanilla | +| -ide | 生成 IDE 项目文件 | | +| -f | 强制构建应用 | false | 示例: `wails init -n test -d mytestproject -g -ide vscode -q` @@ -43,7 +43,7 @@ Wails CLI 有许多用于管理项目的命令。所有命令都以此方式运 **Wails 项目不维护也不对第 3 方模板负责** -如果您不确定某个模板,请检查 `package.json` 中运行的脚本和安装的模块。 +如果您不信任某个模板,请检查 `package.json` 中运行的脚本和安装的模块。 ::: @@ -51,20 +51,20 @@ Wails CLI 有许多用于管理项目的命令。所有命令都以此方式运 `wails build`用于将您的项目编译为生产可用的二进制文件。 -| 标志 | 描述 | 默认 | -| :------------------- | :----------------------------------------------------- | :------- | -| -clean | 清理`build/bin`目录 | | -| -compiler "compiler" | 使用不同的 go 编译器来构建,例如 go1.15beta1 | go | -| -ldflags "flags" | 传递给编译器的额外 ldflags | | -| -nopackage | 不打包应用程序 | | -| -o filename | 输出文件名 | | -| -s | 跳过前端构建 | | -| -f | 强制构建应用 | false | -| -tags "extra tags" | 传递给编译器构建标签(引号和空格分隔) | | -| -upx | 使用“upx”压缩最终二进制文件 | | -| -upxflags | 传递给 upx 的 flags | | -| -v int | 详细级别 (0 - silent, 1 - default, 2 - verbose) | 1 | -| -webview2 | WebView2 安装程序策略:: download,embed,browser,error. | download | +| 标志 | 描述 | 默认 | +| :------------------- | :--------------------------------------------------- | :------- | +| -clean | 清理`build/bin`目录 | | +| -compiler "compiler" | 使用不同的 go 编译器来构建,例如 go1.15beta1 | go | +| -ldflags "flags" | 传递给编译器的额外 ldflags | | +| -nopackage | 不打包应用程序 | | +| -o filename | 输出文件名 | | +| -s | 跳过前端构建 | | +| -f | 强制构建应用 | false | +| -tags "extra tags" | 传递给编译器构建标签(引号和空格分隔) | | +| -upx | 使用“upx”压缩最终二进制文件 | | +| -upxflags | 传递给 upx 的 flags | | +| -v int | 详细级别 (0 - silent, 1 - default, 2 - verbose) | 1 | +| -webview2 | WebView2 安装程序策略:download,embed,browser,error. | download | 如果您更喜欢使用标准 Go 工具进行构建,请参阅[手动构建](/docs/guides/manual-builds)指南。 @@ -72,6 +72,12 @@ Wails CLI 有许多用于管理项目的命令。所有命令都以此方式运 `wails build -clean -o myproject.exe` +:::info 苹果芯片上的 UPX + +在苹果芯片上使用 UPX 相关的[问题](https://github.com/upx/upx/issues/446)。 + +::: + ## 诊断检查 `wails doctor` 将运行诊断程序以确保您的系统已准备好进行开发。 @@ -134,8 +140,10 @@ Your system is ready for Wails development! | -wailsjsdir | 生成生成的 Wails JS 模块的目录 | `wails.json`中的值 | | -debounce | 检测到资源更改后等待重新加载的时间 | 100 (毫秒) | | -devserverurl "url" | 使用第 3 方开发服务器 url, 例如 Vite | "http://localhost:34115" | +| -appargs "args" | 以 shell 样式传递给应用程序的参数 | | +| -platform "platform" | 目标平台/架构 | `runtime.GOOS` | -如果在命令行上提供了`-assetdir`,`-wailsjsdir`,`debounce`或`devserverurl`标志,它们将保存在`wails.json`中,并成为后续调用的默认值。 +如果在命令行上提供了`-assetdir`、`-wailsjsdir`、`debounce`或`devserverurl`标志,它们将保存在`wails.json`中,并成为后续调用的默认值。 示例: @@ -159,7 +167,7 @@ Wails 使用模板来生成项目。`wails generate template`命令有助于构 | 标志 | 描述 | | :--------------- | :----------------------------- | | -name | 模板名称(必填) | -| -frontend "path" | 要在模板中使用的前端项目的路径 | +| -frontend "路径" | 要在模板中使用的前端项目的路径 | 有关创建模板的更多详细信息,请参阅[模板指南](/docs/guides/templates)。 @@ -167,10 +175,10 @@ Wails 使用模板来生成项目。`wails generate template`命令有助于构 `wails update` 将更新 Wails CLI 的版本。 -| 标志 | 描述 | -| :----------------- | :--------------------- | -| -pre | 更新到最新的预发布版本 | -| -version "version" | 安装指定版本的 CLI | +| 标志 | 描述 | +| :-------------- | :--------------------- | +| -pre | 更新到最新的预发布版本 | +| -version "版本" | 安装指定版本的 CLI | ## 版本 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx index 05b2e342..7c801754 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx @@ -66,16 +66,17 @@ type MenuItem struct { } ``` -| 字段 | 类型 | 笔记 | -| ----------- | ----------------------------- | ----------------------------------- | -| Label | string | 菜单文字 | -| Accelerator | [\*keys.Accelerator](#加速器) | 此菜单项的键绑定 | -| Type | [Type](#类型) | 菜单项的类型 | -| Disabled | bool | 禁用菜单项 | -| Hidden | bool | 隐藏此菜单项 | -| Checked | bool | 向菜单项设置选中 (复选框和单选类型) | -| SubMenu | [\*Menu](#菜单) | 设置子菜单 | -| Click | [Callback](#回调) | 单击菜单时的回调函数 | +| 字段 | 类型 | 笔记 | +| ----------- | ----------------------------- | ------------------------------------------- | +| Label | string | 菜单文字 | +| Accelerator | [\*keys.Accelerator](#加速器) | 此菜单项的键绑定 | +| Type | [Type](#类型) | 菜单项的类型 | +| Disabled | bool | 禁用菜单项 | +| Hidden | bool | 隐藏此菜单项 | +| Checked | bool | 向菜单项设置选中 (复选框和单选类型) | +| SubMenu | [\*Menu](#菜单) | 设置子菜单 | +| Click | [Callback](#回调) | 单击菜单时的回调函数 | +| Role | string | 定义此菜单项的[角色](#角色)。暂时只支持 Mac | ### 加速器 @@ -225,3 +226,18 @@ type CallbackData struct { ``` 给函数一个`CallbackData`结构体,它指示哪个菜单项触发了回调。这在使用可能共享回调的单选菜单组时很有用。 + +### 角色 + +:::info 角色 + +目前仅 Mac 支持角色。 + +::: + +一个菜单项可能有一个角色,它本质上是一个预定义的菜单项。我们目前支持以下角色: + +| 角色 | 描述 | +| ------------ | ----------------------------------------------------- | +| AppMenuRole | 标准的 Mac 应用程序菜单。可以使用`menu.AppMenu()`创建 | +| EditMenuRole | 标准的 Mac 编辑菜单。可以使用`menu.EditMenu()`创建 | 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 ea00656b..883952ec 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 @@ -34,7 +34,8 @@ func main() { LogLevel: logger.DEBUG, OnStartup: app.startup, OnDomReady: app.domready, - OnShutdown: app.shutdown, + OnShutdown: app.shutdown,, + WindowStartState: options.Maximised, Bind: []interface{}{ app, }, @@ -43,6 +44,24 @@ func main() { WindowIsTranslucent: false, DisableWindowIcon: false, }, + Mac: &mac.Options{ + TitleBar: &mac.TitleBar{ + TitlebarAppearsTransparent: true, + HideTitle: false, + HideTitleBar: false, + FullSizeContent: false, + UseToolbar: false, + HideToolbarSeparator: true, + }, + Appearance: mac.NSAppearanceNameDarkAqua, + WebviewIsTransparent: true, + WindowIsTranslucent: false, + About: &mac.AboutInfo{ + Title: "My Application", + Message: "© 2021 Me", + Icon: icon, + }, + }, }) if err != nil { log.Fatal(err) @@ -81,7 +100,7 @@ func main() { 类型:bool -默认情况下,主窗口可调整大小。将此设置为 true 将使其保持固定大小。 +默认情况下,主窗口可调整大小。将此设置为 `true` 将使其保持固定大小。 ### 全屏 @@ -89,7 +108,7 @@ func main() { 类型:bool -将此设置为 true 将在启动时使窗口全屏。 +将此设置为 `true` 将在启动时使窗口全屏。 ### 无边框 @@ -97,7 +116,7 @@ func main() { 类型:bool -设置为 时 true,窗口将没有边框或标题栏。另请参阅[无边框窗口](/docs/guides/frameless)。 +设置为`true`时,窗口将没有边框或标题栏。另请参阅[无边框窗口](/docs/guides/frameless)。 ### 最小宽度 @@ -137,7 +156,7 @@ func main() { 类型:bool -设置为 时`true`,应用程序将被隐藏,直到调用[显示窗口](/docs/reference/runtime/window#显示窗口)。 +设置为`true`时,应用程序将被隐藏,直到调用[显示窗口](/docs/reference/runtime/window#显示窗口)。 ### 关闭时隐藏窗口 @@ -179,11 +198,15 @@ func main() { 应用程序要使用的菜单。[菜单参考](/docs/reference/runtime/menu)中有关菜单的更多详细信息。 +注意:在 Mac 上,如果未指定菜单,则将创建默认菜单。 + ### 日志 名称:Logger -类型:logger.Logger 默认值:Logger to Stdout +类型:logger.Logger + +默认值:Logger to Stdout 应用程序要使用的记录器。有关日志记录的更多详细信息,请参阅[日志参考](/docs/reference/runtime/log)。 @@ -191,7 +214,9 @@ func main() { 名称:LogLevel -类型:logger.LogLevel 默认值:Info 在开发模式下,Error 在生产模式下 +类型:logger.LogLevel + +默认值:在开发模式下是`Info`,在生产模式下是`Error`。 默认日志级别。有关日志记录的更多详细信息,请参阅[设置日志等级](/docs/reference/runtime/log#设置日志等级)。 @@ -219,6 +244,20 @@ func main() { 在前端被销毁之后,就在应用程序终止之前,调用此回调。它给出了应用程序上下文。 +### 窗口启动状态 + +名称:WindowStartState + +类型: options.WindowStartState + +定义窗口在启动时应如何呈现。 + +| 值 | Win | Mac | +| ---------- | --- | --- | +| Fullscreen | ✅ | ✅ | +| Maximised | ✅ | ✅ | +| Minimised | ✅ | | + ### 绑定 名称:Bind @@ -243,7 +282,7 @@ func main() { 类型:bool -当 alpha 值为 0 时,设置为 true 将使 WebView 背景透明。这意味着如果你使用`rgba(0,0,0,0)`,主窗口将显示。通常与[窗口半透明](#窗口半透明)结合使用以制作冰霜效果的应用程序。 +设置为 `true` 时将使 WebView 背景透明。这意味着如果你使用`rgba(0,0,0,0)`,主窗口将显示。通常与[窗口半透明](#窗口半透明)结合使用以制作冰霜效果的应用程序。 ### 窗口半透明 @@ -251,7 +290,7 @@ func main() { 类型:bool -将此设置为 true 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作冰霜效果的应用程序。 +将此设置为 `true` 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作冰霜效果的应用程序。 ### 禁用窗口图标 @@ -259,4 +298,167 @@ func main() { 类型:bool -将此设置为 true 将删除标题栏左上角的图标。 +将此设置为 `true` 将删除标题栏左上角的图标。 + +## Mac 特定选项 + +### 标题栏 + +Name: TitleBar + +Type: [\*mac.TitleBar](#标题栏结构) + +TitleBar 结构提供了配置标题栏外观的能力。 + +### 外观 + +Name: Appearance + +Type: [AppearanceType](#外观类型) + +Appearance 用于根据 Apple 的 [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearancename?language=objc) 名称设置应用程序的样式。 + +### 网页透明 + +Name: WebviewIsTransparent + +Type: bool + +设置为 `true` 时将使 WebView 背景透明。这意味着如果你使用`rgba(0,0,0,0)`,主窗口将显示。通常与[窗口半透明](#窗口半透明)结合使用以制作冰霜效果的应用程序。 + +### 窗口半透明 + +Name: WindowIsTranslucent + +Type: bool + +将此设置为 `true` 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作冰霜效果的应用程序。 + +### 关于 + +Name: About + +Type: [About](#关于结构) + +此配置允许您为“AppMenu” role 创建的应用程序菜单中的“关于”菜单项设置标题、消息和图标。 + +#### 标题栏结构 + +可以使用 TitleBar 选项自定义应用程序的标题栏: + +```go +type TitleBar struct { + TitlebarAppearsTransparent bool + HideTitle bool + HideTitleBar bool + FullSizeContent bool + UseToolbar bool + HideToolbarSeparator bool +} +``` + +| 名称 | 描述 | +| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| TitlebarAppearsTransparent | 使标题栏透明。[Apple Docs](https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) | +| HideTitle | 隐藏窗口的标题。[Apple Docs](https://developer.apple.com/documentation/appkit/nswindowtitlevisibility?language=objc) | +| HideTitleBar | 从样式掩码中移除 [NSWindowStyleMaskTitled](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemasktitled/)。 | +| FullSizeContent | 使 webview 填满整个窗口。[Apple Docs](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemaskfullsizecontentview) | +| UseToolbar | 向窗口添加默认工具栏。 [Apple Docs](https://developer.apple.com/documentation/appkit/nstoolbar?language=objc) | +| HideToolbarSeparator | 删除工具栏下方的线条。 [Apple Docs](https://developer.apple.com/documentation/appkit/nstoolbar/1516954-showsbaselineseparator?language=objc) | + +预设的标题栏设置可用: + +| 设置 | 示例 | +| --------------------------- | --------------------------------------------- | +| `mac.TitleBarDefault()` | ![](/img/reference/titlebar-default.png) | +| `mac.TitleBarHidden()` | ![](/img/reference/titlebar-hidden.png) | +| `mac.TitleBarHiddenInset()` | ![](/img/reference/titlebar-hidden-inset.png) | + +示例: + +```go +Mac: &mac.Options{ + TitleBar: mac.TitleBarHiddenInset(), +} +``` + +单击[此处](https://github.com/lukakerr/NSWindowStyles)获取有关自定义标题栏的一些灵感。 + +#### 外观类型 + +您可以指定应用程序的[外观](https://developer.apple.com/documentation/appkit/nsappearance?language=objc)。 + +| 值 | 描述 | +| ----------------------------------------------------- | ------------------------------ | +| DefaultAppearance | 使用默认系统值 | +| NSAppearanceNameAqua | 标准日间系统外观 | +| NSAppearanceNameDarkAqua | 标准黑夜系统外观 | +| NSAppearanceNameVibrantLight | 轻盈灵动的外观 | +| NSAppearanceNameAccessibilityHighContrastAqua | 标准白天系统外观的高对比度版本 | +| NSAppearanceNameAccessibilityHighContrastDarkAqua | 标准黑夜系统外观的高对比度版本 | +| NSAppearanceNameAccessibilityHighContrastVibrantLight | 轻盈灵动外观的高对比度版本 | +| NSAppearanceNameAccessibilityHighContrastVibrantDark | 深色活力外观的高对比度版本 | + +示例: + +```go +Mac: &mac.Options{ + Appearance: mac.NSAppearanceNameDarkAqua, +} +``` + +#### 关于结构 + +```go +type AboutInfo struct { + Title string + Message string + Icon []byte +} +``` + +如果提供了这些设置,“关于”菜单项将出现在应用程序菜单中(使用`AppMenu` role 时)。建议这样配置: + +```go +//go:embed build/appicon.png +var icon []byte + +func main() { + err := wails.Run(&options.App{ + ... + Mac: &mac.Options{ + About: &mac.AboutInfo{ + Title: "My Application", + Message: "© 2021 Me", + Icon: icon, + }, + }, + }) +``` + +“关于”菜单项将出现在应用程序菜单中: + +
+ +
+
+ +单击后,将打开一个关于消息框: + +
+ +
+
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx index c6ebb16f..0d685f1c 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx @@ -17,10 +17,11 @@ sidebar_position: 5 "version": "[项目配置版本]", "outputfilename": "[二进制文件的名称]", "debounceMS": 100, // 在检测到资源更改时,开发服务器等待重新加载的时间 - "devserverurl": "[用于服务本地资源的开发服务器URL。默认:http://localhost:34115]" + "devserverurl": "[用于服务本地资源的开发服务器URL。默认:http://localhost:34115]", + "appargs": "[在dev模式下以shell样式传递给应用程序的参数]" } ``` 该文件将在运行`wails build`或`wails dev`时,由 Wails CLI 读取。 -`wails build/dev`命令中的`assetdir`,`wailsjsdir`,`debounceMS`和`devserverurl`标志将覆盖项目配置并作为后续运行的默认值。 +`wails build/dev`命令中的`assetdir`、`wailsjsdir`、`debounceMS`和`devserverurl`标志将覆盖项目配置并作为后续运行的默认值。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx index edd3923a..28e386da 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx @@ -9,4 +9,10 @@ sidebar_position: 1 Go 运行时可通过导入`github.com/wailsapp/wails/v2/pkg/runtime`. 此包中的所有方法都将 context 作为第一个参数。这个 context 可以从[应用启动回调](/docs/reference/options#应用启动回调) 或[前端 Dom 加载完成回调](/docs/reference/options#前端-dom-加载完成回调)回调中获得。 +:::info 笔记 + +虽然上下文将提供给[应用启动回调](/docs/reference/options#应用启动回调)方法,但不能保证运行时将在此方法中工作,因为窗口正在不同的线程中初始化。如果您希望在启动时调用运行时方法,请使用[前端 Dom 加载完成回调](/docs/reference/options#前端-dom-加载完成回调)方法。 + +::: + Javascript 库可通过`window.runtime`提供给前端。使用 dev 模式时会生成一个运行时包,该包为运行时提供 Typescript 声明。这应该位于您的前端目录中的`wailsjs`目录中。