diff --git a/frontend/src/components/canvas/custom-component/Group.vue b/frontend/src/components/canvas/custom-component/Group.vue index 3a256d56b0..96fc1d7688 100644 --- a/frontend/src/components/canvas/custom-component/Group.vue +++ b/frontend/src/components/canvas/custom-component/Group.vue @@ -1,54 +1,54 @@ diff --git a/frontend/src/components/canvas/store/copy.js b/frontend/src/components/canvas/store/copy.js index b10d829046..468cce3e31 100644 --- a/frontend/src/components/canvas/store/copy.js +++ b/frontend/src/components/canvas/store/copy.js @@ -4,64 +4,64 @@ import generateID from '@/components/canvas/utils/generateID' import { deepCopy } from '@/components/canvas/utils/utils' export default { - state: { - copyData: null, // 复制粘贴剪切 - isCut: false, + state: { + copyData: null, // 复制粘贴剪切 + isCut: false + }, + mutations: { + copy(state) { + if (!state.curComponent) return + state.copyData = { + data: deepCopy(state.curComponent), + index: state.curComponentIndex + } + + state.isCut = false }, - mutations: { - copy(state) { - if (!state.curComponent) return - state.copyData = { - data: deepCopy(state.curComponent), - index: state.curComponentIndex, - } - state.isCut = false - }, + paste(state, isMouse) { + if (!state.copyData) { + toast('请选择组件') + return + } - paste(state, isMouse) { - if (!state.copyData) { - toast('请选择组件') - return - } + const data = state.copyData.data - const data = state.copyData.data + if (isMouse) { + data.style.top = state.menuTop + data.style.left = state.menuLeft + } else { + data.style.top += 10 + data.style.left += 10 + } - if (isMouse) { - data.style.top = state.menuTop - data.style.left = state.menuLeft - } else { - data.style.top += 10 - data.style.left += 10 - } - - data.id = generateID() - store.commit('addComponent', { component: deepCopy(data) }) - if (state.isCut) { - state.copyData = null - } - }, - - cut(state) { - if (!state.curComponent) { - toast('请选择组件') - return - } - - if (state.copyData) { - const data = deepCopy(state.copyData.data) - const index = state.copyData.index - data.id = generateID() - store.commit('addComponent', { component: data, index }) - if (state.curComponentIndex >= index) { - // 如果当前组件索引大于等于插入索引,需要加一,因为当前组件往后移了一位 - state.curComponentIndex++ - } - } - - store.commit('copy') - store.commit('deleteComponent') - state.isCut = true - }, + data.id = generateID() + store.commit('addComponent', { component: deepCopy(data) }) + if (state.isCut) { + state.copyData = null + } }, + + cut(state) { + if (!state.curComponent) { + toast('请选择组件') + return + } + + if (state.copyData) { + const data = deepCopy(state.copyData.data) + const index = state.copyData.index + data.id = generateID() + store.commit('addComponent', { component: data, index }) + if (state.curComponentIndex >= index) { + // 如果当前组件索引大于等于插入索引,需要加一,因为当前组件往后移了一位 + state.curComponentIndex++ + } + } + + store.commit('copy') + store.commit('deleteComponent') + state.isCut = true + } + } } diff --git a/frontend/src/views/panel/list/PanelList.vue b/frontend/src/views/panel/list/PanelList.vue index 2854abe3a6..540b707bc3 100644 --- a/frontend/src/views/panel/list/PanelList.vue +++ b/frontend/src/views/panel/list/PanelList.vue @@ -178,7 +178,7 @@ import bus from '@/utils/bus' import EditPanel from './EditPanel' import { addGroup, delGroup, groupTree, defaultTree, findOne } from '@/api/panel/panel' import { - DEFAULT_COMMON_CANVAS_STYLE_STRING + DEFAULT_COMMON_CANVAS_STYLE_STRING } from '@/views/panel/panel' export default {