File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @kne/modules-dev" ,
3- "version" : " 2.0.23 " ,
3+ "version" : " 2.0.24 " ,
44 "description" : " 用于辅助在项目内启动一个规范化组件开发的环境" ,
55 "publishConfig" : {
66 "source" : " src/index.js" ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
2- import { useParams , Navigate } from "react-router-dom" ;
2+ import { useParams , Navigate , useSearchParams } from "react-router-dom" ;
33import ExamplePage from './ExamplePage' ;
44import ensureSlash from '@kne/ensure-slash' ;
55import Fetch from '@kne/react-fetch' ;
66
77const Example = ( { baseUrl, readme, pageProps} ) => {
88 const { id : current } = useParams ( ) ;
9+ const [ searchParams ] = useSearchParams ( ) ;
10+ const searchString = searchParams . size > 0 ? '?' + searchParams . toString ( ) : '' ;
911 const data = readme [ current ] ;
1012
11- if ( ! readme [ current ] ) {
12- return < Navigate to = { `${ ensureSlash ( baseUrl , true ) } ${ Object . keys ( readme ) [ 0 ] } ` } replace />
13+ if ( ! ( current && readme [ current ] ) ) {
14+ return < Navigate to = { `${ ensureSlash ( baseUrl , true ) } ${ Object . keys ( readme ) [ 0 ] } ${ searchString } ` } replace />
1315 }
1416
1517 const renderExamplePage = ( { data} ) => < ExamplePage pageProps = { pageProps } data = { data } current = { current }
1618 items = { Object . keys ( readme ) . map ( ( name ) => {
1719 return {
1820 label : name ,
1921 key : name ,
20- path : `${ ensureSlash ( baseUrl , true ) } ` + name
22+ path : `${ ensureSlash ( baseUrl , true ) } ` + name + searchString
2123 } ;
2224 } ) } />
2325
You can’t perform that action at this time.
0 commit comments