-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Refactor: upload module && notification module
- Loading branch information
1 parent
f9d6191
commit 3cad5f3
Showing
11 changed files
with
118 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
import db from '#/datastore' | ||
import { clipboard } from 'electron' | ||
import { clipboard, Notification } from 'electron' | ||
|
||
export const handleCopyUrl = (str: string): void => { | ||
if (db.get('settings.autoCopy') !== false) { | ||
clipboard.writeText(str) | ||
} | ||
} | ||
|
||
/** | ||
* 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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.