Download frontend/src/hooks/useSelectElement.ts from CatPtain/web_ppt: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/CatPtain/web_ppt/resolve/main/frontend/src/hooks/useSelectElement.ts
- Command line
-
hf download hf://spaces/CatPtain/web_ppt/frontend/src/hooks/useSelectElement.ts
-
curl -L -o useSelectElement.ts https://huggingface.co/spaces/CatPtain/web_ppt/resolve/main/frontend/src/hooks/useSelectElement.ts
1.07 kB
| import { storeToRefs } from 'pinia' | |
| import { useMainStore, useSlidesStore } from '@/store' | |
| export default () => { | |
| const mainStore = useMainStore() | |
| const { currentSlide } = storeToRefs(useSlidesStore()) | |
| const { hiddenElementIdList, handleElementId } = storeToRefs(mainStore) | |
| // 将当前页面全部元素设置为被选择状态 | |
| const selectAllElements = () => { | |
| const unlockedElements = currentSlide.value.elements.filter(el => !el.lock && !hiddenElementIdList.value.includes(el.id)) | |
| const newActiveElementIdList = unlockedElements.map(el => el.id) | |
| mainStore.setActiveElementIdList(newActiveElementIdList) | |
| } | |
| // 将指定元素设置为被选择状态 | |
| const selectElement = (id: string) => { | |
| if (handleElementId.value === id) return | |
| if (hiddenElementIdList.value.includes(id)) return | |
| const lockedElements = currentSlide.value.elements.filter(el => el.lock) | |
| if (lockedElements.some(el => el.id === id)) return | |
| mainStore.setActiveElementIdList([id]) | |
| } | |
| return { | |
| selectAllElements, | |
| selectElement, | |
| } | |
| } |