35 lines
712 B
JavaScript
35 lines
712 B
JavaScript
|
const { app, BrowserWindow } = require('electron')
|
||
|
const fs = require('fs')
|
||
|
const path = require('path')
|
||
|
|
||
|
function createWindow () {
|
||
|
const win = new BrowserWindow({
|
||
|
width: 800,
|
||
|
height: 600,
|
||
|
webPreferences: {
|
||
|
nodeIntegration: true
|
||
|
}
|
||
|
})
|
||
|
|
||
|
win.loadFile('index.html')
|
||
|
}
|
||
|
const fileName = 'recently-used.md'
|
||
|
fs.writeFile(fileName, 'Lorem Ipsum', () => {
|
||
|
app.addRecentDocument(path.join(process.cwd(), `${fileName}`))
|
||
|
})
|
||
|
|
||
|
app.whenReady().then(createWindow)
|
||
|
|
||
|
app.on('window-all-closed', () => {
|
||
|
app.clearRecentDocuments()
|
||
|
if (process.platform !== 'darwin') {
|
||
|
app.quit()
|
||
|
}
|
||
|
})
|
||
|
|
||
|
app.on('activate', () => {
|
||
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||
|
createWindow()
|
||
|
}
|
||
|
})
|