@@ -11,7 +11,7 @@ import type { MappingAlgorithm } from 'antd';
1111import { App , theme as antdTheme } from 'antd' ;
1212import type { DirectionType , ThemeConfig } from 'antd/es/config-provider' ;
1313import { createSearchParams , useOutlet , useSearchParams , useServerInsertedHTML } from 'dumi' ;
14- import React , { Suspense , useCallback , useEffect } from 'react' ;
14+ import React , { Suspense , useCallback , useEffect , useState } from 'react' ;
1515
1616import { DarkContext } from '../../hooks/useDark' ;
1717import useLayoutState from '../../hooks/useLayoutState' ;
@@ -23,18 +23,14 @@ import type { SiteContextProps } from '../slots/SiteContext';
2323import SiteContext from '../slots/SiteContext' ;
2424
2525import '@ant-design/v5-patch-for-react-19' ;
26+ import Alert from '../slots/Alert' ;
2627
2728type Entries < T > = { [ K in keyof T ] : [ K , T [ K ] ] } [ keyof T ] [ ] ;
2829type SiteState = Partial < Omit < SiteContextProps , 'updateSiteContext' > > ;
2930
3031const RESPONSIVE_MOBILE = 768 ;
3132export const ANT_DESIGN_NOT_SHOW_BANNER = 'ANT_DESIGN_NOT_SHOW_BANNER' ;
3233
33- // const styleCache = createCache();
34- // if (typeof global !== 'undefined') {
35- // (global as any).styleCache = styleCache;
36- // }
37-
3834const getAlgorithm = ( themes : ThemeName [ ] = [ ] ) =>
3935 themes
4036 . map ( ( theme ) => {
@@ -69,7 +65,6 @@ const GlobalLayout: React.FC = () => {
6965 ( props : SiteState ) => {
7066 setSiteState ( ( prev ) => ( { ...prev , ...props } ) ) ;
7167
72- // updating `searchParams` will clear the hash
7368 const oldSearchStr = searchParams . toString ( ) ;
7469
7570 let nextSearchParams : URLSearchParams = searchParams ;
@@ -112,6 +107,8 @@ const GlobalLayout: React.FC = () => {
112107 }
113108 } , [ theme . length , isIndexPage ] ) ;
114109
110+ const [ alertVisible , setAlertVisible ] = useState ( true ) ;
111+
115112 useEffect ( ( ) => {
116113 const _theme = searchParams . getAll ( 'theme' ) as ThemeName [ ] ;
117114 const _direction = searchParams . get ( 'direction' ) as DirectionType ;
@@ -140,8 +137,9 @@ const GlobalLayout: React.FC = () => {
140137 theme : theme ! ,
141138 isMobile : isMobile ! ,
142139 bannerVisible,
140+ alertVisible,
143141 } ) ,
144- [ isMobile , direction , updateSiteConfig , theme ] ,
142+ [ isMobile , direction , updateSiteConfig , alertVisible , theme ] ,
145143 ) ;
146144
147145 const themeConfig = React . useMemo < ThemeConfig > (
@@ -199,6 +197,11 @@ const GlobalLayout: React.FC = () => {
199197 >
200198 < SiteContext value = { siteContextValue } >
201199 < SiteThemeProvider theme = { themeConfig } >
200+ < Alert
201+ afterClose = { ( ) => {
202+ setAlertVisible ( false ) ;
203+ } }
204+ />
202205 < App >
203206 { outlet }
204207 < Suspense > { pathname . startsWith ( '/~demos' ) ? < PeterCat /> : null } </ Suspense >
0 commit comments