Compare commits

..

2 Commits

Author SHA1 Message Date
dkwang 9686f58e97 Merge branch 'main' of https://git.deploy.top/wyh/yunsan-pc 2026-08-28 13:05:55 +08:00
dkwang 491bc21a53 update ats? 2026-08-28 13:04:09 +08:00
1 changed files with 40 additions and 17 deletions

View File

@ -30,12 +30,12 @@ let hlsInstance = null
const videoWrapper = ref(null) const videoWrapper = ref(null)
const scale = ref(1) const savedScale = parseFloat(localStorage.getItem('videoScale') || '1')
const scale = ref(savedScale)
const scrollLeft = ref(0) const scrollLeft = ref(0)
const scrollTop = ref(0) const scrollTop = ref(0)
const minScale = 1 const minScale = 1
const maxScale = 3
const scaleStep = 0.2 const scaleStep = 0.2
const showScrollbar = computed(() => scale.value > 1) const showScrollbar = computed(() => scale.value > 1)
@ -90,29 +90,39 @@ const scrollbarYStyle = computed(() => {
}) })
const zoomIn = () => { const zoomIn = () => {
if (scale.value < maxScale) { scale.value += scaleStep
scale.value = Math.min(maxScale, scale.value + scaleStep) localStorage.setItem('videoScale', scale.value.toString())
updateScrollBounds() centerVideo()
}
} }
const zoomOut = () => { const zoomOut = () => {
if (scale.value > minScale) { if (scale.value > minScale) {
scale.value = Math.max(minScale, scale.value - scaleStep) scale.value = Math.max(minScale, scale.value - scaleStep)
updateScrollBounds() localStorage.setItem('videoScale', scale.value.toString())
centerVideo()
} }
} }
const updateScrollBounds = () => { const centerVideo = () => {
if (!videoWrapper.value) return if (!videoWrapper.value) return
const wrapperWidth = videoWrapper.value.clientWidth const wrapper = videoWrapper.value
const wrapperHeight = videoWrapper.value.clientHeight // clientWidth/clientHeight padding
const maxScrollLeft = Math.max(0, wrapperWidth * (scale.value - 1)) // 使 clientWidth/clientHeight
const maxScrollTop = Math.max(0, wrapperHeight * (scale.value - 1)) const contentWidth = wrapper.clientWidth
const contentHeight = wrapper.clientHeight
scrollLeft.value = Math.min(scrollLeft.value, maxScrollLeft)
scrollTop.value = Math.min(scrollTop.value, maxScrollTop) if (scale.value <= 1) {
scrollLeft.value = 0
scrollTop.value = 0
return
}
const scaledWidth = contentWidth * scale.value
const scaledHeight = contentHeight * scale.value
scrollLeft.value = (scaledWidth - contentWidth) / 2
scrollTop.value = (scaledHeight - contentHeight) / 2
} }
let isDraggingX = false let isDraggingX = false
@ -246,6 +256,16 @@ const initVideo = async () => {
onMounted(() => { onMounted(() => {
initVideo() initVideo()
// DOM
nextTick(() => {
centerVideo()
setTimeout(() => {
centerVideo()
}, 100)
setTimeout(() => {
centerVideo()
}, 300)
})
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
@ -291,11 +311,14 @@ onBeforeUnmount(() => {
width: 100%; width: 100%;
height: 100%; height: 100%;
transition: width 0.1s ease, height 0.1s ease; transition: width 0.1s ease, height 0.1s ease;
display: flex;
align-items: center;
justify-content: center;
.video-ats { .video-ats {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: fill; object-fit: contain;
display: block; display: block;
} }
} }