mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 22:13:36 +08:00

* Refactored build command * Update v2/cmd/wails/build.go Co-authored-by: stffabi <stffabi@users.noreply.github.com> * WIP * Refactor `wails doctor` * Refactor `wails dev` * Refactor `wails dev` * Fix merge conflict * Fix test * Update build_and_test.yml Co-authored-by: stffabi <stffabi@users.noreply.github.com>
33 lines
685 B
JavaScript
33 lines
685 B
JavaScript
// Get input + focus
|
|
let nameElement = document.getElementById("name");
|
|
nameElement.focus();
|
|
|
|
// Setup the greet function
|
|
window.greet = function () {
|
|
// Get name
|
|
let name = nameElement.value;
|
|
|
|
// Check if the input is empty
|
|
if (name === "") return;
|
|
|
|
// Call App.Greet(name)
|
|
try {
|
|
window.go.main.App.Greet(name)
|
|
.then((result) => {
|
|
// Update result with data back from App.Greet()
|
|
document.getElementById("result").innerText = result;
|
|
})
|
|
.catch((err) => {
|
|
console.error(err);
|
|
});
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
};
|
|
|
|
nameElement.onkeydown = function (e) {
|
|
if (e.keyCode == 13) {
|
|
window.greet();
|
|
}
|
|
};
|