Задать вопрос
Ответы пользователя по тегу Node.js
  • Можно ли использовать Nodejs во Vue при написании программы на Electron?

    wickinats
    @wickinats Автор вопроса
    // test.vue
    
    const crypto = require('crypto');
    
      export default {
        methods: {
          test() {
            const secret = 'abcdefg';
            const hash = crypto.createHmac('sha256', secret)
                               .update('I love cupcakes')
                               .digest('hex');
            console.log(hash);
          }
        }
      }


    // electron.js
    
    const { app, BrowserWindow } = require("electron");
    
    function createWindow () {
      const win = new BrowserWindow({
        width: 1200,
        height: 600,
        webPreferences: {
          nodeIntegration: true
        }
      })
    
      win.setMenu(null);
      win.loadFile('./dist/index.html');
    }
    
    app.whenReady().then(createWindow)
    app.on('window-all-closed', () => {
      if (process.platform !== 'darwin') {
        app.quit()
      }
    })
    
    app.on('activate', () => {
      if (BrowserWindow.getAllWindows().length === 0) {
        createWindow()
      }
    })
    Ответ написан
    Комментировать