5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 10:51:35 +08:00
wails/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx
2021-09-27 19:35:30 +10:00

255 lines
5.4 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.

---
title: 参数选项
sidebar_position: 3
---
# 参数选项
## 应用程序参数选项
该`Options.App`结构包含应用程序配置。它被传递给`wails.Run()`方法:
```go title="Example"
import "github.com/wailsapp/wails/v2/pkg/options"
func main() {
err := wails.Run(&options.App{
Title: "Menus Demo",
Width: 800,
Height: 600,
DisableResize: false,
Fullscreen: false,
Frameless: true,
MinWidth: 400,
MinHeight: 400,
MaxWidth: 1280,
MaxHeight: 1024,
StartHidden: false,
HideWindowOnClose: false,
RGBA: &options.RGBA{R: 0, G: 0, B: 0, A: 255},
Assets: assets,
Menu: app.applicationMenu(),
Logger: nil,
LogLevel: logger.DEBUG,
OnStartup: app.startup,
OnDomReady: app.domready,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
Windows: &windows.Options{
WebviewIsTransparent: false,
WindowIsTranslucent: false,
DisableWindowIcon: false,
},
})
if err != nil {
log.Fatal(err)
}
}
```
### 标题
名称Title
类型string
窗口标题栏中显示的文本。
### 宽度
名称Width
类型int
窗口的初始宽度。默认值1024。
### 高度
名称Height
类型int
窗口的初始高度。默认值768
### 禁用调整窗口尺寸
名称DisableResize
类型bool
默认情况下,主窗口可调整大小。将此设置为 true 将使其保持固定大小。
### 全屏
名称Fullscreen
类型bool
将此设置为 true 将在启动时使窗口全屏。
### 无边框
名称Frameless
类型bool
设置为 时 true窗口将没有边框或标题栏。另请参阅[无边框窗口](/docs/guides/frameless)。
### 最小宽度
名称MinWidth
类型int
这将设置窗口的最小宽度。如果给出的值`Width`小于这个值,窗口将被设置为`MinWidth`默认值。
### 最小高度
名称MinHeight
类型int
这将设置窗口的最小高度。如果给出的值`Height`小于这个值,窗口将被设置为`MinHeight`默认值。
### 最大宽度
名称MaxWidth
类型int
这将设置窗口的最大宽度。如果给出的值`Width`大于这个值,窗口将被设置为`MaxWidth`默认值。
### 最大高度
名称MaxHeight
类型int
这将设置窗口的最大高度。如果给出的值`Height`大于这个值,窗口将被设置为`MaxHeight`默认值。
### 启动时隐藏窗口
名称StartHidden
类型bool
设置为 时`true`,应用程序将被隐藏,直到调用[显示窗口](/docs/reference/runtime/window#显示窗口)。
### 关闭时隐藏窗口
名称HideWindowOnClose
类型bool
默认情况下,关闭窗口将关闭应用程序。将此设置为`true`意味着关闭窗口将隐藏窗口。
### RGBA
名称RGBA
类型int (0xRRGGBBAA) 示例0xFF000088 - 透明度为 50% 的红色
该值是默认设置窗口的 RGBA 值。默认值0xFFFFFFFF。
### 资源
名称Assets
类型:\*embed.FS
应用程序要使用的前端资源。需要一个`index.html`文件。
### 菜单
名称Menu
类型:\*menu.Menu
应用程序要使用的菜单。[菜单参考](/docs/reference/runtime/menu)中有关菜单的更多详细信息。
### 日志
名称Logger
类型logger.Logger 默认值Logger to Stdout
应用程序要使用的记录器。有关日志记录的更多详细信息,请参阅[日志参考](/docs/reference/runtime/log)。
### 日志级别
名称LogLevel
类型logger.LogLevel 默认值Info 在开发模式下Error 在生产模式下
默认日志级别。有关日志记录的更多详细信息,请参阅[设置日志等级](/docs/reference/runtime/log#设置日志等级)。
### 应用启动回调
名称OnStartup
类型func(ctx context.Context)
此回调在前端创建之后调用,但在`index.html`加载之前调用。它给出了应用程序上下文。
### 前端 Dom 加载完成回调
名称OnDomReady
类型func(ctx context.Context)
在前端加载`index.html`完毕并且 DOM 准备就绪后调用此回调。它给出了应用程序上下文。
### 应用退出回调
名称OnShutdown
类型func(ctx context.Context)
在前端被销毁之后,就在应用程序终止之前,调用此回调。它给出了应用程序上下文。
### 绑定
名称Bind
类型: []interface{}
定义需要绑定到前端的方法的一部分结构实例。
### 窗口
名称Windows
类型:\*windows.Options
这定义了[Windows 特定的选项](#windows-特定选项).。
## Windows 特定选项
### 网页透明
名称WebviewIsTransparent
类型bool
将此设置为 true 将使 webview 背景透明,其中没有其他颜色呈现。通常与[窗口半透明](#窗口半透明)结合使用 以制作外观现代的应用程序。
### 窗口半透明
名称WindowIsTranslucent
类型bool
将此设置为 true 将使窗口半透明。通常与[网页透明](#网页透明) 结合使用以制作外观现代的应用程序。
### 禁用窗口图标
名称DisableWindowIcon
类型bool
将此设置为 true 将删除标题栏左上角的图标。