Gần đây tôi đã bắt đầu làm ướt chân bằng Electron. Tôi thực sự thích các nguyên tắc đằng sau nó nhưng tôi thấy nó hơi khó hiểu để làm một số thứ.Điện tử - Đầu vào xử lý
Ví dụ: cách bạn xử lý dữ liệu nhập của người dùng? Tôi đã có một main.js và một BrowserWindow trỏ đến một tệp html cục bộ (có chứa một số thiết lập người dùng với trường đầu vào).
Làm cách nào để truy cập dữ liệu này khi biểu mẫu HTML được gửi (cho cùng một tệp hoặc tệp khác)?
main.js
const {app, BrowserWindow} = require('electron')
let win
function createWindow() {
win = new BrowserWindow({width: 800, height: 600})
win.loadURL('file://' + __dirname + '/index.html')
// Emitted when the window is closed.
win.on('closed',() => {
win = null
})
// Open the DevTools.
// win.webContents.openDevTools()
}
app.on('window-all-closed',() => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate',() => {
if (win === null) {
createWindow()
}
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
//Start the main window
app.on('ready', createWindow)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="" method="post">
<input type="text" name="test-1">
</form>
</body>
</html>