diff --git a/src/hooks/useAutoUpdateNotificationToken.ts b/src/hooks/useAutoUpdateNotificationToken.ts index 77d456b..b3ed479 100644 --- a/src/hooks/useAutoUpdateNotificationToken.ts +++ b/src/hooks/useAutoUpdateNotificationToken.ts @@ -2,6 +2,7 @@ import { useEffect, useState } from "react"; import { useNotificationToken } from "@/hooks/useNotificationToken"; import { useNotificationTokenAPI } from "@/hooks/useNotificationTokenAPI"; import { NOTIFICATION_TOKEN_KEY } from "@/utils/constants"; +import { App } from "antd"; export const useAutoUpdateNotificationToken = () => { const [token] = useNotificationToken(); @@ -11,6 +12,7 @@ export const useAutoUpdateNotificationToken = () => { unsetTokenReq, } = useNotificationTokenAPI(); const [isNotificationEnable, setIsNotificationEnable] = useState(false); + const { message } = App.useApp(); useEffect(() => { if (!token) return; isTokenSetedReq.runAsync(token).then(res => { @@ -30,6 +32,10 @@ export const useAutoUpdateNotificationToken = () => { .then(() => { }).then(() => { console.debug('Auto udpate token', token); + message.open({ + key: 'auto-update-token', + content: `通知 Token 已更新`, + }); }); }, [updateTokenReq, unsetTokenReq, isNotificationEnable, token]); } \ No newline at end of file diff --git a/src/sw.ts b/src/sw.ts index ae35efb..a43a831 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -14,9 +14,8 @@ const messaging = getMessaging(app); // 1. 监听安装事件 self.addEventListener('install', (event) => { - // console.log('新版本 Service Worker 安装中...'); - // 强制跳过等待阶段,直接进入激活阶段 - self.skipWaiting(); + console.log('新版本 Service Worker 安装中...'); + // 不能强制更新,会影响旧版本用户的通知 }); self.addEventListener('activate', (event) => {