@@ -7,12 +7,14 @@ import { useTranslation } from 'react-i18next';
7
7
import { useNavigate } from 'react-router-dom' ;
8
8
9
9
import { useAsync , useMount , useStorage } from '@react-devui/hooks' ;
10
+ import { DNotification , DToast } from '@react-devui/ui' ;
10
11
import { DRoot } from '@react-devui/ui' ;
11
12
12
13
import { AppRoutes } from './Routes' ;
13
14
import { LOGIN_PATH } from './config/other' ;
14
15
import { STORAGE_KEY } from './config/storage' ;
15
16
import { useHttp , useInit } from './core' ;
17
+ import { useNotifications , useToasts } from './core/state' ;
16
18
17
19
export type AppTheme = 'light' | 'dark' ;
18
20
@@ -25,6 +27,8 @@ export function App() {
25
27
const [ loading , setLoading ] = useState ( true ) ;
26
28
const languageStorage = useStorage < DLang > ( ...STORAGE_KEY . language ) ;
27
29
const themeStorage = useStorage < AppTheme > ( ...STORAGE_KEY . theme ) ;
30
+ const [ notifications ] = useNotifications ( ) ;
31
+ const [ toasts ] = useToasts ( ) ;
28
32
29
33
useMount ( ( ) => {
30
34
i18n . changeLanguage ( languageStorage . value ) ;
@@ -77,7 +81,17 @@ export function App() {
77
81
[ languageStorage . value ]
78
82
) ;
79
83
80
- return < DRoot context = { rootContext } > { loading ? null : < AppRoutes /> } </ DRoot > ;
84
+ return (
85
+ < DRoot context = { rootContext } >
86
+ { loading ? null : < AppRoutes /> }
87
+ { notifications . map ( ( { key, ...props } ) => (
88
+ < DNotification { ...props } key = { key } > </ DNotification >
89
+ ) ) }
90
+ { toasts . map ( ( { key, ...props } ) => (
91
+ < DToast { ...props } key = { key } > </ DToast >
92
+ ) ) }
93
+ </ DRoot >
94
+ ) ;
81
95
}
82
96
83
97
export default App ;
0 commit comments