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

增加复制节点功能

parent c0c6b795
...@@ -32,6 +32,7 @@ export default new Vuex.Store({ ...@@ -32,6 +32,7 @@ export default new Vuex.Store({
'modifyProject', 'modifyProject',
'addNode', 'addNode',
'deleteNode', 'deleteNode',
'copyNode',
'addAsset', 'addAsset',
'deleteAsset', 'deleteAsset',
'deleteAllAssets', 'deleteAllAssets',
......
...@@ -280,6 +280,27 @@ export const projectStore = { ...@@ -280,6 +280,27 @@ export const projectStore = {
const index = parentChildren.indexOf(node); const index = parentChildren.indexOf(node);
parentChildren.splice(index, 1); 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) { importAssets(state, assets) {
state.data.assets.push(...assets); state.data.assets.push(...assets);
}, },
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<el-link icon="el-icon-more" :underline="false" @click.stop/> <el-link icon="el-icon-more" :underline="false" @click.stop/>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="delete">{{$t('Delete')}}</el-dropdown-item> <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 command="export" divided v-if="!node.parent.parent">{{$t('Export')}}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item v-for="(type, key, index) in $t('view_node_menu')" <el-dropdown-item v-for="(type, key, index) in $t('view_node_menu')"
...@@ -140,6 +141,12 @@ ...@@ -140,6 +141,12 @@
parentNode: node.parent.data parentNode: node.parent.data
}); });
break; break;
case 'copy':
this.copyNode({
node: data,
parentNode: node.parent.data
});
break;
case 'export': case 'export':
this.exportView(data); this.exportView(data);
break; break;
...@@ -155,7 +162,7 @@ ...@@ -155,7 +162,7 @@
break; break;
} }
}, },
...mapMutations(['deleteNode', 'addNode']), ...mapMutations(['copyNode','deleteNode', 'addNode']),
...mapActions(['exportView', 'importView']) ...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