mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
feat: 添加循环放映(208)、设置自动放映间隔
This commit is contained in:
parent
8ff70da477
commit
de4a519816
@ -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',
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user