mirror of
https://github.com/koel/koel
synced 2024-12-21 01:53:11 +00:00
16 lines
444 B
TypeScript
16 lines
444 B
TypeScript
import { ref, watch } from 'vue'
|
|
import { requireInjection } from '@/utils'
|
|
import { ActiveScreenKey } from '@/symbols'
|
|
|
|
export const useScreen = (currentScreen: ScreenName) => {
|
|
const activeScreen = requireInjection(ActiveScreenKey, ref('Home'))
|
|
|
|
const onScreenActivated = (cb: Closure) => watch(activeScreen, screen => screen === currentScreen && cb(), {
|
|
immediate: true
|
|
})
|
|
|
|
return {
|
|
activeScreen,
|
|
onScreenActivated
|
|
}
|
|
}
|