fix
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 37s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s

This commit is contained in:
2026-01-02 18:51:28 +08:00
parent e250a7df2f
commit 5c76e9287e
9 changed files with 60 additions and 66 deletions

View File

@@ -2,14 +2,14 @@
export function getVapidPublicKey() {
return request({
url: '/notification/vapid-public-key',
url: '/Notification/GetVapidPublicKey',
method: 'get'
})
}
export function subscribe(data) {
return request({
url: '/notification/subscribe',
url: '/Notification/Subscribe',
method: 'post',
data
})
@@ -17,7 +17,7 @@ export function subscribe(data) {
export function testNotification(message) {
return request({
url: '/notification/test',
url: '/Notification/TestNotification',
method: 'post',
params: { message }
})

View File

@@ -107,8 +107,13 @@ const handleNotificationToggle = async (checked) => {
return
}
const { data: { publicKey } } = await getVapidPublicKey()
const convertedVapidKey = urlBase64ToUint8Array(publicKey)
let { success, data, message } = await getVapidPublicKey()
if (!success) {
throw new Error(message || '获取 VAPID 公钥失败')
}
const convertedVapidKey = urlBase64ToUint8Array(data)
const subscription = await registration.pushManager.subscribe({
userVisibleOnly: true,