diff --git a/src/app/chat/components/pwa-install-overlay.tsx b/src/app/chat/components/pwa-install-overlay.tsx index dddfc007..fc9a71a2 100644 --- a/src/app/chat/components/pwa-install-overlay.tsx +++ b/src/app/chat/components/pwa-install-overlay.tsx @@ -14,6 +14,7 @@ */ import { useEffect } from "react"; +import { BrowserDetector } from "@/utils/browser-detect"; import { SpAsyncUtil } from "@/utils/storage"; import { pwaUtil } from "@/utils/pwa"; @@ -32,6 +33,7 @@ export function PwaInstallOverlay() { // isInstalled() 检查 standalone display-mode(避免给已安装用户再弹) if (!pwaUtil.isSupported()) return; if (pwaUtil.isInstalled()) return; + if (BrowserDetector.isInAppBrowser()) return; // 提前挂 beforeinstallprompt 监听,避免用户点 OK 时事件已在更早时机丢失。 pwaUtil.prepareInstallPrompt(); diff --git a/src/integrations/index.ts b/src/integrations/index.ts index 9652de67..30be615f 100644 --- a/src/integrations/index.ts +++ b/src/integrations/index.ts @@ -2,5 +2,4 @@ * @file Automatically generated by barrelsby. */ -export * from "./browser-detect"; export * from "./media-recorder"; diff --git a/src/integrations/browser-detect.ts b/src/utils/browser-detect.ts similarity index 79% rename from src/integrations/browser-detect.ts rename to src/utils/browser-detect.ts index fbcd1d5f..4f473193 100644 --- a/src/integrations/browser-detect.ts +++ b/src/utils/browser-detect.ts @@ -29,13 +29,4 @@ export const BrowserDetector = { return /WebView|; wv\)|FBAN|FBAV|MicroMessenger|Instagram|Line\//i.test(userAgent); }, - /** 当前是否以 PWA standalone 模式运行 */ - isPWAStandalone(): boolean { - if (typeof window === "undefined") return false; - return ( - window.matchMedia?.("(display-mode: standalone)").matches === true || - // iOS Safari 旧版 - (navigator as Navigator & { standalone?: boolean }).standalone === true - ); - }, };