From e9d060f74a09d8a9fa0de82f6f1cf3aeabd33060 Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Fri, 2 Jan 2026 14:08:50 +0800 Subject: [PATCH] chore: remove PWA installation banner, associated hooks, manifest, and PWA metadata from the application. --- app/layout.tsx | 10 ---- components/PWAInstallBanner.tsx | 83 ------------------------------- lib/hooks/usePWAInstall.ts | 86 --------------------------------- package-lock.json | 4 +- package.json | 2 +- public/manifest.json | 17 ------- 6 files changed, 3 insertions(+), 199 deletions(-) delete mode 100644 components/PWAInstallBanner.tsx delete mode 100644 lib/hooks/usePWAInstall.ts delete mode 100644 public/manifest.json diff --git a/app/layout.tsx b/app/layout.tsx index 58fc7b1..73e9ca1 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -5,7 +5,6 @@ import { ThemeProvider } from "@/components/ThemeProvider"; import { Analytics } from "@vercel/analytics/react"; import { ServiceWorkerRegister } from "@/components/ServiceWorkerRegister"; import { PasswordGate } from "@/components/PasswordGate"; -import { PWAInstallBanner } from "@/components/PWAInstallBanner"; import { siteConfig } from "@/lib/config/site-config"; @@ -24,14 +23,6 @@ export const metadata: Metadata = { description: siteConfig.description, icons: { icon: '/icon.png', - apple: '/icon.png', - }, - manifest: '/manifest.json', - themeColor: '#000000', - appleWebApp: { - capable: true, - statusBarStyle: 'black-translucent', - title: siteConfig.name, }, }; @@ -47,7 +38,6 @@ export default function RootLayout({ suppressHydrationWarning > - {children} diff --git a/components/PWAInstallBanner.tsx b/components/PWAInstallBanner.tsx deleted file mode 100644 index 57cb8f6..0000000 --- a/components/PWAInstallBanner.tsx +++ /dev/null @@ -1,83 +0,0 @@ -'use client'; - -import { useState, useEffect } from 'react'; -import { usePWAInstall } from '@/lib/hooks/usePWAInstall'; -import { X, Download, Share } from 'lucide-react'; -import { Button } from '@/components/ui/Button'; - -export function PWAInstallBanner() { - const { isInstallable, isIOS, handleInstallClick } = usePWAInstall(); - const [isVisible, setIsVisible] = useState(false); - const [isDismissed, setIsDismissed] = useState(false); - - useEffect(() => { - // Show banner after a short delay to not be too intrusive - if ((isInstallable || isIOS) && !isDismissed) { - const timer = setTimeout(() => setIsVisible(true), 2000); - return () => clearTimeout(timer); - } else { - setIsVisible(false); - } - }, [isInstallable, isIOS, isDismissed]); - - const handleDismiss = () => { - setIsVisible(false); - setIsDismissed(true); - // Optionally save to localStorage to not show again for a while - localStorage.setItem('pwa-banner-dismissed', Date.now().toString()); - }; - - useEffect(() => { - const dismissedAt = localStorage.getItem('pwa-banner-dismissed'); - if (dismissedAt) { - const oneDay = 24 * 60 * 60 * 1000; - if (Date.now() - parseInt(dismissedAt) < oneDay) { - setIsDismissed(true); - } - } - }, []); - - if (!isVisible) return null; - - return ( -
-
-
-
- KVideo -
-
-

安装 KVideo

-

- {isIOS ? '点击浏览器分享按钮,选择“添加到主屏幕”' : '安装到桌面,体验更流畅'} -

-
-
- -
- {!isIOS && ( - - )} - {isIOS && ( -
- -
- )} - -
-
-
- ); -} diff --git a/lib/hooks/usePWAInstall.ts b/lib/hooks/usePWAInstall.ts deleted file mode 100644 index 2e8919b..0000000 --- a/lib/hooks/usePWAInstall.ts +++ /dev/null @@ -1,86 +0,0 @@ -'use client'; - -import { useState, useEffect } from 'react'; - -interface BeforeInstallPromptEvent extends Event { - readonly platforms: string[]; - readonly userChoice: Promise<{ - outcome: 'accepted' | 'dismissed'; - platform: string; - }>; - prompt(): Promise; -} - -export function usePWAInstall() { - const [deferredPrompt, setDeferredPrompt] = useState(null); - const [isInstallable, setIsInstallable] = useState(false); - const [isInstalled, setIsInstalled] = useState(false); - const [isIOS, setIsIOS] = useState(false); - const [isStandalone, setIsStandalone] = useState(false); - - useEffect(() => { - // Check if app is already installed/standalone - const checkStandalone = () => { - const isStandaloneMode = window.matchMedia('(display-mode: standalone)').matches - || (window.navigator as any).standalone - || document.referrer.includes('android-app://'); - setIsStandalone(isStandaloneMode); - setIsInstalled(isStandaloneMode); - }; - - checkStandalone(); - - // Check if iOS - const checkIOS = () => { - const ua = window.navigator.userAgent.toLowerCase(); - const isIOSDevice = /iphone|ipad|ipod/.test(ua); - setIsIOS(isIOSDevice); - }; - - checkIOS(); - - const handleBeforeInstallPrompt = (e: Event) => { - // Prevent the mini-infobar from appearing on mobile - e.preventDefault(); - // Stash the event so it can be triggered later. - setDeferredPrompt(e as BeforeInstallPromptEvent); - setIsInstallable(true); - }; - - const handleAppInstalled = () => { - setIsInstalled(true); - setIsInstallable(false); - setDeferredPrompt(null); - }; - - window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt); - window.addEventListener('appinstalled', handleAppInstalled); - - return () => { - window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt); - window.removeEventListener('appinstalled', handleAppInstalled); - }; - }, []); - - const handleInstallClick = async () => { - if (!deferredPrompt) return; - - // Show the install prompt - deferredPrompt.prompt(); - - // Wait for the user to respond to the prompt - const { outcome } = await deferredPrompt.userChoice; - - if (outcome === 'accepted') { - setIsInstallable(false); - setDeferredPrompt(null); - } - }; - - return { - isInstallable: isInstallable && !isInstalled, - isIOS: isIOS && !isStandalone, - isInstalled, - handleInstallClick, - }; -} diff --git a/package-lock.json b/package-lock.json index ab1e91a..642b1a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kvideo", - "version": "3.9.0", + "version": "3.8.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kvideo", - "version": "3.9.0", + "version": "3.8.9", "dependencies": { "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", diff --git a/package.json b/package.json index 0826697..5dde87f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kvideo", - "version": "3.9.0", + "version": "3.8.9", "private": true, "scripts": { "dev": "next dev", diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index 3b5f9b1..0000000 --- a/public/manifest.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "KVideo - 视频聚合平台", - "short_name": "KVideo", - "description": "视频聚合平台", - "start_url": "/", - "display": "standalone", - "background_color": "#000000", - "theme_color": "#000000", - "icons": [ - { - "src": "/icon.png", - "sizes": "1024x1024", - "type": "image/png", - "purpose": "any maskable" - } - ] -} \ No newline at end of file