Fix webview creation and update site history

Refactored createTab to properly set webview attributes (id, src, allowpopups, partition, preload) for correct loading and management. Updated site-history.json with recent search and navigation entries.
This commit is contained in:
2025-07-31 22:45:57 +12:00
parent e8dc253f03
commit 90dfe73632
2 changed files with 34 additions and 22 deletions
+29 -22
View File
@@ -90,34 +90,41 @@ function createTab(inputUrl) {
console.log('[DEBUG] createTab() inputUrl =', inputUrl); console.log('[DEBUG] createTab() inputUrl =', inputUrl);
const id = crypto.randomUUID(); const id = crypto.randomUUID();
// Handle home page specially // Handle home page specially
if (inputUrl === 'browser://home') { if (inputUrl === 'browser://home') {
// Show home container and hide webviews // Show home container and hide webviews
const homeContainer = document.getElementById('home-container'); const homeContainer = document.getElementById('home-container');
const webviewsEl = document.getElementById('webviews'); const webviewsEl = document.getElementById('webviews');
if (homeContainer) homeContainer.classList.add('active'); if (homeContainer) homeContainer.classList.add('active');
if (webviewsEl) webviewsEl.classList.add('hidden'); if (webviewsEl) webviewsEl.classList.add('hidden');
const tab = { const tab = {
id, id,
url: inputUrl, url: inputUrl,
title: 'New Tab', title: 'New Tab',
favicon: '', favicon: '',
history: [inputUrl], history: [inputUrl],
historyIndex: 0, historyIndex: 0,
isHome: true isHome: true
}; };
tabs.push(tab); tabs.push(tab);
setActiveTab(id); setActiveTab(id);
// Render the tab bar so the new home tab appears // Render the tab bar so the new home tab appears
renderTabs(); renderTabs();
return id; return id;
} }
// For all other URLs, use webview // For all other URLs, use webview
const resolvedUrl = resolveInternalUrl(inputUrl); const resolvedUrl = resolveInternalUrl(inputUrl);
console.log('[DEBUG] createTab() resolvedUrl =', resolvedUrl); console.log('[DEBUG] createTab() resolvedUrl =', resolvedUrl);
const webview = document.createElement('webview'); const webview = document.createElement('webview');
// give the webview an id and set its source and attributes so it actually loads and can be managed
webview.id = `tab-${id}`;
webview.src = resolvedUrl;
webview.setAttribute('allowpopups', '');
webview.setAttribute('partition', 'persist:default');
webview.setAttribute('preload', '../preload.js');
webview.addEventListener('page-favicon-updated', e => { webview.addEventListener('page-favicon-updated', e => {
if (e.favicons.length > 0) updateTabMetadata(id, 'favicon', e.favicons[0]); if (e.favicons.length > 0) updateTabMetadata(id, 'favicon', e.favicons[0]);
}); });
+5
View File
@@ -1,7 +1,12 @@
[ [
"https://duckduckgo.com/?q=dogs&ia=web",
"https://duckduckgo.com/?q=dogs",
"https://www.bing.com/search?q=dogs",
"https://www.google.com/search?q=cats",
"https://www.youtube.com/", "https://www.youtube.com/",
"https://github.com/", "https://github.com/",
"file:///X:/Projects/Code/NebulaBrowser/renderer/index.html", "file:///X:/Projects/Code/NebulaBrowser/renderer/index.html",
"file:///X:/Projects/Code/NebulaBrowser/renderer/index.html",
"https://youtube.com/", "https://youtube.com/",
"file:///X:/Projects/Code/NebulaBrowser/renderer/index.html", "file:///X:/Projects/Code/NebulaBrowser/renderer/index.html",
"https://youtube.com/", "https://youtube.com/",