mirror of
https://github.com/koel/koel
synced 2024-12-21 10:03:10 +00:00
17 lines
444 B
TypeScript
17 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
|
||
|
}
|
||
|
}
|