electron/docs/fiddles/features/navigation-history/preload.js
trop[bot] dddcc09185
docs: navigation history example (#43890)
* docs: add fiddle example

Co-authored-by: Alice Zhao <alice@makenotion.com>

* docs: add tutorial guide

Co-authored-by: Alice Zhao <alice@makenotion.com>

* refactor: PR review comments

Co-authored-by: Alice Zhao <alice@makenotion.com>

* refactor: add eof

Co-authored-by: Alice Zhao <alice@makenotion.com>

* refactor: render navigation history and make demo better.

Co-authored-by: Alice Zhao <alice@makenotion.com>

* refactor: fix broken links

Co-authored-by: Alice Zhao <alice@makenotion.com>

* refactor: add eof newline

Co-authored-by: Alice Zhao <alice@makenotion.com>

* docs: review feedback :)

Co-authored-by: Alice Zhao <alice@makenotion.com>

* chore: lint add space around list

Co-authored-by: Alice Zhao <alice@makenotion.com>

* doc: transformURL

Co-authored-by: Alice Zhao <alice@makenotion.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Alice Zhao <alice@makenotion.com>
2024-09-23 11:02:52 -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)
})