mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { storeToRefs } from 'pinia'
|
|
import { useSlidesStore, useMainStore } from '@/store'
|
|
|
|
export default () => {
|
|
const slidesStore = useSlidesStore()
|
|
const mainStore = useMainStore()
|
|
const { currentSlide } = storeToRefs(slidesStore)
|
|
const { activeElementIdList, hiddenElementIdList } = storeToRefs(mainStore)
|
|
|
|
const toggleHideElement = (id: string) => {
|
|
if (hiddenElementIdList.value.includes(id)) {
|
|
mainStore.setHiddenElementIdList(hiddenElementIdList.value.filter(item => item !== id))
|
|
}
|
|
else mainStore.setHiddenElementIdList([...hiddenElementIdList.value, id])
|
|
|
|
if (activeElementIdList.value.includes(id)) mainStore.setActiveElementIdList([])
|
|
}
|
|
|
|
const showAllElements = () => {
|
|
const currentSlideElIdList = currentSlide.value.elements.map(item => item.id)
|
|
const needHiddenElementIdList = hiddenElementIdList.value.filter(item => !currentSlideElIdList.includes(item))
|
|
mainStore.setHiddenElementIdList(needHiddenElementIdList)
|
|
}
|
|
const hideAllElements = () => {
|
|
const currentSlideElIdList = currentSlide.value.elements.map(item => item.id)
|
|
mainStore.setHiddenElementIdList([...hiddenElementIdList.value, ...currentSlideElIdList])
|
|
if (activeElementIdList.value.length) mainStore.setActiveElementIdList([])
|
|
}
|
|
|
|
return {
|
|
toggleHideElement,
|
|
showAllElements,
|
|
hideAllElements,
|
|
}
|
|
} |