diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 65b8f9a..59becea 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -4,6 +4,7 @@ - [Configuration](configuration.md) - [API Configuration](API-configuration.md) - [I18n](i18n.md) + - [Layout](layout.md) - [Request](request.md) - Guide - [Deploy](deploy.md) diff --git a/docs/configuration.md b/docs/configuration.md index 2d58b14..c95e231 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -39,7 +39,7 @@ You can do some custom configuration in `/src/utils/config.js`: Configuration? Which routes use which layout, unspecified route uses the default layout `Public`, the project currently has `Primary` and `Public` layouts, The default configuration is as follows: - ```js + ```javascript layouts: [ { name: 'primary', @@ -57,7 +57,7 @@ You can do some custom configuration in `/src/utils/config.js`: - `exlude` - Specifies a list of routing rules that do not use this layout, which can be a regular expression or a string. - > Note: `exlude` takes precedence over `include`, and the layout behind it has a higher priority than the previous layout. The development process may need to be combined with the layout in the `src/layouts` directory. For details, see [Using Layout](). + > Note: `exlude` takes precedence over `include`, and the layout previous it has a higher priority than the behind layout. The development process may need to be combined with the layout in the `src/layouts` directory. For details, see [Using Layout](./layout.md). ## i18n @@ -65,7 +65,7 @@ You can do some custom configuration in `/src/utils/config.js`: Configure internationalization, the default configuration is as follows: - ```js + ```javascript i18n: { languages: [ { diff --git a/docs/layout.md b/docs/layout.md new file mode 100644 index 0000000..516d459 --- /dev/null +++ b/docs/layout.md @@ -0,0 +1,60 @@ +# Layout + +## Add a new layout + +Take a new layout named `secondary` as an example to make the route starting with `seconday` use this layout. + +1. Add related configuration in `src/utils/config.js`. For details, please refer to [layouts](/configuration?id=layouts). + + ```javascript + layouts: [ + { + name: 'primary', + include: [/.*/], + exlude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/seconday\/(.*)/], + }, + { + name: 'secondary', + include: [/(\/(en|zh))*\/seconday\/(.*)/], + }, + ], + ``` + +2. Add the `secondary` layout component to the `src/layouts/BaseLayout.js` file. + + ```javascript + import SecondaryLayout from './SecondaryLayout' + + const LayoutMap = { + Primary: PrimaryLayout, + Public: PublicLayout, + Secondary: SecondaryLayout, + } + ``` + +3. Add the `SecondaryLayout.js` file to the `src/layouts/` directory. + + ```javascript + import React from 'react' + + export default ({ children }) => { + Return ( +