notification.js 775 B

1234567891011121314151617181920212223
  1. const path = require('path')
  2. const notifier = require('node-notifier')
  3. const builtinIcons = {
  4. done: path.resolve(__dirname, '../../src/assets/done.png'),
  5. error: path.resolve(__dirname, '../../src/assets/error.png')
  6. }
  7. // https://github.com/mikaelbr/node-notifier/issues/154
  8. // Specify appID to prevent SnoreToast shortcut installation.
  9. // SnoreToast actually uses it as the string in the notification's
  10. // title bar (different from title heading inside notification).
  11. // This only has an effect in Windows.
  12. const snoreToastOptions = notifier.Notification === notifier.WindowsToaster && { appID: 'Vue UI' }
  13. exports.notify = ({ title, message, icon }) => {
  14. notifier.notify({
  15. ...snoreToastOptions,
  16. title,
  17. message,
  18. icon: builtinIcons[icon] || icon
  19. })
  20. }