Browse Source

Ajout creation nouvelle note

Arthur Brandao 5 năm trước cách đây
mục cha
commit
0b2984a519
2 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 3 2
      app/main/application-menu.js
  2. 7 0
      app/render/event.js

+ 3 - 2
app/main/application-menu.js

@@ -1,4 +1,4 @@
-const {Menu, ipcMain, shell} = require('electron')
+const {Menu, shell} = require('electron')
 const demo = require('./function/demo-application-menu');
 
 let template = [
@@ -7,8 +7,9 @@ let template = [
     submenu: [
       {
         label: 'Nouveau',
+        accelerator: 'CmdOrCtrl+N',
         click: () => {
-          console.log('Reset');
+          mainWindow.webContents.send('new-note');
         }
       },
       {

+ 7 - 0
app/render/event.js

@@ -2,4 +2,11 @@ const { ipcRenderer } = require('electron');
 
 ipcRenderer.on('reset-app', (event, arg) => {
     document.location = 'reset.html';
+});
+
+ipcRenderer.on('new-note', (event, arg) => {
+    const current = document.location.pathname.split('/').pop();
+    if (current !== 'edit.html' || (document.location.search.trim() !== '' && current === 'edit.html')) {
+        document.location = 'edit.html';
+    }
 });