From 8a3934097bd8150367379d21bbc856e3417710dd Mon Sep 17 00:00:00 2001 From: WCY-dt <834421194@qq.com> Date: Wed, 28 Jan 2026 21:44:12 +0800 Subject: [PATCH] docs: update README.md to clarify key differences between WebviewWindow and WebviewPanel refactor: improve URL normalization in NewPanel and SetURL methods --- v3/examples/webview-panel/README.md | 2 +- v3/pkg/application/webview_panel.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/v3/examples/webview-panel/README.md b/v3/examples/webview-panel/README.md index c0caf7481..15e571b6d 100644 --- a/v3/examples/webview-panel/README.md +++ b/v3/examples/webview-panel/README.md @@ -176,7 +176,7 @@ panels := window.GetPanels() window.RemovePanel("sidebar") ``` -## Key Differences from Windows +## Key Differences: WebviewWindow vs WebviewPanel | Feature | WebviewWindow | WebviewPanel | |---------|---------------|--------------| diff --git a/v3/pkg/application/webview_panel.go b/v3/pkg/application/webview_panel.go index 848fadd61..1659f5d87 100644 --- a/v3/pkg/application/webview_panel.go +++ b/v3/pkg/application/webview_panel.go @@ -70,7 +70,7 @@ type WebviewPanel struct { } // NewPanel creates a new WebviewPanel with the given options. -// The panel must be associated with a parent window via window.AddPanel(). +// Typically called via window.NewPanel() to associate the panel with a parent window. func NewPanel(options WebviewPanelOptions) *WebviewPanel { id := getNextPanelID() @@ -98,8 +98,9 @@ func NewPanel(options WebviewPanelOptions) *WebviewPanel { // Normalize URL via asset server for local paths if options.URL != "" { - normalizedURL, _ := assetserver.GetStartURL(options.URL) - options.URL = normalizedURL + if normalizedURL, err := assetserver.GetStartURL(options.URL); err == nil && normalizedURL != "" { + options.URL = normalizedURL + } } // Store original bounds for anchor calculations @@ -222,7 +223,10 @@ func (p *WebviewPanel) ZIndex() int { // Local paths (e.g., "/panel.html") are normalized via the asset server. func (p *WebviewPanel) SetURL(url string) *WebviewPanel { // Normalize URL via asset server for local paths - normalizedURL, _ := assetserver.GetStartURL(url) + normalizedURL := url + if normalized, err := assetserver.GetStartURL(url); err == nil && normalized != "" { + normalizedURL = normalized + } p.options.URL = normalizedURL if p.impl != nil && !p.isDestroyed() { InvokeSync(func() {