mirror of
https://github.com/langgenius/dify.git
synced 2026-03-01 12:55:13 +00:00
Compare commits
6 Commits
move-token
...
copilot/su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5a7e7aede | ||
|
|
57df92aba7 | ||
|
|
e6d925cad0 | ||
|
|
ed34e302f2 | ||
|
|
b6141a135c | ||
|
|
00ec2c2623 |
@@ -1,3 +1,36 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
export { SerwistProvider } from '@serwist/turbopack/react'
|
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) => {
|
||||||
|
return Promise.all(
|
||||||
|
registrations.map(registration => registration.unregister()),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
// Silently fail if service worker unregistration fails
|
||||||
|
// This is a development-only optimization and shouldn't block the app
|
||||||
|
console.warn('Failed to unregister service workers:', error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
if (IS_DEV) {
|
||||||
|
return <>{children}</>
|
||||||
|
}
|
||||||
|
|
||||||
|
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
||||||
|
const swUrl = `${basePath}/serwist/sw.js`
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SerwistProvider swUrl={swUrl}>
|
||||||
|
{children}
|
||||||
|
</SerwistProvider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { ToastProvider } from './components/base/toast'
|
|||||||
import BrowserInitializer from './components/browser-initializer'
|
import BrowserInitializer from './components/browser-initializer'
|
||||||
import { ReactScanLoader } from './components/devtools/react-scan/loader'
|
import { ReactScanLoader } from './components/devtools/react-scan/loader'
|
||||||
import { I18nServerProvider } from './components/provider/i18n-server'
|
import { I18nServerProvider } from './components/provider/i18n-server'
|
||||||
import { SerwistProvider } from './components/provider/serwist'
|
import { PWAProvider } from './components/provider/serwist'
|
||||||
import SentryInitializer from './components/sentry-initializer'
|
import SentryInitializer from './components/sentry-initializer'
|
||||||
import RoutePrefixHandle from './routePrefixHandle'
|
import RoutePrefixHandle from './routePrefixHandle'
|
||||||
import './styles/globals.css'
|
import './styles/globals.css'
|
||||||
@@ -40,9 +40,6 @@ const LocaleLayout = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
const locale = await getLocaleOnServer()
|
const locale = await getLocaleOnServer()
|
||||||
|
|
||||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
|
|
||||||
const swUrl = `${basePath}/serwist/sw.js`
|
|
||||||
|
|
||||||
const datasetMap: Record<DatasetAttr, string | undefined> = {
|
const datasetMap: Record<DatasetAttr, string | undefined> = {
|
||||||
[DatasetAttr.DATA_API_PREFIX]: process.env.NEXT_PUBLIC_API_PREFIX,
|
[DatasetAttr.DATA_API_PREFIX]: process.env.NEXT_PUBLIC_API_PREFIX,
|
||||||
[DatasetAttr.DATA_PUBLIC_API_PREFIX]: process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX,
|
[DatasetAttr.DATA_PUBLIC_API_PREFIX]: process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX,
|
||||||
@@ -96,7 +93,7 @@ const LocaleLayout = async ({
|
|||||||
className="color-scheme h-full select-auto"
|
className="color-scheme h-full select-auto"
|
||||||
{...datasetMap}
|
{...datasetMap}
|
||||||
>
|
>
|
||||||
<SerwistProvider swUrl={swUrl}>
|
<PWAProvider>
|
||||||
<ReactScanLoader />
|
<ReactScanLoader />
|
||||||
<JotaiProvider>
|
<JotaiProvider>
|
||||||
<ThemeProvider
|
<ThemeProvider
|
||||||
@@ -124,7 +121,7 @@ const LocaleLayout = async ({
|
|||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</JotaiProvider>
|
</JotaiProvider>
|
||||||
<RoutePrefixHandle />
|
<RoutePrefixHandle />
|
||||||
</SerwistProvider>
|
</PWAProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user