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
ef45b774
Commit
ef45b774
authored
Nov 14, 2019
by
张晨辰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed: scripts.options -> scripts.props
parent
07ecf566
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
60 deletions
+80
-60
project.js
src/store/modules/project.js
+3
-1
common.js
src/utils/common.js
+22
-12
properties.js
src/utils/properties.js
+30
-27
PropsTab.vue
src/views/Editor/Inspector/PropsTab.vue
+13
-8
drawPanel.vue
src/views/Editor/components/drawPanel.vue
+12
-12
No files found.
src/store/modules/project.js
View file @
ef45b774
...
@@ -126,6 +126,7 @@ export const projectStore = {
...
@@ -126,6 +126,7 @@ export const projectStore = {
state
.
operateStack
.
pop
();
state
.
operateStack
.
pop
();
}
}
// 将数据更新至当前选中的节点上
_
.
forIn
(
view
,
(
value
,
key
)
=>
{
_
.
forIn
(
view
,
(
value
,
key
)
=>
{
Vue
.
set
(
state
.
activeComponent
,
key
,
_view
[
key
]);
Vue
.
set
(
state
.
activeComponent
,
key
,
_view
[
key
]);
})
})
...
@@ -143,6 +144,7 @@ export const projectStore = {
...
@@ -143,6 +144,7 @@ export const projectStore = {
Vue
.
set
(
state
.
activeComponent
,
'properties'
,
_properties
);
Vue
.
set
(
state
.
activeComponent
,
'properties'
,
_properties
);
}
}
// 同步修改镜像节点
state
.
activeComponentCopy
=
_
.
cloneDeep
(
state
.
activeComponent
);
state
.
activeComponentCopy
=
_
.
cloneDeep
(
state
.
activeComponent
);
},
},
/**
/**
...
@@ -434,7 +436,7 @@ export const projectStore = {
...
@@ -434,7 +436,7 @@ export const projectStore = {
let
_scripts
=
_
.
cloneDeep
(
state
.
activeComponent
.
scripts
||
[]);
let
_scripts
=
_
.
cloneDeep
(
state
.
activeComponent
.
scripts
||
[]);
_scripts
.
push
({
_scripts
.
push
({
script
:
script
,
script
:
script
,
option
s
:
{}
prop
s
:
{}
});
});
commit
(
'modifyActiveView'
,
{
commit
(
'modifyActiveView'
,
{
scripts
:
_scripts
scripts
:
_scripts
...
...
src/utils/common.js
View file @
ef45b774
...
@@ -26,8 +26,8 @@ export const componentsMap = [
...
@@ -26,8 +26,8 @@ export const componentsMap = [
// 属性的计算方法
// 属性的计算方法
const
propsComputeRules
=
{
const
propsComputeRules
=
{
x
:
'add'
,
left
:
'add'
,
y
:
'add'
,
top
:
'add'
,
rotation
:
'add'
,
rotation
:
'add'
,
scaleX
:
'multi'
,
scaleX
:
'multi'
,
scaleY
:
'multi'
,
scaleY
:
'multi'
,
...
@@ -47,8 +47,8 @@ function invalidAttr(key, value) {
...
@@ -47,8 +47,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,12 +60,14 @@ const attrShortMapper = {
...
@@ -60,12 +60,14 @@ const attrShortMapper = {
// 编辑时想拖拽组件需要生成的css属性
// 编辑时想拖拽组件需要生成的css属性
// 只需要位置,不需要来源透明度等等
// 只需要位置,不需要来源透明度等等
const
operatProps
=
[
'
x'
,
'y'
,
'left'
,
'top
'
,
'width'
,
'height'
,
'rotation'
];
const
operatProps
=
[
'
left'
,
'top'
,
'right'
,
'bottom
'
,
'width'
,
'height'
,
'rotation'
];
// 属性单位 对照表, 如果是数值的时候需要添加单位
// 属性单位 对照表, 如果是数值的时候需要添加单位
const
attrUnitMapper
=
{
const
attrUnitMapper
=
{
x
:
'px'
,
left
:
'px'
,
y
:
'px'
,
top
:
'px'
,
right
:
'px'
,
bottom
:
'px'
,
width
:
'px'
,
width
:
'px'
,
height
:
'px'
,
height
:
'px'
,
fontSize
:
'px'
,
fontSize
:
'px'
,
...
@@ -136,18 +138,22 @@ export const flattenViews = function (views) {
...
@@ -136,18 +138,22 @@ export const flattenViews = function (views) {
*/
*/
function
inheritProps
(
props
,
parent
)
{
function
inheritProps
(
props
,
parent
)
{
_
.
forIn
(
parent
,
(
value
,
key
)
=>
{
_
.
forIn
(
parent
,
(
value
,
key
)
=>
{
let
_pValue
=
parent
[
key
];
if
(
_pValue
===
null
||
_pValue
===
undefined
)
{
return
;
}
let
rule
=
propsComputeRules
[
key
];
let
rule
=
propsComputeRules
[
key
];
// 加法
// 加法
if
(
rule
===
'add'
)
{
if
(
rule
===
'add'
)
{
props
[
key
]
+=
parent
[
key
]
;
props
[
key
]
+=
_pValue
;
}
}
// 乘法
// 乘法
if
(
rule
===
'multi'
)
{
if
(
rule
===
'multi'
)
{
props
[
key
]
*=
parent
[
key
]
;
props
[
key
]
*=
_pValue
;
}
}
// 可见,特殊处理
// 可见,特殊处理
if
(
rule
===
'visible'
)
{
if
(
rule
===
'visible'
)
{
props
[
key
]
=
!
props
[
key
]
||
!
parent
[
key
]
?
false
:
true
;
props
[
key
]
=
!
props
[
key
]
||
!
_pValue
?
false
:
true
;
}
}
});
});
}
}
...
@@ -175,10 +181,14 @@ function completeSelfProps(component) {
...
@@ -175,10 +181,14 @@ function completeSelfProps(component) {
export
const
styles
=
{
export
const
styles
=
{
getStyles
(
value
,
key
)
{
getStyles
(
value
,
key
)
{
const
attr
=
attrShortMapper
[
key
]
||
changeCamle
(
key
);
const
attr
=
attrShortMapper
[
key
]
||
changeCamle
(
key
);
cons
t
unit
=
attrUnitMapper
[
key
]
||
''
;
le
t
unit
=
attrUnitMapper
[
key
]
||
''
;
if
(
invalidAttr
(
key
,
value
))
return
''
;
if
(
invalidAttr
(
key
,
value
))
return
''
;
// if ((key === 'width' || key === 'height') && (value + '').indexOf('%') > -1) {
// unit = '';
// }
switch
(
attr
)
{
switch
(
attr
)
{
case
'rotation'
:
case
'rotation'
:
return
[
'transform'
,
[
`rotate(
${
value
}
deg)`
]];
//`transform: rotate(${value}deg);`;
return
[
'transform'
,
[
`rotate(
${
value
}
deg)`
]];
//`transform: rotate(${value}deg);`;
...
@@ -267,7 +277,7 @@ export const styles = {
...
@@ -267,7 +277,7 @@ export const styles = {
});
});
result
+=
`background-position: center;background-size: 100% 100%;`
result
+=
`background-position: center;background-size: 100% 100%;`
// console.log('getComponentStyle', result);
// console.log('getComponentStyle',
component.name,
result);
return
result
;
return
result
;
}
}
}
}
...
...
src/utils/properties.js
View file @
ef45b774
...
@@ -3,15 +3,25 @@
...
@@ -3,15 +3,25 @@
export
default
{
export
default
{
node
:
{
node
:
{
groupName
:
'基础'
,
groupName
:
'基础'
,
x
:
{
left
:
{
title
:
'
X坐标
'
,
title
:
'
左边距
'
,
type
:
'inputNumber'
,
type
:
'inputNumber'
,
value
:
0
value
:
undefined
,
},
top
:
{
title
:
'上边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
},
y
:
{
right
:
{
title
:
'
Y坐标
'
,
title
:
'
右边距
'
,
type
:
'inputNumber'
,
type
:
'inputNumber'
,
value
:
0
value
:
undefined
,
},
bottom
:
{
title
:
'下边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
},
width
:
{
width
:
{
title
:
'宽度'
,
title
:
'宽度'
,
...
@@ -23,6 +33,18 @@ export default {
...
@@ -23,6 +33,18 @@ export default {
type
:
'inputNumber'
,
type
:
'inputNumber'
,
value
:
1
value
:
1
},
},
horizonCenter
:
{
title
:
'水平偏移'
,
type
:
'inputNumber'
,
value
:
undefined
,
desc
:
'相对于父元素中心点的水平偏移,0为正中心'
},
verticalCenter
:
{
title
:
'垂直偏移'
,
type
:
'inputNumber'
,
value
:
undefined
,
desc
:
'相对于父元素中心点的垂直偏移,0为正中心'
},
rotation
:
{
rotation
:
{
title
:
'旋转'
,
title
:
'旋转'
,
type
:
'inputNumber'
,
type
:
'inputNumber'
,
...
@@ -66,27 +88,8 @@ export default {
...
@@ -66,27 +88,8 @@ export default {
width
:
40
width
:
40
},
},
value
:
true
value
:
true
},
}
left
:
{
title
:
'左边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
top
:
{
title
:
'上边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
right
:
{
title
:
'右边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
bottom
:
{
title
:
'下边距'
,
type
:
'inputNumber'
,
value
:
undefined
,
},
},
},
label
:
{
label
:
{
groupName
:
'文本'
,
groupName
:
'文本'
,
...
...
src/views/Editor/Inspector/PropsTab.vue
View file @
ef45b774
...
@@ -15,7 +15,12 @@
...
@@ -15,7 +15,12 @@
<template
v-for=
"(p, key) in cmpProps"
>
<template
v-for=
"(p, key) in cmpProps"
>
<el-form-item
v-if=
"key !== 'groupName'"
:id=
"activeComponent.uuid + '-' + key"
:key=
"activeComponent.uuid + key"
:label=
"p.title"
>
<el-form-item
v-if=
"key !== 'groupName'"
:id=
"activeComponent.uuid + '-' + key"
:key=
"activeComponent.uuid + key"
:label=
"p.title"
>
<!--
{{
key
}}
-->
<!--
{{
key
}}
-->
<el-tooltip
:disabled=
"!p.desc"
placement=
"top-start"
>
<div
slot=
"content"
>
{{
p
.
desc
}}
</div>
<div>
<dynamic-component
:component-value=
"getPropValue(p, key)"
:component-props=
"getPropProps(p)"
:component-type=
"getPropCmpType(p)"
@
onChange=
"v => handlePropertiesChange(key, v)"
></dynamic-component>
<dynamic-component
:component-value=
"getPropValue(p, key)"
:component-props=
"getPropProps(p)"
:component-type=
"getPropCmpType(p)"
@
onChange=
"v => handlePropertiesChange(key, v)"
></dynamic-component>
</div>
</el-tooltip>
</el-form-item>
</el-form-item>
</
template
>
</
template
>
</el-collapse-item>
</el-collapse-item>
...
@@ -160,6 +165,8 @@ export default {
...
@@ -160,6 +165,8 @@ 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
this
.
$store
.
state
.
env
.
scripts
;
return
this
.
$store
.
state
.
env
.
scripts
;
}
}
},
},
...
@@ -201,11 +208,11 @@ export default {
...
@@ -201,11 +208,11 @@ export default {
* 事件属性发生改变
* 事件属性发生改变
*/
*/
handleScriptChange
(
index
,
key
,
v
)
{
handleScriptChange
(
index
,
key
,
v
)
{
let
_
option
s
=
{};
let
_
prop
s
=
{};
_
option
s
[
key
]
=
v
;
_
prop
s
[
key
]
=
v
;
let
_scripts
=
_
.
cloneDeep
(
this
.
activeComponent
.
scripts
);
let
_scripts
=
_
.
cloneDeep
(
this
.
activeComponent
.
scripts
);
let
_script
=
_scripts
[
index
];
let
_script
=
_scripts
[
index
];
_script
.
options
=
_
.
assign
(
_script
.
options
,
_option
s
);
_script
.
props
=
_
.
assign
(
_script
.
props
,
_prop
s
);
_scripts
[
index
]
=
_script
;
_scripts
[
index
]
=
_script
;
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
this
.
$store
.
dispatch
(
'modifyActiveView'
,
{
scripts
:
_scripts
scripts
:
_scripts
...
@@ -239,7 +246,7 @@ export default {
...
@@ -239,7 +246,7 @@ export default {
getScriptValue
(
item
,
key
,
index
)
{
getScriptValue
(
item
,
key
,
index
)
{
let
_script
=
this
.
activeComponent
.
scripts
[
index
];
let
_script
=
this
.
activeComponent
.
scripts
[
index
];
// let result =
// let result =
return
_script
.
option
s
[
key
]
||
item
.
default
;
return
_script
.
prop
s
[
key
]
||
item
.
default
;
},
},
getScriptProps
(
item
,
index
)
{
getScriptProps
(
item
,
index
)
{
let
_type
=
item
.
type
;
let
_type
=
item
.
type
;
...
@@ -272,14 +279,12 @@ export default {
...
@@ -272,14 +279,12 @@ export default {
return
scriptTypeMap
[
_type
].
component
;
return
scriptTypeMap
[
_type
].
component
;
},
},
getScriptName
(
id
)
{
getScriptName
(
id
)
{
console
.
log
(
'getScriptName'
,
id
);
let
_script
=
this
.
scripts
.
find
(
script
=>
script
.
id
===
id
);
let
_script
=
this
.
scripts
.
find
(
script
=>
script
.
id
===
id
);
return
_script
?
_script
.
name
:
''
;
return
_script
?
_script
.
name
:
''
;
},
},
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
.
option
s
:
{};
return
_script
?
_script
.
prop
s
:
{};
}
}
}
}
};
};
...
...
src/views/Editor/components/drawPanel.vue
View file @
ef45b774
...
@@ -51,8 +51,8 @@ export default {
...
@@ -51,8 +51,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'
,
{
x
:
x
,
left
:
x
,
y
:
y
,
top
:
y
,
width
:
w
,
width
:
w
,
height
:
h
height
:
h
});
});
...
@@ -68,8 +68,8 @@ export default {
...
@@ -68,8 +68,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'
,
{
x
:
x
,
left
:
x
,
y
:
y
top
:
y
});
});
// console.log('handleDragging', x, y);
// console.log('handleDragging', x, y);
}
}
...
@@ -80,10 +80,10 @@ export default {
...
@@ -80,10 +80,10 @@ export default {
}
}
let
_prop
=
this
.
activeComponent
.
properties
;
let
_prop
=
this
.
activeComponent
.
properties
;
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
||
_prop
.
width
!==
w
||
_prop
.
height
!==
h
)
{
if
(
_prop
.
left
!==
x
||
_prop
.
top
!==
y
||
_prop
.
width
!==
w
||
_prop
.
height
!==
h
)
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
x
:
x
,
left
:
x
,
y
:
y
,
top
:
y
,
width
:
w
,
width
:
w
,
height
:
h
height
:
h
});
});
...
@@ -95,10 +95,10 @@ export default {
...
@@ -95,10 +95,10 @@ export default {
}
}
let
_prop
=
this
.
activeComponent
.
properties
;
let
_prop
=
this
.
activeComponent
.
properties
;
if
(
_prop
.
x
!==
x
||
_prop
.
y
!==
y
)
{
if
(
_prop
.
left
!==
x
||
_prop
.
top
!==
y
)
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
this
.
$store
.
dispatch
(
'modifyProperties'
,
{
x
:
x
,
left
:
x
,
y
:
y
top
:
y
});
});
}
}
}
}
...
@@ -118,8 +118,8 @@ export default {
...
@@ -118,8 +118,8 @@ export default {
const
_node
=
properties
.
node
;
const
_node
=
properties
.
node
;
// console.log('********', _props);
// console.log('********', _props);
let
result
=
{
let
result
=
{
x
:
_props
.
x
||
_node
.
x
.
value
,
x
:
_props
.
left
||
_node
.
left
.
value
,
y
:
_props
.
y
||
_node
.
y
.
value
,
y
:
_props
.
top
||
_node
.
top
.
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
};
};
...
...
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