* Port recent-documents fiddle to 12-x-y. * Update recent-documents tutorial. * update for review comments Co-authored-by: Ethan Arrowood <ethan.arrowood@gmail.com>
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			647 B
			
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			647 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
 | 
						|
  })
 | 
						|
 | 
						|
  win.loadFile('index.html')
 | 
						|
}
 | 
						|
 | 
						|
const fileName = 'recently-used.md'
 | 
						|
fs.writeFile(fileName, 'Lorem Ipsum', () => {
 | 
						|
  app.addRecentDocument(path.join(__dirname, 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()
 | 
						|
  }
 | 
						|
})
 |