mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
- 在 App.vue 中移除 NGlobalStyle 组件 - 在 OBSLayout.vue 中更新容器样式,确保高度为100vh并添加overflow隐藏 - 在 FreshRequestOBS.vue 中增加最大高度限制,确保不超出视口高度,并强制隐藏溢出
78 lines
1.9 KiB
Vue
78 lines
1.9 KiB
Vue
<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)
|
|
|
|
const originalBackgroundColor = ref('')
|
|
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
|
|
}
|
|
}
|
|
// 使 .n-layout-content 背景透明
|
|
const layoutContent = document.querySelector('.n-layout-content');
|
|
if (layoutContent instanceof HTMLElement) {
|
|
originalBackgroundColor.value = layoutContent.style.backgroundColor
|
|
layoutContent.style.setProperty('background-color', 'transparent');
|
|
}
|
|
})
|
|
|
|
onUnmounted(() => {
|
|
clearInterval(timer.value)
|
|
// 还原 .n-layout-content 背景颜色
|
|
const layoutContent = document.querySelector('.n-layout-content');
|
|
if (layoutContent instanceof HTMLElement) {
|
|
layoutContent.style.setProperty('background-color', originalBackgroundColor.value);
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="obs-container">
|
|
<RouterView v-slot="{ Component }">
|
|
<KeepAlive>
|
|
<Suspense>
|
|
<component
|
|
:is="Component"
|
|
:active
|
|
:visible
|
|
/>
|
|
<template #fallback>
|
|
<NSpin show />
|
|
</template>
|
|
</Suspense>
|
|
</KeepAlive>
|
|
</RouterView>
|
|
</div>
|
|
</template>
|
|
|
|
<style>
|
|
.obs-container {
|
|
height: 100vh;
|
|
overflow: hidden;
|
|
position: relative;
|
|
}
|
|
|
|
/* 确保OBS中不出现滚动条 */
|
|
body {
|
|
overflow: hidden;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
</style>
|