Files
bilibili-subtitle/src/Router.tsx
IndieKKY 858f83a45c init
2023-05-17 16:37:56 +08:00

27 lines
544 B
TypeScript

import App from './App'
import {useEventEmitter} from 'ahooks'
import React from 'react'
export const EventBusContext = React.createContext<any>(null)
const map: { [key: string]: string } = {
// '/close': 'close',
}
const Router = () => {
const path = map[window.location.pathname] ?? 'app'
if (path === 'close') {
window.close()
}
// 事件总线
const eventBus = useEventEmitter()
return <EventBusContext.Provider value={eventBus}>
{path === 'app' && <App/>}
</EventBusContext.Provider>
}
export default Router