better queue render
This commit is contained in:
43
main.js
43
main.js
@@ -9,6 +9,30 @@ const PathResolver = require("./src/main/PathResolver.js");
|
||||
|
||||
let obj_main_window = null;
|
||||
let obj_queue_manager = null;
|
||||
let obj_notification_config = { is_notify_each_image: false, is_notify_all_done: true };
|
||||
|
||||
const STR_NOTIFICATION_CONFIG_FILE = "notification_config.json";
|
||||
|
||||
const _load_notification_config = () => {
|
||||
let str_config_path = path.join(app.getPath("userData"), STR_NOTIFICATION_CONFIG_FILE);
|
||||
try {
|
||||
if (fs.existsSync(str_config_path)) {
|
||||
let str_content = fs.readFileSync(str_config_path, "utf8");
|
||||
obj_notification_config = JSON.parse(str_content);
|
||||
}
|
||||
} catch (obj_err) {
|
||||
console.error("Erreur lecture config notifications :", obj_err.message);
|
||||
}
|
||||
};
|
||||
|
||||
const _save_notification_config = () => {
|
||||
let str_config_path = path.join(app.getPath("userData"), STR_NOTIFICATION_CONFIG_FILE);
|
||||
try {
|
||||
fs.writeFileSync(str_config_path, JSON.stringify(obj_notification_config, null, 4), "utf8");
|
||||
} catch (obj_err) {
|
||||
console.error("Erreur sauvegarde config notifications :", obj_err.message);
|
||||
}
|
||||
};
|
||||
|
||||
const create_window = () => {
|
||||
obj_main_window = new BrowserWindow({
|
||||
@@ -29,6 +53,8 @@ const create_window = () => {
|
||||
obj_queue_manager = new QueueManager(obj_main_window);
|
||||
|
||||
PathResolver.load_saved_path();
|
||||
_load_notification_config();
|
||||
obj_queue_manager.set_notification_config(obj_notification_config);
|
||||
|
||||
UpdateManager.init(obj_main_window);
|
||||
obj_main_window.webContents.on("did-finish-load", () => {
|
||||
@@ -81,6 +107,10 @@ ipcMain.handle("start-render", (event, obj_config) => {
|
||||
return obj_queue_manager.start(obj_config);
|
||||
});
|
||||
|
||||
ipcMain.handle("check-queue", (event, obj_config) => {
|
||||
return obj_queue_manager.check_queue(obj_config);
|
||||
});
|
||||
|
||||
ipcMain.handle("pause-render", () => {
|
||||
return obj_queue_manager.pause();
|
||||
});
|
||||
@@ -214,3 +244,16 @@ ipcMain.handle("select-output-folder", () => {
|
||||
return obj_result.filePaths[0];
|
||||
});
|
||||
});
|
||||
|
||||
// ── Notification Config ───────────────────────────────────────
|
||||
|
||||
ipcMain.handle("get-notification-config", () => {
|
||||
return obj_notification_config;
|
||||
});
|
||||
|
||||
ipcMain.handle("set-notification-config", (event, obj_config) => {
|
||||
obj_notification_config = obj_config;
|
||||
_save_notification_config();
|
||||
obj_queue_manager.set_notification_config(obj_notification_config);
|
||||
return { is_success: true };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user