├── docs ├── .nojekyll ├── img │ ├── favicon.ico │ ├── rrm-logo.png │ └── docusaurus.png └── assets │ ├── images │ ├── localeDropdown-f0d995e751e7656a1b0dbbc1134e49c2.png │ ├── docsVersionDropdown-35e13cbe46c9923327f30a76a90bff3b.png │ └── docusaurus-plushie-banner-a60f7593abca1e3eef26a9afa244e4fb.jpeg │ └── js │ ├── 5e3106fb.fdb697ed.js │ ├── 80b002d6.c136f31e.js │ ├── ec408539.56917c2d.js │ ├── 1897ff02.dc84d8c2.js │ ├── f7521111.584dd3bd.js │ ├── b0f97ac5.c072f860.js │ ├── 11dd5695.ab75d6b0.js │ ├── 6c88cea6.4a33a54b.js │ ├── 16cda1d6.2211642d.js │ ├── 50805dbf.4c9ea0fd.js │ ├── 731a0905.0ae7809a.js │ ├── 84a82062.54fb4016.js │ ├── 8e02645a.111b319c.js │ ├── 814f3328.98156c54.js │ ├── 81841653.cd624153.js │ ├── b80a438f.48394979.js │ ├── main.e3a6ce89.js.LICENSE.txt │ └── 4972.9fc7005b.js ├── website ├── static │ ├── .nojekyll │ └── img │ │ ├── favicon.ico │ │ ├── docusaurus.png │ │ └── docusaurus-social-card.jpg ├── babel.config.js ├── docs │ ├── tutorial-extras │ │ ├── img │ │ │ ├── localeDropdown.png │ │ │ └── docsVersionDropdown.png │ │ ├── _category_.json │ │ ├── manage-docs-versions.md │ │ └── translate-your-site.md │ ├── tutorial-basics │ │ ├── _category_.json │ │ ├── deploy-your-site.md │ │ ├── create-a-blog-post.md │ │ ├── congratulations.md │ │ ├── create-a-page.md │ │ └── create-a-document.md │ └── intro.md ├── src │ ├── pages │ │ ├── markdown-page.md │ │ ├── index.module.css │ │ └── index.tsx │ ├── components │ │ └── HomepageFeatures │ │ │ ├── styles.module.css │ │ │ └── index.tsx │ └── css │ │ └── custom.css ├── blog │ ├── 2021-08-26-welcome │ │ ├── docusaurus-plushie-banner.jpeg │ │ └── index.md │ ├── 2019-05-28-first-blog-post.md │ ├── authors.yml │ ├── 2021-08-01-mdx-blog-post.mdx │ └── 2019-05-29-long-blog-post.md ├── tsconfig.json ├── .gitignore ├── sidebars.ts ├── README.md └── package.json ├── .gitattributes ├── examples ├── basic │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── Home.tsx │ │ ├── main.tsx │ │ ├── index.css │ │ └── App.tsx │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── actions │ ├── postcss.config.js │ ├── src │ │ ├── vite-env.d.ts │ │ ├── Home.tsx │ │ ├── main.tsx │ │ └── index.css │ ├── .stackblitzrc │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── beforeEnter │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── Home.tsx │ │ ├── main.tsx │ │ ├── index.css │ │ └── App.tsx │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── children │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── Home.tsx │ │ ├── main.tsx │ │ └── index.css │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── custom-link │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ ├── index.css │ │ └── App.tsx │ ├── index.html │ ├── README.md │ ├── tsconfig.json │ ├── package.json │ └── vite.config.ts ├── permission │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── Home.tsx │ │ ├── main.tsx │ │ └── index.css │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── antd-breadcrumbs │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── Home.tsx │ │ ├── pages │ │ │ ├── email │ │ │ │ └── index.tsx │ │ │ ├── my-page │ │ │ │ └── index.tsx │ │ │ ├── contact │ │ │ │ ├── index.tsx │ │ │ │ ├── grid-view │ │ │ │ │ └── index.tsx │ │ │ │ └── list-view │ │ │ │ │ └── index.tsx │ │ │ ├── project │ │ │ │ ├── clients │ │ │ │ │ └── index.tsx │ │ │ │ ├── index.tsx │ │ │ │ ├── todo-list │ │ │ │ │ └── index.tsx │ │ │ │ ├── task-board │ │ │ │ │ └── index.tsx │ │ │ │ ├── ticket-list │ │ │ │ │ └── index.tsx │ │ │ │ └── project-list │ │ │ │ │ └── index.tsx │ │ │ ├── messenger │ │ │ │ └── index.tsx │ │ │ └── dashboard │ │ │ │ ├── detail │ │ │ │ └── index.tsx │ │ │ │ └── index.tsx │ │ ├── main.tsx │ │ ├── index.css │ │ ├── App.tsx │ │ └── router │ │ │ └── index.tsx │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── beforeEachMount │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── Home.tsx │ │ ├── main.tsx │ │ └── index.css │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── lazy-loading │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── pages │ │ │ ├── About.tsx │ │ │ ├── DashboardIndex.tsx │ │ │ ├── Messages.tsx │ │ │ ├── DashboardLayout.tsx │ │ │ └── Dashboard.tsx │ │ ├── main.tsx │ │ └── index.css │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── custom-filter-link │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ ├── index.css │ │ └── snkrs.ts │ ├── index.html │ ├── README.md │ ├── tsconfig.json │ ├── package.json │ └── vite.config.ts ├── custom-query-parsing │ ├── postcss.config.js │ ├── .stackblitzrc │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ └── index.css │ ├── types │ │ └── jsurl.d.ts │ ├── index.html │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── vite.config.ts ├── auth │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ ├── index.css │ │ └── auth.ts │ └── index.html └── README.md ├── .browserslistrc ├── postcss.config.js ├── test ├── index.test.js └── changeable.test.js ├── types └── index.d.ts ├── .eslintrc ├── packages ├── react-router-manage │ ├── src │ │ ├── window.ts │ │ ├── components │ │ │ ├── Spin │ │ │ │ └── index.tsx │ │ │ ├── NotFound │ │ │ │ └── index.tsx │ │ │ ├── NameRedirect │ │ │ │ └── index.tsx │ │ │ ├── RedirectChild │ │ │ │ └── index.tsx │ │ │ └── NoAuth │ │ │ │ └── index.tsx │ │ ├── util │ │ │ └── proxy.ts │ │ ├── changeable.tsx │ │ ├── Context │ │ │ ├── MRouterHistoryContext.tsx │ │ │ └── MRouterContext │ │ │ │ └── index.tsx │ │ ├── index.tsx │ │ └── core │ │ │ ├── MRouterContextProvider │ │ │ ├── replaceHistoryMethods.ts │ │ │ ├── getInitialState.ts │ │ │ └── computedUseRoutesConfig.tsx │ │ │ ├── HashRouter │ │ │ └── index.tsx │ │ │ ├── BrowserRouter │ │ │ └── index.tsx │ │ │ └── CoreRouter.tsx │ ├── README.zh-CN.md │ ├── .eslintrc │ ├── node-main.js │ ├── tsconfig.json │ ├── package.json │ ├── CHANGELOG.md │ └── README.md ├── breadcrumbs │ ├── .eslintrc │ ├── node-main.js │ ├── index.tsx │ ├── tsconfig.json │ └── package.json ├── keep-alive │ ├── .eslintrc │ ├── node-main.js │ ├── index.tsx │ ├── tsconfig.json │ └── package.json └── antd-breadcrumbs │ ├── .eslintrc │ ├── node-main.js │ ├── tsconfig.json │ ├── package.json │ ├── CHANGELOG.md │ └── index.tsx ├── dist ├── assets │ ├── Home-57870331.js │ ├── Home-79ae00a3.js │ ├── index-2e05da30.css │ └── preload-helper-101896b7.js ├── index.html └── entry │ ├── basic │ └── index.html │ └── antd-breadcrumbs │ └── index.html ├── tsconfig.json ├── .eslintignore ├── .editorconfig ├── .npmignore ├── .gitignore ├── prettier.config.js ├── .commitlintrc.js ├── .changeset ├── config.json └── README.md ├── entry ├── auth │ └── index.html ├── children │ └── index.html ├── basic │ └── index.html ├── beforeEnter │ └── index.html ├── permission │ └── index.html ├── custom-link │ └── index.html ├── lazy-loading │ └── index.html ├── beforeEachMount │ └── index.html ├── antd-breadcrumbs │ └── index.html ├── custom-filter-link │ └── index.html └── custom-query-parsing │ └── index.html ├── rollup.config.js ├── babel.config.js ├── index.html ├── vite.config.ts ├── jest.config.js └── rollup.utils.js /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js text eol=lf -------------------------------------------------------------------------------- /examples/basic/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/actions/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/beforeEnter/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/children/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/custom-link/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/permission/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/beforeEachMount/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/lazy-loading/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/custom-filter-link/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /examples/actions/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # Browsers that we support 2 | 3 | last 2 Chrome versions 4 | -------------------------------------------------------------------------------- /docs/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/docs/img/favicon.ico -------------------------------------------------------------------------------- /docs/img/rrm-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/docs/img/rrm-logo.png -------------------------------------------------------------------------------- /docs/img/docusaurus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/docs/img/docusaurus.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require('autoprefixer') 4 | ] 5 | }; 6 | -------------------------------------------------------------------------------- /examples/actions/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/basic/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/beforeEnter/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/children/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/custom-link/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/lazy-loading/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/permission/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/beforeEachMount/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /test/index.test.js: -------------------------------------------------------------------------------- 1 | test('show', () => { 2 | expect('Hello World hanmeimei').toBe('Hello World hanmeimei'); 3 | }); 4 | -------------------------------------------------------------------------------- /website/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/website/static/img/favicon.ico -------------------------------------------------------------------------------- /examples/custom-filter-link/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "installDependencies": true, 3 | "startCommand": "npm run dev" 4 | } 5 | -------------------------------------------------------------------------------- /types/index.d.ts: -------------------------------------------------------------------------------- 1 | interface Window { 2 | __INITIAL_DATA__: { 3 | basename: string; 4 | mode: string; 5 | }; 6 | } 7 | -------------------------------------------------------------------------------- /website/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /website/static/img/docusaurus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/website/static/img/docusaurus.png -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["react-app", "plugin:react-hooks/recommended"], 3 | "rules": { 4 | "import/first": 0 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/window.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | interface Window { 3 | __DEV__: boolean; 4 | } 5 | } 6 | 7 | export {}; 8 | -------------------------------------------------------------------------------- /dist/assets/Home-57870331.js: -------------------------------------------------------------------------------- 1 | import{b as e}from"./index-7b920573.js";const o=()=>e("div",{children:e("h2",{children:"Home"})});export{o as default}; 2 | -------------------------------------------------------------------------------- /dist/assets/Home-79ae00a3.js: -------------------------------------------------------------------------------- 1 | import{b as e}from"./index-7b920573.js";const o=()=>e("div",{children:e("h2",{children:"Home"})});export{o as default}; 2 | -------------------------------------------------------------------------------- /website/static/img/docusaurus-social-card.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/website/static/img/docusaurus-social-card.jpg -------------------------------------------------------------------------------- /packages/react-router-manage/README.zh-CN.md: -------------------------------------------------------------------------------- 1 | # react-router-manage 2 | 3 | [docs](https://github.com/NSFI/react-router-manage/blob/main/README.zh-CN.md) 4 | -------------------------------------------------------------------------------- /website/docs/tutorial-extras/img/localeDropdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/website/docs/tutorial-extras/img/localeDropdown.png -------------------------------------------------------------------------------- /website/docs/tutorial-extras/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Tutorial - Extras", 3 | "position": 3, 4 | "link": { 5 | "type": "generated-index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /website/docs/tutorial-extras/img/docsVersionDropdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/website/docs/tutorial-extras/img/docsVersionDropdown.png -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "packages/react-router-manage" }, 5 | { "path": "packages/antd-breadcrumbs" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /website/src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /examples/auth/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /examples/basic/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /website/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/website/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg -------------------------------------------------------------------------------- /examples/beforeEnter/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /examples/children/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /examples/custom-link/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /examples/permission/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # Ignore 2 | /test 3 | /node_modules 4 | /dist 5 | /build 6 | /es 7 | babel.config.js 8 | jest.config.js 9 | postcss.config.js 10 | demo/webpack.config.js 11 | demo/test.js -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /examples/beforeEachMount/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /docs/assets/images/localeDropdown-f0d995e751e7656a1b0dbbc1134e49c2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/docs/assets/images/localeDropdown-f0d995e751e7656a1b0dbbc1134e49c2.png -------------------------------------------------------------------------------- /examples/custom-filter-link/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | interface Window { 3 | __INITIAL_DATA__: { 4 | basename: string; 5 | mode: string; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # 确保与 Prettier 配置一致 2 | [*] 3 | charset = utf-8 4 | end_of_line = lf 5 | insert_final_newline = true 6 | indent_style = space 7 | indent_size = 2 8 | 9 | [*.md] 10 | max_line_length = 1000 -------------------------------------------------------------------------------- /docs/assets/images/docsVersionDropdown-35e13cbe46c9923327f30a76a90bff3b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/docs/assets/images/docsVersionDropdown-35e13cbe46c9923327f30a76a90bff3b.png -------------------------------------------------------------------------------- /examples/basic/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Home: React.FC = () => { 3 | return ( 4 |
5 |

Home

6 |
7 | ); 8 | }; 9 | 10 | export default Home; 11 | -------------------------------------------------------------------------------- /docs/assets/images/docusaurus-plushie-banner-a60f7593abca1e3eef26a9afa244e4fb.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NSFI/react-router-manage/HEAD/docs/assets/images/docusaurus-plushie-banner-a60f7593abca1e3eef26a9afa244e4fb.jpeg -------------------------------------------------------------------------------- /examples/actions/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Home: React.FC = () => { 3 | return ( 4 |
5 |

Home

6 |
7 | ); 8 | }; 9 | 10 | export default Home; 11 | -------------------------------------------------------------------------------- /examples/children/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Home: React.FC = () => { 3 | return ( 4 |
5 |

Home

6 |
7 | ); 8 | }; 9 | 10 | export default Home; 11 | -------------------------------------------------------------------------------- /examples/permission/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Home: React.FC = () => { 3 | return ( 4 |
5 |

Home

6 |
7 | ); 8 | }; 9 | 10 | export default Home; 11 | -------------------------------------------------------------------------------- /packages/breadcrumbs/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true 5 | }, 6 | "globals": { 7 | "__DEV__": true 8 | }, 9 | "rules": { 10 | "strict": 0 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/keep-alive/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true 5 | }, 6 | "globals": { 7 | "__DEV__": true 8 | }, 9 | "rules": { 10 | "strict": 0 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /website/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // This file is not used in compilation. It is here just for a nice editor experience. 3 | "extends": "@docusaurus/tsconfig", 4 | "compilerOptions": { 5 | "baseUrl": "." 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/beforeEachMount/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Home: React.FC = () => { 3 | return ( 4 |
5 |

Home

6 |
7 | ); 8 | }; 9 | 10 | export default Home; 11 | -------------------------------------------------------------------------------- /packages/antd-breadcrumbs/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true 5 | }, 6 | "globals": { 7 | "__DEV__": true 8 | }, 9 | "rules": { 10 | "strict": 0 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/components/Spin/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Spin: React.FC<{ tip: string }> = ({ tip = "加载中" }) => { 3 | return
{tip}
; 4 | }; 5 | 6 | export default Spin; 7 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Home: React.FC = () => { 3 | return ( 4 |
5 |

Home

6 |
7 | ); 8 | }; 9 | 10 | export default Home; 11 | -------------------------------------------------------------------------------- /packages/react-router-manage/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true 5 | }, 6 | "globals": { 7 | "__DEV__": true 8 | }, 9 | "rules": { 10 | "strict": 0 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/pages/About.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | function AboutPage() { 4 | return ( 5 |
6 |

About

7 |
8 | ); 9 | } 10 | 11 | export default AboutPage; 12 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/pages/DashboardIndex.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | export default function DashboardIndex() { 4 | return ( 5 |
6 |

Dashboard Index

7 |
8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/types/jsurl.d.ts: -------------------------------------------------------------------------------- 1 | declare module "jsurl" { 2 | type Nullable = T | null | undefined; 3 | export function stringify(input: any): string; 4 | export function parse(input?: Nullable): Nullable; 5 | } 6 | -------------------------------------------------------------------------------- /website/src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/components/NotFound/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import NoAuth from "../NoAuth"; 3 | 4 | const NotFound: React.FC = () => { 5 | return ; 6 | }; 7 | 8 | export default NotFound; 9 | -------------------------------------------------------------------------------- /website/docs/tutorial-basics/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Tutorial - Basics", 3 | "position": 2, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "5 minutes to learn the most important Docusaurus concepts." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/beforeEnter/src/Home.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | const Home: React.FC = props => { 3 | console.log(props); 4 | return ( 5 |
6 |

Home

7 |
8 | ); 9 | }; 10 | 11 | export default Home; 12 | -------------------------------------------------------------------------------- /packages/breadcrumbs/node-main.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | if (process.env.NODE_ENV === "production") { 4 | module.exports = require("./umd/antd-breadcrumbs.production.min.js"); 5 | } else { 6 | module.exports = require("./umd/antd-breadcrumbs..development.js"); 7 | } 8 | -------------------------------------------------------------------------------- /packages/keep-alive/node-main.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | if (process.env.NODE_ENV === "production") { 4 | module.exports = require("./umd/antd-breadcrumbs.production.min.js"); 5 | } else { 6 | module.exports = require("./umd/antd-breadcrumbs..development.js"); 7 | } 8 | -------------------------------------------------------------------------------- /packages/antd-breadcrumbs/node-main.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | if (process.env.NODE_ENV === "production") { 4 | module.exports = require("./umd/antd-breadcrumbs.production.min.js"); 5 | } else { 6 | module.exports = require("./umd/antd-breadcrumbs..development.js"); 7 | } 8 | -------------------------------------------------------------------------------- /packages/react-router-manage/node-main.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | if (process.env.NODE_ENV === "production") { 4 | module.exports = require("./umd/react-router-manage.production.min.js"); 5 | } else { 6 | module.exports = require("./umd/react-router-manage.development.js"); 7 | } 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | demo/ 2 | test/ 3 | examples/ 4 | coverage/ 5 | .commitlintrc.js 6 | .eslintignore 7 | .eslintrc.js 8 | .gitattributes 9 | .gitignore 10 | .gitlab-ci.yml 11 | .huskyrc.js 12 | .npmignore 13 | babel.config.js 14 | CHANGELOG.md 15 | postcss.config.js 16 | tsconfig.json 17 | jest.config.js -------------------------------------------------------------------------------- /dist/assets/index-2e05da30.css: -------------------------------------------------------------------------------- 1 | body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace} 2 | -------------------------------------------------------------------------------- /docs/assets/js/5e3106fb.fdb697ed.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [3805], 4 | { 5 | 4469: s => { 6 | s.exports = JSON.parse( 7 | '{"name":"docusaurus-plugin-content-blog","id":"default"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /docs/assets/js/80b002d6.c136f31e.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [6105], 4 | { 5 | 3769: s => { 6 | s.exports = JSON.parse( 7 | '{"name":"docusaurus-plugin-content-docs","id":"default"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /docs/assets/js/ec408539.56917c2d.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [3451], 4 | { 5 | 5745: s => { 6 | s.exports = JSON.parse( 7 | '{"name":"docusaurus-plugin-content-pages","id":"default"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/pages/Messages.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | export default function Messages() { 3 | return ( 4 |
5 |

Messages

6 |
    7 |
  • Message 1
  • 8 |
  • Message 2
  • 9 |
10 |
11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /examples/auth/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/basic/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/children/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/beforeEnter/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/custom-link/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/permission/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/beforeEachMount/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/custom-filter-link/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node 2 | npm-debug.log 3 | node_modules 4 | 5 | # Mac 6 | .DS_Store 7 | 8 | # Windows 9 | Thumbs.db 10 | 11 | # WebStorm 12 | .idea/ 13 | 14 | #VSCode metadata 15 | .vscode 16 | 17 | coverage/ 18 | 19 | 20 | # production 21 | /packages/*/dist/ 22 | /es 23 | 24 | package-lock.json 25 | yarn-error.log 26 | yarn.lock -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/email/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface EmailProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "Email"; 8 | const Email: React.FC = (props: EmailProps) => { 9 | return
Email
; 10 | }; 11 | 12 | export default Email; 13 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/my-page/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface MyPageProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "MyPage"; 8 | const MyPage: React.FC = (props: MyPageProps) => { 9 | return
MyPage
; 10 | }; 11 | 12 | export default MyPage; 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | import "antd/dist/reset.css"; 4 | 5 | import "./index.css"; 6 | import App from "./App"; 7 | 8 | ReactDOM.createRoot(document.getElementById("root")!).render( 9 | 10 | 11 | 12 | ); 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/contact/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface ContactProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "Contact"; 8 | const Contact: React.FC = (props: ContactProps) => { 9 | return
Contact
; 10 | }; 11 | 12 | export default Contact; 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/project/clients/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface ClientProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "Client"; 8 | const Client: React.FC = (props: ClientProps) => { 9 | return
Client
; 10 | }; 11 | 12 | export default Client; 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/project/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface ProjectProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "Project"; 8 | const Project: React.FC = (props: ProjectProps) => { 9 | return
Project
; 10 | }; 11 | 12 | export default Project; 13 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {import('prettier').Options} 3 | */ 4 | module.exports = { 5 | arrowParens: "avoid", 6 | trailingComma: "none", 7 | overrides: [ 8 | { 9 | files: "**/*.md", 10 | options: { 11 | printWidth: 1000, 12 | proseWrap: "never", 13 | tabWidth: 2 14 | } 15 | } 16 | ] 17 | }; 18 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/contact/grid-view/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface GridViewProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "GridView"; 8 | const GridView: React.FC = (props: GridViewProps) => { 9 | return
GridView
; 10 | }; 11 | 12 | export default GridView; 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/contact/list-view/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface ListViewProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "ListView"; 8 | const ListView: React.FC = (props: ListViewProps) => { 9 | return
ListView
; 10 | }; 11 | 12 | export default ListView; 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/messenger/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface MessengerProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "Messenger"; 8 | const Messenger: React.FC = (props: MessengerProps) => { 9 | return
Messenger
; 10 | }; 11 | 12 | export default Messenger; 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/project/todo-list/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface ToDoListProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "ToDoList"; 8 | const ToDoList: React.FC = (props: ToDoListProps) => { 9 | return
ToDoList
; 10 | }; 11 | 12 | export default ToDoList; 13 | -------------------------------------------------------------------------------- /docs/assets/js/1897ff02.dc84d8c2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [1519], 4 | { 5 | 1334: e => { 6 | e.exports = JSON.parse( 7 | '{"label":"hello","permalink":"/react-router-manage/blog/tags/hello","allTagsPath":"/react-router-manage/blog/tags","count":2}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /docs/assets/js/f7521111.584dd3bd.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [9633], 4 | { 5 | 9661: a => { 6 | a.exports = JSON.parse( 7 | '{"label":"hola","permalink":"/react-router-manage/blog/tags/hola","allTagsPath":"/react-router-manage/blog/tags","count":1}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /docs/assets/js/b0f97ac5.c072f860.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [4961], 4 | { 5 | 3733: a => { 6 | a.exports = JSON.parse( 7 | '{"label":"facebook","permalink":"/react-router-manage/blog/tags/facebook","allTagsPath":"/react-router-manage/blog/tags","count":1}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/actions/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { StrictMode } from "react"; 3 | import { createRoot } from "react-dom/client"; 4 | 5 | import App from "./App"; 6 | 7 | const rootElement = document.getElementById("root"); 8 | const root = createRoot(rootElement!); 9 | 10 | root.render( 11 | 12 | 13 | 14 | ); 15 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/project/task-board/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface TaskBoardProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "TaskBoard"; 8 | const TaskBoard: React.FC = (props: TaskBoardProps) => { 9 | return
TaskBoard
; 10 | }; 11 | 12 | export default TaskBoard; 13 | -------------------------------------------------------------------------------- /docs/assets/js/11dd5695.ab75d6b0.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [7306], 4 | { 5 | 4914: a => { 6 | a.exports = JSON.parse( 7 | '{"label":"docusaurus","permalink":"/react-router-manage/blog/tags/docusaurus","allTagsPath":"/react-router-manage/blog/tags","count":4}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /docs/assets/js/6c88cea6.4a33a54b.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [3360], 4 | { 5 | 9118: e => { 6 | e.exports = JSON.parse( 7 | '{"permalink":"/react-router-manage/blog","page":1,"postsPerPage":10,"totalPages":1,"totalCount":4,"blogDescription":"Blog","blogTitle":"Blog"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/actions/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Basic Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/project/ticket-list/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface TicketListProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "TicketList"; 8 | const TicketList: React.FC = (props: TicketListProps) => { 9 | return
TicketList
; 10 | }; 11 | 12 | export default TicketList; 13 | -------------------------------------------------------------------------------- /examples/auth/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Auth Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Basic Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/project/project-list/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | interface ProjectListProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "ProjectList"; 8 | const ProjectList: React.FC = (props: ProjectListProps) => { 9 | return
ProjectList
; 10 | }; 11 | 12 | export default ProjectList; 13 | -------------------------------------------------------------------------------- /examples/beforeEnter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Basic Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/children/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Basic Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/permission/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Basic Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/assets/js/16cda1d6.2211642d.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [7712], 4 | { 5 | 807: e => { 6 | e.exports = JSON.parse( 7 | '{"permalink":"/react-router-manage/blog/tags/hello","page":1,"postsPerPage":10,"totalPages":1,"totalCount":2,"blogDescription":"Blog","blogTitle":"Blog"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /docs/assets/js/50805dbf.4c9ea0fd.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [8779], 4 | { 5 | 9776: e => { 6 | e.exports = JSON.parse( 7 | '{"permalink":"/react-router-manage/blog/tags/hola","page":1,"postsPerPage":10,"totalPages":1,"totalCount":1,"blogDescription":"Blog","blogTitle":"Blog"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/beforeEachMount/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Basic Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/custom-link/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Custom Link Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/assets/js/731a0905.0ae7809a.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [2834], 4 | { 5 | 7917: e => { 6 | e.exports = JSON.parse( 7 | '{"permalink":"/react-router-manage/blog/tags/facebook","page":1,"postsPerPage":10,"totalPages":1,"totalCount":1,"blogDescription":"Blog","blogTitle":"Blog"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/lazy-loading/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Lazy Loading Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/breadcrumbs/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | interface RouterBreadcrumbsProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "RouterBreadcrumbs"; 8 | const RouterBreadcrumbs: React.FC = ( 9 | props: RouterBreadcrumbsProps 10 | ) => { 11 | return
; 12 | }; 13 | 14 | export default RouterBreadcrumbs; 15 | -------------------------------------------------------------------------------- /packages/keep-alive/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | interface RouterBreadcrumbsProps { 4 | id?: number; 5 | } 6 | 7 | const modulePrefix = "RouterBreadcrumbs"; 8 | const RouterBreadcrumbs: React.FC = ( 9 | props: RouterBreadcrumbsProps 10 | ) => { 11 | return
; 12 | }; 13 | 14 | export default RouterBreadcrumbs; 15 | -------------------------------------------------------------------------------- /docs/assets/js/84a82062.54fb4016.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [7889], 4 | { 5 | 8844: e => { 6 | e.exports = JSON.parse( 7 | '{"permalink":"/react-router-manage/blog/tags/docusaurus","page":1,"postsPerPage":10,"totalPages":1,"totalCount":4,"blogDescription":"Blog","blogTitle":"Blog"}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/custom-filter-link/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Custom Filter Link Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/dashboard/detail/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useRouter } from "react-router-manage"; 3 | 4 | interface DetailProps { 5 | id?: number; 6 | } 7 | 8 | const Detail: React.FC = (props: DetailProps) => { 9 | const { params } = useRouter(); 10 | return
current dashboard id is {params.id}
; 11 | }; 12 | 13 | export default Detail; 14 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Custom Query Parsing Example 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/auth/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/basic/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/beforeEnter/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/children/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/custom-link/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/permission/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /packages/breadcrumbs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["./index.tsx"], 3 | "exclude": ["dist/**/*"], 4 | "compilerOptions": { 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "target": "ES2020", 7 | "module": "ES2020", 8 | "moduleResolution": "node", 9 | 10 | "strict": true, 11 | "jsx": "react", 12 | 13 | "skipLibCheck": true, 14 | 15 | "outDir": ".", 16 | "rootDir": "." 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/keep-alive/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["./index.tsx"], 3 | "exclude": ["dist/**/*"], 4 | "compilerOptions": { 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "target": "ES2020", 7 | "module": "ES2020", 8 | "moduleResolution": "node", 9 | 10 | "strict": true, 11 | "jsx": "react", 12 | 13 | "skipLibCheck": true, 14 | 15 | "outDir": ".", 16 | "rootDir": "." 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/beforeEachMount/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /packages/antd-breadcrumbs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["./index.tsx"], 3 | "exclude": ["dist/**/*"], 4 | "compilerOptions": { 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "target": "ES2020", 7 | "module": "ES2020", 8 | "moduleResolution": "node", 9 | 10 | "strict": true, 11 | "jsx": "react", 12 | 13 | "skipLibCheck": true, 14 | 15 | "outDir": ".", 16 | "rootDir": "." 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/react-router-manage/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["./index.tsx"], 3 | "exclude": ["dist/**/*"], 4 | "compilerOptions": { 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "target": "ES2020", 7 | "module": "ES2020", 8 | "moduleResolution": "node", 9 | 10 | "strict": true, 11 | "jsx": "react", 12 | 13 | "skipLibCheck": true, 14 | 15 | "outDir": ".", 16 | "rootDir": "." 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/custom-filter-link/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | -------------------------------------------------------------------------------- /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /** 4 | * 支持的 type 有: 5 | * 6 | * 'build', 'ci', 'docs', 'feat', 'fix', 'perf', 7 | * 'refactor', 'revert', 'style', 'test' 8 | */ 9 | 10 | module.exports = { 11 | extends: ["@commitlint/config-conventional"], 12 | rules: { 13 | "body-leading-blank": [2, "always"], 14 | "footer-leading-blank": [2, "always"], 15 | "subject-case": [0], 16 | "scope-case": [0] 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@2.1.1/schema.json", 3 | "changelog": [ 4 | "@changesets/cli/changelog", 5 | { 6 | "repo": "NSFI/react-router-manage" 7 | } 8 | ], 9 | "commit": false, 10 | "fixed": [["react-router-manage", "@rrmc/antd-breadcrumbs"]], 11 | "access": "public", 12 | "baseBranch": "main", 13 | "updateInternalDependencies": "patch", 14 | "ignore": [] 15 | } 16 | -------------------------------------------------------------------------------- /website/blog/2019-05-28-first-blog-post.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: first-blog-post 3 | title: First Blog Post 4 | authors: 5 | name: Gao Wei 6 | title: Docusaurus Core Team 7 | url: https://github.com/wgao19 8 | image_url: https://github.com/wgao19.png 9 | tags: [hola, docusaurus] 10 | --- 11 | 12 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 13 | -------------------------------------------------------------------------------- /examples/auth/src/auth.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This represents some generic auth provider API, like Firebase. 3 | */ 4 | const fakeAuthProvider = { 5 | isAuthenticated: false, 6 | signin(callback: VoidFunction) { 7 | fakeAuthProvider.isAuthenticated = true; 8 | setTimeout(callback, 100); // fake async 9 | }, 10 | signout(callback: VoidFunction) { 11 | fakeAuthProvider.isAuthenticated = false; 12 | setTimeout(callback, 100); 13 | } 14 | }; 15 | 16 | export { fakeAuthProvider }; 17 | -------------------------------------------------------------------------------- /website/src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS files with the .module.css suffix will be treated as CSS modules 3 | * and scoped locally. 4 | */ 5 | 6 | .heroBanner { 7 | padding: 4rem 0; 8 | text-align: center; 9 | position: relative; 10 | overflow: hidden; 11 | } 12 | 13 | @media screen and (max-width: 996px) { 14 | .heroBanner { 15 | padding: 2rem; 16 | } 17 | } 18 | 19 | .buttons { 20 | display: flex; 21 | align-items: center; 22 | justify-content: center; 23 | } 24 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | antd router breadcrumbs 7 | 8 | 9 |
10 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /entry/auth/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | auth 7 | 8 | 9 |
10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with multi-package repos, or single-package repos to help you version and publish your code. You can find the full documentation for it [in our repository](https://github.com/changesets/changesets) 4 | 5 | We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 6 | -------------------------------------------------------------------------------- /entry/children/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | children 7 | 8 | 9 |
10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /website/blog/authors.yml: -------------------------------------------------------------------------------- 1 | endi: 2 | name: Endilie Yacop Sucipto 3 | title: Maintainer of Docusaurus 4 | url: https://github.com/endiliey 5 | image_url: https://github.com/endiliey.png 6 | 7 | yangshun: 8 | name: Yangshun Tay 9 | title: Front End Engineer @ Facebook 10 | url: https://github.com/yangshun 11 | image_url: https://github.com/yangshun.png 12 | 13 | slorber: 14 | name: Sébastien Lorber 15 | title: Docusaurus maintainer 16 | url: https://sebastienlorber.com 17 | image_url: https://github.com/slorber.png 18 | -------------------------------------------------------------------------------- /examples/actions/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 3 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 11 | monospace; 12 | } 13 | 14 | .header { 15 | border-bottom: 1px solid #eeeeee; 16 | } 17 | .content { 18 | text-align: left; 19 | } 20 | -------------------------------------------------------------------------------- /entry/basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Auth Example 7 | 8 | 9 |
10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /entry/beforeEnter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | React Router - Auth Example 8 | 9 | 10 | 11 |
12 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /entry/permission/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | children 7 | 8 | 9 |
10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Auth Example 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /entry/custom-link/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | custom-link 7 | 8 | 9 |
10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | 4 | module.exports = function rollup(options) { 5 | return fs 6 | .readdirSync("packages") 7 | .flatMap(dir => { 8 | let configPath = path.join("packages", dir, "rollup.config.js"); 9 | try { 10 | fs.readFileSync(configPath); 11 | } catch (e) { 12 | return null; 13 | } 14 | let packageBuild = require(`.${path.sep}${configPath}`); 15 | return packageBuild(options); 16 | }) 17 | .filter(p => p); 18 | }; 19 | -------------------------------------------------------------------------------- /entry/lazy-loading/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | lazy-loading 7 | 8 | 9 |
10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /website/blog/2021-08-01-mdx-blog-post.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | slug: mdx-blog-post 3 | title: MDX Blog Post 4 | authors: [slorber] 5 | tags: [docusaurus] 6 | --- 7 | 8 | Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/). 9 | 10 | :::tip 11 | 12 | Use the power of React to create interactive blog posts. 13 | 14 | ```js 15 | 16 | ``` 17 | 18 | 19 | 20 | ::: 21 | -------------------------------------------------------------------------------- /entry/beforeEachMount/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | beforeEachMount 7 | 8 | 9 |
10 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/util/proxy.ts: -------------------------------------------------------------------------------- 1 | export function proxyRoutesMapFromTarget( 2 | obj: T, 3 | target: Record, 4 | filterKeys: string[] = [] 5 | ) { 6 | const keys = Object.keys(target).filter(i => !filterKeys.includes(i)); 7 | keys.forEach(key => { 8 | Object.defineProperty(obj, key, { 9 | get: () => { 10 | const route = target[key]; 11 | if (Array.isArray(route)) { 12 | return route[route.length - 1]; 13 | } 14 | return route; 15 | } 16 | }); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /docs/assets/js/8e02645a.111b319c.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [6044], 4 | { 5 | 978: a => { 6 | a.exports = JSON.parse( 7 | '[{"label":"facebook","permalink":"/react-router-manage/blog/tags/facebook","count":1},{"label":"hello","permalink":"/react-router-manage/blog/tags/hello","count":2},{"label":"docusaurus","permalink":"/react-router-manage/blog/tags/docusaurus","count":4},{"label":"hola","permalink":"/react-router-manage/blog/tags/hola","count":1}]' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/pages/DashboardLayout.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Link, Outlet } from "react-router-dom"; 3 | 4 | export default function DashboardLayout() { 5 | return ( 6 |
7 | 17 | 18 |
19 | 20 | 21 |
22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /examples/custom-link/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom Active Link 3 | toc: false 4 | --- 5 | 6 | # Custom Link Example 7 | 8 | This example demonstrates how to make a custom `` component to render something different when the link is "active" using the `useMatch()` and `useResolvedPath()` hooks. 9 | 10 | ## Preview 11 | 12 | Open this example on [StackBlitz](https://stackblitz.com): 13 | 14 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/custom-link?file=src/App.tsx) 15 | -------------------------------------------------------------------------------- /docs/assets/js/814f3328.98156c54.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [2535], 4 | { 5 | 5641: e => { 6 | e.exports = JSON.parse( 7 | '{"title":"Recent posts","items":[{"title":"Welcome","permalink":"/react-router-manage/blog/welcome"},{"title":"MDX Blog Post","permalink":"/react-router-manage/blog/mdx-blog-post"},{"title":"Long Blog Post","permalink":"/react-router-manage/blog/long-blog-post"},{"title":"First Blog Post","permalink":"/react-router-manage/blog/first-blog-post"}]}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /entry/antd-breadcrumbs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | antd router breadcrumbs 7 | 8 | 9 |
10 | 16 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /entry/custom-filter-link/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | custom-filter-link 7 | 8 | 9 |
10 | 16 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/assets/js/81841653.cd624153.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [6818], 4 | { 5 | 7647: a => { 6 | a.exports = JSON.parse( 7 | '{"title":"Tutorial - Extras","slug":"/category/tutorial---extras","permalink":"/react-router-manage/docs/category/tutorial---extras","navigation":{"previous":{"title":"Congratulations!","permalink":"/react-router-manage/docs/tutorial-basics/congratulations"},"next":{"title":"Manage Docs Versions","permalink":"/react-router-manage/docs/tutorial-extras/manage-docs-versions"}}}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /entry/custom-query-parsing/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | custom-query-parsing 7 | 8 | 9 |
10 | 16 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Examples 3 | order: 6 4 | --- 5 | 6 | # React Router Manage Examples 7 | 8 | Welcome to the examples for React Router Manage. 9 | 10 | Here you'll find various examples of using React Router Manage to accomplish certain tasks. Each example is a complete application including a build and even a button to preview a live instance of the app so you can play with it. You'll most often be interested in checking out the code in `src/App.tsx` (or `src/App.js`), but we included the entire source code for the app for completeness. 11 | 12 | Also, remember to check out the README! 13 | 14 | Enjoy! 15 | -------------------------------------------------------------------------------- /examples/custom-filter-link/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom Filter Link 3 | toc: false 4 | --- 5 | 6 | # Custom Filter Link Example 7 | 8 | This example demonstrates how to use a query string parameter to mark a link as "active" or not. This is a common technique when implementing a filter in a sidebar where you're browsing products. 9 | 10 | ## Preview 11 | 12 | Open this example on [StackBlitz](https://stackblitz.com): 13 | 14 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/custom-filter-link?file=src/App.tsx) 15 | -------------------------------------------------------------------------------- /examples/actions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/basic/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/children/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/beforeEnter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/custom-link/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/lazy-loading/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/permission/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /docs/assets/js/b80a438f.48394979.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [6382], 4 | { 5 | 2310: t => { 6 | t.exports = JSON.parse( 7 | '{"title":"Tutorial - Basics","description":"5 minutes to learn the most important Docusaurus concepts.","slug":"/category/tutorial---basics","permalink":"/react-router-manage/docs/category/tutorial---basics","navigation":{"previous":{"title":"Tutorial Intro","permalink":"/react-router-manage/docs/intro"},"next":{"title":"Create a Page","permalink":"/react-router-manage/docs/tutorial-basics/create-a-page"}}}' 8 | ); 9 | } 10 | } 11 | ]); 12 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/beforeEachMount/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/custom-filter-link/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "importsNotUsedAsValues": "error" 19 | }, 20 | "include": ["./src"] 21 | } 22 | -------------------------------------------------------------------------------- /dist/entry/basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Router - Auth Example 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src", "types"], 3 | "compilerOptions": { 4 | "baseUrl": ".", 5 | "target": "ESNext", 6 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 7 | "allowJs": false, 8 | "skipLibCheck": true, 9 | "esModuleInterop": false, 10 | "allowSyntheticDefaultImports": true, 11 | "strict": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "module": "ESNext", 14 | "moduleResolution": "Node", 15 | "resolveJsonModule": true, 16 | "isolatedModules": true, 17 | "noEmit": true, 18 | "jsx": "react", 19 | "importsNotUsedAsValues": "error" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/actions/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basics 3 | toc: false 4 | order: 1 5 | --- 6 | 7 | # Basic Example 8 | 9 | This example demonstrates some of the basic features of React Router, including: 10 | 11 | - Layouts and nested ``s 12 | - Index ``s 13 | - Catch-all ``s 14 | - Using `` as a placeholder for child routes 15 | - Using ``s for navigation 16 | 17 | ## Preview 18 | 19 | Open this example on [StackBlitz](https://stackblitz.com): 20 | 21 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx) 22 | -------------------------------------------------------------------------------- /examples/basic/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basics 3 | toc: false 4 | order: 1 5 | --- 6 | 7 | # Basic Example 8 | 9 | This example demonstrates some of the basic features of React Router, including: 10 | 11 | - Layouts and nested ``s 12 | - Index ``s 13 | - Catch-all ``s 14 | - Using `` as a placeholder for child routes 15 | - Using ``s for navigation 16 | 17 | ## Preview 18 | 19 | Open this example on [StackBlitz](https://stackblitz.com): 20 | 21 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx) 22 | -------------------------------------------------------------------------------- /examples/beforeEnter/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basics 3 | toc: false 4 | order: 1 5 | --- 6 | 7 | # Basic Example 8 | 9 | This example demonstrates some of the basic features of React Router, including: 10 | 11 | - Layouts and nested ``s 12 | - Index ``s 13 | - Catch-all ``s 14 | - Using `` as a placeholder for child routes 15 | - Using ``s for navigation 16 | 17 | ## Preview 18 | 19 | Open this example on [StackBlitz](https://stackblitz.com): 20 | 21 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx) 22 | -------------------------------------------------------------------------------- /examples/children/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basics 3 | toc: false 4 | order: 1 5 | --- 6 | 7 | # Basic Example 8 | 9 | This example demonstrates some of the basic features of React Router, including: 10 | 11 | - Layouts and nested ``s 12 | - Index ``s 13 | - Catch-all ``s 14 | - Using `` as a placeholder for child routes 15 | - Using ``s for navigation 16 | 17 | ## Preview 18 | 19 | Open this example on [StackBlitz](https://stackblitz.com): 20 | 21 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx) 22 | -------------------------------------------------------------------------------- /examples/permission/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basics 3 | toc: false 4 | order: 1 5 | --- 6 | 7 | # Basic Example 8 | 9 | This example demonstrates some of the basic features of React Router, including: 10 | 11 | - Layouts and nested ``s 12 | - Index ``s 13 | - Catch-all ``s 14 | - Using `` as a placeholder for child routes 15 | - Using ``s for navigation 16 | 17 | ## Preview 18 | 19 | Open this example on [StackBlitz](https://stackblitz.com): 20 | 21 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx) 22 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basics 3 | toc: false 4 | order: 1 5 | --- 6 | 7 | # Basic Example 8 | 9 | This example demonstrates some of the basic features of React Router, including: 10 | 11 | - Layouts and nested ``s 12 | - Index ``s 13 | - Catch-all ``s 14 | - Using `` as a placeholder for child routes 15 | - Using ``s for navigation 16 | 17 | ## Preview 18 | 19 | Open this example on [StackBlitz](https://stackblitz.com): 20 | 21 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx) 22 | -------------------------------------------------------------------------------- /examples/beforeEachMount/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basics 3 | toc: false 4 | order: 1 5 | --- 6 | 7 | # Basic Example 8 | 9 | This example demonstrates some of the basic features of React Router, including: 10 | 11 | - Layouts and nested ``s 12 | - Index ``s 13 | - Catch-all ``s 14 | - Using `` as a placeholder for child routes 15 | - Using ``s for navigation 16 | 17 | ## Preview 18 | 19 | Open this example on [StackBlitz](https://stackblitz.com): 20 | 21 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx) 22 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom Query Parsing 3 | toc: false 4 | --- 5 | 6 | # Custom Query Parsing Example 7 | 8 | This example demonstrates how to store a complex data structure in the URL query string using a custom hook. 9 | 10 | It's a good example of how React Router's low-level hooks provide you with all the flexibility you need to create your own custom hooks that fit the needs of your app. 11 | 12 | ## Preview 13 | 14 | Open this example on [StackBlitz](https://stackblitz.com): 15 | 16 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/custom-query-parsing?file=src/App.tsx) 17 | -------------------------------------------------------------------------------- /dist/assets/preload-helper-101896b7.js: -------------------------------------------------------------------------------- 1 | const h="modulepreload",m=function(l){return"/"+l},a={},k=function(o,i,u){if(!i||i.length===0)return o();const c=document.getElementsByTagName("link");return Promise.all(i.map(e=>{if(e=m(e),e in a)return;a[e]=!0;const n=e.endsWith(".css"),f=n?'[rel="stylesheet"]':"";if(!!u)for(let r=c.length-1;r>=0;r--){const s=c[r];if(s.href===e&&(!n||s.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${e}"]${f}`))return;const t=document.createElement("link");if(t.rel=n?"stylesheet":h,n||(t.as="script",t.crossOrigin=""),t.href=e,document.head.appendChild(t),n)return new Promise((r,s)=>{t.addEventListener("load",r),t.addEventListener("error",()=>s(new Error(`Unable to preload CSS for ${e}`)))})})).then(()=>o())};export{k as _}; 2 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | const { BABEL_ENV, NODE_ENV } = process.env; 2 | const isCjs = NODE_ENV === "test" || BABEL_ENV === "commonjs"; 3 | 4 | module.exports = function (api) { 5 | api.cache(true); 6 | const presets = [ 7 | [ 8 | "@babel/preset-env", 9 | { 10 | useBuiltIns: "usage", 11 | corejs: 3, 12 | modules: false, 13 | loose: true 14 | } 15 | ], 16 | "@babel/preset-react", 17 | "@babel/preset-typescript" 18 | ]; 19 | 20 | const plugins = []; 21 | if (isCjs) { 22 | ["@babel/plugin-transform-runtime"]; 23 | // This plugin transforms ECMAScript modules to CommonJS. 24 | plugins.push("@babel/plugin-transform-modules-commonjs"); 25 | } 26 | 27 | return { presets, plugins }; 28 | }; 29 | -------------------------------------------------------------------------------- /examples/lazy-loading/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Lazy Loading 3 | toc: false 4 | --- 5 | 6 | # Lazy Loading Example 7 | 8 | This example demonstrates how to lazily load both 9 | 10 | - individual route elements 11 | - entire portions of your route hierarchy 12 | 13 | on demand using `React.lazy()` and dynamic `import()`. Using this technique, pages that are not required on the home page can be split out into separate bundles, thereby decreasing load time on the initial page and improving performance. 14 | 15 | ## Preview 16 | 17 | Open this example on [StackBlitz](https://stackblitz.com): 18 | 19 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/lazy-loading?file=src/App.tsx) 20 | -------------------------------------------------------------------------------- /dist/entry/antd-breadcrumbs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | antd router breadcrumbs 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/actions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "query-string": "^7.1.1", 13 | "react": "^18.2.0", 14 | "react-dom": "^18.2.0", 15 | "react-router-manage": "1.1.5" 16 | }, 17 | "devDependencies": { 18 | "@rollup/plugin-replace": "^2.2.1", 19 | "@types/node": "14.x", 20 | "@types/react": "^18.0.0", 21 | "@types/react-dom": "^18.0.0", 22 | "@vitejs/plugin-react": "^1.0.1", 23 | "autoprefixer": "^10.4.8", 24 | "less": "^3.1.3", 25 | "typescript": "^4.3.5", 26 | "vite": "^2.5.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/basic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "query-string": "^7.1.1", 13 | "react": "^17.0.2", 14 | "react-dom": "^17.0.2", 15 | "react-router-manage": "^1.1.2" 16 | }, 17 | "devDependencies": { 18 | "@rollup/plugin-replace": "^2.2.1", 19 | "@types/node": "14.x", 20 | "@types/react": "^17.0.19", 21 | "@types/react-dom": "^17.0.9", 22 | "@vitejs/plugin-react": "^1.0.1", 23 | "autoprefixer": "^10.4.8", 24 | "less": "^3.1.3", 25 | "typescript": "^4.3.5", 26 | "vite": "^2.5.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/changeable.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import Spin from "./components/Spin"; 3 | const LoadingCmp = () => ( 4 | <> 5 | 6 | 7 | ); 8 | 9 | /** 10 | * LoadingComponent Define the Suspense component's fallback and beforeEnter when a component is loaded, 11 | * and the state component when calling next 12 | */ 13 | interface ChangeableI { 14 | LoadingComponent: React.FunctionComponent; 15 | } 16 | 17 | const changeable: ChangeableI = { 18 | LoadingComponent: LoadingCmp 19 | }; 20 | 21 | function setChangeable(options: Partial) { 22 | Object.entries(options).forEach(([key, value]) => { 23 | changeable[key as keyof ChangeableI] = value; 24 | }); 25 | } 26 | 27 | export { changeable, setChangeable }; 28 | -------------------------------------------------------------------------------- /examples/beforeEnter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "query-string": "^7.1.1", 13 | "react": "^17.0.2", 14 | "react-dom": "^17.0.2", 15 | "react-router-manage": "^1.1.2" 16 | }, 17 | "devDependencies": { 18 | "@rollup/plugin-replace": "^2.2.1", 19 | "@types/node": "14.x", 20 | "@types/react": "^17.0.19", 21 | "@types/react-dom": "^17.0.9", 22 | "@vitejs/plugin-react": "^1.0.1", 23 | "autoprefixer": "^10.4.8", 24 | "less": "^3.1.3", 25 | "typescript": "^4.3.5", 26 | "vite": "^2.5.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/components/NameRedirect/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Navigate } from "react-router-dom"; 3 | import { useRouter } from "../../index"; 4 | 5 | const NameRedirect: React.FC<{ 6 | name: string; 7 | component?: React.ComponentType; 8 | }> = ({ name, component: Component }) => { 9 | const { routesMap, currentRoute } = useRouter(); 10 | 11 | const targetRoute = routesMap[name]; 12 | 13 | if (!targetRoute) { 14 | if (__DEV__) { 15 | Error(`routesMap.${name} 路由不存在`); 16 | } 17 | } 18 | 19 | if (name === currentRoute.name) { 20 | if (Component) { 21 | return ; 22 | } 23 | return <>; 24 | } 25 | 26 | return ; 27 | }; 28 | 29 | export default NameRedirect; 30 | -------------------------------------------------------------------------------- /examples/children/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "query-string": "^7.1.1", 13 | "react": "^17.0.2", 14 | "react-dom": "^17.0.2", 15 | "react-router-manage": "^1.1.2-beta.0" 16 | }, 17 | "devDependencies": { 18 | "@rollup/plugin-replace": "^2.2.1", 19 | "@types/node": "14.x", 20 | "@types/react": "^17.0.19", 21 | "@types/react-dom": "^17.0.9", 22 | "@vitejs/plugin-react": "^1.0.1", 23 | "autoprefixer": "^10.4.8", 24 | "less": "^3.1.3", 25 | "typescript": "^4.3.5", 26 | "vite": "^2.5.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/permission/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "query-string": "^7.1.1", 13 | "react": "^17.0.2", 14 | "react-dom": "^17.0.2", 15 | "react-router-manage": "^1.1.4-beta.0" 16 | }, 17 | "devDependencies": { 18 | "@rollup/plugin-replace": "^2.2.1", 19 | "@types/node": "14.x", 20 | "@types/react": "^17.0.19", 21 | "@types/react-dom": "^17.0.9", 22 | "@vitejs/plugin-react": "^1.0.1", 23 | "autoprefixer": "^10.4.8", 24 | "less": "^3.1.3", 25 | "typescript": "^4.3.5", 26 | "vite": "^2.5.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/Context/MRouterHistoryContext.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import type { RouteHistoryObject } from "../type"; 3 | 4 | const MRouterHistoryContext = React.createContext(null!); 5 | MRouterHistoryContext.displayName = "MRouterHistoryContext"; 6 | 7 | export function useHistory() { 8 | return React.useContext(MRouterHistoryContext).history; 9 | } 10 | 11 | export function useRouteHooks() { 12 | return React.useContext(MRouterHistoryContext).routeHooks; 13 | } 14 | 15 | export function useRouteHooksRef() { 16 | return React.useContext(MRouterHistoryContext).routeHooksRef; 17 | } 18 | 19 | export function useHistoryMethods() { 20 | return React.useContext(MRouterHistoryContext).historyMethods; 21 | } 22 | 23 | export default MRouterHistoryContext; 24 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "query-string": "^7.1.1", 13 | "react": "^18.0.2", 14 | "react-dom": "^18.0.2", 15 | "react-router-manage": "latest", 16 | "@rrmc/antd-breadcrumbs": "latest" 17 | }, 18 | "devDependencies": { 19 | "@rollup/plugin-replace": "^2.2.1", 20 | "@types/node": "14.x", 21 | "@types/react": "^18.0.0", 22 | "@types/react-dom": "^18.0.0", 23 | "@vitejs/plugin-react": "^1.0.1", 24 | "autoprefixer": "^10.4.8", 25 | "less": "^3.1.3", 26 | "typescript": "^4.3.5", 27 | "vite": "^2.5.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /website/docs/tutorial-basics/deploy-your-site.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 5 3 | --- 4 | 5 | # Deploy your site 6 | 7 | Docusaurus is a **static-site-generator** (also called **[Jamstack](https://jamstack.org/)**). 8 | 9 | It builds your site as simple **static HTML, JavaScript and CSS files**. 10 | 11 | ## Build your site 12 | 13 | Build your site **for production**: 14 | 15 | ```bash 16 | npm run build 17 | ``` 18 | 19 | The static files are generated in the `build` folder. 20 | 21 | ## Deploy your site 22 | 23 | Test your production build locally: 24 | 25 | ```bash 26 | npm run serve 27 | ``` 28 | 29 | The `build` folder is now served at [http://localhost:3000/](http://localhost:3000/). 30 | 31 | You can now deploy the `build` folder **almost anywhere** easily, **for free** or very small cost (read the **[Deployment Guide](https://docusaurus.io/docs/deployment)**). 32 | -------------------------------------------------------------------------------- /examples/beforeEachMount/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "history": "^5.2.0", 13 | "query-string": "^7.1.1", 14 | "react": "^17.0.2", 15 | "react-dom": "^17.0.2", 16 | "react-router": "^6.3.0", 17 | "react-router-dom": "^6.3.0", 18 | "react-router-manage": "latest" 19 | }, 20 | "devDependencies": { 21 | "@rollup/plugin-replace": "^2.2.1", 22 | "@types/node": "14.x", 23 | "@types/react": "^17.0.19", 24 | "@types/react-dom": "^17.0.9", 25 | "@vitejs/plugin-react": "^1.0.1", 26 | "autoprefixer": "^10.4.8", 27 | "less": "^3.1.3", 28 | "typescript": "^4.3.5", 29 | "vite": "^2.5.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/custom-link/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-link", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "history": "^5.2.0", 13 | "query-string": "^7.1.1", 14 | "react": "^17.0.2", 15 | "react-dom": "^17.0.2", 16 | "react-router": "^6.3.0", 17 | "react-router-dom": "^6.3.0", 18 | "react-router-manage": "^1.0.0" 19 | }, 20 | "devDependencies": { 21 | "@rollup/plugin-replace": "^2.2.1", 22 | "@types/node": "14.x", 23 | "@types/react": "^17.0.19", 24 | "@types/react-dom": "^17.0.9", 25 | "@vitejs/plugin-react": "^1.0.1", 26 | "autoprefixer": "^10.4.8", 27 | "less": "^3.1.3", 28 | "typescript": "^4.3.5", 29 | "vite": "^2.5.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /website/blog/2021-08-26-welcome/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: welcome 3 | title: Welcome 4 | authors: [slorber, yangshun] 5 | tags: [facebook, hello, docusaurus] 6 | --- 7 | 8 | [Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog). 9 | 10 | Simply add Markdown files (or folders) to the `blog` directory. 11 | 12 | Regular blog authors can be added to `authors.yml`. 13 | 14 | The blog post date can be extracted from filenames, such as: 15 | 16 | - `2019-05-30-welcome.md` 17 | - `2019-05-30-welcome/index.md` 18 | 19 | A blog post folder can be convenient to co-locate blog post images: 20 | 21 | ![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg) 22 | 23 | The blog supports tags as well! 24 | 25 | **And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config. 26 | -------------------------------------------------------------------------------- /examples/lazy-loading/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lazy-loading", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "history": "^5.2.0", 13 | "query-string": "^7.1.1", 14 | "react": "^17.0.2", 15 | "react-dom": "^17.0.2", 16 | "react-router": "^6.3.0", 17 | "react-router-dom": "^6.3.0", 18 | "react-router-manage": "^1.0.0" 19 | }, 20 | "devDependencies": { 21 | "@rollup/plugin-replace": "^2.2.1", 22 | "@types/node": "14.x", 23 | "@types/react": "^17.0.19", 24 | "@types/react-dom": "^17.0.9", 25 | "@vitejs/plugin-react": "^1.0.1", 26 | "autoprefixer": "^10.4.8", 27 | "less": "^3.1.3", 28 | "typescript": "^4.3.5", 29 | "vite": "^2.5.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /website/sidebars.ts: -------------------------------------------------------------------------------- 1 | import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; 2 | 3 | /** 4 | * Creating a sidebar enables you to: 5 | - create an ordered group of docs 6 | - render a sidebar for each doc of that group 7 | - provide next/previous navigation 8 | 9 | The sidebars can be generated from the filesystem, or explicitly defined here. 10 | 11 | Create as many sidebars as you want. 12 | */ 13 | const sidebars: SidebarsConfig = { 14 | // By default, Docusaurus generates a sidebar from the docs folder structure 15 | tutorialSidebar: [{ type: "autogenerated", dirName: "." }] 16 | 17 | // But you can create a sidebar manually 18 | /* 19 | tutorialSidebar: [ 20 | 'intro', 21 | 'hello', 22 | { 23 | type: 'category', 24 | label: 'Tutorial', 25 | items: ['tutorial-basics/create-a-document'], 26 | }, 27 | ], 28 | */ 29 | }; 30 | 31 | export default sidebars; 32 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage/index.tsx" 31 | ) 32 | } 33 | } 34 | : {} 35 | }); 36 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. 4 | 5 | ### Installation 6 | 7 | ``` 8 | $ yarn 9 | ``` 10 | 11 | ### Local Development 12 | 13 | ``` 14 | $ yarn start 15 | ``` 16 | 17 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ### Build 20 | 21 | ``` 22 | $ yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ### Deployment 28 | 29 | Using SSH: 30 | 31 | ``` 32 | $ USE_SSH=true yarn deploy 33 | ``` 34 | 35 | Not using SSH: 36 | 37 | ``` 38 | $ GIT_USER= yarn deploy 39 | ``` 40 | 41 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 42 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-query-parsing", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "cross-env": "^7.0.3", 12 | "history": "^5.2.0", 13 | "jsurl": "^0.1.5", 14 | "query-string": "^7.1.1", 15 | "react": "^17.0.2", 16 | "react-dom": "^17.0.2", 17 | "react-router": "^6.3.0", 18 | "react-router-dom": "^6.3.0", 19 | "react-router-manage": "^1.0.0" 20 | }, 21 | "devDependencies": { 22 | "@rollup/plugin-replace": "^2.2.1", 23 | "@types/node": "14.x", 24 | "@types/react": "^17.0.19", 25 | "@types/react-dom": "^17.0.9", 26 | "@vitejs/plugin-react": "^1.0.1", 27 | "autoprefixer": "^10.4.8", 28 | "less": "^3.1.3", 29 | "typescript": "^4.3.5", 30 | "vite": "^2.5.0" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/custom-filter-link/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-filter-link", 3 | "private": true, 4 | "scripts": { 5 | "dev": "cross-env USE_SOURCE=1 vite", 6 | "start": "cross-env vite", 7 | "build": "tsc && vite build", 8 | "serve": "vite preview" 9 | }, 10 | "dependencies": { 11 | "@reach/visually-hidden": "^0.17.0", 12 | "cross-env": "^7.0.3", 13 | "history": "^5.2.0", 14 | "query-string": "^7.1.1", 15 | "react": "^17.0.2", 16 | "react-dom": "^17.0.2", 17 | "react-router": "^6.3.0", 18 | "react-router-dom": "^6.3.0", 19 | "react-router-manage": "^1.0.0" 20 | }, 21 | "devDependencies": { 22 | "@rollup/plugin-replace": "^2.2.1", 23 | "@types/node": "14.x", 24 | "@types/react": "^17.0.19", 25 | "@types/react-dom": "^17.0.9", 26 | "@vitejs/plugin-react": "^1.0.1", 27 | "autoprefixer": "^10.4.8", 28 | "less": "^3.1.3", 29 | "typescript": "^4.3.5", 30 | "vite": "^4.5.14" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/breadcrumbs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rrmc/breadcrumbs", 3 | "version": "1.1.5", 4 | "author": "wenxinping@corp.netease.com", 5 | "description": "react-router breadcrumbs for antd", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/NSFI/react-router-manage.git", 9 | "directory": "packages/antd-breadcrumbs" 10 | }, 11 | "license": "MIT", 12 | "main": "./dist/main.js", 13 | "unpkg": "./dist/umd/antd-breadcrumbs.production.min.js", 14 | "module": "./dist/index.js", 15 | "types": "./dist/index.d.ts", 16 | "peerDependencies": { 17 | "react": ">=16.8", 18 | "react-dom": ">=16.8", 19 | "react-router-manage": "^1.1.5" 20 | }, 21 | "devDependencies": { 22 | "react-router-manage": "^1.1.5" 23 | }, 24 | "files": [ 25 | "dist/", 26 | "README.md" 27 | ], 28 | "sideEffects": false, 29 | "keywords": [ 30 | "react", 31 | "router", 32 | "breadcrumb", 33 | "breadcrumbs", 34 | "antd-breadcrumbs", 35 | "antd-router-breadcrumbs" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /packages/keep-alive/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rrmc/keep-alive", 3 | "version": "1.1.5", 4 | "author": "wenxinping@corp.netease.com", 5 | "description": "react-router breadcrumbs for antd", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/NSFI/react-router-manage.git", 9 | "directory": "packages/antd-breadcrumbs" 10 | }, 11 | "license": "MIT", 12 | "main": "./dist/main.js", 13 | "unpkg": "./dist/umd/antd-breadcrumbs.production.min.js", 14 | "module": "./dist/index.js", 15 | "types": "./dist/index.d.ts", 16 | "peerDependencies": { 17 | "react": ">=16.8", 18 | "react-dom": ">=16.8", 19 | "react-router-manage": "^1.1.5" 20 | }, 21 | "devDependencies": { 22 | "react-router-manage": "^1.1.5" 23 | }, 24 | "files": [ 25 | "dist/", 26 | "README.md" 27 | ], 28 | "sideEffects": false, 29 | "keywords": [ 30 | "react", 31 | "router", 32 | "breadcrumb", 33 | "breadcrumbs", 34 | "antd-breadcrumbs", 35 | "antd-router-breadcrumbs" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/components/RedirectChild/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { useMemo } from "react"; 3 | import { Navigate } from "react-router"; 4 | import { useRouter } from "../../hooks"; 5 | import NoAuth from "../NoAuth"; 6 | 7 | const RedirectChild: React.FC = () => { 8 | const { currentRoute } = useRouter(); 9 | 10 | const redirectPath = useMemo(() => { 11 | if (!currentRoute) { 12 | return ""; 13 | } 14 | const itemsAndChildren = currentRoute._itemsAndChildren || []; 15 | 16 | const childRoute = itemsAndChildren?.find(i => { 17 | return i._isHasAuth; 18 | }); 19 | 20 | return childRoute?.path || ""; 21 | }, [currentRoute]); 22 | 23 | let replace = false; 24 | // 父级也没配置component,则会进行多次重定向进行replace, 以便浏览器回退行为 25 | if (!currentRoute.parent?.component) { 26 | replace = true; 27 | } 28 | if (!redirectPath) { 29 | return ; 30 | } 31 | return ; 32 | }; 33 | 34 | export default RedirectChild; 35 | -------------------------------------------------------------------------------- /website/docs/tutorial-basics/create-a-blog-post.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | --- 4 | 5 | # Create a Blog Post 6 | 7 | Docusaurus creates a **page for each blog post**, but also a **blog index page**, a **tag system**, an **RSS** feed... 8 | 9 | ## Create your first Post 10 | 11 | Create a file at `blog/2021-02-28-greetings.md`: 12 | 13 | ```md title="blog/2021-02-28-greetings.md" 14 | --- 15 | slug: greetings 16 | title: Greetings! 17 | authors: 18 | - name: Joel Marcey 19 | title: Co-creator of Docusaurus 1 20 | url: https://github.com/JoelMarcey 21 | image_url: https://github.com/JoelMarcey.png 22 | - name: Sébastien Lorber 23 | title: Docusaurus maintainer 24 | url: https://sebastienlorber.com 25 | image_url: https://github.com/slorber.png 26 | tags: [greetings] 27 | --- 28 | 29 | Congratulations, you have made your first post! 30 | 31 | Feel free to play around and edit this post as much you like. 32 | ``` 33 | 34 | A new blog post is now available at [http://localhost:3000/blog/greetings](http://localhost:3000/blog/greetings). 35 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | examples 8 | 9 | 10 | 11 |
12 |

examples

13 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import BrowserRouter from "./core/BrowserRouter"; 3 | import HashRouter from "./core/HashRouter"; 4 | import { 5 | useAddRoutes, 6 | useRemoveRoutes, 7 | useUpdateRoutes 8 | } from "./context/MRouterContext"; 9 | import { useHistory } from "./context/MRouterHistoryContext"; 10 | 11 | import CoreRouter, { MRouterPropsI } from "./core/CoreRouter"; 12 | 13 | export type { 14 | RouterConfigI, 15 | RouteTypeI, 16 | RouteTypeExtendsI, 17 | RoutesMapI 18 | } from "./type"; 19 | 20 | export { defineRouterConfig } from "./util"; 21 | export { useBeforeLeave, useNavigate, useRouter } from "./hooks"; 22 | 23 | const MRouter: React.FC = props => { 24 | return ; 25 | }; 26 | 27 | const MHRouter: React.FC = props => { 28 | return ; 29 | }; 30 | 31 | export { 32 | MRouter, 33 | MHRouter, 34 | useAddRoutes, 35 | useRemoveRoutes, 36 | useUpdateRoutes, 37 | useHistory 38 | }; 39 | -------------------------------------------------------------------------------- /packages/antd-breadcrumbs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rrmc/antd-breadcrumbs", 3 | "version": "2.0.5", 4 | "author": "wenxinping@corp.netease.com", 5 | "description": "react-router breadcrumbs for antd", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/NSFI/react-router-manage.git", 9 | "directory": "packages/antd-breadcrumbs" 10 | }, 11 | "license": "MIT", 12 | "main": "./dist/main.js", 13 | "unpkg": "./dist/umd/antd-breadcrumbs.production.min.js", 14 | "module": "./dist/index.js", 15 | "types": "./dist/index.d.ts", 16 | "peerDependencies": { 17 | "react": ">=16.8", 18 | "react-dom": ">=16.8", 19 | "antd": ">=4.0.0", 20 | "react-router-manage": "^2.0.5" 21 | }, 22 | "devDependencies": { 23 | "antd": "^5.0.3", 24 | "react-router-manage": "^2.0.5" 25 | }, 26 | "files": [ 27 | "dist/", 28 | "README.md" 29 | ], 30 | "sideEffects": false, 31 | "keywords": [ 32 | "react", 33 | "router", 34 | "breadcrumb", 35 | "breadcrumbs", 36 | "antd-breadcrumbs", 37 | "antd-router-breadcrumbs" 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/pages/dashboard/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Button } from "antd"; 3 | import { useRouter } from "react-router-manage"; 4 | 5 | interface DashboardProps { 6 | id?: number; 7 | } 8 | 9 | const modulePrefix = "Dashboard"; 10 | const Dashboard: React.FC = (props: DashboardProps) => { 11 | const { navigate, routesMap } = useRouter(); 12 | return ( 13 |
14 |
    15 |
  1. 16 | 25 |
  2. 26 |
  3. 27 | 36 |
  4. 37 |
38 |
39 | ); 40 | }; 41 | 42 | export default Dashboard; 43 | -------------------------------------------------------------------------------- /website/src/css/custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Any CSS included here will be global. The classic template 3 | * bundles Infima by default. Infima is a CSS framework designed to 4 | * work well for content-centric websites. 5 | */ 6 | 7 | /* You can override the default Infima variables here. */ 8 | :root { 9 | --ifm-color-primary: #2e8555; 10 | --ifm-color-primary-dark: #29784c; 11 | --ifm-color-primary-darker: #277148; 12 | --ifm-color-primary-darkest: #205d3b; 13 | --ifm-color-primary-light: #33925d; 14 | --ifm-color-primary-lighter: #359962; 15 | --ifm-color-primary-lightest: #3cad6e; 16 | --ifm-code-font-size: 95%; 17 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); 18 | } 19 | 20 | /* For readability concerns, you should choose a lighter palette in dark mode. */ 21 | [data-theme="dark"] { 22 | --ifm-color-primary: #25c2a0; 23 | --ifm-color-primary-dark: #21af90; 24 | --ifm-color-primary-darker: #1fa588; 25 | --ifm-color-primary-darkest: #1a8870; 26 | --ifm-color-primary-light: #29d5b0; 27 | --ifm-color-primary-lighter: #32d8b4; 28 | --ifm-color-primary-lightest: #4fddbf; 29 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3); 30 | } 31 | -------------------------------------------------------------------------------- /website/docs/tutorial-basics/congratulations.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 6 3 | --- 4 | 5 | # Congratulations! 6 | 7 | You have just learned the **basics of Docusaurus** and made some changes to the **initial template**. 8 | 9 | Docusaurus has **much more to offer**! 10 | 11 | Have **5 more minutes**? Take a look at **[versioning](../tutorial-extras/manage-docs-versions.md)** and **[i18n](../tutorial-extras/translate-your-site.md)**. 12 | 13 | Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://github.com/facebook/docusaurus/discussions/4610) 14 | 15 | ## What's next? 16 | 17 | - Read the [official documentation](https://docusaurus.io/) 18 | - Modify your site configuration with [`docusaurus.config.js`](https://docusaurus.io/docs/api/docusaurus-config) 19 | - Add navbar and footer items with [`themeConfig`](https://docusaurus.io/docs/api/themes/configuration) 20 | - Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout) 21 | - Add a [search bar](https://docusaurus.io/docs/search) 22 | - Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase) 23 | - Get involved in the [Docusaurus Community](https://docusaurus.io/community/support) 24 | -------------------------------------------------------------------------------- /test/changeable.test.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import "@testing-library/jest-dom"; 3 | import { render, screen } from "@testing-library/react"; 4 | import { 5 | MRouter, 6 | defineRouterConfig, 7 | useRouter 8 | } from "../packages/react-router-manage/index"; 9 | import { routes, Page } from "./routeConfig"; 10 | 11 | const WrapComponent = ({ children }) => { 12 | const { currentRoute } = useRouter(); 13 | return ( 14 |
15 |
{currentRoute.path}
16 |
{children}
17 |
18 | ); 19 | }; 20 | 21 | const appRouterConfig = defineRouterConfig({ 22 | basename: "/", 23 | routes: routes, 24 | LoadingComponent: () =>
current component is loading
25 | }); 26 | 27 | describe("changeable tests", () => { 28 | it("配置了beforeEnter组件显示加载中", () => { 29 | history.pushState({}, "", "/a/page2/noJump"); 30 | render( 31 | 36 | ); 37 | 38 | const result = screen.getByText(/current component is loading/); 39 | expect(result).toBeInTheDocument(); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /website/docs/tutorial-basics/create-a-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Create a Page 6 | 7 | Add **Markdown or React** files to `src/pages` to create a **standalone page**: 8 | 9 | - `src/pages/index.js` → `localhost:3000/` 10 | - `src/pages/foo.md` → `localhost:3000/foo` 11 | - `src/pages/foo/bar.js` → `localhost:3000/foo/bar` 12 | 13 | ## Create your first React Page 14 | 15 | Create a file at `src/pages/my-react-page.js`: 16 | 17 | ```jsx title="src/pages/my-react-page.js" 18 | import React from "react"; 19 | import Layout from "@theme/Layout"; 20 | 21 | export default function MyReactPage() { 22 | return ( 23 | 24 |

My React page

25 |

This is a React page

26 |
27 | ); 28 | } 29 | ``` 30 | 31 | A new page is now available at [http://localhost:3000/my-react-page](http://localhost:3000/my-react-page). 32 | 33 | ## Create your first Markdown Page 34 | 35 | Create a file at `src/pages/my-markdown-page.md`: 36 | 37 | ```mdx title="src/pages/my-markdown-page.md" 38 | # My Markdown page 39 | 40 | This is a Markdown page 41 | ``` 42 | 43 | A new page is now available at [http://localhost:3000/my-markdown-page](http://localhost:3000/my-markdown-page). 44 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/components/NoAuth/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | const PageConfig = { 4 | "401": { 5 | title: "401 NO PERMISSION", 6 | img: "//ysf.qiyukf.net/yx/9c9ce7793b3c0657da5d80e740a89681" 7 | }, 8 | "404": { 9 | title: "404 NOT FOUND", 10 | img: "https://ysf.nosdn.127.net/ysh/6be90dea7806767fe65e7b48982b7a61" 11 | } 12 | } as Record; 13 | 14 | const NoAuth: React.FC<{ code?: "404" | "401" }> = ({ code = "401" }) => { 15 | const config = PageConfig[code]; 16 | return ( 17 |
28 | {config.title} 29 |
37 | {config.title} 38 |
39 |
40 | ); 41 | }; 42 | 43 | NoAuth.displayName = "NoAuth"; 44 | 45 | export default NoAuth; 46 | -------------------------------------------------------------------------------- /examples/beforeEachMount/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage" 31 | ), 32 | history: path.join(__dirname, "./node_modules/history"), 33 | "react-router": path.join(__dirname, "./node_modules/react-router"), 34 | "react-router-dom": path.join( 35 | __dirname, 36 | "./node_modules/react-router-dom" 37 | ), 38 | "query-string": path.join(__dirname, "./node_modules/query-string") 39 | } 40 | } 41 | : {} 42 | }); 43 | -------------------------------------------------------------------------------- /examples/custom-link/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage" 31 | ), 32 | history: path.join(__dirname, "./node_modules/history"), 33 | "react-router": path.join(__dirname, "./node_modules/react-router"), 34 | "react-router-dom": path.join( 35 | __dirname, 36 | "./node_modules/react-router-dom" 37 | ), 38 | "query-string": path.join(__dirname, "./node_modules/query-string") 39 | } 40 | } 41 | : {} 42 | }); 43 | -------------------------------------------------------------------------------- /examples/lazy-loading/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage" 31 | ), 32 | history: path.join(__dirname, "./node_modules/history"), 33 | "react-router": path.join(__dirname, "./node_modules/react-router"), 34 | "react-router-dom": path.join( 35 | __dirname, 36 | "./node_modules/react-router-dom" 37 | ), 38 | "query-string": path.join(__dirname, "./node_modules/query-string") 39 | } 40 | } 41 | : {} 42 | }); 43 | -------------------------------------------------------------------------------- /examples/custom-filter-link/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage" 31 | ), 32 | history: path.join(__dirname, "./node_modules/history"), 33 | "react-router": path.join(__dirname, "./node_modules/react-router"), 34 | "react-router-dom": path.join( 35 | __dirname, 36 | "./node_modules/react-router-dom" 37 | ), 38 | "query-string": path.join(__dirname, "./node_modules/query-string") 39 | } 40 | } 41 | : {} 42 | }); 43 | -------------------------------------------------------------------------------- /examples/custom-query-parsing/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage" 31 | ), 32 | history: path.join(__dirname, "./node_modules/history"), 33 | "react-router": path.join(__dirname, "./node_modules/react-router"), 34 | "react-router-dom": path.join( 35 | __dirname, 36 | "./node_modules/react-router-dom" 37 | ), 38 | "query-string": path.join(__dirname, "./node_modules/query-string") 39 | } 40 | } 41 | : {} 42 | }); 43 | -------------------------------------------------------------------------------- /website/docs/tutorial-basics/create-a-document.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | # Create a Document 6 | 7 | Documents are **groups of pages** connected through: 8 | 9 | - a **sidebar** 10 | - **previous/next navigation** 11 | - **versioning** 12 | 13 | ## Create your first Doc 14 | 15 | Create a Markdown file at `docs/hello.md`: 16 | 17 | ```md title="docs/hello.md" 18 | # Hello 19 | 20 | This is my **first Docusaurus document**! 21 | ``` 22 | 23 | A new document is now available at [http://localhost:3000/docs/hello](http://localhost:3000/docs/hello). 24 | 25 | ## Configure the Sidebar 26 | 27 | Docusaurus automatically **creates a sidebar** from the `docs` folder. 28 | 29 | Add metadata to customize the sidebar label and position: 30 | 31 | ```md title="docs/hello.md" {1-4} 32 | --- 33 | sidebar_label: "Hi!" 34 | sidebar_position: 3 35 | --- 36 | 37 | # Hello 38 | 39 | This is my **first Docusaurus document**! 40 | ``` 41 | 42 | It is also possible to create your sidebar explicitly in `sidebars.js`: 43 | 44 | ```js title="sidebars.js" 45 | export default { 46 | tutorialSidebar: [ 47 | "intro", 48 | // highlight-next-line 49 | "hello", 50 | { 51 | type: "category", 52 | label: "Tutorial", 53 | items: ["tutorial-basics/create-a-document"] 54 | } 55 | ] 56 | }; 57 | ``` 58 | -------------------------------------------------------------------------------- /examples/lazy-loading/src/pages/Dashboard.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Routes, Route, Outlet, Link } from "react-router-dom"; 3 | 4 | export default function Dashboard() { 5 | // These routes are defined when this component is loaded on demand via 6 | // dynamic import() on the home page! 7 | return ( 8 | 9 | }> 10 | } /> 11 | } /> 12 | 13 | 14 | ); 15 | } 16 | 17 | function DashboardLayout() { 18 | return ( 19 |
20 | 30 | 31 |
32 | 33 | 34 |
35 | ); 36 | } 37 | 38 | function DashboardIndex() { 39 | return ( 40 |
41 |

Dashboard Index

42 |
43 | ); 44 | } 45 | 46 | function Messages() { 47 | return ( 48 |
49 |

Messages

50 |
    51 |
  • Message 1
  • 52 |
  • Message 2
  • 53 |
54 |
55 | ); 56 | } 57 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids", 15 | "typecheck": "tsc" 16 | }, 17 | "dependencies": { 18 | "@docusaurus/core": "3.1.0", 19 | "@docusaurus/preset-classic": "3.1.0", 20 | "@mdx-js/react": "^3.0.0", 21 | "clsx": "^2.0.0", 22 | "prism-react-renderer": "^2.3.0", 23 | "react": "^18.0.0", 24 | "react-dom": "^18.0.0" 25 | }, 26 | "devDependencies": { 27 | "@docusaurus/module-type-aliases": "3.1.0", 28 | "@docusaurus/tsconfig": "3.1.0", 29 | "@docusaurus/types": "3.1.0", 30 | "typescript": "~5.2.2" 31 | }, 32 | "browserslist": { 33 | "production": [ 34 | ">0.5%", 35 | "not dead", 36 | "not op_mini all" 37 | ], 38 | "development": [ 39 | "last 3 chrome version", 40 | "last 3 firefox version", 41 | "last 5 safari version" 42 | ] 43 | }, 44 | "engines": { 45 | "node": ">=18.0" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/react-router-manage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-router-manage", 3 | "version": "2.0.5", 4 | "author": "wenxinping@corp.netease.com", 5 | "description": "react-router-manage extends react-router(v6), it Including authentication, configuration, addition, deletion and modification", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/NSFI/react-router-manage.git", 9 | "directory": "packages/react-router-manage" 10 | }, 11 | "license": "MIT", 12 | "main": "./dist/main.js", 13 | "unpkg": "./dist/umd/react-router-dom.production.min.js", 14 | "module": "./dist/index.js", 15 | "types": "./dist/index.d.ts", 16 | "peerDependencies": { 17 | "react": ">=16.8", 18 | "react-dom": ">=16.8" 19 | }, 20 | "dependencies": { 21 | "query-string": "^7.1.1", 22 | "react-router": "6.9.0", 23 | "react-router-dom": "6.9.0", 24 | "@remix-run/router": "1.4.0" 25 | }, 26 | "devDependencies": { 27 | "@types/query-string": "^6.3.0" 28 | }, 29 | "files": [ 30 | "dist/", 31 | "README.md" 32 | ], 33 | "sideEffects": false, 34 | "keywords": [ 35 | "react", 36 | "router", 37 | "react-router", 38 | "router-manage", 39 | "router-pro", 40 | "route", 41 | "routing", 42 | "history", 43 | "guard", 44 | "react router guard", 45 | "路由管理" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | build: { 18 | rollupOptions: { 19 | input: { 20 | main: path.resolve(__dirname, "index.html"), 21 | breadcrumbs: path.resolve( 22 | __dirname, 23 | "entry/antd-breadcrumbs/index.html" 24 | ), 25 | basic: path.resolve(__dirname, "entry/basic/index.html") 26 | } 27 | } 28 | }, 29 | css: { 30 | preprocessorOptions: { 31 | less: { 32 | javascriptEnabled: true 33 | } 34 | } 35 | }, 36 | resolve: process.env.USE_SOURCE 37 | ? { 38 | alias: { 39 | "react-router-manage": path.join( 40 | __dirname, 41 | "./packages/react-router-manage" 42 | ), 43 | "@rrmc/antd-breadcrumbs": path.join( 44 | __dirname, 45 | "./packages/antd-breadcrumbs" 46 | ) 47 | } 48 | } 49 | : {} 50 | }); 51 | -------------------------------------------------------------------------------- /examples/actions/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage/index.tsx" 31 | ), 32 | "@remix-run/router": path.resolve( 33 | __dirname, 34 | "./node_modules/@remix-run/router" 35 | ), 36 | history: path.join(__dirname, "./node_modules/history"), 37 | "react-router": path.join(__dirname, "./node_modules/react-router"), 38 | "react-router-dom": path.join( 39 | __dirname, 40 | "./node_modules/react-router-dom" 41 | ), 42 | "query-string": path.join(__dirname, "./node_modules/query-string") 43 | } 44 | } 45 | : {} 46 | }); 47 | -------------------------------------------------------------------------------- /examples/basic/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage/index.tsx" 31 | ), 32 | "@remix-run/router": path.resolve( 33 | __dirname, 34 | "./node_modules/@remix-run/router" 35 | ), 36 | history: path.join(__dirname, "./node_modules/history"), 37 | "react-router": path.join(__dirname, "./node_modules/react-router"), 38 | "react-router-dom": path.join( 39 | __dirname, 40 | "./node_modules/react-router-dom" 41 | ), 42 | "query-string": path.join(__dirname, "./node_modules/query-string") 43 | } 44 | } 45 | : {} 46 | }); 47 | -------------------------------------------------------------------------------- /examples/beforeEnter/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage/index.tsx" 31 | ), 32 | "@remix-run/router": path.resolve( 33 | __dirname, 34 | "./node_modules/@remix-run/router" 35 | ), 36 | history: path.join(__dirname, "./node_modules/history"), 37 | "react-router": path.join(__dirname, "./node_modules/react-router"), 38 | "react-router-dom": path.join( 39 | __dirname, 40 | "./node_modules/react-router-dom" 41 | ), 42 | "query-string": path.join(__dirname, "./node_modules/query-string") 43 | } 44 | } 45 | : {} 46 | }); 47 | -------------------------------------------------------------------------------- /examples/children/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage/index.tsx" 31 | ), 32 | "@remix-run/router": path.resolve( 33 | __dirname, 34 | "./node_modules/@remix-run/router" 35 | ), 36 | history: path.join(__dirname, "./node_modules/history"), 37 | "react-router": path.join(__dirname, "./node_modules/react-router"), 38 | "react-router-dom": path.join( 39 | __dirname, 40 | "./node_modules/react-router-dom" 41 | ), 42 | "query-string": path.join(__dirname, "./node_modules/query-string") 43 | } 44 | } 45 | : {} 46 | }); 47 | -------------------------------------------------------------------------------- /examples/permission/vite.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { defineConfig } from "vite"; 3 | import react from "@vitejs/plugin-react"; 4 | import rollupReplace from "@rollup/plugin-replace"; 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [ 8 | rollupReplace({ 9 | preventAssignment: true, 10 | values: { 11 | __DEV__: JSON.stringify(true), 12 | "process.env.NODE_ENV": JSON.stringify("development") 13 | } 14 | }), 15 | react() 16 | ], 17 | 18 | css: { 19 | preprocessorOptions: { 20 | less: { 21 | javascriptEnabled: true 22 | } 23 | } 24 | }, 25 | resolve: process.env.USE_SOURCE 26 | ? { 27 | alias: { 28 | "react-router-manage": path.join( 29 | __dirname, 30 | "../../packages/react-router-manage/index.tsx" 31 | ), 32 | "@remix-run/router": path.resolve( 33 | __dirname, 34 | "./node_modules/@remix-run/router" 35 | ), 36 | history: path.join(__dirname, "./node_modules/history"), 37 | "react-router": path.join(__dirname, "./node_modules/react-router"), 38 | "react-router-dom": path.join( 39 | __dirname, 40 | "./node_modules/react-router-dom" 41 | ), 42 | "query-string": path.join(__dirname, "./node_modules/query-string") 43 | } 44 | } 45 | : {} 46 | }); 47 | -------------------------------------------------------------------------------- /website/src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import clsx from "clsx"; 2 | import Link from "@docusaurus/Link"; 3 | import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; 4 | import Layout from "@theme/Layout"; 5 | import HomepageFeatures from "@site/src/components/HomepageFeatures"; 6 | import Heading from "@theme/Heading"; 7 | 8 | import styles from "./index.module.css"; 9 | 10 | function HomepageHeader() { 11 | const { siteConfig } = useDocusaurusContext(); 12 | return ( 13 |
14 |
15 | 16 | {siteConfig.title} 17 | 18 |

{siteConfig.tagline}

19 |
20 | 24 | Docusaurus Tutorial - 5min ⏱️ 25 | 26 |
27 |
28 |
29 | ); 30 | } 31 | 32 | export default function Home(): JSX.Element { 33 | const { siteConfig } = useDocusaurusContext(); 34 | return ( 35 | 39 | 40 |
41 | 42 |
43 |
44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /website/docs/tutorial-extras/manage-docs-versions.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Manage Docs Versions 6 | 7 | Docusaurus can manage multiple versions of your docs. 8 | 9 | ## Create a docs version 10 | 11 | Release a version 1.0 of your project: 12 | 13 | ```bash 14 | npm run docusaurus docs:version 1.0 15 | ``` 16 | 17 | The `docs` folder is copied into `versioned_docs/version-1.0` and `versions.json` is created. 18 | 19 | Your docs now have 2 versions: 20 | 21 | - `1.0` at `http://localhost:3000/docs/` for the version 1.0 docs 22 | - `current` at `http://localhost:3000/docs/next/` for the **upcoming, unreleased docs** 23 | 24 | ## Add a Version Dropdown 25 | 26 | To navigate seamlessly across versions, add a version dropdown. 27 | 28 | Modify the `docusaurus.config.js` file: 29 | 30 | ```js title="docusaurus.config.js" 31 | export default { 32 | themeConfig: { 33 | navbar: { 34 | items: [ 35 | // highlight-start 36 | { 37 | type: "docsVersionDropdown" 38 | } 39 | // highlight-end 40 | ] 41 | } 42 | } 43 | }; 44 | ``` 45 | 46 | The docs version dropdown appears in your navbar: 47 | 48 | ![Docs Version Dropdown](./img/docsVersionDropdown.png) 49 | 50 | ## Update an existing version 51 | 52 | It is possible to edit versioned docs in their respective folder: 53 | 54 | - `versioned_docs/version-1.0/hello.md` updates `http://localhost:3000/docs/hello` 55 | - `docs/hello.md` updates `http://localhost:3000/docs/next/hello` 56 | -------------------------------------------------------------------------------- /docs/assets/js/main.e3a6ce89.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress 8 | * @license MIT */ 9 | 10 | /** 11 | * Prism: Lightweight, robust, elegant syntax highlighting 12 | * 13 | * @license MIT 14 | * @author Lea Verou 15 | * @namespace 16 | * @public 17 | */ 18 | 19 | /** @license React v0.20.2 20 | * scheduler.production.min.js 21 | * 22 | * Copyright (c) Facebook, Inc. and its affiliates. 23 | * 24 | * This source code is licensed under the MIT license found in the 25 | * LICENSE file in the root directory of this source tree. 26 | */ 27 | 28 | /** @license React v16.13.1 29 | * react-is.production.min.js 30 | * 31 | * Copyright (c) Facebook, Inc. and its affiliates. 32 | * 33 | * This source code is licensed under the MIT license found in the 34 | * LICENSE file in the root directory of this source tree. 35 | */ 36 | 37 | /** @license React v17.0.2 38 | * react-dom.production.min.js 39 | * 40 | * Copyright (c) Facebook, Inc. and its affiliates. 41 | * 42 | * This source code is licensed under the MIT license found in the 43 | * LICENSE file in the root directory of this source tree. 44 | */ 45 | 46 | /** @license React v17.0.2 47 | * react.production.min.js 48 | * 49 | * Copyright (c) Facebook, Inc. and its affiliates. 50 | * 51 | * This source code is licensed under the MIT license found in the 52 | * LICENSE file in the root directory of this source tree. 53 | */ 54 | -------------------------------------------------------------------------------- /website/docs/intro.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Tutorial Intro 6 | 7 | Let's discover **Docusaurus in less than 5 minutes**. 8 | 9 | ## Getting Started 10 | 11 | Get started by **creating a new site**. 12 | 13 | Or **try Docusaurus immediately** with **[docusaurus.new](https://docusaurus.new)**. 14 | 15 | ### What you'll need 16 | 17 | - [Node.js](https://nodejs.org/en/download/) version 18.0 or above: 18 | - When installing Node.js, you are recommended to check all checkboxes related to dependencies. 19 | 20 | ## Generate a new site 21 | 22 | Generate a new Docusaurus site using the **classic template**. 23 | 24 | The classic template will automatically be added to your project after you run the command: 25 | 26 | ```bash 27 | npm init docusaurus@latest my-website classic 28 | ``` 29 | 30 | You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor. 31 | 32 | The command also installs all necessary dependencies you need to run Docusaurus. 33 | 34 | ## Start your site 35 | 36 | Run the development server: 37 | 38 | ```bash 39 | cd my-website 40 | npm run start 41 | ``` 42 | 43 | The `cd` command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there. 44 | 45 | The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/. 46 | 47 | Open `docs/intro.md` (this page) and edit some lines: the site **reloads automatically** and displays your changes. 48 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/core/MRouterContextProvider/replaceHistoryMethods.ts: -------------------------------------------------------------------------------- 1 | import type { To } from "react-router-dom"; 2 | import { HistoryMethodsI, OldBrowserHistory } from "../../type"; 3 | import { getRealTo } from "../../util"; 4 | 5 | export default function replaceHistoryMethods( 6 | history: OldBrowserHistory, 7 | allExecuteEventCbs: (historyCb: () => void, to?: To) => void, 8 | oldHistoryMethods: HistoryMethodsI 9 | ) { 10 | history.go = (delta: number) => { 11 | allExecuteEventCbs(() => { 12 | const res = oldHistoryMethods.go(delta); 13 | // history.go = oldHistoryMethods.go; 14 | return res; 15 | }); 16 | }; 17 | history.push = (to: To, state?: any) => { 18 | to = getRealTo(to); 19 | allExecuteEventCbs(() => { 20 | const res = oldHistoryMethods.push(to, state); 21 | // history.push = oldHistoryMethods.push; 22 | return res; 23 | }, to); 24 | }; 25 | 26 | history.replace = (to: To, state?: any) => { 27 | to = getRealTo(to); 28 | allExecuteEventCbs(() => { 29 | const res = oldHistoryMethods.replace(to, state); 30 | // history.replace = oldHistoryMethods.replace; 31 | return res; 32 | }, to); 33 | }; 34 | 35 | history.back = () => { 36 | allExecuteEventCbs(() => { 37 | const res = oldHistoryMethods.go(-1); 38 | // history.back = oldHistoryMethods.back; 39 | return res; 40 | }); 41 | }; 42 | 43 | history.forward = () => { 44 | allExecuteEventCbs(() => { 45 | const res = oldHistoryMethods.go(1); 46 | // history.forward = oldHistoryMethods.forward; 47 | return res; 48 | }); 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Menu, Layout } from "antd"; 3 | 4 | import { MRouter, MHRouter, useRouter } from "react-router-manage"; 5 | import routerConfig from "./router"; 6 | import AntdRouterBreadcrumbs from "@rrmc/antd-breadcrumbs"; 7 | import { useMemo } from "react"; 8 | 9 | const { Sider, Content } = Layout; 10 | 11 | const Router = window.__INITIAL_DATA__.mode === "hash" ? MHRouter : MRouter; 12 | 13 | function getItems(routes) { 14 | return routes.map(i => { 15 | const item: any = { 16 | key: i.name, 17 | label: i.title 18 | }; 19 | if (i.items?.length) { 20 | item.children = getItems(i.items); 21 | } 22 | return item; 23 | }); 24 | } 25 | 26 | function RouterLayout({ children }) { 27 | const { routes, routesMap, navigate } = useRouter(); 28 | 29 | const items = useMemo(() => { 30 | return getItems(routes); 31 | }, [routes]); 32 | return ( 33 | 34 | 35 | { 40 | console.log(key); 41 | navigate(routesMap[key]?.path); 42 | }} 43 | > 44 | 45 | 46 |
47 | 48 |
49 | 50 |
{children}
51 |
52 |
53 | ); 54 | } 55 | 56 | export default function App() { 57 | return ( 58 |
59 |

Antd router breadcrumbs2

60 | 61 |
62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * For a detailed explanation regarding each configuration property, visit: 3 | * https://jestjs.io/docs/en/configuration.html 4 | */ 5 | 6 | module.exports = { 7 | collectCoverageFrom: [ 8 | 'packages/**/src/**/*.{js,jsx,ts,tsx}', 9 | '!packages/**/*.d.ts', 10 | '!packages/**/dist/**/*', 11 | ], 12 | moduleFileExtensions: [ 13 | 'js', 'jsx', 'json', 'ts', 'tsx', 'md' 14 | ], 15 | // 测试之前的准备 16 | setupFiles: [ 17 | // 'react-app-ployfill/jsdom', 18 | ], 19 | testMatch: [ 20 | '/test/**/*.test.{js,jsx,ts,tsx}' 21 | ], 22 | // 测试运行的环境 23 | testEnvironment: 'enzyme', 24 | testEnvironmentOptions: { 25 | enzymeAdapter: 'react17', 26 | }, 27 | transform: { 28 | '^.+\\.(js|jsx|ts|tsx)$': '/node_modules/babel-jest', 29 | // '^.+\\.css$': '/config/jest/cssTransform.js', 30 | // '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '/config/jest/fileTransform.js' 31 | }, 32 | 33 | transformIgnorePatterns: [ 34 | '/node_modules/(?!(ppfish)|(gsap))', 35 | '^.+\\.module\\.(css|sass|scss)$' 36 | ], 37 | modulePaths: [], 38 | 39 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module 40 | moduleNameMapper: { 41 | '.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'identity-obj-proxy', 42 | }, 43 | 44 | // Automatically clear mock calls and instances between every test 45 | clearMocks: true, 46 | 47 | // Indicates whether the coverage information should be collected while executing the test 48 | collectCoverage: true, 49 | 50 | // The directory where Jest should output its coverage files 51 | coverageDirectory: 'coverage', 52 | testPathIgnorePatterns: [ 53 | '/node_modules/' 54 | ], 55 | globals: { 56 | "__DEV__": true 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/core/MRouterContextProvider/getInitialState.ts: -------------------------------------------------------------------------------- 1 | import { NewStateI, NewStateQueryI } from "../../type"; 2 | import { computedNewState } from "../../util"; 3 | 4 | // Initialized data to prevent double calculation 5 | // defineRouterConfig may be called multiple times in the same application 6 | let initialStateMap = new Map< 7 | number, 8 | { 9 | queryData: NewStateQueryI; 10 | initialData: NewStateI; 11 | } 12 | >(); 13 | 14 | function getSameQueryData( 15 | prevData: NewStateQueryI, 16 | currentData: NewStateQueryI 17 | ) { 18 | return ( 19 | prevData.basename === currentData.basename && 20 | prevData.hasAuth === currentData.hasAuth && 21 | prevData.beforeEachMount === currentData.beforeEachMount && 22 | prevData.inputRoutes === currentData.inputRoutes && 23 | prevData.permissionList === currentData.permissionList 24 | ); 25 | } 26 | function getInitialState( 27 | currentQueryData: NewStateQueryI & { _defineId: number } 28 | ): NewStateI { 29 | const { 30 | inputRoutes, 31 | hasAuth, 32 | permissionList, 33 | permissionMode, 34 | beforeEachMount, 35 | basename, 36 | location, 37 | _defineId 38 | } = currentQueryData; 39 | const prevData = initialStateMap.get(_defineId); 40 | if (prevData) { 41 | const isSameQueryData = getSameQueryData( 42 | prevData.queryData, 43 | currentQueryData 44 | ); 45 | if (isSameQueryData) { 46 | return prevData.initialData; 47 | } 48 | } 49 | const _initialState = computedNewState({ 50 | inputRoutes, 51 | permissionList, 52 | permissionMode, 53 | hasAuth, 54 | beforeEachMount, 55 | basename, 56 | location 57 | }); 58 | initialStateMap.set(_defineId, { 59 | queryData: currentQueryData, 60 | initialData: _initialState 61 | }); 62 | return _initialState; 63 | } 64 | 65 | export default getInitialState; 66 | -------------------------------------------------------------------------------- /packages/antd-breadcrumbs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @rrmc/antd-breadcrumbs 2 | 3 | ## 2.0.5 4 | 5 | ### Patch Changes 6 | 7 | - Updated dependencies [62c1693] 8 | - Updated dependencies [064b691] 9 | - react-router-manage@2.0.5 10 | 11 | ## 2.0.5-beta.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies 16 | - react-router-manage@2.0.5-beta.1 17 | 18 | ## 2.0.5-beta.0 19 | 20 | ### Patch Changes 21 | 22 | - Updated dependencies 23 | - react-router-manage@2.0.5-beta.0 24 | 25 | ## 2.0.4 26 | 27 | ### Patch Changes 28 | 29 | - Updated dependencies 30 | - react-router-manage@2.0.4 31 | 32 | ## 2.0.3 33 | 34 | ### Patch Changes 35 | 36 | - Updated dependencies 37 | - react-router-manage@2.0.3 38 | 39 | ## 2.0.2 40 | 41 | ### Patch Changes 42 | 43 | - Updated dependencies 44 | - react-router-manage@2.0.2 45 | 46 | ## 2.0.1 47 | 48 | ### Patch Changes 49 | 50 | - release v2.0.1 51 | - ab88d54: upgrade react-router version to 6.9.0 52 | - Updated dependencies 53 | - Updated dependencies [ab88d54] 54 | - react-router-manage@2.0.1 55 | 56 | ## 2.0.1-beta.0 57 | 58 | ### Patch Changes 59 | 60 | - upgrade react-router version to 6.9.0 61 | - Updated dependencies 62 | - react-router-manage@2.0.1-beta.0 63 | 64 | ## 2.0.0 65 | 66 | ### Minor Changes 67 | 68 | - bd5a383: release package: @rrmc/antd-breadcrumbs 69 | 70 | ### Patch Changes 71 | 72 | - f04642e: add package @rrmc/antd-breadcrumbs docs 73 | - release package @rrmc/antd-breadcrumbs 74 | - Updated dependencies [f04642e] 75 | - Updated dependencies [bd5a383] 76 | - Updated dependencies 77 | - react-router-manage@2.0.0 78 | 79 | ## 1.2.0 80 | 81 | ### Patch Changes 82 | 83 | - add package @rrmc/antd-breadcrumbs docs 84 | - Updated dependencies 85 | - react-router-manage@1.2.0 86 | 87 | ## 1.2.0-beta.0 88 | 89 | ### Minor Changes 90 | 91 | - release package: @rrmc/antd-breadcrumbs 92 | 93 | ### Patch Changes 94 | 95 | - Updated dependencies 96 | - react-router-manage@1.2.0-beta.0 97 | -------------------------------------------------------------------------------- /website/docs/tutorial-extras/translate-your-site.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | # Translate your site 6 | 7 | Let's translate `docs/intro.md` to French. 8 | 9 | ## Configure i18n 10 | 11 | Modify `docusaurus.config.js` to add support for the `fr` locale: 12 | 13 | ```js title="docusaurus.config.js" 14 | export default { 15 | i18n: { 16 | defaultLocale: "en", 17 | locales: ["en", "fr"] 18 | } 19 | }; 20 | ``` 21 | 22 | ## Translate a doc 23 | 24 | Copy the `docs/intro.md` file to the `i18n/fr` folder: 25 | 26 | ```bash 27 | mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/ 28 | 29 | cp docs/intro.md i18n/fr/docusaurus-plugin-content-docs/current/intro.md 30 | ``` 31 | 32 | Translate `i18n/fr/docusaurus-plugin-content-docs/current/intro.md` in French. 33 | 34 | ## Start your localized site 35 | 36 | Start your site on the French locale: 37 | 38 | ```bash 39 | npm run start -- --locale fr 40 | ``` 41 | 42 | Your localized site is accessible at [http://localhost:3000/fr/](http://localhost:3000/fr/) and the `Getting Started` page is translated. 43 | 44 | :::caution 45 | 46 | In development, you can only use one locale at a time. 47 | 48 | ::: 49 | 50 | ## Add a Locale Dropdown 51 | 52 | To navigate seamlessly across languages, add a locale dropdown. 53 | 54 | Modify the `docusaurus.config.js` file: 55 | 56 | ```js title="docusaurus.config.js" 57 | export default { 58 | themeConfig: { 59 | navbar: { 60 | items: [ 61 | // highlight-start 62 | { 63 | type: "localeDropdown" 64 | } 65 | // highlight-end 66 | ] 67 | } 68 | } 69 | }; 70 | ``` 71 | 72 | The locale dropdown now appears in your navbar: 73 | 74 | ![Locale Dropdown](./img/localeDropdown.png) 75 | 76 | ## Build your localized site 77 | 78 | Build your site for a specific locale: 79 | 80 | ```bash 81 | npm run build -- --locale fr 82 | ``` 83 | 84 | Or build your site to include all the locales at once: 85 | 86 | ```bash 87 | npm run build 88 | ``` 89 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/core/MRouterContextProvider/computedUseRoutesConfig.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Suspense } from "react"; 3 | import { changeable } from "../../changeable"; 4 | import { RouteConfig, RouteTypeExtendsI } from "../../type"; 5 | import { flattenArr } from "../../util"; 6 | 7 | export default function computedUseRoutesConfig(routes: RouteTypeExtendsI[]) { 8 | const _routes = routes.map(route => { 9 | let _routeConfig: RouteConfig | undefined; 10 | let _itemsRouteConfig: RouteConfig[] = []; 11 | const { 12 | _component: Component, 13 | path, 14 | items, 15 | children, 16 | _isHasAuth, 17 | _props, 18 | props 19 | } = route; 20 | 21 | // _props is the user interceptor hook, if there is no hook, use props 22 | const needInputProps = _props || props; 23 | if (Component) { 24 | const LoadingCmp = changeable.LoadingComponent; 25 | if (!_isHasAuth) { 26 | /** Without permission, the child also has no permission */ 27 | return { 28 | path: path.endsWith("*") ? path : `${path}/*`, 29 | element: ( 30 | }> 31 | 32 | 33 | ) 34 | } as RouteConfig; 35 | } 36 | _routeConfig = { 37 | path, 38 | element: ( 39 | }> 40 | 41 | 42 | ) 43 | } as RouteConfig; 44 | if (children) { 45 | _routeConfig.children = computedUseRoutesConfig(children); 46 | } 47 | if (items) { 48 | _itemsRouteConfig = computedUseRoutesConfig(items); 49 | } 50 | } 51 | 52 | const nextRoutes = [_routeConfig, ..._itemsRouteConfig].filter(i => { 53 | return i !== undefined; 54 | }) as RouteConfig[]; 55 | return nextRoutes; 56 | }); 57 | return flattenArr(_routes); 58 | } 59 | -------------------------------------------------------------------------------- /website/src/components/HomepageFeatures/index.tsx: -------------------------------------------------------------------------------- 1 | import clsx from "clsx"; 2 | import Heading from "@theme/Heading"; 3 | import styles from "./styles.module.css"; 4 | 5 | type FeatureItem = { 6 | title: string; 7 | Svg: React.ComponentType>; 8 | description: JSX.Element; 9 | }; 10 | 11 | const FeatureList: FeatureItem[] = [ 12 | { 13 | title: "Easy to Use", 14 | Svg: require("@site/static/img/undraw_docusaurus_mountain.svg").default, 15 | description: ( 16 | <> 17 | Docusaurus was designed from the ground up to be easily installed and 18 | used to get your website up and running quickly. 19 | 20 | ) 21 | }, 22 | { 23 | title: "Focus on What Matters", 24 | Svg: require("@site/static/img/undraw_docusaurus_tree.svg").default, 25 | description: ( 26 | <> 27 | Docusaurus lets you focus on your docs, and we'll do the chores. Go 28 | ahead and move your docs into the docs directory. 29 | 30 | ) 31 | }, 32 | { 33 | title: "Powered by React", 34 | Svg: require("@site/static/img/undraw_docusaurus_react.svg").default, 35 | description: ( 36 | <> 37 | Extend or customize your website layout by reusing React. Docusaurus can 38 | be extended while reusing the same header and footer. 39 | 40 | ) 41 | } 42 | ]; 43 | 44 | function Feature({ title, Svg, description }: FeatureItem) { 45 | return ( 46 |
47 |
48 | 49 |
50 |
51 | {title} 52 |

{description}

53 |
54 |
55 | ); 56 | } 57 | 58 | export default function HomepageFeatures(): JSX.Element { 59 | return ( 60 |
61 |
62 |
63 | {FeatureList.map((props, idx) => ( 64 | 65 | ))} 66 |
67 |
68 |
69 | ); 70 | } 71 | -------------------------------------------------------------------------------- /rollup.utils.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const fse = require("fs-extra"); 3 | 4 | const PRETTY = !!process.env.PRETTY; 5 | 6 | /** 7 | * Determine the relevant directories for a rollup build, relative to the 8 | * current working directory and taking LOCAL_BUILD_DIRECTORY into account 9 | * 10 | * ROOT_DIR Root directory for the react-router repo 11 | * SOURCE_DIR Source package directory we will read input files from 12 | * OUTPUT_DIR Destination directory to write rollup output to 13 | * 14 | * @param {string} packageName npm package name (i.e., @remix-run/router) 15 | * @param {string} [folderName] folder name (i.e., router). Defaults to package name 16 | */ 17 | function getBuildDirectories(packageName, folderName) { 18 | let ROOT_DIR = __dirname; 19 | let SOURCE_DIR = folderName 20 | ? path.join(__dirname, "packages", folderName) 21 | : path.join(__dirname, "packages", ...packageName.split("/")); 22 | 23 | // Update if we're not running from root 24 | if (process.cwd() !== __dirname) { 25 | ROOT_DIR = path.dirname(path.dirname(process.cwd())); 26 | SOURCE_DIR = process.cwd(); 27 | } 28 | 29 | let OUTPUT_DIR = path.join(SOURCE_DIR, "dist"); 30 | 31 | if (process.env.LOCAL_BUILD_DIRECTORY) { 32 | try { 33 | let nodeModulesDir = path.join( 34 | process.cwd(), 35 | process.env.LOCAL_BUILD_DIRECTORY, 36 | "node_modules" 37 | ); 38 | fse.readdirSync(nodeModulesDir); 39 | OUTPUT_DIR = path.join(nodeModulesDir, ...packageName.split("/"), "dist"); 40 | } catch (e) { 41 | console.error( 42 | "Oops! You pointed LOCAL_BUILD_DIRECTORY to a directory that " + 43 | "does not have a node_modules/ folder. Please `npm install` in that " + 44 | "directory and try again." 45 | ); 46 | process.exit(1); 47 | } 48 | } 49 | 50 | return { ROOT_DIR, SOURCE_DIR, OUTPUT_DIR }; 51 | } 52 | 53 | function createBanner(packageName, version) { 54 | return `/** 55 | * ${packageName} v${version} 56 | * 57 | * Copyright (c) onshinpei Inc. 58 | * 59 | * This source code is licensed under the MIT license found in the 60 | * LICENSE.md file in the root directory of this source tree. 61 | * 62 | * @license MIT 63 | */`; 64 | } 65 | 66 | module.exports = { 67 | getBuildDirectories, 68 | createBanner, 69 | PRETTY 70 | }; 71 | -------------------------------------------------------------------------------- /examples/custom-filter-link/src/snkrs.ts: -------------------------------------------------------------------------------- 1 | interface Sneaker { 2 | id: string; 3 | colorway: string; 4 | imageUrl: string; 5 | model: string; 6 | brand: string; 7 | } 8 | 9 | let SNEAKERS: Sneaker[] = [ 10 | { 11 | id: "1", 12 | colorway: "Pine Green", 13 | imageUrl: 14 | "https://images.mcan.sh/b_auto,c_pad,f_auto,h_400,q_auto,w_400/v1/shoes/bkkj0lqzlwlwdwtofqxs", 15 | model: "Blazer Low 77 Vintage", 16 | brand: "Nike" 17 | }, 18 | { 19 | id: "2", 20 | colorway: "Reverse Infrared", 21 | imageUrl: 22 | "https://images.mcan.sh/b_auto,c_pad,f_auto,h_400,q_auto,w_400/v1/shoes/RPlzC_CBHjiMM4dr90gdU", 23 | model: "Air Max 90", 24 | brand: "Nike" 25 | }, 26 | { 27 | id: "3", 28 | colorway: "White/Black/Desert", 29 | imageUrl: 30 | "https://images.mcan.sh/b_auto,c_pad,f_auto,h_400,q_auto,w_400/v1/shoes/0bf9336b-03c9-4cbd-b482-f4e80b770582", 31 | model: "Court Legacy", 32 | brand: "Nike" 33 | }, 34 | { 35 | id: "5", 36 | colorway: "Beluga 2.0", 37 | imageUrl: 38 | "https://images.mcan.sh/b_auto,c_pad,f_auto,h_400,q_auto,w_400/v1/shoes/irxakb1ij0uzmcvn9szo", 39 | model: "Yeezy 350 v2", 40 | brand: "Adidas" 41 | }, 42 | { 43 | id: "6", 44 | colorway: "Pumpkin Spice", 45 | imageUrl: 46 | "https://images.mcan.sh/b_auto,c_pad,f_auto,h_400,q_auto,w_400/v1/shoes/g9tjjjdn476nhou1c1dj", 47 | model: "Grid SD", 48 | brand: "Saucony" 49 | }, 50 | { 51 | id: "7", 52 | colorway: "Golden Coast", 53 | imageUrl: 54 | "https://images.mcan.sh/b_auto,c_pad,f_auto,h_400,q_auto,w_400/v1/shoes/erg1lxa8x29h1wtbog9a", 55 | model: "Checkerboard Slip-On", 56 | brand: "Vans" 57 | }, 58 | { 59 | id: "8", 60 | colorway: "Have a Nike Day", 61 | imageUrl: 62 | "https://images.mcan.sh/b_auto,c_pad,f_auto,h_400,q_auto,w_400/v1/shoes/u4z27k4wyzr7bxatlfgj", 63 | model: "Air Max 1", 64 | brand: "Nike" 65 | } 66 | ]; 67 | 68 | function filterByBrand(brand: string) { 69 | return SNEAKERS.filter( 70 | sneaker => sneaker.brand.toLowerCase() === brand.toLowerCase() 71 | ); 72 | } 73 | 74 | function getSneakerById(id: string) { 75 | return SNEAKERS.find(sneaker => sneaker.id === id); 76 | } 77 | 78 | let brands = [...new Set(SNEAKERS.map(sneaker => sneaker.brand))]; 79 | 80 | export { brands, SNEAKERS, filterByBrand, getSneakerById }; 81 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/Context/MRouterContext/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { 3 | addRoutesAction, 4 | removeRoutesAction, 5 | updateRoutesAction 6 | } from "./actions"; 7 | import type { 8 | Action, 9 | AddRoutesI, 10 | RoutesMapI, 11 | UpdateRoutesI, 12 | MRouterContextObject, 13 | MRouterStateI 14 | } from "../../type"; 15 | import { RouterActionEnum } from "../../type"; 16 | 17 | const MRouterContext = React.createContext({ 18 | state: { 19 | inputRoutes: [], 20 | authInputRoutes: [], 21 | permissionList: [], 22 | routesMap: {} as RoutesMapI, 23 | flattenRoutes: [] 24 | }, 25 | methods: {} 26 | } as unknown as MRouterContextObject); 27 | MRouterContext.displayName = "MRouterContext"; 28 | 29 | export function MRouterReducer( 30 | state: MRouterStateI, 31 | action: Action 32 | ): MRouterStateI { 33 | const { type, payload } = action; 34 | switch (type) { 35 | case RouterActionEnum.ADD_ROUTES: { 36 | return addRoutesAction(state, payload); 37 | } 38 | case RouterActionEnum.REMOVE_ROUTES: { 39 | return removeRoutesAction(state, payload); 40 | } 41 | case RouterActionEnum.UPDATE_ROUTES: { 42 | return updateRoutesAction(state, payload); 43 | } 44 | case RouterActionEnum.UPDATE_INPUT_ROUTES: { 45 | return { 46 | ...state, 47 | inputRoutes: payload 48 | }; 49 | } 50 | case RouterActionEnum.UPDATE_CURRENT_ROUTE: { 51 | return { 52 | ...state, 53 | currentRoute: payload 54 | }; 55 | } 56 | case RouterActionEnum.UPDATE_STATE: { 57 | return { 58 | ...state, 59 | ...payload 60 | }; 61 | } 62 | default: { 63 | return { ...state }; 64 | } 65 | } 66 | } 67 | 68 | export function useRouterState(): MRouterStateI { 69 | return React.useContext(MRouterContext).state; 70 | } 71 | 72 | /** Dynamically add routing method */ 73 | export function useAddRoutes(): AddRoutesI { 74 | return React.useContext(MRouterContext).methods.addRoutes; 75 | } 76 | 77 | export function useRemoveRoutes(): (routeNames: string[]) => void { 78 | return React.useContext(MRouterContext).methods.removeRoutes; 79 | } 80 | 81 | export function useUpdateRoutes(): UpdateRoutesI { 82 | return React.useContext(MRouterContext).methods.updateRoutes; 83 | } 84 | 85 | export default MRouterContext; 86 | -------------------------------------------------------------------------------- /docs/assets/js/4972.9fc7005b.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | (self.webpackChunkdocs = self.webpackChunkdocs || []).push([ 3 | [4972], 4 | { 5 | 4972: (e, t, n) => { 6 | n.r(t), n.d(t, { default: () => c }); 7 | var a = n(7294), 8 | l = n(5999), 9 | o = n(1944), 10 | r = n(3285); 11 | function c() { 12 | return a.createElement( 13 | a.Fragment, 14 | null, 15 | a.createElement(o.d, { 16 | title: (0, l.I)({ 17 | id: "theme.NotFound.title", 18 | message: "Page Not Found" 19 | }) 20 | }), 21 | a.createElement( 22 | r.Z, 23 | null, 24 | a.createElement( 25 | "main", 26 | { className: "container margin-vert--xl" }, 27 | a.createElement( 28 | "div", 29 | { className: "row" }, 30 | a.createElement( 31 | "div", 32 | { className: "col col--6 col--offset-3" }, 33 | a.createElement( 34 | "h1", 35 | { className: "hero__title" }, 36 | a.createElement( 37 | l.Z, 38 | { 39 | id: "theme.NotFound.title", 40 | description: "The title of the 404 page" 41 | }, 42 | "Page Not Found" 43 | ) 44 | ), 45 | a.createElement( 46 | "p", 47 | null, 48 | a.createElement( 49 | l.Z, 50 | { 51 | id: "theme.NotFound.p1", 52 | description: "The first paragraph of the 404 page" 53 | }, 54 | "We could not find what you were looking for." 55 | ) 56 | ), 57 | a.createElement( 58 | "p", 59 | null, 60 | a.createElement( 61 | l.Z, 62 | { 63 | id: "theme.NotFound.p2", 64 | description: "The 2nd paragraph of the 404 page" 65 | }, 66 | "Please contact the owner of the site that linked you to the original URL and let them know their link is broken." 67 | ) 68 | ) 69 | ) 70 | ) 71 | ) 72 | ) 73 | ); 74 | } 75 | } 76 | } 77 | ]); 78 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/core/HashRouter/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { useMemo } from "react"; 3 | import { unstable_batchedUpdates } from "react-dom"; 4 | import type { BrowserRouterProps, Location } from "react-router-dom"; 5 | import { Router } from "react-router-dom"; 6 | import { createHashHistory } from "@remix-run/router"; 7 | import type { OldHashHistory, RouteCbI, RouteHistoryObject } from "../../type"; 8 | import MRouterHistoryContext from "../../context/MRouterHistoryContext"; 9 | 10 | /** 11 | * A `` for use in web browsers. Provides the cleanest URLs. 12 | */ 13 | export default function HashRouter({ 14 | basename, 15 | children, 16 | syncUpdateCurrentRoute 17 | }: BrowserRouterProps & { 18 | syncUpdateCurrentRoute: (location: Location) => void; 19 | }) { 20 | const historyRef = React.useRef(null!); 21 | const routeHooksRef = React.useRef(null!); 22 | if (historyRef.current == null) { 23 | const history = createHashHistory({ window, v5Compat: true }); 24 | historyRef.current = { 25 | ...history, 26 | back: () => history.go(-1), 27 | forward: () => history.go(1) 28 | }; 29 | routeHooksRef.current = []; 30 | } 31 | const historyContext = useMemo(() => { 32 | return { 33 | history: historyRef.current as OldHashHistory, 34 | routeHooks: routeHooksRef.current as RouteCbI[], 35 | routeHooksRef, 36 | historyMethods: { 37 | push: historyRef.current.push, 38 | replace: historyRef.current.replace, 39 | go: historyRef.current.go 40 | } 41 | } as RouteHistoryObject; 42 | }, []); 43 | 44 | const history = historyRef.current; 45 | 46 | const [state, setState] = React.useState({ 47 | action: history.action, 48 | location: history.location 49 | }); 50 | 51 | React.useLayoutEffect(() => { 52 | let mounted = true; 53 | const removeListenFn = history.listen(routeData => { 54 | const { location } = routeData; 55 | if (!mounted) { 56 | return; 57 | } 58 | unstable_batchedUpdates(() => { 59 | setState(routeData); 60 | syncUpdateCurrentRoute(location); 61 | }); 62 | }); 63 | return () => { 64 | mounted = false; 65 | removeListenFn(); 66 | }; 67 | }, [history, syncUpdateCurrentRoute]); 68 | return ( 69 | 70 | 76 | {children} 77 | 78 | 79 | ); 80 | } 81 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/core/BrowserRouter/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { useMemo } from "react"; 3 | import { unstable_batchedUpdates } from "react-dom"; 4 | import type { BrowserRouterProps, Location } from "react-router-dom"; 5 | import { Router } from "react-router-dom"; 6 | import { createBrowserHistory } from "@remix-run/router"; 7 | import type { 8 | OldBrowserHistory, 9 | RouteCbI, 10 | RouteHistoryObject 11 | } from "../../type"; 12 | import MRouterHistoryContext from "../../context/MRouterHistoryContext"; 13 | 14 | /** 15 | * A `` for use in web browsers. Provides the cleanest URLs. 16 | */ 17 | export default function BrowserRouter({ 18 | basename, 19 | children, 20 | syncUpdateCurrentRoute 21 | }: BrowserRouterProps & { 22 | syncUpdateCurrentRoute: (location: Location) => void; 23 | }) { 24 | const historyRef = React.useRef(null!); 25 | const routeHooksRef = React.useRef(null!); 26 | if (historyRef.current == null) { 27 | const history = createBrowserHistory({ window, v5Compat: true }); 28 | historyRef.current = { 29 | ...history, 30 | back: () => history.go(-1), 31 | forward: () => history.go(1) 32 | }; 33 | routeHooksRef.current = []; 34 | } 35 | 36 | const historyContext = useMemo(() => { 37 | return { 38 | history: historyRef.current as OldBrowserHistory, 39 | routeHooks: routeHooksRef.current as RouteCbI[], 40 | routeHooksRef, 41 | historyMethods: { 42 | push: historyRef.current.push, 43 | replace: historyRef.current.replace, 44 | go: historyRef.current.go, 45 | back: historyRef.current.back, 46 | forward: historyRef.current.forward 47 | } 48 | } as RouteHistoryObject; 49 | }, []); 50 | 51 | const history = historyRef.current; 52 | 53 | const [state, setState] = React.useState({ 54 | action: history.action, 55 | location: history.location 56 | }); 57 | 58 | React.useLayoutEffect(() => { 59 | let mounted = true; 60 | const removeListenFn = history.listen(routeData => { 61 | const { location } = routeData; 62 | if (!mounted) { 63 | return; 64 | } 65 | unstable_batchedUpdates(() => { 66 | setState(routeData); 67 | syncUpdateCurrentRoute(location); 68 | }); 69 | }); 70 | return () => { 71 | mounted = false; 72 | removeListenFn(); 73 | }; 74 | }, [history, syncUpdateCurrentRoute]); 75 | return ( 76 | 77 | 83 | {children} 84 | 85 | 86 | ); 87 | } 88 | -------------------------------------------------------------------------------- /examples/custom-link/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import type { LinkProps } from "react-router-dom"; 3 | import { 4 | defineRouterConfig, 5 | MRouter, 6 | MHRouter, 7 | Outlet, 8 | Link, 9 | useMatch, 10 | useResolvedPath 11 | } from "react-router-manage"; 12 | 13 | const Router = window.__INITIAL_DATA__.mode === "hash" ? MHRouter : MRouter; 14 | 15 | const routerConfig = defineRouterConfig({ 16 | basename: 17 | window.__INITIAL_DATA__.mode !== "hash" 18 | ? window.__INITIAL_DATA__.basename 19 | : "/", 20 | routes: [ 21 | { 22 | path: "", 23 | name: "layout", 24 | component: Layout, 25 | children: [ 26 | { 27 | path: "/home", 28 | name: "home", 29 | component: Home 30 | }, 31 | { 32 | path: "/about", 33 | name: "about", 34 | component: About 35 | }, 36 | { 37 | path: "*", 38 | name: "all", 39 | component: NoMatch 40 | } 41 | ] 42 | } 43 | ] 44 | }); 45 | 46 | export default function App() { 47 | return ( 48 |
49 |

Custom Link Example

50 | 51 |

52 | This example demonstrates how to create a custom{" "} 53 | <Link> component that knows whether or not it is 54 | "active" using the low-level useResolvedPath() and 55 | useMatch() hooks. 56 |

57 | 58 | {children => children} 59 |
60 | ); 61 | } 62 | 63 | function CustomLink({ children, to, ...props }: LinkProps) { 64 | let resolved = useResolvedPath(to); 65 | let match = useMatch({ path: resolved.pathname, end: true }); 66 | return ( 67 |
68 | 73 | {children} 74 | 75 | {match && " (active)"} 76 |
77 | ); 78 | } 79 | 80 | function Layout() { 81 | return ( 82 |
83 | 93 | 94 |
95 | 96 | 97 |
98 | ); 99 | } 100 | 101 | function Home() { 102 | return ( 103 |
104 |

Home

105 |
106 | ); 107 | } 108 | 109 | function About() { 110 | return ( 111 |
112 |

About

113 |
114 | ); 115 | } 116 | 117 | function NoMatch() { 118 | return ( 119 |
120 |

Nothing to see here!

121 |

122 | Go to the home page 123 |

124 |
125 | ); 126 | } 127 | -------------------------------------------------------------------------------- /packages/react-router-manage/src/core/CoreRouter.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { useCallback, useMemo, useRef } from "react"; 3 | import type { Location } from "react-router-dom"; 4 | import BrowserRouter from "./BrowserRouter"; 5 | import HashRouter from "./HashRouter"; 6 | import MRouterContextProvider from "./MRouterContextProvider"; 7 | import { PermissionModeType, RouterBaseConfigI } from "../type"; 8 | 9 | export interface MRouterPropsI { 10 | permissionList?: string[]; 11 | permissionMode?: PermissionModeType; 12 | wrapComponent?: React.FunctionComponent; 13 | hasAuth?: boolean; 14 | routerConfig: RouterBaseConfigI; 15 | children?: (children: React.ReactNode) => React.ReactNode; 16 | } 17 | 18 | interface CoreRouterPropsI extends MRouterPropsI { 19 | RouterComponent: typeof BrowserRouter | typeof HashRouter; 20 | } 21 | const CoreRouter: React.FC = ({ 22 | permissionList, 23 | permissionMode, 24 | wrapComponent: WrapComponent, 25 | hasAuth = true, 26 | routerConfig, 27 | children, 28 | RouterComponent 29 | }) => { 30 | const syncUpdateCurrentRouteRef = useRef<{ 31 | updateCurrentRoute: (location: Location) => void; 32 | }>(null!); 33 | const syncUpdateCurrentRoute = useCallback((location: Location) => { 34 | syncUpdateCurrentRouteRef.current?.updateCurrentRoute?.(location); 35 | }, []); 36 | 37 | if (__DEV__) { 38 | /** Determine whether routerConfig has ‘_isDefined’ attribute */ 39 | if (!routerConfig._isDefined) { 40 | console.error( 41 | `The routerConfig does not call defineRouterConfig definition, You should use 'const routerConfig = defineRouterConfig({...})'` 42 | ); 43 | } 44 | /** Judge incoming 'WrapComponent' and 'children' */ 45 | if (WrapComponent && children) { 46 | console.warn( 47 | `MRouter attributes 'children' and 'WrapComponent' are optional attributes. If both exist, children will be used` 48 | ); 49 | } 50 | if (children && typeof children !== "function") { 51 | console.error( 52 | 'MRoute attributes children needs to be a function, not a function at present "%s"', 53 | children 54 | ); 55 | } 56 | } 57 | 58 | const _children = useMemo(() => { 59 | if (children && typeof children === "function") { 60 | return children; 61 | } 62 | if (WrapComponent) { 63 | WrapComponent.displayName = "WrapComponent"; 64 | return function wrapComponent(children: React.ReactNode) { 65 | return {children}; 66 | }; 67 | } 68 | }, [WrapComponent, children]); 69 | 70 | return ( 71 | 72 | 79 | {_children} 80 | 81 | 82 | ); 83 | }; 84 | 85 | export default CoreRouter; 86 | -------------------------------------------------------------------------------- /examples/antd-breadcrumbs/src/router/index.tsx: -------------------------------------------------------------------------------- 1 | import { lazy } from "react"; 2 | import { defineRouterConfig } from "react-router-manage"; 3 | 4 | const routerConfig = defineRouterConfig({ 5 | basename: 6 | window.__INITIAL_DATA__.mode !== "hash" 7 | ? window.__INITIAL_DATA__.basename 8 | : "/", 9 | routes: [ 10 | { 11 | title: "Main", 12 | path: "main", 13 | name: "main", 14 | items: [ 15 | { 16 | title: "My Page", 17 | path: "my-page", 18 | name: "myPage", 19 | component: lazy(() => import("../pages/my-page")) 20 | }, 21 | { 22 | title: "DashBoard", 23 | path: "dashboard", 24 | name: "dashboard", 25 | component: lazy(() => import("../pages/dashboard")), 26 | items: [ 27 | { 28 | name: "DashBoardDetail", 29 | title: "Detail", 30 | path: "detail/:id", 31 | component: lazy(() => import("../pages/dashboard/detail")), 32 | breadcrumbs: { 33 | text: item => `${item.title}测试` 34 | } 35 | } 36 | ] 37 | } 38 | ] 39 | }, 40 | { 41 | title: "App", 42 | path: "app", 43 | name: "app", 44 | items: [ 45 | { 46 | title: "Contact", 47 | path: "contact", 48 | name: "contact", 49 | component: lazy(() => import("../pages/contact")) 50 | }, 51 | { 52 | title: "email", 53 | path: "email", 54 | name: "email", 55 | component: lazy(() => import("../pages/email")) 56 | }, 57 | { 58 | title: "Messenger", 59 | path: "messenger", 60 | name: "messenger", 61 | component: lazy(() => import("../pages/messenger")) 62 | }, 63 | { 64 | title: "Project", 65 | path: "project", 66 | name: "project", 67 | items: [ 68 | { 69 | title: "Taskboard", 70 | path: "task-board", 71 | name: "taskboard", 72 | component: lazy(() => import("../pages/project/task-board")) 73 | }, 74 | { 75 | title: "ProjectList", 76 | path: "list", 77 | name: "projectList", 78 | component: lazy(() => import("../pages/project/project-list")) 79 | }, 80 | { 81 | title: "TicketList", 82 | path: "ticket-list", 83 | name: "ticketList", 84 | component: lazy(() => import("../pages/project/ticket-list")) 85 | }, 86 | { 87 | title: "Clients", 88 | path: "clients", 89 | name: "Clients", 90 | component: lazy(() => import("../pages/project/clients")) 91 | } 92 | ] 93 | } 94 | ] 95 | } 96 | ] 97 | }); 98 | 99 | export default routerConfig; 100 | -------------------------------------------------------------------------------- /examples/basic/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | import { 4 | defineRouterConfig, 5 | Link, 6 | MHRouter, 7 | MRouter 8 | } from "react-router-manage"; 9 | 10 | function Layout({ children }) { 11 | return ( 12 |
13 | {/* A "layout route" is a good place to put markup you want to 14 | share across all the pages on your site, like navigation. */} 15 | 31 | 32 |
33 | 34 | {children} 35 |
36 | ); 37 | } 38 | 39 | function Home() { 40 | return ( 41 |
42 |

Home

43 |
44 | ); 45 | } 46 | 47 | function About() { 48 | return ( 49 |
50 |

About

51 |
52 | ); 53 | } 54 | 55 | function Dashboard() { 56 | return ( 57 |
58 |

Dashboard

59 |
60 | ); 61 | } 62 | 63 | function NoMatch() { 64 | return ( 65 |
66 |

Nothing to see here!

67 |

68 | Go to the home page 69 |

70 |
71 | ); 72 | } 73 | const Router = window.__INITIAL_DATA__.mode === "hash" ? MHRouter : MRouter; 74 | 75 | const routerConfig = defineRouterConfig({ 76 | basename: 77 | window.__INITIAL_DATA__.mode !== "hash" 78 | ? window.__INITIAL_DATA__.basename 79 | : "/", 80 | routes: [ 81 | { 82 | path: "/", 83 | name: "layout", 84 | // component: Layout, 85 | items: [ 86 | { 87 | path: "home", 88 | name: "home", 89 | component: React.lazy(() => import("./Home")), 90 | beforeEnter(to, next) { 91 | console.log("beforeEnter", to, next); 92 | // next(); 93 | } 94 | }, 95 | { 96 | path: "dashboard", 97 | name: "dashboard", 98 | component: Dashboard 99 | }, 100 | { 101 | path: "about", 102 | name: "about", 103 | component: About 104 | }, 105 | { 106 | path: "*", 107 | name: "all", 108 | component: NoMatch 109 | } 110 | ] 111 | } 112 | ] 113 | }); 114 | 115 | export default function App() { 116 | return ( 117 |
118 |

beforeEnter Example

119 | 120 | {/* Routes nest inside one another. Nested route paths build upon 121 | parent route paths, and nested route elements render inside 122 | parent route elements. See the note about below. */} 123 | 124 | 125 |
126 | ); 127 | } 128 | -------------------------------------------------------------------------------- /packages/react-router-manage/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # react-router-manage 2 | 3 | ## 2.0.5 4 | 5 | ### Patch Changes 6 | 7 | - 62c1693: fix tag error 8 | - 064b691: Fixed the issue of props transparent transmission failure caused by configuring beforeEnter 9 | 10 | ## 2.0.5-beta.1 11 | 12 | ### Patch Changes 13 | 14 | - fix tag error 15 | 16 | ## 2.0.5-beta.0 17 | 18 | ### Patch Changes 19 | 20 | - Fixed the issue of props transparent transmission failure caused by configuring beforeEnter 21 | 22 | ## 2.0.4 23 | 24 | ### Patch Changes 25 | 26 | - Add external call jumps, such as initializing micro frontend applications outside of 27 | 28 | ## 2.0.3 29 | 30 | ### Patch Changes 31 | 32 | - useBeforeLeave adds beforeunload options 33 | 34 | ## 2.0.2 35 | 36 | ### Patch Changes 37 | 38 | - support configure 'index' 39 | 40 | ## 2.0.1 41 | 42 | ### Patch Changes 43 | 44 | - release v2.0.1 45 | - ab88d54: upgrade react-router version to 6.9.0 46 | 47 | ## 2.0.1-beta.0 48 | 49 | ### Patch Changes 50 | 51 | - upgrade react-router version to 6.9.0 52 | 53 | ## 2.0.0 54 | 55 | ### Minor Changes 56 | 57 | - bd5a383: release package: @rrmc/antd-breadcrumbs 58 | 59 | ### Patch Changes 60 | 61 | - f04642e: add package @rrmc/antd-breadcrumbs docs 62 | - release package @rrmc/antd-breadcrumbs 63 | 64 | ## 1.2.0 65 | 66 | ### Patch Changes 67 | 68 | - add package @rrmc/antd-breadcrumbs docs 69 | 70 | ## 1.2.0-beta.0 71 | 72 | ### Minor Changes 73 | 74 | - release package: @rrmc/antd-breadcrumbs 75 | 76 | ## 1.1.6 77 | 78 | ### Patch Changes 79 | 80 | - fix HashRouter history listen error 81 | 82 | ## 1.1.5 83 | 84 | ### Patch Changes 85 | 86 | - lock react-router version 87 | 88 | ## 1.1.4 89 | 90 | ### Patch Changes 91 | 92 | - c15ae4f: fix: export interface RoutesMapI 93 | - 8f83a1e: core add permissionMode `parent` and `children` supports permission 94 | - release v1.1.4 95 | - 4647148: remove routesMap's **paramsRoutesMap and **flattenRoutess property 96 | - 98b1b67: inputRoutes change add to MRouterContext 97 | 98 | ## 1.1.4-beta.3 99 | 100 | ### Patch Changes 101 | 102 | - inputRoutes change add to MRouterContext 103 | 104 | ## 1.1.4-beta.2 105 | 106 | ### Patch Changes 107 | 108 | - fix: export interface RoutesMapI 109 | 110 | ## 1.1.4-beta.1 111 | 112 | ### Patch Changes 113 | 114 | - remove routesMap's paramsRoutesMap and flattenRoutes property 115 | 116 | ## 1.1.4-beta.0 117 | 118 | ### Patch Changes 119 | 120 | - core add permissionMode `parent` and `children` supports permission 121 | 122 | ## 1.1.3 123 | 124 | ### Patch Changes 125 | 126 | - fix the problem of lazy component warning 127 | 128 | ## 1.1.2 129 | 130 | ### Patch Changes 131 | 132 | - fix: children route path can configured empty 133 | - 91aaf4f: When configuring sub routes, the path can be empty 134 | - 8c4c64b: modify 'getCurrentRoute' get params route 135 | 136 | ## 1.1.2-beta.1 137 | 138 | ### Patch Changes 139 | 140 | - modify 'getCurrentRoute' get params route 141 | 142 | ## 1.1.2-beta.0 143 | 144 | ### Patch Changes 145 | 146 | - When configuring sub routes, the path can be empty 147 | 148 | ## 1.1.0 149 | 150 | ### Patch Changes 151 | 152 | - test 153 | -------------------------------------------------------------------------------- /packages/react-router-manage/README.md: -------------------------------------------------------------------------------- 1 | # react-router-manage 2 | 3 | [docs](https://github.com/NSFI/react-router-manage/blob/main/README.md) 4 | 5 |

6 | 7 | 8 | 9 | 10 | Downloads per month on npm. 11 | 12 | 13 | Total downloads on npm. 14 | 15 | 16 | 17 | 18 | gzip size 19 |

20 | 21 |

22 | English | 简体中文 23 |

24 | 25 | ## Features 26 | 27 | `react-router-manage` is based on `react-router` `v6`. It can realize the function of authentication, guard, add, delete and check of route by configuration. Because `react-router` `v5` upgrades to `v6` have a high cost, `react-router-manage` provides the API from the original `v5` section for compatible projects that use `v5` for smooth upgrades to `v6` 28 | 29 | - 🛠 [**[`config router`](https://github.com/NSFI/react-router-manage/blob/main/README.md#routerConfig)**] - Centralized router configuration, fast and convenient management. 30 | - + [**[`addRoutes`](https://github.com/NSFI/react-router-manage/blob/main/README.md#useAddRoutes)**] - Dynamically add `routes`: you can use hook `useAddRoutes` to add routes and automatically refresh the view. 31 | - ➖ [**[`removeRoutes`](https://github.com/NSFI/react-router-manage/blob/main/README.md#useRemoveRoutes)**] - Dynamically delete routes: you can use hook `useRemoveRoutes` to delete routes and automatically refresh the view. 32 | - 🖇 [**[`updateRoutes`](https://github.com/NSFI/react-router-manage/blob/main/README.md#useUpdateRoutes)**] - Dynamically modify routes: you can use hook `useUpdateRoutes` to modify routes. 33 | - 🔐 [**permission**] - Permission control: configure the code of the route and automatically manage the permission of the route 34 | - 👨‍✈️‍ [**route guard**] - Provide hooks for route entry config `beforeEnter` and **[`beforeEachMount`](https://github.com/NSFI/react-router-manage/blob/main/README.md#beforeEachMount)**, route exit hook **[`useBeforeLeave`](https://github.com/NSFI/react-router-manage/blob/main/README.md#useBeforeLeave)** 35 | - 🌲 [**navigation**] - level navigation: supports level navigation, and automatically generates navigation bars for parent-child routes, such as breadcrumbs and menu navigation 36 | 37 | ## About 38 | 39 | `react-router-manage` is used in many projects within [Netease BizEase](https://growthease.com/). In order to give back to the community, it has decided to open source, and is willing to build a useful react router management library with friends in the community 40 | -------------------------------------------------------------------------------- /website/blog/2019-05-29-long-blog-post.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: long-blog-post 3 | title: Long Blog Post 4 | authors: endi 5 | tags: [hello, docusaurus] 6 | --- 7 | 8 | This is the summary of a very long blog post, 9 | 10 | Use a `` comment to limit blog post size in the list view. 11 | 12 | 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 15 | 16 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 17 | 18 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 19 | 20 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 21 | 22 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 23 | 24 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 25 | 26 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 27 | 28 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 29 | 30 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 31 | 32 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 33 | 34 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 35 | 36 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 37 | 38 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 39 | 40 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 41 | 42 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 43 | 44 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 45 | -------------------------------------------------------------------------------- /packages/antd-breadcrumbs/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { useParams, useRouter } from "react-router-manage"; 3 | import type { RouteTypeExtendsI } from "react-router-manage"; 4 | import { Breadcrumb } from "antd"; 5 | 6 | interface AntdRouterBreadcrumbsProps { 7 | text?: React.ReactNode; // 面包屑文案,例如新增xx还是编辑xx可以自定义 8 | separator?: string; // 分隔符 9 | } 10 | 11 | const AntdRouterBreadcrumbs: React.FC = ({ 12 | text, 13 | separator 14 | }) => { 15 | const { currentRoute, navigate } = useRouter(); 16 | const params = useParams(); 17 | const _routes = React.useMemo(() => { 18 | const _levelRoutes: RouteTypeExtendsI[] = []; 19 | let _parentRoute: RouteTypeExtendsI | undefined = currentRoute; 20 | while (_parentRoute) { 21 | if (_parentRoute.breadcrumbs?.isRoot) { 22 | // 如果是面包屑的根节点,则不再向上找 23 | _parentRoute = undefined; 24 | } else { 25 | if (!_parentRoute.breadcrumbs?.hidden) { 26 | // 如果面包屑设置了隐藏,则会跳过这一级别的显示 27 | _levelRoutes.unshift(_parentRoute); 28 | } 29 | _parentRoute = _parentRoute.parent; 30 | } 31 | } 32 | return _levelRoutes; 33 | }, [currentRoute]); 34 | 35 | // 点击面包屑 36 | const onClick = React.useCallback( 37 | (item: RouteTypeExtendsI) => { 38 | const { path } = item; 39 | const { component } = item; 40 | // 接下path中的参数 41 | // let realPath = path; 42 | path && component && navigate(path, { params }); 43 | }, 44 | [navigate, params] 45 | ); 46 | 47 | const getIsCanClick = React.useCallback( 48 | (item: RouteTypeExtendsI, index: number) => { 49 | if (!item.component || index === _routes.length - 1) { 50 | return false; 51 | } 52 | return true; 53 | }, 54 | [_routes.length] 55 | ); 56 | 57 | return ( 58 | 59 | {_routes.map((item: RouteTypeExtendsI, index) => { 60 | const isCanClick = getIsCanClick(item, index); 61 | // let routeBreadcrumbTittle = item.breadcrumbs?.text || item.title; 62 | let routeBreadcrumbTittle: string | undefined | React.ReactNode = 63 | item.title; 64 | if (typeof item.breadcrumbs?.text === "string") { 65 | routeBreadcrumbTittle = item.breadcrumbs?.text; 66 | } else if (typeof item.breadcrumbs?.text === "function") { 67 | routeBreadcrumbTittle = item.breadcrumbs.text(item); 68 | } 69 | const title = 70 | index === _routes.length - 1 71 | ? text || routeBreadcrumbTittle 72 | : routeBreadcrumbTittle; 73 | return ( 74 | 80 | {isCanClick ? ( 81 | { 83 | // 最后一个面包屑不点击 84 | index !== _routes.length - 1 && onClick(item); 85 | }} 86 | > 87 | {title} 88 | 89 | ) : ( 90 | <>{title} 91 | )} 92 | 93 | ); 94 | })} 95 | 96 | ); 97 | }; 98 | 99 | export default AntdRouterBreadcrumbs; 100 | -------------------------------------------------------------------------------- /examples/beforeEnter/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | import { 4 | defineRouterConfig, 5 | Link, 6 | MHRouter, 7 | MRouter 8 | } from "react-router-manage"; 9 | 10 | function Layout({ children }) { 11 | return ( 12 |
13 | {/* A "layout route" is a good place to put markup you want to 14 | share across all the pages on your site, like navigation. */} 15 | 31 | 32 |
33 | 34 | {children} 35 |
36 | ); 37 | } 38 | 39 | function Home() { 40 | return ( 41 |
42 |

Home

43 |
44 | ); 45 | } 46 | 47 | function About() { 48 | return ( 49 |
50 |

About

51 |
52 | ); 53 | } 54 | 55 | function Dashboard(props) { 56 | console.log(props); 57 | return ( 58 |
59 |

Dashboard

60 |

{props.age}

61 |
62 | ); 63 | } 64 | 65 | function NoMatch() { 66 | return ( 67 |
68 |

Nothing to see here!

69 |

70 | Go to the home page 71 |

72 |
73 | ); 74 | } 75 | const Router = window.__INITIAL_DATA__.mode === "hash" ? MHRouter : MRouter; 76 | 77 | const routerConfig = defineRouterConfig({ 78 | basename: 79 | window.__INITIAL_DATA__.mode !== "hash" 80 | ? window.__INITIAL_DATA__.basename 81 | : "/", 82 | routes: [ 83 | { 84 | path: "/", 85 | name: "layout", 86 | // component: Layout, 87 | items: [ 88 | { 89 | path: "home", 90 | name: "home", 91 | component: React.lazy(() => import("./Home")), 92 | beforeEnter(to, next) { 93 | // alert("beforeEnter"); 94 | // debugger; 95 | next(); 96 | }, 97 | props: { 98 | name: "home" 99 | } 100 | }, 101 | { 102 | path: "dashboard", 103 | name: "dashboard", 104 | component: Dashboard, 105 | props: { 106 | name: "dashboard", 107 | age: 18 108 | } 109 | }, 110 | { 111 | path: "about", 112 | name: "about", 113 | component: About, 114 | props: { 115 | name: "about" 116 | } 117 | }, 118 | { 119 | path: "*", 120 | name: "all", 121 | component: NoMatch 122 | } 123 | ] 124 | } 125 | ] 126 | }); 127 | 128 | export default function App() { 129 | return ( 130 |
131 |

beforeEnter Example

132 | 133 | {/* Routes nest inside one another. Nested route paths build upon 134 | parent route paths, and nested route elements render inside 135 | parent route elements. See the note about below. */} 136 | 137 | 138 |
139 | ); 140 | } 141 | --------------------------------------------------------------------------------