mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 03:10:08 +08:00
* feat: update tsgo * chore: update alpha.15 * feat: add script * chore: update ai-core version to alpha.16 and add npm registry settings * chore
24 lines
677 B
TypeScript
24 lines
677 B
TypeScript
import { Notification } from '@types'
|
|
import { Notification as ElectronNotification } from 'electron'
|
|
|
|
import { windowService } from './WindowService'
|
|
|
|
class NotificationService {
|
|
public async sendNotification(notification: Notification) {
|
|
// 使用 Electron Notification API
|
|
const electronNotification = new ElectronNotification({
|
|
title: notification.title,
|
|
body: notification.message
|
|
})
|
|
|
|
electronNotification.on('click', () => {
|
|
windowService.getMainWindow()?.show()
|
|
windowService.getMainWindow()?.webContents.send('notification-click', notification)
|
|
})
|
|
|
|
electronNotification.show()
|
|
}
|
|
}
|
|
|
|
export default NotificationService
|