Feature: add remoteNotice

This commit is contained in:
PiEgg
2022-10-30 16:08:29 +08:00
parent a355bc07f4
commit 9317871fdb
7 changed files with 277 additions and 4 deletions

View File

@@ -15,7 +15,9 @@ export const handleCopyUrl = (str: string): void => {
export const showNotification = (options: IPrivateShowNotificationOption = {
title: '',
body: '',
clickToCopy: false
clickToCopy: false,
copyContent: '',
clickFn: () => {}
}) => {
const notification = new Notification({
title: options.title,
@@ -24,7 +26,10 @@ export const showNotification = (options: IPrivateShowNotificationOption = {
})
const handleClick = () => {
if (options.clickToCopy) {
clipboard.writeText(options.body)
clipboard.writeText(options.copyContent || options.body)
}
if (options.clickFn) {
options.clickFn()
}
}
notification.once('click', handleClick)