diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index da1302e13..381b96088 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -280,6 +280,9 @@ func (f *Frontend) Quit() { func (f *Frontend) setupChromium() { chromium := edge.NewChromium() f.chromium = chromium + if opts := f.frontendOptions.Windows; opts != nil && opts.WebviewUserDataPath != "" { + chromium.DataPath = opts.WebviewUserDataPath + } chromium.MessageCallback = f.processMessage chromium.WebResourceRequestedCallback = f.processRequest chromium.NavigationCompletedCallback = f.navigationCompleted diff --git a/v2/pkg/options/windows/windows.go b/v2/pkg/options/windows/windows.go index 4dc92cfee..af2b2d7ad 100644 --- a/v2/pkg/options/windows/windows.go +++ b/v2/pkg/options/windows/windows.go @@ -8,4 +8,8 @@ type Options struct { // Draw a border around the window, even if the window is frameless EnableFramelessBorder 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 } diff --git a/website/docs/reference/options.mdx b/website/docs/reference/options.mdx index 57ce5065b..0bb60a260 100644 --- a/website/docs/reference/options.mdx +++ b/website/docs/reference/options.mdx @@ -46,6 +46,7 @@ func main() { WindowIsTranslucent: false, DisableWindowIcon: false, EnableFramelessBorder: false, + WebviewUserDataPath: "", }, Mac: &mac.Options{ TitleBar: &mac.TitleBar{ @@ -363,6 +364,14 @@ Type: bool Setting this to `true` will add a border around the window if [Frameless](#Frameless) has been activated. This allows hiding the title bar but still having a border around the window. +### WebviewUserDataPath + +Name: WebviewUserDataPath + +Type: string + +This defines the path where the WebView2 stores the user data. If empty `%APPDATA%\[BinaryName.exe]` will be used. + ## Mac Specific Options ### TitleBar