(Электрон JS) Как создать простую аутентификацию при входе в систему в настольном приложении - PullRequest
1 голос
/ 08 марта 2020

Я видел несколько видео в Интернете, но я все еще не понимаю, как создать систему входа в систему.

Как вы делаете это? Просто простой, который проверяет, правильно ли введено имя пользователя и пароль ввода, и если это так, то он просто меняет html, загруженный в данный момент, на другой.

<body><div id="loginBox">
        <div id="logHeader">
            WELCOME!
        </div>
        <form>
        <input type="text" id="userN" class="logInput" placeholder="Username" maxlength="24"/>
        <input type="password" id="passW" class="logInput" placeholder="Password" maxlength="40"/>
        <input type="submit" id="sub" value="Log In" onclick="validate()"/>
        </form>
    </div>
    <script>
        function validate(){
            var username = document.getElementById("userN").value;
            var password = document.getElementById("passW").value;
            if ( username == "Louis" && password == "01"){
                win.loadfile("pass.html")
                return false;
                }
        }
    </script></body>

Мой javascript файл просто basi c:

const { app, BrowserWindow } = require('electron')

function createWindow () {
  // Create the browser window.
  const win = new BrowserWindow({
    width: 400,
    height: 490,
    resizable: false,

    webPreferences: {
      nodeIntegration: true
    }
  })

  // and load the index.html of the app.
  win.loadFile('index.html')
  win.setMenu(null)

}

// 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)

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // 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()
  }
})

app.on('activate', () => {
  // 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()
  }
})
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...