2020-03-19 09:03:21 -04:00
|
|
|
import db from '#/datastore'
|
2021-03-28 05:44:07 -04:00
|
|
|
import { clipboard, Notification } from 'electron'
|
2020-03-19 09:03:21 -04:00
|
|
|
|
2020-06-28 03:30:58 -04:00
|
|
|
export const handleCopyUrl = (str: string): void => {
|
2020-05-04 04:50:29 -04:00
|
|
|
if (db.get('settings.autoCopy') !== false) {
|
2020-03-19 09:03:21 -04:00
|
|
|
clipboard.writeText(str)
|
|
|
|
}
|
|
|
|
}
|
2021-03-28 05:44:07 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* show notification
|
|
|
|
* @param options
|
|
|
|
*/
|
|
|
|
export const showNotification = (options: IPrivateShowNotificationOption = {
|
|
|
|
title: '',
|
|
|
|
body: '',
|
|
|
|
clickToCopy: false
|
|
|
|
}) => {
|
|
|
|
const notification = new Notification({
|
|
|
|
title: options.title,
|
|
|
|
body: options.body
|
|
|
|
})
|
|
|
|
const handleClick = () => {
|
|
|
|
if (options.clickToCopy) {
|
|
|
|
clipboard.writeText(options.body)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notification.once('click', handleClick)
|
|
|
|
notification.once('close', () => {
|
|
|
|
notification.removeListener('click', handleClick)
|
|
|
|
})
|
|
|
|
notification.show()
|
|
|
|
}
|