Skip to content

Commit d265a54

Browse files
committed
fixed notification buttons not work
1 parent 0f891dd commit d265a54

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/background/messages/notify.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import type { PlasmoMessaging } from "@plasmohq/messaging"
22

33
import icon from 'raw:assets/icon.png'
44

5-
export type RequestBody = Partial<chrome.notifications.NotificationOptions<true>> & {
5+
export type RequestBody = Partial<Omit<chrome.notifications.NotificationOptions<true>, 'buttons'>> & {
6+
messages?: string[],
67
buttons?: (chrome.notifications.ButtonOptions & { clicked: (id: string, index: number) => void })[],
78
onClicked?: (id: string) => void
89
}
@@ -20,11 +21,12 @@ async function createNotification(option: chrome.notifications.NotificationOptio
2021
}
2122

2223
const handler: PlasmoMessaging.MessageHandler<RequestBody, string> = async (req, res) => {
23-
const { title, message, type, buttons, onClicked, ...option } = req.body
24+
const { title, message, messages, type, buttons, onClicked, ...option } = req.body
2425
const id = await createNotification({
2526
type: type ?? 'basic',
2627
title,
27-
message,
28+
message: message ?? messages?.join('\n') ?? '',
29+
buttons: buttons?.map(({ clicked, ...option }) => option),
2830
...option,
2931
iconUrl: icon
3032
})

src/background/update-listener.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ getSettingStorage('settings.version').then(async (settings) => {
7171
await sendInternal('notify', {
7272
type: 'list',
7373
title: 'bilibili-vup-stream-enhancer 已推出新版本',
74-
message: `当前版本: v${currentVersion}`,
7574
items: [
75+
{ title: '当前版本', message: `v${currentVersion}` },
7676
{ title: '最新版本', message: `v${latest.tag_name}` },
7777
{ title: '发布日期', message: new Date(latest.published_at).toDateString() }
7878
],

0 commit comments

Comments
 (0)