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
26881ed0
Commit
26881ed0
authored
Sep 27, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
节点增加uuid字段
parent
10674cff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
project.js
src/store/modules/project.js
+25
-24
No files found.
src/store/modules/project.js
View file @
26881ed0
...
...
@@ -3,8 +3,8 @@
*/
import
Vue
from
"vue"
;
import
{
projectApi
}
from
"../../api"
;
import
{
compoleteComponentData
}
from
'../../utils/compoleteCmpData'
;
import
{
projectApi
}
from
"../../api"
;
import
{
compoleteComponentData
}
from
'../../utils/compoleteCmpData'
;
import
path
from
"path"
;
import
generateUUID
from
"uuid/v4"
;
...
...
@@ -27,14 +27,14 @@ export const projectStore = {
state
.
dirty
=
dirty
;
},
updateProject
(
state
,
project
)
{
const
{
id
,
name
,
creator
,
data
}
=
project
;
const
{
id
,
name
,
creator
,
data
}
=
project
;
state
.
id
=
id
;
state
.
name
=
name
;
state
.
creator
=
creator
;
const
localData
=
state
.
data
;
if
(
data
)
{
const
{
views
,
assets
,
dataMapping
}
=
JSON
.
parse
(
data
);
const
{
views
,
assets
,
dataMapping
}
=
JSON
.
parse
(
data
);
if
(
!
localData
.
views
||
localData
.
views
.
length
===
0
)
{
Vue
.
set
(
localData
,
'views'
,
views
||
[]);
}
...
...
@@ -44,7 +44,7 @@ export const projectStore = {
if
(
!
localData
.
dataMapping
||
localData
.
dataMapping
.
length
===
0
)
{
Vue
.
set
(
localData
,
'dataMapping'
,
dataMapping
||
[]);
}
}
else
{
}
else
{
Vue
.
set
(
localData
,
'views'
,
[]);
Vue
.
set
(
localData
,
'assets'
,
[]);
Vue
.
set
(
localData
,
'dataMapping'
,
[]);
...
...
@@ -53,8 +53,8 @@ export const projectStore = {
},
/**
* 激活组件
* @param {*} state
* @param {*} id
* @param {*} state
* @param {*} id
*/
activeComponent
(
state
,
item
)
{
// todo drag
...
...
@@ -70,13 +70,14 @@ export const projectStore = {
// state.activeIdList = [id];
console
.
log
(
'mutations activeComponent'
,
state
);
},
modifyProject
(
state
,
)
{
modifyProject
(
state
,)
{
},
addNode
(
state
,
{
node
,
name
,
type
})
{
addNode
(
state
,
{
node
,
name
,
type
})
{
const
child
=
{
name
,
type
,
uuid
:
generateUUID
(),
};
if
(
node
)
{
if
(
!
node
.
children
)
{
...
...
@@ -87,12 +88,12 @@ export const projectStore = {
state
.
data
.
views
.
push
(
child
);
}
},
deleteNode
(
state
,
{
node
,
parentNode
})
{
deleteNode
(
state
,
{
node
,
parentNode
})
{
const
index
=
parentNode
.
children
.
indexOf
(
node
);
parentNode
.
children
.
splice
(
index
,
1
);
},
addAsset
(
state
,
{
url
,
file
})
{
addAsset
(
state
,
{
url
,
file
})
{
const
ext
=
path
.
extname
(
file
.
name
);
state
.
data
.
assets
.
push
({
name
:
path
.
basename
(
file
.
name
,
ext
),
...
...
@@ -102,7 +103,7 @@ export const projectStore = {
})
},
deleteAsset
(
state
,
uuid
)
{
const
{
assets
}
=
state
.
data
;
const
{
assets
}
=
state
.
data
;
for
(
let
i
=
0
,
li
=
assets
.
length
;
i
<
li
;
i
++
)
{
const
asset
=
state
.
data
.
assets
[
i
];
if
(
asset
.
uuid
===
uuid
)
{
...
...
@@ -136,7 +137,7 @@ export const projectStore = {
},
getters
:
{
project
(
state
)
{
const
{
id
,
name
,
creator
,
data
}
=
state
;
const
{
id
,
name
,
creator
,
data
}
=
state
;
return
{
id
,
name
,
creator
,
data
:
JSON
.
stringify
(
data
),
...
...
@@ -179,17 +180,17 @@ export const projectStore = {
}
},
actions
:
{
saveToLocal
({
getters
,
commit
})
{
const
{
project
}
=
getters
;
saveToLocal
({
getters
,
commit
})
{
const
{
project
}
=
getters
;
localStorage
.
setItem
(
'project-'
+
project
.
id
,
JSON
.
stringify
(
project
));
commit
(
'setDirty'
,
true
);
},
localVersionExist
({
commit
},
projectID
)
{
localVersionExist
({
commit
},
projectID
)
{
let
json
=
localStorage
.
getItem
(
'project-'
+
projectID
);
return
!!
json
;
},
loadFromLocal
({
commit
},
projectID
)
{
loadFromLocal
({
commit
},
projectID
)
{
let
json
=
localStorage
.
getItem
(
'project-'
+
projectID
);
if
(
json
)
{
const
project
=
JSON
.
parse
(
json
);
...
...
@@ -197,11 +198,11 @@ export const projectStore = {
commit
(
'setDirty'
,
true
);
}
},
deleteLocalVersion
({
state
,
commit
},
projectID
)
{
deleteLocalVersion
({
state
,
commit
},
projectID
)
{
localStorage
.
removeItem
(
'project-'
+
projectID
);
commit
(
'setDirty'
,
false
);
},
async
loadFromRemote
({
commit
,
dispatch
},
projectID
)
{
async
loadFromRemote
({
commit
,
dispatch
},
projectID
)
{
const
project
=
await
projectApi
.
fetchOne
(
projectID
);
if
(
project
)
{
dispatch
(
'deleteLocalVersion'
,
projectID
);
...
...
@@ -210,20 +211,20 @@ export const projectStore = {
throw
new
Error
(
'Project does not exist'
)
}
},
async
saveToRemote
({
state
,
dispatch
,
getters
})
{
async
saveToRemote
({
state
,
dispatch
,
getters
})
{
await
projectApi
.
saveOne
(
getters
.
project
);
dispatch
(
'deleteLocalVersion'
,
state
.
id
);
},
async
updateProject
({
commit
},
projectID
)
{
async
updateProject
({
commit
},
projectID
)
{
const
project
=
await
projectApi
.
getData
(
projectID
);
commit
(
'updateProject'
,
project
);
},
/**
* 选中节点
* @param {*} param0
* @param {*} data
* @param {*} param0
* @param {*} data
*/
activeComponent
({
commit
},
data
)
{
activeComponent
({
commit
},
data
)
{
console
.
log
(
'actions activeComponent'
,
data
);
commit
(
'activeComponent'
,
data
);
...
...
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