mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
fix obs components display
This commit is contained in:
44
src/views/OBSLayout.vue
Normal file
44
src/views/OBSLayout.vue
Normal file
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import { NSpin } from 'naive-ui'
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
const timer = ref<any>()
|
||||
const visible = ref(true)
|
||||
const active = ref(true)
|
||||
onMounted(() => {
|
||||
timer.value = setInterval(() => {
|
||||
if (!visible.value || !active.value) return
|
||||
window.$mitt.emit('onOBSComponentUpdate')
|
||||
}, 1000)
|
||||
|
||||
//@ts-expect-error 这里获取不了
|
||||
if (window.obsstudio) {
|
||||
//@ts-expect-error 这里获取不了
|
||||
window.obsstudio.onVisibilityChange = function (visibility: boolean) {
|
||||
visible.value = visibility
|
||||
}
|
||||
//@ts-expect-error 这里获取不了
|
||||
window.obsstudio.onActiveChange = function (a: boolean) {
|
||||
active.value = a
|
||||
}
|
||||
}
|
||||
})
|
||||
onUnmounted(() => {
|
||||
clearInterval(timer.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="height: 100vh;">
|
||||
<RouterView v-slot="{ Component }">
|
||||
<KeepAlive>
|
||||
<Suspense>
|
||||
<component :is="Component" :active :visible />
|
||||
<template #fallback>
|
||||
<NSpin show />
|
||||
</template>
|
||||
</Suspense>
|
||||
</KeepAlive>
|
||||
</RouterView>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user