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
afc8d0df
Commit
afc8d0df
authored
Nov 15, 2019
by
张晨辰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: delete scripts & events
parent
c67c09a2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
271 additions
and
127 deletions
+271
-127
index.vue
src/components/customElement/node/index.vue
+12
-2
project.js
src/store/modules/project.js
+91
-57
pane.scss
src/themes/light/pane.scss
+5
-4
common.js
src/utils/common.js
+18
-7
properties.js
src/utils/properties.js
+38
-28
BehaviorTab.vue
src/views/Editor/Inspector/BehaviorTab.vue
+23
-6
PropsTab.vue
src/views/Editor/Inspector/PropsTab.vue
+21
-8
Playground.vue
src/views/Editor/Playground.vue
+1
-1
drawPanel.vue
src/views/Editor/components/drawPanel.vue
+16
-14
viewsTree.vue
src/views/Editor/components/viewsTree.vue
+46
-0
No files found.
src/components/customElement/node/index.vue
View file @
afc8d0df
<
template
>
<
template
>
<div
:style=
"customStyle"
class=
"zero-custom-cmp zero-custom-node"
v-html=
"selfText"
></div>
<div
:style=
"customStyle"
class=
"zero-custom-cmp zero-custom-node"
>
<p
class=
"custom-node-html"
v-if=
"selfText"
>
{{
selfText
}}
</p>
<slot></slot>
</div>
</
template
>
</
template
>
<
style
>
<
style
lang=
"scss"
>
.zero-custom-cmp
{
.zero-custom-cmp
{
position
:
absolute
;
position
:
absolute
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
.custom-node-html
{
position
:
absolute
;
padding
:
0
;
margin
:
0
;
width
:
100%
;
height
:
100%
;
}
}
}
</
style
>
</
style
>
...
...
src/store/modules/project.js
View file @
afc8d0df
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
*/
*/
import
Vue
from
"vue"
;
import
Vue
from
"vue"
;
import
JSZip
from
"jszip"
;
import
JSZip
from
"jszip"
;
import
{
projectApi
}
from
"../../api"
;
import
{
projectApi
}
from
"../../api"
;
import
path
from
"path"
;
import
path
from
"path"
;
import
generateUUID
from
"uuid/v4"
;
import
generateUUID
from
"uuid/v4"
;
import
{
getCmpProps
,
flattenViews
,
getCmpByUUID
}
from
'../../utils/common'
;
import
{
getCmpProps
,
flattenViews
,
getCmpByUUID
}
from
'../../utils/common'
;
import
{
saveAs
}
from
"../../utils"
;
import
{
saveAs
}
from
"../../utils"
;
import
{
template
}
from
"../../template"
;
import
{
template
}
from
"../../template"
;
const
defaultOptions
=
{
const
defaultOptions
=
{
pageTitle
:
'no title'
,
pageTitle
:
'no title'
,
...
@@ -52,14 +52,14 @@ export const projectStore = {
...
@@ -52,14 +52,14 @@ export const projectStore = {
state
.
dirty
=
dirty
;
state
.
dirty
=
dirty
;
},
},
updateProject
(
state
,
project
)
{
updateProject
(
state
,
project
)
{
const
{
id
,
name
,
creator
,
data
}
=
project
;
const
{
id
,
name
,
creator
,
data
}
=
project
;
state
.
id
=
id
;
state
.
id
=
id
;
state
.
name
=
name
;
state
.
name
=
name
;
state
.
creator
=
creator
;
state
.
creator
=
creator
;
const
localData
=
state
.
data
;
const
localData
=
state
.
data
;
if
(
data
)
{
if
(
data
)
{
const
{
views
,
assets
,
dataMapping
,
processes
,
options
,
}
=
JSON
.
parse
(
data
);
const
{
views
,
assets
,
dataMapping
,
processes
,
options
,
}
=
JSON
.
parse
(
data
);
Vue
.
set
(
localData
,
'options'
,
options
||
getDefaultOptions
());
Vue
.
set
(
localData
,
'options'
,
options
||
getDefaultOptions
());
Vue
.
set
(
localData
,
'views'
,
views
||
[]);
Vue
.
set
(
localData
,
'views'
,
views
||
[]);
...
@@ -117,8 +117,17 @@ export const projectStore = {
...
@@ -117,8 +117,17 @@ export const projectStore = {
state
.
stackIndex
=
0
;
// 开始编辑的时候,重置操作栈的下标
state
.
stackIndex
=
0
;
// 开始编辑的时候,重置操作栈的下标
let
newView
=
_
.
merge
(
oldView
,
view
);
let
newView
=
_
.
merge
(
oldView
,
view
);
// 如果是scripts和events的修改,直接覆盖 不merge
if
(
view
.
scripts
)
{
newView
.
scripts
=
_
.
cloneDeep
(
view
.
scripts
)
}
if
(
view
.
events
)
{
newView
.
events
=
_
.
cloneDeep
(
view
.
events
)
}
// 在操作栈中插入最新值
// 在操作栈中插入最新值
state
.
operateStack
.
unshift
(
_
.
cloneDeep
(
_
.
assign
({
uuid
:
newView
.
uuid
},
view
)));
state
.
operateStack
.
unshift
(
_
.
cloneDeep
(
_
.
assign
({
uuid
:
newView
.
uuid
},
view
)));
// 操作栈最大200
// 操作栈最大200
if
(
state
.
operateStack
.
length
>
200
)
{
if
(
state
.
operateStack
.
length
>
200
)
{
state
.
operateStack
.
pop
();
state
.
operateStack
.
pop
();
...
@@ -126,35 +135,35 @@ export const projectStore = {
...
@@ -126,35 +135,35 @@ export const projectStore = {
// 将数据更新至当前选中的节点上
// 将数据更新至当前选中的节点上
_
.
forIn
(
view
,
(
value
,
key
)
=>
{
_
.
forIn
(
view
,
(
value
,
key
)
=>
{
if
(
key
===
'properties'
)
{
//
if (key === 'properties') {
// horizonCenter和left\right
// horizonCenter和left\right
// verticalCenter和top\bottom
// verticalCenter和top\bottom
// 互斥,只要修改了一项,则把互斥项置空
// 互斥,只要修改了一项,则把互斥项置空
if
(
value
.
horizonCenter
)
{
//
if (value.horizonCenter) {
delete
newView
.
properties
.
left
;
//
delete newView.properties.left;
delete
newView
.
properties
.
right
;
//
delete newView.properties.right;
}
//
}
if
(
value
.
verticalCenter
)
{
//
if (value.verticalCenter) {
delete
newView
.
properties
.
top
;
//
delete newView.properties.top;
delete
newView
.
properties
.
bottom
;
//
delete newView.properties.bottom;
}
//
}
if
(
value
.
left
||
value
.
right
)
{
//
if (value.left || value.right) {
delete
newView
.
properties
.
horizonCenter
;
//
delete newView.properties.horizonCenter;
}
//
}
if
(
value
.
top
||
value
.
bottom
)
{
//
if (value.top || value.bottom) {
delete
newView
.
properties
.
verticalCenter
;
//
delete newView.properties.verticalCenter;
}
//
}
// 如果left\right top\bottom组合同时存在
// 如果left\right top\bottom组合同时存在
// 则根据数值,计算width height
// 则根据数值,计算width height
if
(
newView
.
properties
.
left
&&
newView
.
properties
.
right
)
{
// if (newView.properties.left && newView.properties.right) {
// //
}
// }
if
(
newView
.
properties
.
top
&&
newView
.
properties
.
bottom
)
{
// if (newView.properties.top && newView.properties.bottom) {
}
}
// }
// }
Vue
.
set
(
state
.
activeComponent
,
key
,
newView
[
key
]);
Vue
.
set
(
state
.
activeComponent
,
key
,
newView
[
key
]);
})
})
...
@@ -223,7 +232,7 @@ export const projectStore = {
...
@@ -223,7 +232,7 @@ export const projectStore = {
modifyProject
(
state
)
{
modifyProject
(
state
)
{
},
},
addNode
(
state
,
{
node
,
name
,
type
})
{
addNode
(
state
,
{
node
,
name
,
type
})
{
const
child
=
{
const
child
=
{
name
,
name
,
type
,
type
,
...
@@ -243,7 +252,7 @@ export const projectStore = {
...
@@ -243,7 +252,7 @@ export const projectStore = {
importView
(
state
,
view
)
{
importView
(
state
,
view
)
{
state
.
data
.
views
.
push
(
view
);
state
.
data
.
views
.
push
(
view
);
},
},
deleteNode
(
state
,
{
node
,
parentNode
})
{
deleteNode
(
state
,
{
node
,
parentNode
})
{
const
parentChildren
=
parentNode
.
children
||
parentNode
;
const
parentChildren
=
parentNode
.
children
||
parentNode
;
const
index
=
parentChildren
.
indexOf
(
node
);
const
index
=
parentChildren
.
indexOf
(
node
);
parentChildren
.
splice
(
index
,
1
);
parentChildren
.
splice
(
index
,
1
);
...
@@ -251,7 +260,7 @@ export const projectStore = {
...
@@ -251,7 +260,7 @@ export const projectStore = {
importAssets
(
state
,
assets
)
{
importAssets
(
state
,
assets
)
{
state
.
data
.
assets
.
push
(...
assets
);
state
.
data
.
assets
.
push
(...
assets
);
},
},
addAsset
(
state
,
{
url
,
file
})
{
addAsset
(
state
,
{
url
,
file
})
{
const
ext
=
path
.
extname
(
file
.
name
);
const
ext
=
path
.
extname
(
file
.
name
);
state
.
data
.
assets
.
push
({
state
.
data
.
assets
.
push
({
name
:
path
.
basename
(
file
.
name
,
ext
),
name
:
path
.
basename
(
file
.
name
,
ext
),
...
@@ -261,7 +270,7 @@ export const projectStore = {
...
@@ -261,7 +270,7 @@ export const projectStore = {
})
})
},
},
deleteAsset
(
state
,
uuid
)
{
deleteAsset
(
state
,
uuid
)
{
const
{
assets
}
=
state
.
data
;
const
{
assets
}
=
state
.
data
;
for
(
let
i
=
0
,
li
=
assets
.
length
;
i
<
li
;
i
++
)
{
for
(
let
i
=
0
,
li
=
assets
.
length
;
i
<
li
;
i
++
)
{
const
asset
=
state
.
data
.
assets
[
i
];
const
asset
=
state
.
data
.
assets
[
i
];
if
(
asset
.
uuid
===
uuid
)
{
if
(
asset
.
uuid
===
uuid
)
{
...
@@ -295,7 +304,7 @@ export const projectStore = {
...
@@ -295,7 +304,7 @@ export const projectStore = {
},
},
getters
:
{
getters
:
{
project
(
state
)
{
project
(
state
)
{
const
{
id
,
name
,
creator
,
data
}
=
state
;
const
{
id
,
name
,
creator
,
data
}
=
state
;
return
{
return
{
id
,
name
,
creator
,
id
,
name
,
creator
,
data
:
JSON
.
stringify
(
data
),
data
:
JSON
.
stringify
(
data
),
...
@@ -343,19 +352,35 @@ export const projectStore = {
...
@@ -343,19 +352,35 @@ export const projectStore = {
// console.log('componentList', result);
// console.log('componentList', result);
return
result
;
return
result
;
},
},
/**
* 返回Array格式的views
*/
views
:
state
=>
{
// 如果有选中的节点,则展示对应的视图组
// 否则展示第一个视图组
let
_view
=
[];
if
(
state
.
activeViews
)
{
_view
=
state
.
data
.
views
.
filter
(
v
=>
v
.
uuid
===
state
.
activeViews
)
}
else
{
_view
=
state
.
data
.
views
.
length
?
[].
concat
(
state
.
data
.
views
[
0
])
:
[];
}
console
.
log
(
'_view'
,
_view
);
return
_view
;
}
},
},
actions
:
{
actions
:
{
saveToLocal
({
getters
,
commit
})
{
saveToLocal
({
getters
,
commit
})
{
const
{
project
}
=
getters
;
const
{
project
}
=
getters
;
localStorage
.
setItem
(
'project-'
+
project
.
id
,
JSON
.
stringify
(
project
));
localStorage
.
setItem
(
'project-'
+
project
.
id
,
JSON
.
stringify
(
project
));
commit
(
'setDirty'
,
true
);
commit
(
'setDirty'
,
true
);
},
},
localVersionExist
({
commit
},
projectID
)
{
localVersionExist
({
commit
},
projectID
)
{
let
json
=
localStorage
.
getItem
(
'project-'
+
projectID
);
let
json
=
localStorage
.
getItem
(
'project-'
+
projectID
);
return
!!
json
;
return
!!
json
;
},
},
loadFromLocal
({
commit
},
projectID
)
{
loadFromLocal
({
commit
},
projectID
)
{
let
json
=
localStorage
.
getItem
(
'project-'
+
projectID
);
let
json
=
localStorage
.
getItem
(
'project-'
+
projectID
);
if
(
json
)
{
if
(
json
)
{
const
project
=
JSON
.
parse
(
json
);
const
project
=
JSON
.
parse
(
json
);
...
@@ -363,11 +388,11 @@ export const projectStore = {
...
@@ -363,11 +388,11 @@ export const projectStore = {
commit
(
'setDirty'
,
true
);
commit
(
'setDirty'
,
true
);
}
}
},
},
deleteLocalVersion
({
state
,
commit
},
projectID
)
{
deleteLocalVersion
({
state
,
commit
},
projectID
)
{
localStorage
.
removeItem
(
'project-'
+
projectID
);
localStorage
.
removeItem
(
'project-'
+
projectID
);
commit
(
'setDirty'
,
false
);
commit
(
'setDirty'
,
false
);
},
},
async
loadFromRemote
({
commit
,
dispatch
},
projectID
)
{
async
loadFromRemote
({
commit
,
dispatch
},
projectID
)
{
const
project
=
await
projectApi
.
fetchOne
(
projectID
);
const
project
=
await
projectApi
.
fetchOne
(
projectID
);
if
(
project
)
{
if
(
project
)
{
dispatch
(
'deleteLocalVersion'
,
projectID
);
dispatch
(
'deleteLocalVersion'
,
projectID
);
...
@@ -376,11 +401,11 @@ export const projectStore = {
...
@@ -376,11 +401,11 @@ export const projectStore = {
throw
new
Error
(
'Project does not exist'
)
throw
new
Error
(
'Project does not exist'
)
}
}
},
},
async
saveToRemote
({
state
,
dispatch
,
getters
})
{
async
saveToRemote
({
state
,
dispatch
,
getters
})
{
await
projectApi
.
saveOne
(
getters
.
project
);
await
projectApi
.
saveOne
(
getters
.
project
);
dispatch
(
'deleteLocalVersion'
,
state
.
id
);
dispatch
(
'deleteLocalVersion'
,
state
.
id
);
},
},
async
updateProject
({
commit
},
projectID
)
{
async
updateProject
({
commit
},
projectID
)
{
const
project
=
await
projectApi
.
getData
(
projectID
);
const
project
=
await
projectApi
.
getData
(
projectID
);
commit
(
'updateProject'
,
project
);
commit
(
'updateProject'
,
project
);
},
},
...
@@ -409,14 +434,13 @@ export const projectStore = {
...
@@ -409,14 +434,13 @@ export const projectStore = {
/**
/**
* 修改属性
* 修改属性
*/
*/
modifyProperties
({
commit
,
state
},
props
)
{
modifyProperties
({
commit
,
state
,
getters
},
props
)
{
// debugger;
// debugger;
// 如果当前修改的是“来源”属性,节点又没有高度宽度,则取图片的高度宽度
// 如果当前修改的是“来源”属性,节点又没有高度宽度,则取图片的高度宽度
let
_source
=
Object
.
keys
(
props
).
indexOf
(
'source'
)
>
-
1
;
if
(
props
.
source
)
{
if
(
_source
)
{
let
_props
=
state
.
activeComponent
.
properties
;
let
_props
=
state
.
activeComponent
.
properties
;
if
(
!
_props
.
width
||
!
_props
.
height
)
{
if
(
!
_props
.
width
||
!
_props
.
height
)
{
let
_url
=
props
[
'source'
]
;
//_source.value;
let
_url
=
props
.
source
;
//_source.value;
if
(
_url
.
indexOf
(
'asset://'
)
===
0
)
{
if
(
_url
.
indexOf
(
'asset://'
)
===
0
)
{
let
uuid
=
_url
.
split
(
'//'
)[
1
];
let
uuid
=
_url
.
split
(
'//'
)[
1
];
let
asset
=
state
.
data
.
assets
.
find
(
a
=>
a
.
uuid
===
uuid
);
let
asset
=
state
.
data
.
assets
.
find
(
a
=>
a
.
uuid
===
uuid
);
...
@@ -435,6 +459,16 @@ export const projectStore = {
...
@@ -435,6 +459,16 @@ export const projectStore = {
}
}
}
}
let
finalProps
=
_
.
merge
({},
_
.
cloneDeep
(
state
.
activeComponent
.
properties
),
props
);
// 属性冲突&属性关联计算
// if (finalProps.left && finalProps.right) {
// left right 同时存在,计算其宽度
// }
commit
(
'modifyActiveView'
,
{
commit
(
'modifyActiveView'
,
{
properties
:
props
properties
:
props
})
})
...
@@ -444,13 +478,13 @@ export const projectStore = {
...
@@ -444,13 +478,13 @@ export const projectStore = {
* @param {*} param0
* @param {*} param0
* @param {*} props
* @param {*} props
*/
*/
modifyCopyProperties
({
commit
},
props
)
{
modifyCopyProperties
({
commit
},
props
)
{
commit
(
'modifyCopyProperties'
,
props
)
commit
(
'modifyCopyProperties'
,
props
)
},
},
/**
/**
* 修改当前选中的节点
* 修改当前选中的节点
*/
*/
modifyActiveView
({
commit
},
view
)
{
modifyActiveView
({
commit
},
view
)
{
commit
(
'modifyActiveView'
,
view
)
commit
(
'modifyActiveView'
,
view
)
},
},
...
@@ -459,7 +493,7 @@ export const projectStore = {
...
@@ -459,7 +493,7 @@ export const projectStore = {
* @param {*} param0
* @param {*} param0
* @param {*} data
* @param {*} data
*/
*/
addNodeScript
({
commit
,
state
},
script
)
{
addNodeScript
({
commit
,
state
},
script
)
{
let
_scripts
=
_
.
cloneDeep
(
state
.
activeComponent
.
scripts
||
[]);
let
_scripts
=
_
.
cloneDeep
(
state
.
activeComponent
.
scripts
||
[]);
_scripts
.
push
({
_scripts
.
push
({
script
:
script
,
script
:
script
,
...
@@ -470,15 +504,15 @@ export const projectStore = {
...
@@ -470,15 +504,15 @@ export const projectStore = {
})
})
},
},
exportView
({
state
},
view
)
{
exportView
({
state
},
view
)
{
let
zip
=
new
JSZip
();
let
zip
=
new
JSZip
();
zip
.
file
(
'view.json'
,
JSON
.
stringify
(
view
));
zip
.
file
(
'view.json'
,
JSON
.
stringify
(
view
));
zip
.
generateAsync
({
type
:
"blob"
}).
then
(
function
(
content
)
{
zip
.
generateAsync
({
type
:
"blob"
}).
then
(
function
(
content
)
{
saveAs
(
content
,
`view-
${
view
.
name
}
.zrv`
);
saveAs
(
content
,
`view-
${
view
.
name
}
.zrv`
);
});
});
},
},
async
packProject
({
state
})
{
async
packProject
({
state
})
{
const
result
=
await
projectApi
.
pack
(
state
.
id
);
const
result
=
await
projectApi
.
pack
(
state
.
id
);
console
.
log
(
result
)
console
.
log
(
result
)
return
result
;
return
result
;
...
...
src/themes/light/pane.scss
View file @
afc8d0df
...
@@ -5,6 +5,11 @@
...
@@ -5,6 +5,11 @@
display
:
flex
;
display
:
flex
;
flex-direction
:
column-reverse
;
flex-direction
:
column-reverse
;
&
.pane-playground
.content
{
display
:
block
;
width
:
100%
;
}
&
:focus
{
&
:focus
{
outline
:
none
;
outline
:
none
;
...
@@ -28,10 +33,6 @@
...
@@ -28,10 +33,6 @@
flex
:
1
;
flex
:
1
;
border-radius
:
2px
;
border-radius
:
2px
;
position
:
relative
;
position
:
relative
;
&
.background
{
display
:
block
;
width
:
100%
;
}
}
}
.title-bar
{
.title-bar
{
...
...
src/utils/common.js
View file @
afc8d0df
...
@@ -26,6 +26,8 @@ export const componentsMap = [
...
@@ -26,6 +26,8 @@ export const componentsMap = [
// 属性的计算方法
// 属性的计算方法
const
propsComputeRules
=
{
const
propsComputeRules
=
{
x
:
'add'
,
y
:
'add'
,
left
:
'add'
,
left
:
'add'
,
top
:
'add'
,
top
:
'add'
,
rotation
:
'add'
,
rotation
:
'add'
,
...
@@ -47,8 +49,8 @@ function invalidAttr(key, value) {
...
@@ -47,8 +49,8 @@ function invalidAttr(key, value) {
// 属性简称 对照表
// 属性简称 对照表
const
attrShortMapper
=
{
const
attrShortMapper
=
{
//
x: 'left',
x
:
'left'
,
//
y: 'top',
y
:
'top'
,
align
:
'text-align'
,
align
:
'text-align'
,
size
:
'font-size'
,
size
:
'font-size'
,
alpha
:
'opacity'
,
alpha
:
'opacity'
,
...
@@ -60,10 +62,12 @@ const attrShortMapper = {
...
@@ -60,10 +62,12 @@ const attrShortMapper = {
// 编辑时想拖拽组件需要生成的css属性
// 编辑时想拖拽组件需要生成的css属性
// 只需要位置,不需要来源透明度等等
// 只需要位置,不需要来源透明度等等
const
operatProps
=
[
'
left'
,
'top'
,
'right'
,
'bottom'
,
'width'
,
'height'
,
'rotation'
];
const
operatProps
=
[
'
x'
,
'y'
,
'left'
,
'top'
,
'right'
,
'bottom'
,
'width'
,
'height'
,
'rotation'
];
// 属性单位 对照表, 如果是数值的时候需要添加单位
// 属性单位 对照表, 如果是数值的时候需要添加单位
const
attrUnitMapper
=
{
const
attrUnitMapper
=
{
x
:
'px'
,
y
:
'px'
,
left
:
'px'
,
left
:
'px'
,
top
:
'px'
,
top
:
'px'
,
right
:
'px'
,
right
:
'px'
,
...
@@ -139,22 +143,29 @@ export const flattenViews = function (views) {
...
@@ -139,22 +143,29 @@ export const flattenViews = function (views) {
* @param {*} props
* @param {*} props
* @param {*} parent
* @param {*} parent
*/
*/
function
inheritProps
(
props
,
parent
)
{
function
inheritProps
(
props
,
parent
,
onlyOpera
)
{
_
.
forIn
(
parent
,
(
value
,
key
)
=>
{
_
.
forIn
(
parent
,
(
value
,
key
)
=>
{
let
_pValue
=
parent
[
key
];
let
_pValue
=
parent
[
key
];
if
(
_pValue
===
null
||
_pValue
===
undefined
)
{
if
(
_pValue
===
null
||
_pValue
===
undefined
)
{
return
;
return
;
}
}
let
rule
=
propsComputeRules
[
key
];
let
rule
=
propsComputeRules
[
key
];
// 加法
// 加法
if
(
rule
===
'add'
)
{
if
(
rule
===
'add'
)
{
if
(
props
[
key
]
===
null
||
props
[
key
]
===
undefined
)
{
props
[
key
]
=
0
;
}
props
[
key
]
+=
_pValue
;
props
[
key
]
+=
_pValue
;
}
}
// 乘法
// 乘法
if
(
rule
===
'multi'
)
{
if
(
rule
===
'multi'
)
{
if
(
props
[
key
]
===
null
||
props
[
key
]
===
undefined
)
{
props
[
key
]
=
1
;
}
props
[
key
]
*=
_pValue
;
props
[
key
]
*=
_pValue
;
}
}
// 可见,特殊处理
// 可见,特殊处理
// 节点和父节点的visible只要有一个是false,值就是false,否则为true
if
(
rule
===
'visible'
)
{
if
(
rule
===
'visible'
)
{
props
[
key
]
=
!
props
[
key
]
||
!
_pValue
?
false
:
true
;
props
[
key
]
=
!
props
[
key
]
||
!
_pValue
?
false
:
true
;
}
}
...
@@ -168,7 +179,7 @@ function inheritProps(props, parent) {
...
@@ -168,7 +179,7 @@ function inheritProps(props, parent) {
function
completeSelfProps
(
component
)
{
function
completeSelfProps
(
component
)
{
// 根据组件类型,获取默认属性
// 根据组件类型,获取默认属性
let
defaultProps
=
getCmpProps
(
component
.
type
);
let
defaultProps
=
getCmpProps
(
component
.
type
);
// 把这些属性格式转换成key: value
// 把这些属性格式转换成key: value
defaultProps
=
_
.
mapValues
(
defaultProps
,
o
=>
(
o
.
value
));
defaultProps
=
_
.
mapValues
(
defaultProps
,
o
=>
(
o
.
value
));
...
@@ -245,7 +256,7 @@ export const styles = {
...
@@ -245,7 +256,7 @@ export const styles = {
if
(
propsMatrix
.
length
)
{
if
(
propsMatrix
.
length
)
{
propsMatrix
.
forEach
(
prop
=>
{
propsMatrix
.
forEach
(
prop
=>
{
// 继承每个父节点的属性
// 继承每个父节点的属性
inheritProps
(
cmpSelfProps
,
prop
);
inheritProps
(
cmpSelfProps
,
prop
,
onlyOpera
);
});
});
}
}
...
...
src/utils/properties.js
View file @
afc8d0df
...
@@ -3,26 +3,36 @@
...
@@ -3,26 +3,36 @@
export
default
{
export
default
{
node
:
{
node
:
{
groupName
:
'基础'
,
groupName
:
'基础'
,
left
:
{
x
:
{
title
:
'
左边距
'
,
title
:
'
x坐标
'
,
type
:
'inputNumber'
,
type
:
'inputNumber'
,
value
:
undefined
,
value
:
0
,
},
right
:
{
title
:
'右边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
top
:
{
title
:
'上边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
},
bottom
:
{
y
:
{
title
:
'
下边距
'
,
title
:
'
y坐标
'
,
type
:
'inputNumber'
,
type
:
'inputNumber'
,
value
:
undefined
,
value
:
0
,
},
},
// left: {
// title: '左边距',
// type: 'inputNumber',
// value: undefined,
// },
// right: {
// title: '右边距',
// type: 'inputNumber',
// value: undefined,
// },
// top: {
// title: '上边距',
// type: 'inputNumber',
// value: undefined,
// },
// bottom: {
// title: '下边距',
// type: 'inputNumber',
// value: undefined,
// },
width
:
{
width
:
{
title
:
'宽度'
,
title
:
'宽度'
,
type
:
'inputNumber'
,
type
:
'inputNumber'
,
...
@@ -33,18 +43,18 @@ export default {
...
@@ -33,18 +43,18 @@ export default {
type
:
'inputNumber'
,
type
:
'inputNumber'
,
value
:
1
value
:
1
},
},
horizonCenter
:
{
//
horizonCenter: {
title
:
'水平偏移'
,
//
title: '水平偏移',
type
:
'inputNumber'
,
//
type: 'inputNumber',
value
:
undefined
,
//
value: undefined,
desc
:
'相对于父元素中心点的水平偏移,0为正中心'
//
desc: '相对于父元素中心点的水平偏移,0为正中心'
},
//
},
verticalCenter
:
{
//
verticalCenter: {
title
:
'垂直偏移'
,
//
title: '垂直偏移',
type
:
'inputNumber'
,
//
type: 'inputNumber',
value
:
undefined
,
//
value: undefined,
desc
:
'相对于父元素中心点的垂直偏移,0为正中心'
//
desc: '相对于父元素中心点的垂直偏移,0为正中心'
},
//
},
rotation
:
{
rotation
:
{
title
:
'旋转'
,
title
:
'旋转'
,
type
:
'inputNumber'
,
type
:
'inputNumber'
,
...
...
src/views/Editor/Inspector/BehaviorTab.vue
View file @
afc8d0df
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
{{
$t
(
'Edit Behavior'
)
}}
{{
$t
(
'Edit Behavior'
)
}}
<i
v-if=
"evn.behaviors && evn.behaviors.length"
class=
"el-icon-check el-icon--right"
></i>
<i
v-if=
"evn.behaviors && evn.behaviors.length"
class=
"el-icon-check el-icon--right"
></i>
</el-button>
</el-button>
<el-button
icon=
"el-icon-delete"
size=
"mini"
v-if=
"evn.behaviors && evn.behaviors.length"
@
click=
"deleteBehavior(key)"
>
</el-button>
</div>
</div>
</el-form-item>
</el-form-item>
</div>
</div>
...
@@ -78,11 +80,13 @@ export default {
...
@@ -78,11 +80,13 @@ export default {
if
(
_event
.
behaviors
&&
_event
.
behaviors
.
length
)
{
if
(
_event
.
behaviors
&&
_event
.
behaviors
.
length
)
{
let
event
=
{};
let
event
=
{};
event
[
key
]
=
{
event
[
key
]
=
{
once
:
v
,
once
:
v
,
behaviors
:
_event
.
behaviors
behaviors
:
_event
.
behaviors
};
};
let
events
=
this
.
activeComponent
.
events
;
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
events
:
event
events
:
_
.
merge
({},
events
,
event
)
});
});
}
}
},
},
...
@@ -90,15 +94,28 @@ export default {
...
@@ -90,15 +94,28 @@ export default {
* 行为发生变化,同步数据
* 行为发生变化,同步数据
*/
*/
handleBehaviorsChange
(
v
)
{
handleBehaviorsChange
(
v
)
{
if
(
this
.
currentEvent
/* && v && v.length*/
)
{
if
(
this
.
currentEvent
/* && v && v.length*/
)
{
let
event
=
{};
let
event
=
{};
let
currentEvent
=
this
.
eventsObj
[
this
.
currentEvent
];
let
currentEvent
=
this
.
eventsObj
[
this
.
currentEvent
];
event
[
this
.
currentEvent
]
=
Object
.
assign
(
currentEvent
/*, { behaviors: v }*/
);
event
[
this
.
currentEvent
]
=
Object
.
assign
(
currentEvent
/*, { behaviors: v }*/
);
let
events
=
this
.
activeComponent
.
events
;
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
events
:
event
events
:
_
.
merge
({},
events
,
event
)
});
});
this
.
updateEventsObj
();
this
.
updateEventsObj
();
}
}
},
/**
* 删除行为
*/
deleteBehavior
(
key
)
{
let
_events
=
this
.
activeComponent
.
events
||
{};
delete
_events
[
key
];
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
events
:
_events
});
this
.
updateEventsObj
();
}
}
},
},
watch
:
{
watch
:
{
...
...
src/views/Editor/Inspector/PropsTab.vue
View file @
afc8d0df
...
@@ -35,6 +35,9 @@
...
@@ -35,6 +35,9 @@
<dynamic-component
:component-value=
"getScriptValue(p, key, index)"
:component-props=
"getScriptProps(p, index)"
:component-type=
"getScriptType(p, index)"
@
onChange=
"v => handleScriptChange(index, key, v)"
></dynamic-component>
<dynamic-component
:component-value=
"getScriptValue(p, key, index)"
:component-props=
"getScriptProps(p, index)"
:component-type=
"getScriptType(p, index)"
@
onChange=
"v => handleScriptChange(index, key, v)"
></dynamic-component>
</el-form-item>
</el-form-item>
</
template
>
</
template
>
<el-form-item
label=
""
>
<el-button
@
click=
"deleteNodeScript(index)"
>
删除
</el-button>
</el-form-item>
</el-collapse-item>
</el-collapse-item>
</template>
</template>
</el-collapse>
</el-collapse>
...
@@ -54,9 +57,6 @@
...
@@ -54,9 +57,6 @@
</el-collapse>
</el-collapse>
</el-form>
</el-form>
</el-scrollbar>
</el-scrollbar>
<!-- <div class="script-config-dialog" v-show="scriptDialog">
<el-tree :data="scripts" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</div> -->
</div>
</div>
</template>
</template>
...
@@ -167,9 +167,9 @@ export default {
...
@@ -167,9 +167,9 @@ export default {
return
getCmpProps
(
this
.
activeComponent
.
type
);
return
getCmpProps
(
this
.
activeComponent
.
type
);
},
},
scripts
:
function
()
{
scripts
:
function
()
{
console
.
log
(
'scripts'
,
this
.
$store
.
state
.
env
.
scripts
);
return
_
.
filter
(
this
.
$store
.
state
.
env
.
scripts
,
s
=>
{
return
s
!==
null
&&
s
!==
undefined
;
return
this
.
$store
.
state
.
env
.
scripts
;
})
;
}
}
},
},
watch
:
{
watch
:
{
...
@@ -243,7 +243,7 @@ export default {
...
@@ -243,7 +243,7 @@ export default {
*/
*/
getPropValue
(
item
,
key
)
{
getPropValue
(
item
,
key
)
{
let
_properties
=
this
.
activeComponentCopy
.
properties
;
let
_properties
=
this
.
activeComponentCopy
.
properties
;
return
(
_properties
[
key
]
===
undefined
||
_properties
[
key
]
===
null
)
?
item
.
value
:
_properties
[
key
];
return
_properties
[
key
]
===
undefined
||
_properties
[
key
]
===
null
?
item
.
value
:
_properties
[
key
];
},
},
getScriptValue
(
item
,
key
,
index
)
{
getScriptValue
(
item
,
key
,
index
)
{
let
_script
=
this
.
activeComponent
.
scripts
[
index
];
let
_script
=
this
.
activeComponent
.
scripts
[
index
];
...
@@ -287,6 +287,19 @@ export default {
...
@@ -287,6 +287,19 @@ export default {
getScriptOptions
(
id
)
{
getScriptOptions
(
id
)
{
let
_script
=
this
.
scripts
.
find
(
script
=>
script
.
id
===
id
);
let
_script
=
this
.
scripts
.
find
(
script
=>
script
.
id
===
id
);
return
_script
?
_script
.
props
:
{};
return
_script
?
_script
.
props
:
{};
},
/**
* 删除节点脚本
*/
deleteNodeScript
(
index
)
{
let
_scripts
=
_
.
cloneDeep
(
this
.
activeComponent
.
scripts
);
_
.
remove
(
_scripts
,
(
s
,
sindex
)
=>
{
return
sindex
===
index
;
});
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
scripts
:
_scripts
});
}
}
}
}
};
};
...
@@ -302,7 +315,7 @@ export default {
...
@@ -302,7 +315,7 @@ export default {
.el-divider__text
{
.el-divider__text
{
background-color
:
#e9e9e9
;
background-color
:
#e9e9e9
;
}
}
.zero-inspector-props-group
{
.zero-inspector-props-group
{
width
:
100%
;
width
:
100%
;
max-height
:
600px
;
max-height
:
600px
;
overflow-x
:
hidden
;
overflow-x
:
hidden
;
...
...
src/views/Editor/Playground.vue
View file @
afc8d0df
<
template
>
<
template
>
<pane
icon=
"el-icon-s-open"
:title=
"$t('panes.Playground')"
>
<pane
icon=
"el-icon-s-open"
class=
"pane-playground"
:title=
"$t('panes.Playground')"
>
<div
class=
"zero-playground-body-center"
>
<div
class=
"zero-playground-body-center"
>
<div
class=
"zero-playground-draw-panel"
>
<div
class=
"zero-playground-draw-panel"
>
<draw-panel></draw-panel>
<draw-panel></draw-panel>
...
...
src/views/Editor/components/drawPanel.vue
View file @
afc8d0df
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
>
>
<wrap
:component-data=
"item"
/>
<wrap
:component-data=
"item"
/>
</div>
</div>
<!--
<views-tree
:views=
"views"
></views-tree>
-->
<template
v-if=
"!!this.activeComponentId"
>
<template
v-if=
"!!this.activeComponentId"
>
<vue-draggable-resizable
<vue-draggable-resizable
:prevent-deactivation=
"true"
:prevent-deactivation=
"true"
...
@@ -33,12 +34,13 @@
...
@@ -33,12 +34,13 @@
<
script
>
<
script
>
import
{
mapState
,
mapGetters
}
from
'vuex'
;
import
{
mapState
,
mapGetters
}
from
'vuex'
;
import
wrap
from
'./wrap'
;
import
wrap
from
'./wrap'
;
import
viewsTree
from
'./viewsTree'
;
import
{
styles
}
from
'../../../utils/common'
;
import
{
styles
}
from
'../../../utils/common'
;
import
properties
from
'../../../utils/properties'
;
import
properties
from
'../../../utils/properties'
;
import
VueDraggableResizable
from
'vue-draggable-resizable'
;
import
VueDraggableResizable
from
'vue-draggable-resizable'
;
export
default
{
export
default
{
components
:
{
wrap
,
VueDraggableResizable
},
components
:
{
wrap
,
VueDraggableResizable
,
viewsTree
},
methods
:
{
methods
:
{
handleDeactivated
()
{
handleDeactivated
()
{
// this.$store.dispatch('changeEditaleStatus', false);
// this.$store.dispatch('changeEditaleStatus', false);
...
@@ -51,8 +53,8 @@ export default {
...
@@ -51,8 +53,8 @@ export default {
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
||
_prop
.
width
!==
w
||
_prop
.
height
!==
h
)
{
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
||
_prop
.
width
!==
w
||
_prop
.
height
!==
h
)
{
this
.
$store
.
dispatch
(
'modifyCopyProperties'
,
{
this
.
$store
.
dispatch
(
'modifyCopyProperties'
,
{
left
:
x
,
x
:
x
,
top
:
y
,
y
:
y
,
width
:
w
,
width
:
w
,
height
:
h
height
:
h
});
});
...
@@ -68,8 +70,8 @@ export default {
...
@@ -68,8 +70,8 @@ export default {
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
)
{
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
)
{
this
.
$store
.
dispatch
(
'modifyCopyProperties'
,
{
this
.
$store
.
dispatch
(
'modifyCopyProperties'
,
{
left
:
x
,
x
:
x
,
top
:
y
y
:
y
});
});
// console.log('handleDragging', x, y);
// console.log('handleDragging', x, y);
}
}
...
@@ -80,10 +82,10 @@ export default {
...
@@ -80,10 +82,10 @@ export default {
}
}
let
_prop
=
this
.
activeComponent
.
properties
;
let
_prop
=
this
.
activeComponent
.
properties
;
if
(
_prop
.
left
!==
x
||
_prop
.
top
!==
y
||
_prop
.
width
!==
w
||
_prop
.
height
!==
h
)
{
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
||
_prop
.
width
!==
w
||
_prop
.
height
!==
h
)
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
left
:
x
,
x
:
x
,
top
:
y
,
y
:
y
,
width
:
w
,
width
:
w
,
height
:
h
height
:
h
});
});
...
@@ -95,17 +97,17 @@ export default {
...
@@ -95,17 +97,17 @@ export default {
}
}
let
_prop
=
this
.
activeComponent
.
properties
;
let
_prop
=
this
.
activeComponent
.
properties
;
if
(
_prop
.
left
!==
x
||
_prop
.
top
!==
y
)
{
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
)
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
left
:
x
,
x
:
x
,
top
:
y
y
:
y
});
});
}
}
}
}
},
},
computed
:
{
computed
:
{
...
mapState
([
'project'
]),
...
mapState
([
'project'
]),
...
mapGetters
([
'activeComponent'
,
'activeComponentCopy'
,
'componentList'
,
'activeComponentId'
]),
...
mapGetters
([
'activeComponent'
,
'activeComponentCopy'
,
'
views'
,
'
componentList'
,
'activeComponentId'
]),
active
()
{
active
()
{
return
!!
this
.
activeComponentId
;
return
!!
this
.
activeComponentId
;
// return this.activeComponentId === (this.activeComponent || {}).uuid;
// return this.activeComponentId === (this.activeComponent || {}).uuid;
...
@@ -118,8 +120,8 @@ export default {
...
@@ -118,8 +120,8 @@ export default {
const
_node
=
properties
.
node
;
const
_node
=
properties
.
node
;
// console.log('********', _props);
// console.log('********', _props);
let
result
=
{
let
result
=
{
x
:
_props
.
left
||
_node
.
left
.
value
,
x
:
_props
.
x
||
_node
.
x
.
value
,
y
:
_props
.
top
||
_node
.
top
.
value
,
y
:
_props
.
y
||
_node
.
y
.
value
,
w
:
_props
.
width
||
_node
.
width
.
value
,
w
:
_props
.
width
||
_node
.
width
.
value
,
h
:
_props
.
height
||
_node
.
height
.
value
h
:
_props
.
height
||
_node
.
height
.
value
};
};
...
...
src/views/Editor/components/viewsTree.vue
0 → 100644
View file @
afc8d0df
<
template
>
<div
class=
"views-tree"
>
<custom-node
v-for=
"view in views"
:key=
"view.uuid"
:custom-style=
"styleObject(view)"
:properties=
"view.properties"
>
<template
v-if=
"view.children"
>
<views-tree
:views=
"view.children"
></views-tree>
</
template
>
</custom-node>
</div>
</template>
<
script
>
import
{
mapState
,
mapGetters
}
from
'vuex'
;
import
{
styles
}
from
'../../../utils/common'
;
import
customNode
from
'../../../components/customElement/node/index.vue'
;
export
default
{
name
:
'viewsTree'
,
props
:
{
views
:
{
type
:
Array
,
default
:
[]
}
},
components
:
{
'custom-node'
:
customNode
},
computed
:
{
...
mapState
([
'project'
]),
...
mapGetters
([
'activeComponentCopy'
,
'componentList'
])
},
methods
:
{
styleObject
(
view
)
{
let
result
=
''
;
if
(
view
.
uuid
===
this
.
activeComponentCopy
.
uuid
)
{
result
=
styles
.
getComponentStyle
(
this
.
activeComponentCopy
,
this
.
project
,
this
.
componentList
);
}
else
{
result
=
styles
.
getComponentStyle
(
view
,
this
.
project
,
this
.
componentList
);
}
return
result
;
}
}
};
</
script
>
<
style
>
</
style
>
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