electron-util
Version:
Useful utilities for Electron apps and modules
90 lines (71 loc) • 2.75 kB
TypeScript
import { type MenuItemConstructorOptions } from 'electron';
export type ShowAboutWindowOptions = {
/**
An absolute path to the app icon.
Only used on Linux and Windows.
Note: On Linux, the icon must be a real file on disk, not inside an ASAR archive. If your icon is packaged in app.asar, you need to configure your build to unpack it. For electron-builder, add "asarUnpack" with the icon glob pattern to your build config. This function will automatically fix the path to point to app.asar.unpacked if needed.
*/
readonly icon?: string;
/**
The copyright text.
*/
readonly copyright?: string;
/**
The URL to the app's website.
Only used on Linux.
*/
readonly website?: string;
/**
Some additional text if needed.
Only used on Windows.
*/
readonly text?: string;
/**
Customizable for localization. Used in the menu item label and window title (Windows-only).
The app name is automatically appended at runtime.
Only used on Linux and Windows.
@default 'About'
*/
readonly title?: string;
};
export type AboutMenuItemOptions = ShowAboutWindowOptions;
/**
Shows an 'About' window. On macOS and Linux, the native 'About' window is shown, and on Windows, a simple custom dialog is shown.
On macOS, the `icon`, `text`, `title`, and `website` options are ignored.
_It will show `Electron` as the app name until you build your app for production._
Note: On Linux, the icon must be unpacked from the ASAR archive. Configure your electron-builder with "asarUnpack" to ensure the icon file is available on disk.
@param options
@example
```
import {showAboutWindow} from 'electron-util';
showAboutWindow({
icon: path.join(__dirname, 'static/Icon.png'),
copyright: 'Copyright © Sindre Sorhus',
text: 'Some more info.'
});
```
*/
export declare const showAboutWindow: (options: ShowAboutWindowOptions) => void;
/**
Accepts the same options as `.showAboutWindow()`.
@returns A `MenuItemConstructorOptions` that creates a menu item, which shows the about dialog when clicked.
Note: On Linux, the icon must be unpacked from the ASAR archive. See `showAboutWindow` documentation for details.
@example
```
import {Menu} from 'electron';
import {aboutMenuItem} from 'electron-util';
const menu = Menu.buildFromTemplate([
{
label: 'Help',
submenu: [
aboutMenuItem({
icon: path.join(__dirname, 'static/Icon.png'),
copyright: 'Copyright © Sindre Sorhus',
text: 'Some more info.'
})
]
}
]);
Menu.setApplicationMenu(menu);
*/
export declare const aboutMenuItem: (options?: AboutMenuItemOptions) => MenuItemConstructorOptions;