Member-only story
Electron — Taskbar Widgets
Electron is a framework that lets us create cross-platform desktop apps.
The apps are created by creating web apps that are wrapped with a wrapper.
In this article, we’ll look at the add recent documents menu to an Electron app.
Recent Documents
We can use the app.addRecentDocument
method to create a recent documents menu.
For example, we can write:
const { app, BrowserWindow } = require('electron')function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('index.html')
}app.whenReady().then(createWindow)
app.addRecentDocument('/Users/USERNAME/Desktop/work.type')
in main.js
.
We call the addRecentDocument
method to add a recent document.
Then app.clearRecentDocuments()
method clears the recent documents list.
On Windows, we’ve to register our app by following these Application Registration instructions to register our app.
This way, the recent document items would appear on the list.