main.js aktualisiert
This commit is contained in:
18
main.js
18
main.js
@@ -6,7 +6,7 @@ const chokidar = require("chokidar");
|
||||
const axios = require("axios");
|
||||
|
||||
let OUT_DIR; // endgültiger Eingangsordner (wird in app.whenReady gesetzt)
|
||||
let IMG_DIR; // Ausgabeordner für latest.png
|
||||
let IMG_DIR; // Ausgabeordner für PNGs (History)
|
||||
|
||||
let win;
|
||||
function createWindow() {
|
||||
@@ -217,23 +217,17 @@ async function processFile(filePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
// PNG speichern (latest.png) — alte PNGs löschen
|
||||
// PNG speichern — neue Datei mit Timestamp (History)
|
||||
const pngBuffer = renderResult.buffer;
|
||||
try {
|
||||
fs.readdirSync(IMG_DIR).forEach(f => {
|
||||
const fileToDelete = path.join(IMG_DIR, f);
|
||||
try { if (fs.lstatSync(fileToDelete).isFile()) fs.unlinkSync(fileToDelete); } catch(e){}
|
||||
});
|
||||
} catch(e){}
|
||||
|
||||
const outFile = path.join(IMG_DIR, "latest.png");
|
||||
const timestamp = Date.now();
|
||||
const outFile = path.join(IMG_DIR, `label-${timestamp}.png`);
|
||||
fs.writeFileSync(outFile, pngBuffer);
|
||||
console.log("PNG erstellt:", outFile);
|
||||
|
||||
// verarbeitete ZPL-Datei löschen (optional)
|
||||
// ZPL-Datei löschen (optional)
|
||||
try { fs.unlinkSync(filePath); } catch(e){ console.warn("Konnte ZPL nicht löschen:", e.message); }
|
||||
|
||||
// Fenster benachrichtigen
|
||||
// Fenster benachrichtigen (sende neuen PNG-Pfad)
|
||||
win.webContents.send("show-png", outFile);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user