Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app/icon-genie/docs): more refinement for Electron #11163

Merged
merged 22 commits into from
Nov 13, 2021

Conversation

hawkeye64
Copy link
Member

The "linux-512x512.png" is not needed. The file itself should be renamed to "icon.png", which can be used by all platforms for the Tray icon (the others are needed for the embedded icons), and seems silly to use "linux-512x512.png" when building for other platforms. But, we don't want to introduce any breaking changes, so if "icon.png" does not exist, we will copy "linux-512x512.png" to "icon.png". Then, in "electron-main.js" only one image file is needed for the tray icon. Additionally, we can fix "quasar-conf-file.js" to prevent the "can't stat 'icons/icon'" that only happens under Linux.

Icon Genie has also been modified to create/update the electron-src/icons/icon.png file.

Additionally, this PR introduces the electron-handler.js script. It is imported by electron-main.

import { useElectronHandler } from './electron-handler'

Here is what electron-handler looks like:

// import { ipcMain } from 'electron'

// This file is where you can handle commands based on your exposed API methods
// added in electron-preload - it helps to keep separation-of-concerns out of
// your electron-main. If you use this file, please uncomment the above import
// line.

export function useElectronHandler () {
  // add handlers here for your exposed API from electron-preload.
  // 'event' is always the first parameter followed by any passed
  // params from your API

  // Example:
  // ipcMain.handle('myAPI:doAThing', (event, parm1) => {
  //   // access what you need here: file system, etc
  // })
}

Basically, it's a best practices ideology for separation-of-concerns where developers can add their ipcMain interactions from the electron-preload so that electron-main doesn't have to deal with them (especially when you can get into dozens of interactions on a full-fledged Electron app).

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Documentation
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe: Electron template changes

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • It's submitted to the dev branch (or v[X] branch)
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • It's been tested on a Cordova (iOS, Android) app
  • It's been tested on a Electron app
  • Any necessary documentation has been added or updated in the docs (for faster update click on "Suggest an edit on GitHub" at bottom of page) or explained in the PR's description.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Basically, the "linux-512x512.png" is not needed. The file itself should be renamed to "icon.png", which can be used by all platforms for the Tray icon (the others are needed for the embedded icons). But, we don't want to introduce any breaking changes, so if "icon.png" does not exist, we will copy "linux-512x512.png" to "icon.png". Then, in "electron-main.js" only one image file is needed for the tray icon. Additionally, we can fix "quasar-conf-file.js" to prevent the "can't stat 'icons/icon'" that only happens under linux.
This is to support changes in App in regards to "icon.png"
The 'electron-handler.js' file is being introduced to help developers keep their separation-of-concerns out of the 'electron-main.js' file. It keeps things modular and also introduces a 'useElectronHandler()' method, which keeps it comfortable with those familiar with Vue's composition API. This method is an empty function containing commented example code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants