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,