Files
gelectron/src/electron/dialog.js
T
miles 86c19b0012 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.
2026-07-26 17:12:47 -05:00

71 lines
2.0 KiB
JavaScript

'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;