de/frontend/src/components/canvas/store/layer.js

43 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { swap, toBottom, toTop, moveUp, moveDown } from '@/components/canvas/utils/utils'
import toast from '@/components/canvas/utils/toast'
export default {
mutations: {
upComponent({ componentData, curComponentIndex }) {
// 上移图层 index表示元素在数组中越往后
if (curComponentIndex < componentData.length - 1) {
moveUp(componentData, curComponentIndex)
} else {
toast('已经到顶了')
}
},
downComponent({ componentData, curComponentIndex }) {
// 下移图层 index表示元素在数组中越往前
if (curComponentIndex > 0) {
moveDown(componentData, curComponentIndex)
} else {
toast('已经到底了')
}
},
topComponent({ componentData, curComponentIndex }) {
// 置顶
if (curComponentIndex < componentData.length - 1) {
toTop(componentData, curComponentIndex)
} else {
toast('已经到顶了')
}
},
bottomComponent({ componentData, curComponentIndex }) {
// 置底
if (curComponentIndex > 0) {
toBottom(componentData, curComponentIndex)
} else {
toast('已经到底了')
}
}
}
}