forked from WinmezzZ/react-antd-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
69 additions
and
29,367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,25 @@ | ||
import React, { FC } from 'react' | ||
import { Route, RouteConfigObject } from 'react-router-dom' | ||
import { Route } from 'react-router-dom' | ||
import { RouteProps } from 'react-router' | ||
import PrivateRoute from './pravateRoute' | ||
import { useIntl } from 'react-intl' | ||
|
||
export interface RouteProps extends RouteConfigObject { | ||
meta: { | ||
/** document title locale id */ | ||
titleId: string | ||
/** authorization? */ | ||
auth?: boolean | ||
} | ||
children?: RouteProps[] | ||
} | ||
|
||
interface Props { | ||
routes: RouteProps[] | ||
export interface WrapperRouteProps extends RouteProps { | ||
/** document title locale id */ | ||
titleId: string | ||
/** authorization? */ | ||
auth?: boolean | ||
} | ||
|
||
const RenderRoutes: FC<Props> = ({ routes }) => { | ||
const WrapperRouteComponent: FC<WrapperRouteProps> = ({ titleId, auth, ...props }) => { | ||
const { formatMessage } = useIntl() | ||
return ( | ||
<> | ||
{routes.map(route => { | ||
const { meta } = route | ||
const { titleId, auth } = meta | ||
const WitchRoute = auth ? PrivateRoute : Route | ||
meta.titleId && | ||
(document.title = formatMessage({ | ||
id: titleId | ||
})) | ||
return WitchRoute | ||
})} | ||
</> | ||
) | ||
const WitchRoute = auth ? PrivateRoute : Route | ||
if (titleId) { | ||
document.title = formatMessage({ | ||
id: titleId | ||
}) | ||
} | ||
return <WitchRoute {...props} /> | ||
} | ||
|
||
export default RenderRoutes | ||
export default WrapperRouteComponent |
Oops, something went wrong.