mirror of
https://github.com/mileswolfallen2/gelectron.git
synced 2026-12-04 16:07:43 +00:00
feat: add Gelectron compatibility layer for Electron modules
- Introduced contextBridge module for exposing APIs to the main world. - Added dialog module for handling open, save, and message dialogs. - Created index module as a drop-in replacement for Electron's main API. - Implemented ipcMain and ipcRenderer modules for inter-process communication. - Developed menu and menu item modules for creating application menus. - Added nativeImage module for handling images in various formats. - Implemented notification module for displaying system notifications. - Created preload-loader for injecting preload scripts into the renderer process. - Developed runtime module for running Electron apps in a Node.js environment. - Added safe-storage module for basic string encryption and decryption. - Implemented shell module for opening external URLs and managing file paths. - Created tray module for managing system tray icons and menus. - Developed webContents utilities for interacting with browser windows.
This commit is contained in:
1 parent
4af8378d72
commit
86c19b0012
39 files changed
+4687
-2
No files matched your search
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Gelectron - Notification module (Electron compatible)
|
||||
*/
|
||||
|
||||
const { EventEmitter } = require('events');
|
||||
|
||||
class Notification extends EventEmitter {
|
||||
static _notifications = new Map();
|
||||
static _nextId = 1;
|
||||
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
this.id = Notification._nextId++;
|
||||
this.title = options.title || '';
|
||||
this.body = options.body || '';
|
||||
this.subtitle = options.subtitle || '';
|
||||
this.silent = options.silent || false;
|
||||
this.icon = options.icon || null;
|
||||
this.urgency = options.urgency || 'normal';
|
||||
this.timeoutType = options.timeoutType || 'default';
|
||||
this.closeButtonText = options.closeButtonText || '';
|
||||
this.toastXml = options.toastXml || '';
|
||||
this.actions = options.actions || [];
|
||||
this.replyPlaceholder = options.replyPlaceholder || '';
|
||||
|
||||
Notification._notifications.set(this.id, this);
|
||||
}
|
||||
|
||||
static isSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
show() {
|
||||
if (typeof Notification !== 'undefined' && Notification.permission === 'granted') {
|
||||
new globalThis.Notification(this.title, {
|
||||
body: this.body,
|
||||
icon: this.icon,
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`[gelectron] Notification shown: ${this.title}`);
|
||||
this.emit('show');
|
||||
return true;
|
||||
}
|
||||
|
||||
close() {
|
||||
Notification._notifications.delete(this.id);
|
||||
console.log(`[gelectron] Notification ${this.id} closed`);
|
||||
this.emit('close');
|
||||
}
|
||||
|
||||
static fromNotification(notification) {
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { Notification };
|
||||
Reference in new issue
Block a user