mirror of
https://github.com/koel/koel
synced 2024-12-24 11:33:05 +00:00
17 lines
621 B
TypeScript
17 lines
621 B
TypeScript
|
import { RouterKey } from '@/symbols'
|
||
|
import { requireInjection } from '@/utils'
|
||
|
|
||
|
export const useRouter = () => {
|
||
|
const router = requireInjection(RouterKey)
|
||
|
|
||
|
return {
|
||
|
go: router.go.bind(router),
|
||
|
onRouteChanged: router.onRouteChanged.bind(router),
|
||
|
resolveRoute: router.resolve.bind(router),
|
||
|
triggerNotFound: router.triggerNotFound.bind(router),
|
||
|
getRouteParam: (name: string) => router.$currentRoute.value?.params?.[name],
|
||
|
getCurrentScreen: () => router.$currentRoute.value?.screen,
|
||
|
isCurrentScreen: (...screens: ScreenName[]) => screens.includes(router.$currentRoute.value?.screen!)
|
||
|
}
|
||
|
}
|