5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 00:59:34 +08:00

Merge pull request #1105 from stffabi/feature/webview2-datapath

[v2, windows] Add WebviewUserDataPath to windows options
This commit is contained in:
Lea Anthony 2022-01-26 08:18:04 +11:00 committed by GitHub
commit 5c24f8bf83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 3 deletions

View File

@ -22,7 +22,7 @@ require (
github.com/leaanthony/debme v1.2.1
github.com/leaanthony/go-ansi-parser v1.0.1
github.com/leaanthony/go-common-file-dialog v1.0.3
github.com/leaanthony/go-webview2 v1.0.2
github.com/leaanthony/go-webview2 v1.0.3-0.20220125181555-00f20a61c17d
github.com/leaanthony/gosod v1.0.3
github.com/leaanthony/idgen v1.0.0
github.com/leaanthony/slicer v1.5.0

View File

@ -118,8 +118,8 @@ github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQ
github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM=
github.com/leaanthony/go-common-file-dialog v1.0.3 h1:O0uGjKnWtdEADGrkg+TyAAbZylykMwwx/MNEXn9fp+Y=
github.com/leaanthony/go-common-file-dialog v1.0.3/go.mod h1:TGhEc9eSJgRsupZ+iH1ZgAOnEo9zp05cRH2j08RPrF0=
github.com/leaanthony/go-webview2 v1.0.2 h1:IjTbpAXUig33G3LUqf+8EClZutg2Z/C1cbxqhHKPxbU=
github.com/leaanthony/go-webview2 v1.0.2/go.mod h1:iX54IaVk1FnDqMuHJ47VYLPQOcVqQiOe9SJACt9CAbU=
github.com/leaanthony/go-webview2 v1.0.3-0.20220125181555-00f20a61c17d h1:xJZ3wwHc0BgvXz3NL2PUMGa3Ee4jPuTFeK/N7LDnV74=
github.com/leaanthony/go-webview2 v1.0.3-0.20220125181555-00f20a61c17d/go.mod h1:iX54IaVk1FnDqMuHJ47VYLPQOcVqQiOe9SJACt9CAbU=
github.com/leaanthony/gosod v1.0.3 h1:Fnt+/B6NjQOVuCWOKYRREZnjGyvg+mEhd1nkkA04aTQ=
github.com/leaanthony/gosod v1.0.3/go.mod h1:BJ2J+oHsQIyIQpnLPjnqFGTMnOZXDbvWtRCSG7jGxs4=
github.com/leaanthony/idgen v1.0.0 h1:IZreR+JGEzFV4yeVuBZA25gM0keUoFy+RDUldncQ+Jw=

View File

@ -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

View File

@ -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
}

View File

@ -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