Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-editor
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-editor
Commits
385306d8
Commit
385306d8
authored
Dec 18, 2019
by
任建锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
复制支持复制子级
parent
f771a7e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
13 deletions
+43
-13
project.js
src/store/modules/project.js
+43
-13
No files found.
src/store/modules/project.js
View file @
385306d8
...
...
@@ -36,6 +36,42 @@ function getDefaultOptions() {
return
clonePureObj
(
defaultOptions
);
}
function
setUUIDForAllChildren
(
node
){
if
(
node
.
children
&&
node
.
children
.
length
>
0
){
for
(
let
i
=
0
;
i
<
node
.
children
.
length
;
i
++
){
node
.
children
[
i
]
=
copyBaseRoot
(
node
.
children
[
i
])
setUUIDForAllChildren
(
node
.
children
[
i
])
}
}
}
function
copyBaseRoot
(
node
){
let
_node
=
JSON
.
parse
(
JSON
.
stringify
(
node
));
let
data
if
(
_node
.
children
&&
_node
.
children
.
length
>
0
){
data
=
{
name
:
_node
.
name
,
type
:
_node
.
type
,
properties
:
_node
.
properties
,
events
:
_node
.
events
,
uuid
:
generateUUID
(),
children
:
_node
.
children
};
}
else
{
data
=
{
name
:
_node
.
name
,
type
:
_node
.
type
,
properties
:
_node
.
properties
,
events
:
_node
.
events
,
uuid
:
generateUUID
(),
};
}
return
data
}
export
const
projectStore
=
{
state
:
{
id
:
''
,
...
...
@@ -282,25 +318,19 @@ 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
(),
};
let
_node1
=
node
let
_node
=
copyBaseRoot
(
_node1
);
setUUIDForAllChildren
(
_node
)
if
(
parentNode
)
{
if
(
!
parentNode
.
children
)
{
Vue
.
set
(
parentNode
,
'children'
,
[]);
}
parentNode
.
children
.
push
(
child
);
parentNode
.
children
.
push
(
_node
);
}
else
{
state
.
data
.
views
.
push
(
child
);
state
.
data
.
views
.
push
(
_node
);
}
},
importAssets
(
state
,
assets
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment