diff --git a/src/AuthRoute.tsx b/src/AuthRoute.tsx index 57948cb..a70354f 100644 --- a/src/AuthRoute.tsx +++ b/src/AuthRoute.tsx @@ -1,4 +1,5 @@ import { getLoginStatus } from '@/utils/auth.ts' +import { PRODUCTION_NAME } from '@/constants/Common.constants.ts' const AuthRoute = () => { const matches = useMatches() @@ -8,6 +9,9 @@ const AuthRoute = () => { const isLogin = getLoginStatus() return useMemo(() => { + document.title = `${handle?.titlePrefix ?? ''}${ + handle?.title ? handle?.title : PRODUCTION_NAME + }${handle?.titlePostfix ?? ''}` if (handle?.auth && !isLogin) { return } @@ -15,7 +19,15 @@ const AuthRoute = () => { return } return outlet - }, [handle?.auth, isLogin, lastMatch.pathname, outlet]) + }, [ + handle?.auth, + handle?.title, + handle?.titlePostfix, + handle?.titlePrefix, + isLogin, + lastMatch.pathname, + outlet + ]) } export default AuthRoute diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 324bb5f..1311793 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -13,6 +13,9 @@ type RouteHandle = { name?: string menu?: boolean auth?: boolean + titlePrefix?: string + title?: string + titlePostfix?: string } type _Response = {