Cambios esteticos y de ping para el servidor
This commit is contained in:
@@ -4,7 +4,6 @@ import { electronApp, optimizer, is } from "@electron-toolkit/utils";
|
||||
import icon from "../../resources/icon.png?asset";
|
||||
import { NfcService } from "../services/NfcService";
|
||||
|
||||
let nfcService: NfcService | null = null;
|
||||
|
||||
function createWindow(): void {
|
||||
// Create the browser window.
|
||||
@@ -20,7 +19,11 @@ function createWindow(): void {
|
||||
},
|
||||
});
|
||||
|
||||
nfcService = new NfcService();
|
||||
new NfcService((event) => {
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send(`nfc:${event.type}`, event);
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.on("ready-to-show", () => {
|
||||
mainWindow.show();
|
||||
@@ -57,6 +60,19 @@ app.whenReady().then(() => {
|
||||
// IPC test
|
||||
ipcMain.on("ping", () => console.log("pong"));
|
||||
|
||||
ipcMain.handle("ping:url", async (_event, url: string) => {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "HEAD",
|
||||
signal: AbortSignal.timeout(5000),
|
||||
});
|
||||
return response.ok;
|
||||
} catch (error) {
|
||||
console.error(`Ping failed for ${url}:`, error);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
createWindow();
|
||||
|
||||
app.on("activate", function () {
|
||||
|
||||
Reference in New Issue
Block a user