docs: update README.md to clarify key differences between WebviewWindow and WebviewPanel

refactor: improve URL normalization in NewPanel and SetURL methods
This commit is contained in:
WCY-dt 2026-01-28 21:44:12 +08:00
commit 8a3934097b
2 changed files with 9 additions and 5 deletions

View file

@ -176,7 +176,7 @@ panels := window.GetPanels()
window.RemovePanel("sidebar")
```
## Key Differences from Windows
## Key Differences: WebviewWindow vs WebviewPanel
| Feature | WebviewWindow | WebviewPanel |
|---------|---------------|--------------|

View file

@ -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() {