fix obs components display

This commit is contained in:
2025-03-18 19:58:54 +08:00
parent 300a38e851
commit eb43d88e44
22 changed files with 308 additions and 232 deletions

View File

@@ -7,6 +7,12 @@ import { onMounted, onUnmounted, ref } from 'vue'
import QuestionDisplayCard from '../manage/QuestionDisplayCard.vue'
import { useWebRTC } from '@/store/useRTC'
const props = defineProps<{
id?: number,
active: boolean,
visible: boolean,
}>()
const hash = ref('')
const token = useRouteQuery('token')
const rtc = await useWebRTC().Init('slave')
@@ -50,33 +56,16 @@ async function getQuestionAndSetting() {
function handleScroll(value: { clientHeight: number, scrollHeight: number, scrollTop: number }) {
cardRef.value?.setScroll(value)
}
const visiable = ref(true)
const active = ref(true)
let timer: any
onMounted(() => {
timer = setInterval(() => {
if (!visiable.value || !active.value) return
window.$mitt.on('onOBSComponentUpdate', () => {
checkIfChanged()
}, 1000)
//@ts-expect-error 这里获取不了
if (window.obsstudio) {
//@ts-expect-error 这里获取不了
window.obsstudio.onVisibilityChange = function (visibility: boolean) {
visiable.value = visibility
}
//@ts-expect-error 这里获取不了
window.obsstudio.onActiveChange = function (a: boolean) {
active.value = a
}
}
})
rtc?.on('function.question.sync-scroll', handleScroll)
})
onUnmounted(() => {
clearInterval(timer)
window.$mitt.off('onOBSComponentUpdate')
rtc?.off('function.question.sync-scroll', handleScroll)
})
</script>