diff --git a/src/index.js b/src/index.js index 4c8c84f..3711155 100644 --- a/src/index.js +++ b/src/index.js @@ -40,6 +40,10 @@ let menu_template = [ accelerator: "Ctrl+O", click: openFile }, + { + label: "Open Recent", + submenu:[] + }, { label: "Exit", click: function () { @@ -193,7 +197,7 @@ ipcMain.on("save", (event, data, new_file) => { }) ipcMain.on("loadFile", (event, file_name) => { - loadFile(); + loadFile(file_name); }) ipcMain.on("newFile", (event) => { @@ -230,6 +234,21 @@ const createWindow = () => { } }); + let recent_files = store.get("recent_files"); + for (let menu of menu_template[0].submenu) { + if (menu.label == "Open Recent") { + for (let file of recent_files) { + if (fs.existsSync(file)) { + menu.submenu.push({ + label: file, click: () => { + mainWindow.webContents.send("open", file); + } + }) + } + } + } + } + let menu = Menu.buildFromTemplate(menu_template); Menu.setApplicationMenu(menu); diff --git a/src/js/script.js b/src/js/script.js index 7233a8c..c961924 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -618,7 +618,6 @@ async function updateRecentFiles(new_file) { let recent_files = await ipcRenderer.invoke("getStoreValue", "recent_files"); if (recent_files.includes(new_file)) { recent_files.splice(recent_files.indexOf(new_file), 1); - // delete recent_files[recent_files.indexOf(new_file)]; } recent_files.splice(0, 0, new_file); ipcRenderer.invoke("setStoreValue", "recent_files", recent_files); diff --git a/src/splash.html b/src/splash.html index b45780b..8904b34 100644 --- a/src/splash.html +++ b/src/splash.html @@ -14,7 +14,7 @@
-