Commit fe222d42 authored by 任建锋's avatar 任建锋

增加复制节点功能

parent c0c6b795
......@@ -32,6 +32,7 @@ export default new Vuex.Store({
'modifyProject',
'addNode',
'deleteNode',
'copyNode',
'addAsset',
'deleteAsset',
'deleteAllAssets',
......
......@@ -280,6 +280,27 @@ export const projectStore = {
const index = parentChildren.indexOf(node);
parentChildren.splice(index, 1);
},
copyNode(state, {node, parentNode}) {
// const parentChildren = parentNode.children || parentNode;
// const index = parentChildren.indexOf(node);
//parentNode.children.push(node);
// parentChildren.push(parentChildren[index]);
const child = {
name:node.name,
type:node.type,
properties: node.properties,
events: node.events,
uuid: generateUUID(),
};
if (parentNode) {
if (!parentNode.children) {
Vue.set(parentNode, 'children', []);
}
parentNode.children.push(child);
} else {
state.data.views.push(child);
}
},
importAssets(state, assets) {
state.data.assets.push(...assets);
},
......
......@@ -35,6 +35,7 @@
<el-link icon="el-icon-more" :underline="false" @click.stop/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="delete">{{$t('Delete')}}</el-dropdown-item>
<el-dropdown-item command="copy">{{$t('Copy')}}</el-dropdown-item>
<el-dropdown-item command="export" divided v-if="!node.parent.parent">{{$t('Export')}}
</el-dropdown-item>
<el-dropdown-item v-for="(type, key, index) in $t('view_node_menu')"
......@@ -140,6 +141,12 @@
parentNode: node.parent.data
});
break;
case 'copy':
this.copyNode({
node: data,
parentNode: node.parent.data
});
break;
case 'export':
this.exportView(data);
break;
......@@ -155,7 +162,7 @@
break;
}
},
...mapMutations(['deleteNode', 'addNode']),
...mapMutations(['copyNode','deleteNode', 'addNode']),
...mapActions(['exportView', 'importView'])
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment