跳到主要内容
版本: v2.9.0

窗口

这些方法可以控制应用程序窗口。

WindowSetTitle

设置窗口标题栏中的文本。

Go: WindowSetTitle(ctx context.Context, title string)
JS: WindowSetTitle(title: string)

WindowFullscreen

使窗口全屏显示。

Go: WindowFullscreen(ctx context.Context)
JS: WindowFullscreen()

WindowUnfullscreen

恢复全屏显示之前的窗口尺寸和位置。

Go: WindowUnfullscreen(ctx context.Context)
JS: WindowUnfullscreen()

WindowIsFullscreen

如果窗口处于全屏显示状态,则返回 true。

Go: WindowIsFullscreen(ctx context.Context) bool
JS: WindowIsFullscreen() Promise<boolean>

WindowCenter

将窗口居中于窗口当前所在的显示器。

Go: WindowCenter(ctx context.Context)
JS: WindowCenter()

WindowExecJS

在窗口中执行任意的 JS 代码。

此方法会异步在浏览器中运行代码并立即返回。如果脚本引发任何错误,它们只会出现在浏览器控制台中。

Go: WindowExecJS(ctx context.Context, js string)

WindowReload

执行“重新加载”(重新加载当前页面)。

Go: WindowReload(ctx context.Context)
JS: WindowReload()

WindowReloadApp

重新加载应用程序前端。

Go: WindowReloadApp(ctx context.Context)
JS: WindowReloadApp()

WindowSetSystemDefaultTheme

仅限 Windows。

Go: WindowSetSystemDefaultTheme(ctx context.Context)
JS: WindowSetSystemDefaultTheme()

将窗口主题设置为系统默认主题(深色/浅色)。

WindowSetLightTheme

仅限 Windows。

Go: WindowSetLightTheme(ctx context.Context)
JS: WindowSetLightTheme()

将窗口主题设置为浅色。

WindowSetDarkTheme

仅限 Windows。

Go: WindowSetDarkTheme(ctx context.Context)
JS: WindowSetDarkTheme()

将窗口主题设置为深色。

WindowShow

显示窗口,如果它当前处于隐藏状态。

Go: WindowShow(ctx context.Context)
JS: WindowShow()

WindowHide

隐藏窗口,如果它当前处于显示状态。

Go: WindowHide(ctx context.Context)
JS: WindowHide()

WindowIsNormal

如果窗口没有最小化、最大化或全屏显示,则返回 true。

Go: WindowIsNormal(ctx context.Context) bool
JS: WindowIsNormal() Promise<boolean>

WindowSetSize

设置窗口的宽度和高度。

Go: WindowSetSize(ctx context.Context, width int, height int)
JS: WindowSetSize(width: number, height: number)

WindowGetSize

获取窗口的宽度和高度。

Go: WindowGetSize(ctx context.Context) (width int, height int)
JS: WindowGetSize(): Promise<Size>

WindowSetMinSize

设置最小窗口大小。如果窗口当前小于给定的尺寸,则会调整窗口大小。

设置大小为0,0将禁用此限制。

Go: WindowSetMinSize(ctx context.Context, width int, height int)
JS: WindowSetMinSize(width: number, height: number)

WindowSetMaxSize

设置最大窗口大小。如果窗口当前大于给定的尺寸,则会调整窗口大小。

设置大小为0,0将禁用此限制。

Go: WindowSetMaxSize(ctx context.Context, width int, height int)
JS: WindowSetMaxSize(width: number, height: number)

WindowSetAlwaysOnTop

设置窗口始终置顶或不置顶。

Go: WindowSetAlwaysOnTop(ctx context.Context, b bool)
JS: WindowSetAlwaysOnTop(b: boolean)

WindowSetPosition

设置窗口相对于窗口当前所在的显示器的位置。

Go: WindowSetPosition(ctx context.Context, x int, y int)
JS: WindowSetPosition(x: number, y: number)

WindowGetPosition

获取窗口相对于窗口当前所在的显示器的位置。

Go: WindowGetPosition(ctx context.Context) (x int, y int)
JS: WindowGetPosition(): Promise<Position>

WindowMaximise

将窗口最大化以填充屏幕。

Go: WindowMaximise(ctx context.Context)
JS: WindowMaximise()

WindowUnmaximise

将窗口恢复到最大化之前的尺寸和位置。

Go: WindowUnmaximise(ctx context.Context)
JS: WindowUnmaximise()

WindowIsMaximised

如果窗口处于最大化状态,则返回 true。

Go: WindowIsMaximised(ctx context.Context) bool
JS: WindowIsMaximised() Promise<boolean>

WindowToggleMaximise

在最大化和取消最大化之间切换。

Go: WindowToggleMaximise(ctx context.Context)
JS: WindowToggleMaximise()

WindowMinimise

最小化窗口。

Go: WindowMinimise(ctx context.Context)
JS: WindowMinimise()

WindowUnminimise

将窗口恢复到最小化之前的尺寸和位置。

Go: WindowUnminimise(ctx context.Context)
JS: WindowUnminimise()

WindowIsMinimised

如果窗口处于最小化状态,则返回 true。

Go: WindowIsMinimised(ctx context.Context) bool
JS: WindowIsMinimised() Promise<boolean>

WindowSetBackgroundColour

将窗口的背景颜色设置为给定的 RGBA 颜色定义。此颜色将显示所有透明像素。

R、G、B 和 A 的有效值为 0-255。

Windows

在 Windows 上,仅支持 0 或 255 的 alpha 值。任何不为 0 的值都将被视为 255。

Go: WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)
JS: WindowSetBackgroundColour(R, G, B, A)

WindowPrint

打开本机打印对话框。

Go: WindowPrint(ctx context.Context)
JS: WindowPrint()

TypeScript 对象定义

Position

interface Position {
x: number;
y: number;
}

Size

interface Size {
w: number;
h: number;
}