program finalizat

This commit is contained in:
andrei-mihnea-cerbu
2024-10-29 15:07:26 +02:00
parent ab1eaec413
commit 979539d3db
138 changed files with 14602 additions and 5068 deletions
+43
View File
@@ -5,6 +5,7 @@ import path from 'path';
export class WindowManager {
private readonly mainWindow: BrowserWindow;
private readonly pathToPagesDir: string;
private announcementWindow: BrowserWindow | null = null;
constructor(mainWindow: BrowserWindow, pathToPagesDir: string) {
this.pathToPagesDir = pathToPagesDir;
@@ -89,4 +90,46 @@ export class WindowManager {
return undefined; // Return undefined if no file was selected
}
}
// Method to display an announcement in a new window
async displayAnnouncement(): Promise<void> {
if (this.announcementWindow) {
// If the window is already open, focus it
this.announcementWindow.focus();
return;
}
const mainScreen = require('electron').screen.getPrimaryDisplay();
const { width, height } = mainScreen.size;
// Initialize the announcement window
this.announcementWindow = new BrowserWindow({
width: width / 3,
height: height / 2,
resizable: false,
title: 'Announcement',
webPreferences: {
preload: path.join(__dirname, '..', 'main', 'preload.js'),
contextIsolation: true,
nodeIntegration: false,
},
});
this.announcementWindow.removeMenu();
// Load the announcement page
const announcementPath = path.join(this.pathToPagesDir, 'announcement.html');
await this.announcementWindow.loadFile(announcementPath);
// Handle window close
this.announcementWindow.on('closed', () => {
this.announcementWindow = null; // Clean up the reference
});
}
async closeAnnouncementWindow(): Promise<void> {
if (this.announcementWindow) {
this.announcementWindow.close();
}
}
}