Fix web push delivery handling and worker console
Some checks failed
docker-images / resolve-build-targets (push) Successful in 5s
docker-images / build-and-push (admin) (push) Successful in 30s
docker-images / submit-indexnow (push) Has been cancelled
docker-images / build-and-push (frontend) (push) Has been cancelled
docker-images / build-and-push (backend) (push) Has been cancelled

This commit is contained in:
2026-04-04 04:15:20 +08:00
parent ab18bbaf23
commit 381dc9b854
19 changed files with 1607 additions and 747 deletions

View File

@@ -360,7 +360,7 @@ const webPushAvailable = Boolean(webPushPublicKey);
import { mountTurnstile, type MountedTurnstile } from '../lib/utils/turnstile';
import {
ensureBrowserPushSubscription,
getBrowserPushSubscription,
getBrowserPushSubscriptionState,
supportsBrowserPush,
} from '../lib/utils/web-push';
@@ -505,6 +505,14 @@ const webPushAvailable = Boolean(webPushPublicKey);
}
};
const forgetSubmitted = () => {
try {
window.localStorage.removeItem(SUBSCRIBED_KEY);
} catch {
// Ignore storage failures.
}
};
const resetStatus = () => {
delete status.dataset.state;
status.textContent = defaultStatus;
@@ -811,7 +819,19 @@ const webPushAvailable = Boolean(webPushPublicKey);
}
try {
const subscription = await getBrowserPushSubscription();
const { subscription, stale } = await getBrowserPushSubscriptionState(
browserPushPublicKey,
);
if (stale) {
forgetSubmitted();
setBrowserAvailability({
selectable: true,
note: '检测到提醒配置已更新,需要重新开启一次提醒。',
});
return;
}
if (subscription) {
rememberSubmitted();
setBrowserAvailability({