feat: add layout header which ensure title of page is correct
This commit is contained in:
parent
e2fc9224c7
commit
120df2d8b5
18
src/client/pages/Layout/Header.tsx
Normal file
18
src/client/pages/Layout/Header.tsx
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { useUserInfo } from '@/store/user';
|
||||||
|
import React from 'react';
|
||||||
|
import { Helmet } from 'react-helmet';
|
||||||
|
|
||||||
|
export const LayoutHeader: React.FC = React.memo(() => {
|
||||||
|
const userInfo = useUserInfo();
|
||||||
|
let title = 'Tianji - Insight into everything';
|
||||||
|
if (userInfo) {
|
||||||
|
title = userInfo.currentWorkspace.name + ' | ' + title;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Helmet>
|
||||||
|
<title>{title}</title>
|
||||||
|
</Helmet>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
LayoutHeader.displayName = 'LayoutHeader';
|
@ -1,3 +1,4 @@
|
|||||||
|
import { LayoutHeader } from '@/pages/Layout/Header';
|
||||||
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router';
|
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router';
|
||||||
// import { TanStackRouterDevtools } from '@tanstack/router-devtools';
|
// import { TanStackRouterDevtools } from '@tanstack/router-devtools';
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
@ -12,6 +13,8 @@ export const Route = createRootRouteWithContext<RouterContext>()({
|
|||||||
return (
|
return (
|
||||||
// https://github.com/TanStack/router/issues/857
|
// https://github.com/TanStack/router/issues/857
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
|
<LayoutHeader />
|
||||||
|
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
|
||||||
{/* <TanStackRouterDevtools position="bottom-right" /> */}
|
{/* <TanStackRouterDevtools position="bottom-right" /> */}
|
||||||
|
@ -3,7 +3,6 @@ import { ErrorTip } from '@/components/ErrorTip';
|
|||||||
import { Loading } from '@/components/Loading';
|
import { Loading } from '@/components/Loading';
|
||||||
import { NotFoundTip } from '@/components/NotFoundTip';
|
import { NotFoundTip } from '@/components/NotFoundTip';
|
||||||
import { MonitorStatusPage } from '@/components/monitor/StatusPage';
|
import { MonitorStatusPage } from '@/components/monitor/StatusPage';
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
import { createFileRoute } from '@tanstack/react-router';
|
||||||
|
|
||||||
export const Route = createFileRoute('/status/$slug')({
|
export const Route = createFileRoute('/status/$slug')({
|
||||||
|
Loading…
Reference in New Issue
Block a user