From de4a519816d614b46c23ab0cdef5a3adc51a72da Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Sun, 30 Jul 2023 16:05:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E6=94=BE=E6=98=A0=EF=BC=88208=EF=BC=89=E3=80=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=87=AA=E5=8A=A8=E6=94=BE=E6=98=A0=E9=97=B4=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Screen/BaseView.vue | 40 ++++++++++++++++++++++++--- src/views/Screen/hooks/useExecPlay.ts | 29 ++++++++++++++++--- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/views/Screen/BaseView.vue b/src/views/Screen/BaseView.vue index 4913209e..7f8722e2 100644 --- a/src/views/Screen/BaseView.vue +++ b/src/views/Screen/BaseView.vue @@ -93,6 +93,10 @@ const { autoPlayTimer, autoPlay, closeAutoPlay, + autoPlayInterval, + setAutoPlayInterval, + loopPlay, + setLoopPlay, mousewheelListener, touchStartListener, touchEndListener, @@ -140,6 +144,38 @@ const contextmenus = (): ContextmenuItem[] => { handler: () => turnSlideToIndex(slides.value.length - 1), }, { divider: true }, + { + text: autoPlayTimer.value ? '取消自动放映' : '自动放映', + handler: autoPlayTimer.value ? closeAutoPlay : autoPlay, + children: [ + { + text: '2.5秒', + subText: autoPlayInterval.value === 2500 ? '√' : '', + handler: () => setAutoPlayInterval(2500), + }, + { + text: '5秒', + subText: autoPlayInterval.value === 5000 ? '√' : '', + handler: () => setAutoPlayInterval(5000), + }, + { + text: '7.5秒', + subText: autoPlayInterval.value === 7500 ? '√' : '', + handler: () => setAutoPlayInterval(7500), + }, + { + text: '10秒', + subText: autoPlayInterval.value === 10000 ? '√' : '', + handler: () => setAutoPlayInterval(10000), + }, + ], + }, + { + text: '循环放映', + subText: loopPlay.value ? '√' : '', + handler: () => setLoopPlay(!loopPlay.value), + }, + { divider: true }, { text: '显示工具栏', handler: () => rightToolsVisible.value = true, @@ -157,10 +193,6 @@ const contextmenus = (): ContextmenuItem[] => { handler: () => props.changeViewMode('presenter'), }, { divider: true }, - { - text: autoPlayTimer.value ? '取消自动放映' : '自动放映', - handler: autoPlayTimer.value ? closeAutoPlay : autoPlay, - }, { text: '结束放映', subText: 'ESC', diff --git a/src/views/Screen/hooks/useExecPlay.ts b/src/views/Screen/hooks/useExecPlay.ts index a5a7bb7d..358ff1d8 100644 --- a/src/views/Screen/hooks/useExecPlay.ts +++ b/src/views/Screen/hooks/useExecPlay.ts @@ -100,6 +100,12 @@ export default () => { } onUnmounted(closeAutoPlay) + // 循环放映 + const loopPlay = ref(false) + const setLoopPlay = (loop: boolean) => { + loopPlay.value = loop + } + const throttleMassage = throttle(function(msg) { message.success(msg) }, 1000, { leading: true, trailing: false }) @@ -121,7 +127,8 @@ export default () => { else animationIndex.value = formatedAnimations.value.length } else { - throttleMassage('已经是第一页了') + if (loopPlay.value) turnSlideToIndex(slides.value.length - 1) + else throttleMassage('已经是第一页了') } inAnimation.value = false } @@ -135,17 +142,27 @@ export default () => { inAnimation.value = false } else { - throttleMassage('已经是最后一页了') - closeAutoPlay() + if (loopPlay.value) turnSlideToIndex(0) + else { + throttleMassage('已经是最后一页了') + closeAutoPlay() + } inAnimation.value = false } } // 自动播放 + const autoPlayInterval = ref(2500) const autoPlay = () => { closeAutoPlay() message.success('开始自动放映') - autoPlayTimer.value = setInterval(execNext, 2500) + autoPlayTimer.value = setInterval(execNext, autoPlayInterval.value) + } + + const setAutoPlayInterval = (interval: number) => { + closeAutoPlay() + autoPlayInterval.value = interval + autoPlay() } // 鼠标滚动翻页 @@ -219,8 +236,12 @@ export default () => { return { autoPlayTimer, + autoPlayInterval, + setAutoPlayInterval, autoPlay, closeAutoPlay, + loopPlay, + setLoopPlay, mousewheelListener, touchStartListener, touchEndListener,