electron/docs/fiddles/features/navigation-history/preload.js
Alice Zhao ceea1225a2
docs: navigation history example (#42980)
* docs: add fiddle example

* docs: add tutorial guide

* refactor: PR review comments

* refactor: add eof

* refactor: render navigation history and make demo better.

* refactor: fix broken links

* refactor: add eof newline

* docs: review feedback :)

* chore: lint add space around list

* doc: transformURL
2024-09-23 10:18:26 -07:00

12 lines
590 B
JavaScript

const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('electronAPI', {
goBack: () => ipcRenderer.invoke('nav:back'),
goForward: () => ipcRenderer.invoke('nav:forward'),
canGoBack: () => ipcRenderer.invoke('nav:canGoBack'),
canGoForward: () => ipcRenderer.invoke('nav:canGoForward'),
loadURL: (url) => ipcRenderer.invoke('nav:loadURL', url),
getCurrentURL: () => ipcRenderer.invoke('nav:getCurrentURL'),
getHistory: () => ipcRenderer.invoke('nav:getHistory'),
onNavigationUpdate: (callback) => ipcRenderer.on('nav:updated', callback)
})