mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 12:59:18 +08:00
feat: proactively unregister service workers in dev mode
Co-authored-by: hyoban <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
parent
ed34e302f2
commit
e6d925cad0
@ -1,9 +1,20 @@
|
||||
'use client'
|
||||
|
||||
import { SerwistProvider } from '@serwist/turbopack/react'
|
||||
import { useEffect } from 'react'
|
||||
import { IS_DEV } from '@/config'
|
||||
|
||||
export function PWAProvider({ children }: { children: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
if (IS_DEV && 'serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.getRegistrations().then((registrations) => {
|
||||
registrations.forEach((registration) => {
|
||||
registration.unregister()
|
||||
})
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
if (IS_DEV) {
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user