feat 搭建架构骨架

This commit is contained in:
Ironsp
2026-09-24 09:09:47 +08:00
parent dd9f6b77a4
commit 7a2efa3fea
180 changed files with 18967 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
import { onMounted, onUnmounted, ref, type Ref } from 'vue'
/** 元素可见性(配合图片懒加载/曝光统计) */
export function useIntersection(
target: Ref<Element | null | undefined>,
options?: IntersectionObserverInit,
): {
isVisible: Ref<boolean>
} {
const isVisible = ref(false)
let observer: IntersectionObserver | null = null
onMounted(() => {
const el = target.value
if (!el) return
observer = new IntersectionObserver((entries) => {
const entry = entries[0]
if (entry) isVisible.value = entry.isIntersecting
}, options)
observer.observe(el)
})
onUnmounted(() => {
observer?.disconnect()
observer = null
})
return { isVisible }
}