enhance(event):加入事件总线。
This commit is contained in:
		
							
								
								
									
										5
									
								
								src/EventBus.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/EventBus.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| import { EventEmitter } from 'events'; | ||||
| import { createContext } from 'react'; | ||||
|  | ||||
| export const eventBus = new EventEmitter(); | ||||
| export const EventBusContext = createContext<EventEmitter>(eventBus); | ||||
| @@ -3,6 +3,7 @@ import { useColorScheme } from '@mantine/hooks'; | ||||
| import { Notifications } from '@mantine/notifications'; | ||||
| import React, { FC, useState } from 'react'; | ||||
| import ReactDOM from 'react-dom/client'; | ||||
| import { eventBus, EventBusContext } from './EventBus'; | ||||
| import { MainLayout } from './MainLayout'; | ||||
| import { useAppTheme } from './theme'; | ||||
|  | ||||
| @@ -13,12 +14,14 @@ const AppMain: FC = () => { | ||||
|  | ||||
|   return ( | ||||
|     <React.StrictMode> | ||||
|       <EventBusContext.Provider value={eventBus}> | ||||
|         <ColorSchemeProvider colorScheme={colorScheme} toggleColorScheme={setColorScheme}> | ||||
|           <MantineProvider theme={theme} withGlobalStyles withNormalizeCSS> | ||||
|             <Notifications position="bottom-right" limit={5} zIndex={999} /> | ||||
|             <MainLayout /> | ||||
|           </MantineProvider> | ||||
|         </ColorSchemeProvider> | ||||
|       </EventBusContext.Provider> | ||||
|     </React.StrictMode> | ||||
|   ); | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user