docs: 补充代码注释

This commit is contained in:
pipipi-pikachu 2021-02-14 12:24:25 +08:00
parent 132c2a0afa
commit d82641503f
5 changed files with 26 additions and 1 deletions

View File

@ -101,6 +101,7 @@ export default defineComponent({
const animations = ANIMATIONS
//
const animationSequence = computed(() => {
if (!currentSlideAnimations.value) return []
const animationSequence = []
@ -119,6 +120,7 @@ export default defineComponent({
return animationSequence
})
//
const handleElementAnimation = computed(() => {
if (!handleElement.value) return null
const animations = currentSlideAnimations.value || []
@ -127,12 +129,14 @@ export default defineComponent({
return animationTypes[animation.type]
})
//
const deleteAnimation = (elId: string) => {
const animations = (currentSlideAnimations.value as PPTAnimation[]).filter(item => item.elId !== elId)
store.commit(MutationTypes.UPDATE_SLIDE, { animations })
addHistorySnapshot()
}
//
const handleDragEnd = (eventData: { newIndex: number; oldIndex: number }) => {
const { newIndex, oldIndex } = eventData
if (oldIndex === newIndex) return
@ -146,6 +150,7 @@ export default defineComponent({
addHistorySnapshot()
}
//
const runAnimation = (elId: string, animationType: string) => {
const prefix = 'animate__'
const elRef = document.querySelector(`#editable-element-${elId} [class^=editable-element-]`)
@ -160,6 +165,7 @@ export default defineComponent({
}
}
//
const updateElementAnimation = (type: string) => {
const animations = (currentSlideAnimations.value as PPTAnimation[]).map(item => {
if (item.elId === handleElement.value.id) return { ...item, type }
@ -172,6 +178,7 @@ export default defineComponent({
runAnimation(handleElement.value.id, type)
}
//
const addAnimation = (type: string) => {
if (handleElementAnimation.value) {
updateElementAnimation(type)

View File

@ -180,6 +180,7 @@ export default defineComponent({
const { addHistorySnapshot } = useHistorySnapshot()
//
const updateLeft = (value: number) => {
const props = { left: value }
store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
@ -190,6 +191,8 @@ export default defineComponent({
store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
addHistorySnapshot()
}
//
const updateWidth = (value: number) => {
const props = { width: value }
store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
@ -205,11 +208,15 @@ export default defineComponent({
store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
addHistorySnapshot()
}
//
const updateFixedRatio = (value: boolean) => {
const props = { fixedRatio: value }
store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
addHistorySnapshot()
}
// 45
const updateRotate45 = (command: '+' | '-') => {
let _rotate = Math.floor(rotate.value / 45) * 45
if (command === '+') _rotate = _rotate + 45

View File

@ -52,6 +52,7 @@ export default defineComponent({
const { addHistorySnapshot } = useHistorySnapshot()
const { combineElements, uncombineElements } = useCombineElement()
//
const canCombine = computed(() => {
const firstGroupId = activeElementList.value[0].groupId
if (!firstGroupId) return true
@ -60,11 +61,12 @@ export default defineComponent({
return !inSameGroup
})
//
const alignActiveElement = (command: ElementAlignCommand) => {
const { minX, maxX, minY, maxY } = getElementListRange(activeElementList.value)
const elementList: PPTElement[] = JSON.parse(JSON.stringify(currentSlide.value.elements))
//
//
const groupElementRangeMap = {}
for (const activeElement of activeElementList.value) {
if (activeElement.groupId && !groupElementRangeMap[activeElement.groupId]) {
@ -73,6 +75,7 @@ export default defineComponent({
}
}
//
if (command === ElementAlignCommands.LEFT) {
elementList.forEach(element => {
if (activeElementIdList.value.includes(element.id)) {

View File

@ -40,12 +40,14 @@ export default defineComponent({
const { addHistorySnapshot } = useHistorySnapshot()
//
const updateTurningMode = (mode: string) => {
if (mode === currentTurningMode.value) return
store.commit(MutationTypes.UPDATE_SLIDE, { turningMode: mode })
addHistorySnapshot()
}
//
const applyAllSlide = () => {
const newSlides = slides.value.map(slide => {
return {

View File

@ -217,6 +217,7 @@ export default defineComponent({
const { addHistorySnapshot } = useHistorySnapshot()
//
const updateBackgroundType = (type: 'solid' | 'image' | 'gradient') => {
if (type === 'solid') {
const newBackground: SlideBackground = {
@ -248,17 +249,20 @@ export default defineComponent({
addHistorySnapshot()
}
//
const updateBackground = (props: Partial<SlideBackground>) => {
store.commit(MutationTypes.UPDATE_SLIDE, { background: { ...background.value, ...props } })
addHistorySnapshot()
}
//
const uploadBackgroundImage = (files: File[]) => {
const imageFile = files[0]
if (!imageFile) return
getImageDataURL(imageFile).then(dataURL => updateBackground({ image: dataURL }))
}
//
const applyBackgroundAllSlide = () => {
const newSlides = slides.value.map(slide => {
return {
@ -270,10 +274,12 @@ export default defineComponent({
addHistorySnapshot()
}
//
const updateTheme = (themeProps: Partial<SlideTheme>) => {
store.commit(MutationTypes.SET_THEME, themeProps)
}
//
const applyThemeAllSlide = () => {
const newSlides: Slide[] = JSON.parse(JSON.stringify(slides.value))
const { themeColor, backgroundColor, fontColor } = theme.value