mirror of
https://github.com/zuiidea/antd-admin.git
synced 2024-04-21 12:32:14 +00:00
1.7 KiB
1.7 KiB
Layout
Add a new layout
Take a new layout named secondary as an example to make the route starting with seconday use this layout.
- Add related configuration in
src/utils/config.js. For details, please refer to layouts.
layouts: [
{
name: 'primary',
include: [/.*/],
exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/seconday\/(.*)/],
},
{
name: 'secondary',
include: [/(\/(en|zh))*\/seconday\/(.*)/],
},
],
- Add the
secondarylayout component to thesrc/layouts/BaseLayout.jsfile.
import SecondaryLayout from './SecondaryLayout'
const LayoutMap = {
Primary: PrimaryLayout,
Public: PublicLayout,
Secondary: SecondaryLayout,
}
- Add the
SecondaryLayout.jsfile to thesrc/layouts/directory.
import React from 'react'
export default ({ children }) => {
Return (
<div>
<h1>Seconday</h1>
{children}
</div>
)
}
- Add a
seconday/index.jsfile to thesrc/pages/directory.
import React from 'react'
export default ({ children }) => {
Return <div>Seconday page Content</div>
}
- Finally, start the development mode
npm run start, open http://localhost:7000/seconday/ and you will see the page for thesecondaylayout.