Electron: Как открыть новое окно BrowserWindow новых размеров одним нажатием кнопки? - PullRequest
0 голосов
/ 28 мая 2020

Моя кнопка открывает окно, только если введенные пользователем данные верны.

В моем файле rendererlogin. js файл У меня есть это:

var firebaseConfig = {
    apiKey: "____",
    authDomain: "____",
    databaseURL: "____",
    projectId: "____",
    storageBucket: "____",
    messagingSenderId: "____",
    appId: "____",
    measurementId: "____"
  };
  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);




    var blogin = document.getElementById('blogin');



    blogin.addEventListener('click',function(){
      var loginpass = document.getElementById('pass').value;
      var loginemail = document.getElementById('email').value;

      firebase.auth().signInWithEmailAndPassword(loginemail,loginpass)
      .catch(function(error){
        if(error != null){
            if(error.code === 'auth/wrong-password'){
                alert('Incorrect Password');
                document.getElementById('pass').value = '';
            } else if(error.code === 'auth/too-many-requests'){
                alert('Too many unsuccessful attempts. Try again later.')
                document.getElementById('email').value = '';
                document.getElementById('pass').value = '';
            } else if(error.code === 'auth/user-not-found'){
                document.getElementById('emailinvalid').textContent = "⚠ User does not exist"
                document.getElementById('email').style.borderColor = 'red';
                document.getElementById('email').style.borderWidth = '1px';
            }
            console.log(error.message);
            console.log(error.code);
            return;
        }
      })
    }, false)

В моем main. js файл У меня есть это:

// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
const path = require('path')

function createWindow () {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 550,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: true
    }
  })
  // and load the index.html of the app.
  mainWindow.loadFile('./dis/index.html')




  // Open the DevTools.
  // mainWindow.webContents.openDevTools()
}

const mainMainWindow = new BrowserWindow({
  width: 100,
  height: 100,
  webPreferences: {
    preload: path.join(__dirname, 'preload.js'),
    nodeIntegration: true
  }
})


// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
  createWindow()

  app.on('activate', function () {
    // On macOS it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
})




// Quit when all windows are closed.
app.on('window-all-closed', function () {
  // On macOS it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') app.quit()
})

В моей предварительной загрузке. js файл:

// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
  const replaceText = (selector, text) => {
    const element = document.getElementById(selector)
    if (element) element.innerText = text
  }

  for (const type of ['chrome', 'node', 'electron']) {
    replaceText(`${type}-version`, process.versions[type])
  }
})

Я пробовал использовать require ('electronic'). Remote, однако он всегда говорит, что 'require' не определен.

Я также пробовал использовать window.open (mainMainWindow), однако тогда я не могу закрыть предыдущее окно входа в систему.

Как я могу выполнить sh это?

...