fix
This commit is contained in:
@@ -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 }
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user