5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-07 00:51:49 +08:00

Add some more API docs. Small refactors.

This commit is contained in:
Lea Anthony 2023-09-24 17:23:24 +10:00
parent 31c167b412
commit fb820bcdad
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
7 changed files with 95 additions and 49 deletions

View File

@ -312,3 +312,19 @@ This is a brief summary of the exported methods in the provided `App` struct. Do
../v3/pkg/application/options_application.go
--8<--
```
### Windows Options
```go title="application_options_windows.go"
--8<--
../v3/pkg/application/options_application_win.go
--8<--
```
### Mac Options
```go title="options_application_mac.go"
--8<--
../v3/pkg/application/options_application_mac.go
--8<--
```

View File

@ -19,6 +19,12 @@ func main() {
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
Windows: application.WindowsOptions{
WndProcInterceptor: nil,
DisableQuitOnLastWindowClosed: false,
WebviewUserDataPath: "",
WebviewBrowserPath: "",
},
Assets: application.AssetOptions{
FS: assets,
},

View File

@ -20,7 +20,7 @@ type Options struct {
Mac MacOptions
// Windows is the Windows specific configuration for Windows builds
Windows WindowsApplicationOptions
Windows WindowsOptions
// Bind allows you to bind Go methods to the frontend.
Bind []any

View File

@ -0,0 +1,22 @@
package application
// ActivationPolicy is the activation policy for the application.
type ActivationPolicy int
const (
// ActivationPolicyRegular is used for applications that have a user interface,
ActivationPolicyRegular ActivationPolicy = iota
// ActivationPolicyAccessory is used for applications that do not have a main window,
// such as system tray applications or background applications.
ActivationPolicyAccessory
ActivationPolicyProhibited
)
// MacOptions contains options for macOS applications.
type MacOptions struct {
// ActivationPolicy is the activation policy for the application. Defaults to
// applicationActivationPolicyRegular.
ActivationPolicy ActivationPolicy
// If set to true, the application will terminate when the last window is closed.
ApplicationShouldTerminateAfterLastWindowClosed bool
}

View File

@ -0,0 +1,21 @@
package application
// WindowsOptions contains options for Windows applications.
type WindowsOptions struct {
// WndProcInterceptor is a function that will be called for every message sent in the application.
// Use this to hook into the main message loop. This is useful for handling custom window messages.
// If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop.
// If `shouldReturn` is `false` then returnCode will be ignored and the message will be processed by the main message loop.
WndProcInterceptor func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnCode uintptr, shouldReturn bool)
// DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed.
DisableQuitOnLastWindowClosed bool
// Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used.
// If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code.
WebviewUserDataPath string
// Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used.
WebviewBrowserPath string
}

View File

@ -2,32 +2,19 @@ package application
import "github.com/wailsapp/wails/v3/pkg/events"
type ActivationPolicy int
const (
ActivationPolicyRegular ActivationPolicy = iota
// ActivationPolicyAccessory is used for applications that do not have a main window,
// such as system tray applications or background applications.
ActivationPolicyAccessory
ActivationPolicyProhibited
)
type MacOptions struct {
// ActivationPolicy is the activation policy for the application. Defaults to
// applicationActivationPolicyRegular.
ActivationPolicy ActivationPolicy
// If set to true, the application will terminate when the last window is closed.
ApplicationShouldTerminateAfterLastWindowClosed bool
}
// MacBackdrop is the backdrop type for macOS
type MacBackdrop int
const (
// MacBackdropNormal - The default value. The window will have a normal opaque background.
MacBackdropNormal MacBackdrop = iota
// MacBackdropTransparent - The window will have a transparent background, with the content underneath it being visible
MacBackdropTransparent
// MacBackdropTranslucent - The window will have a translucent background, with the content underneath it being "fuzzy" or "frosted"
MacBackdropTranslucent
)
// MacToolbarStyle is the style of toolbar for macOS
type MacToolbarStyle int
const (
@ -43,14 +30,19 @@ const (
MacToolbarStyleUnifiedCompact
)
// MacWindow contains macOS specific options
// MacWindow contains macOS specific options for Webview Windows
type MacWindow struct {
// Backdrop is the backdrop type for the window
Backdrop MacBackdrop
// DisableShadow will disable the window shadow
DisableShadow bool
// TitleBar contains options for the Mac titlebar
TitleBar MacTitleBar
// Appearance is the appearance type for the window
Appearance MacAppearanceType
// InvisibleTitleBarHeight defines the height of an invisible titlebar which responds to dragging
InvisibleTitleBarHeight int
// Maps events from platform specific to the event name
// Maps events from platform specific to common event types
EventMapping map[events.WindowEventType]events.WindowEventType
// EnableFraudulentWebsiteWarnings will enable warnings for fraudulent websites.
@ -60,12 +52,19 @@ type MacWindow struct {
// MacTitleBar contains options for the Mac titlebar
type MacTitleBar struct {
// AppearsTransparent will make the titlebar transparent
AppearsTransparent bool
// Hide will hide the titlebar
Hide bool
// HideTitle will hide the title
HideTitle bool
// FullSizeContent will extend the window content to the full size of the window
FullSizeContent bool
// UseToolbar will use a toolbar instead of a titlebar
UseToolbar bool
// HideToolbarSeparator will hide the toolbar separator
HideToolbarSeparator bool
// ToolbarStyle is the style of toolbar to use
ToolbarStyle MacToolbarStyle
}

View File

@ -2,24 +2,6 @@ package application
import "github.com/wailsapp/wails/v3/pkg/events"
type WindowsApplicationOptions struct {
// WndProcInterceptor is a function that will be called for every message sent in the application.
// Use this to hook into the main message loop. This is useful for handling custom window messages.
// If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop.
// If `shouldReturn` is `false` then returnCode will be ignored and the message will be processed by the main message loop.
WndProcInterceptor func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnCode uintptr, shouldReturn bool)
// DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed.
DisableQuitOnLastWindowClosed bool
// Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used.
// If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code.
WebviewUserDataPath string
// Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used.
WebviewBrowserPath string
}
type BackdropType int32
const (