Electron
DOs and DONTs
- Don's handle dialogs in renderer process, which will block rendering
Common Issue
How to access current user directory in electon (and other special directories) ?
https://github.com/electron/electron/blob/master/docs/api/app.md#appgetpathname
basically:
- home User's home directory.
-
appData Per-user application data directory, which by default points to:
- %APPDATA% on Windows
- $XDG_CONFIG_HOME or ~/.config on Linux
- ~/Library/Application Support on macOS
- userData The directory for storing your app's configuration files, which by default it is the appData directory appended with your app's name.
- temp Temporary directory.
- exe The current executable file.
- module The libchromiumcontent library.
- desktop The current user's Desktop directory.
- documents Directory for a user's "My Documents".
- downloads Directory for a user's downloads.
- music Directory for a user's music.
- pictures Directory for a user's pictures.
- videos Directory for a user's videos.
- logs Directory for your app's log folder.
- pepperFlashSystemPlugin Full path to the system version of the Pepper Flash plugin.
debug main process
https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process.md
file manipulation
copy file electron 1.8.2 use node 8.2.1, which doesn't support copyFile, copyFileSync yet https://stackoverflow.com/questions/11293857/fastest-way-to-copy-file-in-node-js
hide window when click the close icon
// override close event handler,when 「close」,hide instead let willQuit = false; // if use want to quit win.on('close', ev => { if (willQuit) { win = null; } else { ev.preventDefault(); win.hide(); } }); // click 'quit' menu from dock icon. app.on('before-quit', () => { willQuit = true }); app.on('activate', () => { // 在macOS上,当单击dock图标并且没有其他窗口打开时, // 通常在应用程序中重新创建一个窗口。 if (win === null) { createWindow() } else { if (!win.isVisible()) { win.restore(); } } });
https://discuss.atom.io/t/change-app-name-in-menu-bar/39839
Hi, to answer in two words; you cant.
The more detailed answer; The menu containing the Application Name and About dialog are part of OS X’s interface, it displays the name of the application that is running. During development you are, like most people, simply loading your application into electron, therefore it is electron that is running so Mac OSX displays Electron and it’s dialog information.
When you build your application (package it to use your terminology) you are building the application to run as whatever you have named your app and therefore it will display your applications name.
If you want to do this during development then you can simply build/package your application everytime you make a change, this from a time perspective is very wasteful as its easier to just run your application code during development inside electron where you can make changes in real time and they instantly apply, if you build/package your own app you would need to repackage it every time you made a change to the code.