mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 22:46:38 +08:00
9f15f42b47
Document that NEXT_PUBLIC_WAVELET_BACKEND_URL must stay unset for local next dev so axios hits /api/* and Next rewrites proxy to the backend.
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
'use client';
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useEffect } from 'react';
|
|
import { ConfigService } from '@/lib/services/config';
|
|
import { usePathname } from 'next/navigation';
|
|
import { useTranslations } from 'next-intl';
|
|
|
|
export function SiteTitleUpdater() {
|
|
const pathname = usePathname();
|
|
const t = useTranslations('providers.titleUpdater');
|
|
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 = ` - ${t('login')}`;
|
|
} else if (pathname === '/register') {
|
|
suffix = ` - ${t('register')}`;
|
|
} else if (pathname.startsWith('/admin')) {
|
|
suffix = ` - ${t('admin')}`;
|
|
} else if (pathname === '/home') {
|
|
suffix = ` - ${t('dashboard')}`;
|
|
} else if (pathname === '/') {
|
|
suffix = '';
|
|
}
|
|
|
|
document.title = `${siteName}${suffix}`;
|
|
}, [publicConfigQuery.data?.site_name, pathname, t]);
|
|
|
|
return null;
|
|
}
|