Improve theme and navigation IPC between pages
Enhanced inter-process communication for theme updates and navigation between home, settings, and main browser pages. Theme changes in settings now propagate to home via Electron IPC and postMessage fallback. Navigation requests from home and other webviews are handled more robustly, supporting both Electron IPC and postMessage. Also refactored tab creation and improved event handling for better reliability.
This commit is contained in:
+16
-2
@@ -87,11 +87,16 @@ function renderBookmarks() {
|
||||
|
||||
// Navigate via IPC to host page
|
||||
box.onclick = () => {
|
||||
const url = b.url;
|
||||
if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
||||
window.electronAPI.sendToHost('navigate', b.url);
|
||||
window.electronAPI.sendToHost('navigate', url);
|
||||
} else {
|
||||
console.error('Unable to send navigation IPC to host');
|
||||
}
|
||||
// Fallback: post message to embedding page
|
||||
if (window.parent && typeof window.parent.postMessage === 'function') {
|
||||
window.parent.postMessage({ type: 'navigate', url }, '*');
|
||||
}
|
||||
};
|
||||
|
||||
box.appendChild(label);
|
||||
@@ -205,7 +210,16 @@ searchBtn.addEventListener('click', () => {
|
||||
const searchEngineUrl = searchEngines[selectedSearchEngine];
|
||||
target = `${searchEngineUrl}${encodeURIComponent(input)}`;
|
||||
}
|
||||
window.location.href = target;
|
||||
// Always send navigation request to host
|
||||
if (window.electronAPI && typeof window.electronAPI.sendToHost === 'function') {
|
||||
window.electronAPI.sendToHost('navigate', target);
|
||||
return;
|
||||
}
|
||||
// Fallback: post message to embedding page
|
||||
if (window.parent && typeof window.parent.postMessage === 'function') {
|
||||
window.parent.postMessage({ type: 'navigate', url: target }, '*');
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
searchInput.addEventListener('keydown', e => {
|
||||
|
||||
Reference in New Issue
Block a user