diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 8d7b170..b743f52 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -3,6 +3,8 @@ // import list from '../utils/router'; // import { useState } from 'react' // import { Alert } from 'antd'; +import { useEffect, useState } from "react"; + import { motion } from "framer-motion" import isVip from "../utils/isVip" @@ -35,6 +37,27 @@ export default function Navbar() { // const [showText , setShowText] = useState(false) // const location = useLocation() // const tag = list.done.find((e)=> e.url === location.pathname) + + const [registration, setRegistration] = useState(null); + + useEffect(() => { + // Check if service worker is supported + if ('serviceWorker' in navigator) { + // Register the service worker + navigator.serviceWorker.register('/sw.js').then((reg) => { + setRegistration(reg); + }); + } + }, []); + + const updateServiceWorker = () => { + if (registration) { + registration.update(); + } else { + console.log('无更新'); + } + }; + return (
@@ -60,12 +83,17 @@ export default function Navbar() { } */} {/* */} - + {registration? +
+
+ {/*
有更新可用!
*/} +
有更新:v0.4.3
+
+ +
:'' + } + {/*
-
- {/* -
-
请我喝咖啡
*/}