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,70 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Gelectron - dialog module (Electron compatible)
|
||||
*/
|
||||
|
||||
const dialog = {
|
||||
showOpenDialog(browserWindowOrOptions, options) {
|
||||
let opts = options || browserWindowOrOptions || {};
|
||||
if (browserWindowOrOptions && browserWindowOrOptions.webContents) {
|
||||
opts = options || {};
|
||||
}
|
||||
|
||||
// Route through native if available
|
||||
if (typeof globalThis.__gelectron_dialog_open === 'function') {
|
||||
return globalThis.__gelectron_dialog_open(opts);
|
||||
}
|
||||
|
||||
return Promise.resolve({ canceled: true, filePaths: [] });
|
||||
},
|
||||
|
||||
showSaveDialog(browserWindowOrOptions, options) {
|
||||
let opts = options || browserWindowOrOptions || {};
|
||||
if (browserWindowOrOptions && browserWindowOrOptions.webContents) {
|
||||
opts = options || {};
|
||||
}
|
||||
|
||||
if (typeof globalThis.__gelectron_dialog_save === 'function') {
|
||||
return globalThis.__gelectron_dialog_save(opts);
|
||||
}
|
||||
|
||||
return Promise.resolve({ canceled: true, filePath: undefined });
|
||||
},
|
||||
|
||||
showMessageBox(browserWindowOrOptions, options) {
|
||||
let opts = options || browserWindowOrOptions || {};
|
||||
if (browserWindowOrOptions && browserWindowOrOptions.webContents) {
|
||||
opts = options || {};
|
||||
}
|
||||
|
||||
if (typeof globalThis.__gelectron_dialog_message === 'function') {
|
||||
return globalThis.__gelectron_dialog_message(opts);
|
||||
}
|
||||
|
||||
return Promise.resolve({ response: 0, checkboxChecked: false });
|
||||
},
|
||||
|
||||
showErrorBox(title, content) {
|
||||
console.error(`[gelectron] ${title}: ${content}`);
|
||||
},
|
||||
|
||||
showMessageBoxSync(browserWindowOrOptions, options) {
|
||||
let opts = options || browserWindowOrOptions || {};
|
||||
if (browserWindowOrOptions && browserWindowOrOptions.webContents) {
|
||||
opts = options || {};
|
||||
}
|
||||
|
||||
if (typeof globalThis.__gelectron_dialog_message_sync === 'function') {
|
||||
return globalThis.__gelectron_dialog_message_sync(opts);
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
showCertificateTrustDialog(browserWindowOrOptions, options) {
|
||||
return Promise.resolve();
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = dialog;
|
||||
Reference in new issue
Block a user