Files
OpenFlare/frontend/components/providers/title-updater.tsx
T
ryan a44043262e perf(frontend): split admin bundles and tighten data fetching
Add next/dynamic lazy loading for database, logs, and settings heavy
modules; migrate access-logs and task-executions to React Query; parallelize
login auth-sources with public config; consolidate users table tooltips;
enable lazy image decoding; and replace barrel @/lib/services imports with
direct module paths.
2026-06-17 12:12:47 +08:00

37 lines
1008 B
TypeScript

"use client"
import {useQuery} from '@tanstack/react-query'
import {useEffect} from 'react'
import {ConfigService} from '@/lib/services/config'
import {usePathname} from 'next/navigation'
export function SiteTitleUpdater() {
const pathname = usePathname()
const publicConfigQuery = useQuery({
queryKey: ["public-config"],
queryFn: () => ConfigService.getPublicConfig(),
})
useEffect(() => {
const siteName = publicConfigQuery.data?.site_name || "Wavelet Platform"
// Determine the page suffix based on path
let suffix = ""
if (pathname === "/login") {
suffix = " - 登录"
} else if (pathname === "/register") {
suffix = " - 注册"
} else if (pathname.startsWith("/admin")) {
suffix = " - 后台管理"
} else if (pathname === "/home") {
suffix = " - 控制台"
} else if (pathname === "/") {
suffix = ""
}
document.title = `${siteName}${suffix}`
}, [publicConfigQuery.data?.site_name, pathname])
return null
}