mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-18 18:09:30 +08:00
221 lines
4.8 KiB
Plaintext
221 lines
4.8 KiB
Plaintext
---
|
||
sidebar_position: 4
|
||
---
|
||
|
||
# 窗口
|
||
|
||
## 概述
|
||
|
||
这些方法可以控制应用程序窗口。
|
||
|
||
### 窗口标题
|
||
Go 方法签名: `WindowSetTitle(ctx context.Context, title string)`
|
||
|
||
JS 方法签名: `WindowSetTitle(title: string)`
|
||
|
||
设置窗口标题栏中的文本。
|
||
|
||
### 窗口全屏
|
||
Go 方法签名: `WindowFullscreen(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowFullscreen()`
|
||
|
||
使窗口全屏。
|
||
|
||
### 窗口取消全屏
|
||
Go 方法签名: `WindowUnfullscreen(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowUnfullscreen()`
|
||
|
||
在全屏之前恢复先前的窗口尺寸和位置。
|
||
|
||
### 窗口居中
|
||
Go 方法签名: `WindowCenter(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowCenter()`
|
||
|
||
使窗口在当前窗口所在的监视器上居中。
|
||
|
||
### 窗口重新加载
|
||
Go 方法签名: `WindowReload(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowReload()`
|
||
|
||
执行“重新加载”(重新加载 index.html)
|
||
|
||
### 窗口设置系统默认主题
|
||
Go 方法签名: `WindowSetSystemDefaultTheme(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowSetSystemDefaultTheme()`
|
||
|
||
仅限 Windows。
|
||
|
||
### 窗口设置浅色主题
|
||
|
||
### 窗口设置深色主题
|
||
将窗口主题设置为系统默认值(浅色/深色)。
|
||
|
||
Go 方法签名: `WindowSetLightTheme(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowSetLightTheme()`
|
||
|
||
仅限 Windows。
|
||
|
||
### 显示窗口
|
||
设置窗口主题为浅色 。
|
||
|
||
Go 方法签名: `WindowSetDarkTheme(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowSetLightTheme()`
|
||
|
||
仅限 Windows。
|
||
|
||
### 隐藏窗口
|
||
设置窗口主题为深色。
|
||
|
||
Go 方法签名: `WindowShow(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowSetLightTheme()`
|
||
|
||
如果窗口当前处于隐藏状态,则显示该窗口。
|
||
|
||
### 设置窗口尺寸
|
||
Go 方法签名: `WindowHide(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowHide()`
|
||
|
||
隐藏窗口(如果当前可见)。
|
||
|
||
### 获取窗口尺寸
|
||
Go 方法签名: `WindowSetSize(ctx context.Context, width int, height int)`
|
||
|
||
JS 方法签名: `WindowSetSize(size: Size)`
|
||
|
||
设置窗口的宽度和高度。
|
||
|
||
### 设置窗口最小尺寸
|
||
Go 方法签名: `WindowGetSize(ctx context.Context) (width int, height int)`
|
||
|
||
JS 方法签名: `WindowGetSize() : Size`
|
||
|
||
获取窗口的宽度和高度。
|
||
|
||
### 设置窗口最大尺寸
|
||
Go 方法签名: `WindowSetMinSize(ctx context.Context, width int, height int)`
|
||
|
||
JS 方法签名: `WindowSetMinSize(size: Size)`
|
||
|
||
Gets the width and height of the window.
|
||
|
||
### 设置窗口位置
|
||
将大小设置为 `0,0` 将禁用此约束。
|
||
|
||
Go 方法签名: `WindowSetMaxSize(ctx context.Context, width int, height int)`
|
||
|
||
设置最小窗口大小。 如果窗口当前小于给定尺寸,将调整窗口大小。
|
||
|
||
Setting a size of `0,0` will disable this constraint.
|
||
|
||
### 获取窗口位置
|
||
将大小设置为 `0,0` 将禁用此约束。
|
||
|
||
Go 方法签名: `WindowSetPosition(ctx context.Context, x int, y int)`
|
||
|
||
设置最大窗口大小。 如果窗口当前大于给定尺寸,将调整窗口大小。
|
||
|
||
Setting a size of `0,0` will disable this constraint.
|
||
|
||
### 窗口最大化
|
||
Go 方法签名: `WindowGetPosition(ctx context.Context) (x int, y int)`
|
||
|
||
JS 方法签名: `WindowGetPosition() : Position`
|
||
|
||
获取相对于窗口当前所在显示器的窗口位置。
|
||
|
||
|
||
### 窗口取消最大化
|
||
Go 方法签名: `WindowMaximise(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowMaximise()`
|
||
|
||
最大化窗口以填满屏幕。
|
||
|
||
### 窗口最大化切换
|
||
Go 方法签名: `WindowUnmaximise(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowUnmaximise()`
|
||
|
||
将窗口恢复到最大化之前的尺寸和位置。
|
||
|
||
### 窗口最小化
|
||
Go 方法签名: `WindowToggleMaximise(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowToggleMaximise()`
|
||
|
||
在最大化和最大化之间切换。
|
||
|
||
### 窗口取消最小化
|
||
Go 方法签名: `WindowMinimise(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowMinimise()`
|
||
|
||
最小化窗口。
|
||
|
||
### 窗口设置 RGBA
|
||
Go 方法签名: `WindowUnminimise(ctx context.Context)`
|
||
|
||
JS 方法签名: `WindowUnminimise()`
|
||
|
||
将窗口恢复到最小化之前的尺寸和位置。
|
||
|
||
### 位置
|
||
Go 方法签名: `WindowSetRGBA(ctx context.Context, R, G, B, A uint8)`
|
||
|
||
JS 方法签名: `WindowSetRGBA(R, G, B, A)`
|
||
|
||
窗口
|
||
|
||
### 尺寸
|
||
R、G、B 和 A 的有效值为 0-255。
|
||
|
||
JS 方法签名: `WindowSetMaxSize(size: Size)`
|
||
|
||
Restores the window to the dimensions and position prior to minimising.
|
||
|
||
### WindowSetBackgroundColour
|
||
Go Signature: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`
|
||
|
||
JS 方法签名: `WindowSetPosition(position: Position)`
|
||
|
||
将窗口的背景颜色设置为给定的 RGBA 颜色定义。 此颜色将显示所有透明像素。
|
||
|
||
Valid values for R, G, B and A are 0-255.
|
||
|
||
:::info Windows
|
||
|
||
在 Windows 上,仅支持 0 或 255 的 alpha 值。 任何不为 0 的值都将被视为 255。
|
||
|
||
:::
|
||
|
||
## Typescript 对象定义
|
||
|
||
### Position
|
||
|
||
```ts
|
||
interface Position {
|
||
x: number;
|
||
y: number;
|
||
}
|
||
```
|
||
|
||
### Size
|
||
|
||
```ts
|
||
interface Size {
|
||
w: number;
|
||
h: number;
|
||
}
|
||
```
|
||
|
||
|