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
058d0999
Commit
058d0999
authored
Oct 12, 2019
by
张晨辰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: asset拖拽
parent
d772678d
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
181 additions
and
128 deletions
+181
-128
index.vue
src/components/customElement/image/index.vue
+3
-3
index.vue
src/components/customSettings/slider/index.vue
+1
-9
index.vue
src/components/customSettings/source/index.vue
+10
-5
config.js
src/config.js
+2
-2
project.js
src/store/modules/project.js
+42
-9
index.scss
src/themes/light/index.scss
+1
-0
inspector.scss
src/themes/light/inspector.scss
+14
-0
common.js
src/utils/common.js
+13
-4
FileItem.vue
src/views/Editor/Assets/FileItem.vue
+2
-1
Inspector.vue
src/views/Editor/Inspector.vue
+1
-1
Views.vue
src/views/Editor/Views.vue
+89
-92
wrapper.vue
src/views/Editor/components/wrapper.vue
+3
-2
No files found.
src/components/customElement/image/index.vue
View file @
058d0999
<
template
>
<
template
>
<div
class=
"zero-custom-picture"
:style=
"`background-image:url($
{properties.source}); background-size: contain;`"
>
</div>
<div
class=
"zero-custom-picture"
></div>
</
template
>
</
template
>
<
style
>
<
style
>
.zero-custom-picture
{
/*
.zero-custom-picture {
height: 100%;
height: 100%;
background-position: center;
background-position: center;
}
}
*/
</
style
>
</
style
>
<
script
>
<
script
>
...
...
src/components/customSettings/slider/index.vue
View file @
058d0999
...
@@ -2,15 +2,7 @@
...
@@ -2,15 +2,7 @@
<el-slider
class=
"zero-slider"
v-model=
"swvalue"
:min=
"min"
:max=
"max"
:step=
"step"
show-input
:show-input-controls=
"false"
input-size=
"mini"
></el-slider>
<el-slider
class=
"zero-slider"
v-model=
"swvalue"
:min=
"min"
:max=
"max"
:step=
"step"
show-input
:show-input-controls=
"false"
input-size=
"mini"
></el-slider>
</
template
>
</
template
>
<
style
>
<
style
>
.el-slider.zero-slider
{
width
:
180px
;
}
.zero-slider
.el-slider__runway.show-input
{
width
:
100px
;
}
.zero-slider
>
.el-slider__input
{
width
:
60px
;
}
/* .zero-slider > .el-slider__input > span {
/* .zero-slider > .el-slider__input > span {
display: none;
display: none;
}
}
...
...
src/components/customSettings/source/index.vue
View file @
058d0999
<
template
>
<
template
>
<el-input
disabled
v-model=
"swvalue"
@
drop
.
native=
"drop(event)
"
></el-input>
<el-input
v-model=
"swvalue"
@
drop
.
native=
"drop"
@
dragover
.
native=
"dragOver
"
></el-input>
</
template
>
</
template
>
<
style
>
<
style
>
</
style
>
</
style
>
<
script
>
<
script
>
export
default
{
export
default
{
...
@@ -11,7 +10,7 @@ export default {
...
@@ -11,7 +10,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
swvalue
:
(
this
.
value
||
''
).
split
(
'/'
).
pop
()
swvalue
:
this
.
value
||
''
};
};
},
},
watch
:
{
watch
:
{
...
@@ -21,8 +20,14 @@ export default {
...
@@ -21,8 +20,14 @@ export default {
},
},
methods
:
{
methods
:
{
drop
(
e
)
{
drop
(
e
)
{
console
.
log
(
'native drop'
,
e
);
if
(
this
.
$store
.
state
.
project
.
dragUUID
)
{
// debugger;
console
.
log
(
'native drop'
,
this
.
$store
.
state
);
this
.
swvalue
=
`asset://
${
this
.
$store
.
state
.
project
.
dragUUID
}
`
}
},
dragOver
(
e
)
{
e
.
preventDefault
();
}
}
}
}
};
};
...
...
src/config.js
View file @
058d0999
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
* Created by rockyl on 2019-09-19.
* Created by rockyl on 2019-09-19.
*/
*/
//export const API_HOST = 'http://10.10.93.73
:7777';
export
const
API_HOST
=
'http://10.10.95.74
:7777'
;
export
const
API_HOST
=
'http://localhost:3002'
;
//
export const API_HOST = 'http://localhost:3002';
export
const
UPLOAD_FILE_URL
=
API_HOST
+
'/api/uploadFile'
;
export
const
UPLOAD_FILE_URL
=
API_HOST
+
'/api/uploadFile'
;
export
const
PARSE_BUNDLE_URL
=
API_HOST
+
'/api/parsePSD'
;
export
const
PARSE_BUNDLE_URL
=
API_HOST
+
'/api/parsePSD'
;
...
...
src/store/modules/project.js
View file @
058d0999
...
@@ -23,6 +23,8 @@ export const projectStore = {
...
@@ -23,6 +23,8 @@ export const projectStore = {
},
},
activeComponent
:
{},
activeComponent
:
{},
activeIdList
:
[],
activeIdList
:
[],
activeViews
:
''
,
dragUUID
:
''
,
dirty
:
false
,
dirty
:
false
,
},
},
mutations
:
{
mutations
:
{
...
@@ -54,8 +56,8 @@ export const projectStore = {
...
@@ -54,8 +56,8 @@ export const projectStore = {
* @param {*} id
* @param {*} id
*/
*/
activeComponent
(
state
,
item
)
{
activeComponent
(
state
,
item
)
{
if
(
item
!==
state
.
activeComponent
)
{
// debugger;
// debugger;
if
(
item
!==
state
.
activeComponent
)
{
state
.
activeComponent
=
item
||
state
.
activeComponent
;
state
.
activeComponent
=
item
||
state
.
activeComponent
;
state
.
activeComponent
.
properties
=
state
.
activeComponent
.
properties
||
{};
state
.
activeComponent
.
properties
=
state
.
activeComponent
.
properties
||
{};
console
.
log
(
'mutations activeComponent'
,
state
);
console
.
log
(
'mutations activeComponent'
,
state
);
...
@@ -102,6 +104,14 @@ export const projectStore = {
...
@@ -102,6 +104,14 @@ export const projectStore = {
}
}
console
.
log
(
'modifyComponent'
,
state
.
activeComponent
);
console
.
log
(
'modifyComponent'
,
state
.
activeComponent
);
},
},
/**
* assets拖拽
* @param {*} data
*/
assetDragStart
(
state
,
data
)
{
console
.
log
(
'assetDragStart'
,
data
);
state
.
dragUUID
=
data
.
uuid
;
},
modifyProject
(
state
,
)
{
modifyProject
(
state
,
)
{
},
},
...
@@ -195,10 +205,14 @@ export const projectStore = {
...
@@ -195,10 +205,14 @@ export const projectStore = {
* 当前激活的组件
* 当前激活的组件
*/
*/
activeComponent
:
state
=>
{
activeComponent
:
state
=>
{
let
_cmp
=
state
.
activeComponent
||
{}
// if (state.activeComponent) {
console
.
log
(
'activeComponent'
,
_cmp
);
// let _cmp = state.activeComponent || {}
// console.log('activeComponent', _cmp);
return
{
...
_cmp
,
uuid
:
_cmp
.
uuid
||
generateUUID
()
}
// return { ..._cmp, uuid: _cmp.uuid || generateUUID() }
// } else {
// return {};
// }
return
state
.
activeComponent
;
},
},
/**
/**
* 当前激活的组件ID
* 当前激活的组件ID
...
@@ -210,12 +224,18 @@ export const projectStore = {
...
@@ -210,12 +224,18 @@ export const projectStore = {
* 扁平化所有节点
* 扁平化所有节点
*/
*/
componentList
:
state
=>
{
componentList
:
state
=>
{
// debugger;
const
flatten
=
arr
=>
{
const
flatten
=
arr
=>
{
return
arr
.
reduce
((
flat
,
toFlat
)
=>
{
return
arr
.
reduce
((
flat
,
toFlat
)
=>
{
return
flat
.
concat
(
toFlat
.
children
?
flatten
(
toFlat
.
children
).
concat
([
toFlat
])
:
[
toFlat
]);
return
flat
.
concat
(
toFlat
.
children
?
flatten
(
toFlat
.
children
).
concat
([
toFlat
])
:
[
toFlat
]);
},
[]);
},
[]);
};
};
let
result
=
flatten
(
state
.
data
.
views
);
let
_view
=
state
.
data
.
views
.
length
?
[].
concat
(
state
.
data
.
views
[
0
])
:
[];
if
(
state
.
activeViews
)
{
_view
=
state
.
data
.
views
.
filter
(
v
=>
v
.
uuid
===
state
.
activeViews
)
}
// debugger;
let
result
=
flatten
(
_view
);
// let result = state.data.views.flatMap(v => [v, v.children || []])
// let result = state.data.views.flatMap(v => [v, v.children || []])
console
.
log
(
'componentList'
,
result
);
console
.
log
(
'componentList'
,
result
);
return
result
;
return
result
;
...
@@ -263,13 +283,26 @@ export const projectStore = {
...
@@ -263,13 +283,26 @@ export const projectStore = {
},
},
/**
/**
* 选中节点
* 选中节点
* @param {*} param
0
* @param {*} param
* @param {*} data
* @param {*} data
*/
*/
activeComponent
({
commit
},
data
)
{
activeComponent
({
commit
,
state
},
data
)
{
console
.
log
(
'actions activeComponent'
,
data
);
console
.
log
(
'actions activeComponent'
,
data
);
commit
(
'activeComponent'
,
data
);
let
getTopView
=
node
=>
{
if
(
node
.
parent
&&
!
node
.
parent
.
parent
)
{
return
node
;
}
else
{
return
getTopView
(
node
.
parent
);
}
}
let
_view
=
getTopView
(
data
.
node
);
if
(
_view
&&
_view
.
data
)
{
state
.
activeViews
=
_view
.
data
.
uuid
;
}
commit
(
'activeComponent'
,
data
.
data
);
},
},
/**
/**
* 修改属性
* 修改属性
...
...
src/themes/light/index.scss
View file @
058d0999
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
@import
"./home.scss"
;
@import
"./home.scss"
;
@import
"./editor.scss"
;
@import
"./editor.scss"
;
@import
"./playground.scss"
;
@import
"./playground.scss"
;
@import
"./inspector.scss"
;
@import
"~element-ui/packages/theme-chalk/src/index.scss"
;
@import
"~element-ui/packages/theme-chalk/src/index.scss"
;
...
...
src/themes/light/inspector.scss
0 → 100644
View file @
058d0999
.zero-inspector-form
{
.el-input-number.el-input-number--mini
,
.el-select.el-select--mini
{
width
:
100%
;
}
.el-slider.zero-slider
{
width
:
180px
;
}
.zero-slider
.el-slider__runway.show-input
{
width
:
100px
;
}
.zero-slider
>
.el-slider__input
{
width
:
60px
;
}
}
\ No newline at end of file
src/utils/common.js
View file @
058d0999
...
@@ -49,6 +49,10 @@ const attrUnitMapper = {
...
@@ -49,6 +49,10 @@ const attrUnitMapper = {
minHeight
:
'px'
minHeight
:
'px'
};
};
// function getAssetByUUID(asset, uuid){
// return
// }
export
const
styles
=
{
export
const
styles
=
{
getStyles
(
value
,
key
)
{
getStyles
(
value
,
key
)
{
const
attr
=
attrShortMapper
[
key
]
||
changeCamle
(
key
);
const
attr
=
attrShortMapper
[
key
]
||
changeCamle
(
key
);
...
@@ -75,10 +79,15 @@ export const styles = {
...
@@ -75,10 +79,15 @@ export const styles = {
* 根据Object类型的属性对象,生成dom中style属性可用的数据格式
* 根据Object类型的属性对象,生成dom中style属性可用的数据格式
* @param {*} obj
* @param {*} obj
*/
*/
getStylesFromObj
(
obj
)
{
getStylesFromObj
(
obj
,
project
)
{
let
resultObj
=
{};
let
resultObj
=
{};
_
.
forIn
(
obj
,
(
value
,
key
)
=>
{
_
.
forIn
(
obj
,
(
value
,
key
)
=>
{
if
(
key
===
'source'
&&
value
.
indexOf
(
'asset://'
)
===
0
)
{
let
uuid
=
value
.
split
(
'//'
)[
1
];
let
asset
=
project
.
data
.
assets
.
find
(
a
=>
a
.
uuid
===
uuid
);
value
=
asset
?
asset
.
url
:
''
;
}
let
_style
=
styles
.
getStyles
(
value
,
key
);
let
_style
=
styles
.
getStyles
(
value
,
key
);
if
(
!
_style
)
{
if
(
!
_style
)
{
return
;
return
;
...
@@ -96,7 +105,7 @@ export const styles = {
...
@@ -96,7 +105,7 @@ export const styles = {
* 根据组件数据,生成完整的style
* 根据组件数据,生成完整的style
* @param {*} component
* @param {*} component
*/
*/
getComponentStyle
(
component
)
{
getComponentStyle
(
component
,
project
)
{
let
result
=
''
;
let
result
=
''
;
// 根据组件类型,获取默认属性
// 根据组件类型,获取默认属性
...
@@ -104,8 +113,8 @@ export const styles = {
...
@@ -104,8 +113,8 @@ export const styles = {
defaultProps
=
_
.
omit
(
defaultProps
,
_
.
keys
(
component
.
properties
));
defaultProps
=
_
.
omit
(
defaultProps
,
_
.
keys
(
component
.
properties
));
defaultProps
=
_
.
mapValues
(
defaultProps
,
o
=>
(
o
.
value
));
defaultProps
=
_
.
mapValues
(
defaultProps
,
o
=>
(
o
.
value
));
let
_cmpProps
=
styles
.
getStylesFromObj
(
component
.
properties
);
let
_cmpProps
=
styles
.
getStylesFromObj
(
component
.
properties
,
project
);
let
_defaultProps
=
styles
.
getStylesFromObj
(
defaultProps
);
let
_defaultProps
=
styles
.
getStylesFromObj
(
defaultProps
,
project
);
_
.
forIn
({
_
.
forIn
({
...
_defaultProps
,
...
_defaultProps
,
...
...
src/views/Editor/Assets/FileItem.vue
View file @
058d0999
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"file-item"
>
<div
class=
"file-item"
>
<div
class=
"icon"
>
<div
class=
"icon"
>
<i
v-if=
"!showThumbnail"
draggable=
"true"
class=
"file-icon"
:class=
"fileIcon"
></i>
<i
v-if=
"!showThumbnail"
draggable=
"true"
class=
"file-icon"
:class=
"fileIcon"
></i>
<img
v-if=
"showThumbnail"
draggable=
"true"
class=
"thumbnail"
:src=
"thumbnailUrl"
alt=
"thumb"
@
dblclick=
"onDbclick()"
>
<img
@
dragstart=
"assetDragStart(data)"
v-if=
"showThumbnail"
draggable=
"true"
class=
"thumbnail"
:src=
"thumbnailUrl"
alt=
"thumb"
@
dblclick=
"onDbclick()"
>
<div
class=
"operate-bar"
>
<div
class=
"operate-bar"
>
<el-button
circle
size=
"mini"
type=
"success"
icon=
"el-icon-edit"
@
dblclick
.
native
.
stop
@
click=
"onClickEdit"
/>
<el-button
circle
size=
"mini"
type=
"success"
icon=
"el-icon-edit"
@
dblclick
.
native
.
stop
@
click=
"onClickEdit"
/>
<el-button
circle
size=
"mini"
type=
"danger"
icon=
"el-icon-delete"
@
dblclick
.
native
.
stop
<el-button
circle
size=
"mini"
type=
"danger"
icon=
"el-icon-delete"
@
dblclick
.
native
.
stop
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
...
mapMutations
([
...
mapMutations
([
'deleteAsset'
,
'deleteAsset'
,
'modifyAsset'
,
'modifyAsset'
,
'assetDragStart'
]),
]),
}
}
}
}
...
...
src/views/Editor/Inspector.vue
View file @
058d0999
<
template
>
<
template
>
<pane
icon=
"el-icon-s-operation"
:title=
"$t('panes.Inspector')"
>
<pane
icon=
"el-icon-s-operation"
:title=
"$t('panes.Inspector')"
>
<div
class=
"zero-inspector-form"
>
<div
class=
"zero-inspector-form"
>
<el-form
ref=
"form"
size=
"mini"
v-if=
"activeComponent.
name
"
:model=
"form"
label-width=
"80px"
>
<el-form
ref=
"form"
size=
"mini"
v-if=
"activeComponent.
uuid
"
:model=
"form"
label-width=
"80px"
>
<el-divider
content-position=
"left"
>
配置
</el-divider>
<el-divider
content-position=
"left"
>
配置
</el-divider>
<el-form-item
label=
"名称"
>
<el-form-item
label=
"名称"
>
<el-input
v-model=
"form.name"
@
input=
"v => handleChange('name', v)"
></el-input>
<el-input
v-model=
"form.name"
@
input=
"v => handleChange('name', v)"
></el-input>
...
...
src/views/Editor/Views.vue
View file @
058d0999
...
@@ -54,13 +54,13 @@
...
@@ -54,13 +54,13 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
mapState
,
mapMutations
,
mapActions
}
from
'vuex'
;
import
{
mapState
,
mapMutations
,
mapActions
}
from
'vuex'
;
import
Pane
from
'../../components/Pane'
;
import
Pane
from
'../../components/Pane'
;
import
{
PARSE_BUNDLE_URL
}
from
"../../config"
;
import
{
PARSE_BUNDLE_URL
}
from
'../../config'
;
export
default
{
export
default
{
name
:
'Views'
,
name
:
'Views'
,
components
:
{
Pane
},
components
:
{
Pane
},
data
()
{
data
()
{
return
{
return
{
defaultProps
:
{
defaultProps
:
{
...
@@ -84,8 +84,8 @@
...
@@ -84,8 +84,8 @@
/**
/**
* 点击左侧视图列表
* 点击左侧视图列表
*/
*/
handleNodeClick
(
data
)
{
handleNodeClick
(
data
,
node
)
{
this
.
$store
.
commit
(
'activeComponent'
,
data
);
this
.
$store
.
dispatch
(
'activeComponent'
,
{
data
,
node
}
);
},
},
toAddView
()
{
toAddView
()
{
this
.
$prompt
(
this
.
$t
(
'Input view name'
),
this
.
$t
(
'Alert'
),
{
this
.
$prompt
(
this
.
$t
(
'Input view name'
),
this
.
$t
(
'Alert'
),
{
...
@@ -94,19 +94,16 @@
...
@@ -94,19 +94,16 @@
inputPattern
:
/^.
{1,64}
$/
,
inputPattern
:
/^.
{1,64}
$/
,
inputErrorMessage
:
this
.
$t
(
'Invalid view name'
)
inputErrorMessage
:
this
.
$t
(
'Invalid view name'
)
})
})
.
then
(({
value
})
=>
{
.
then
(({
value
})
=>
{
this
.
addNode
({
this
.
addNode
({
name
:
value
,
name
:
value
,
type
:
'node'
type
:
'node'
});
});
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{});
});
},
toImportView
()
{
},
selectNode
(
data
,
node
,
target
)
{
},
},
toImportView
()
{},
selectNode
(
data
,
node
,
target
)
{},
onMoreMenu
(
command
,
data
,
node
)
{
onMoreMenu
(
command
,
data
,
node
)
{
switch
(
command
)
{
switch
(
command
)
{
case
'delete'
:
case
'delete'
:
...
@@ -133,7 +130,7 @@
...
@@ -133,7 +130,7 @@
uploadFileSuccess
(
response
,
file
)
{
uploadFileSuccess
(
response
,
file
)
{
if
(
response
.
success
)
{
if
(
response
.
success
)
{
console
.
log
(
'upload success'
,
response
);
console
.
log
(
'upload success'
,
response
);
const
{
view
,
assets
}
=
response
.
data
;
const
{
view
,
assets
}
=
response
.
data
;
this
.
importView
(
view
);
this
.
importView
(
view
);
this
.
importAssets
(
assets
);
this
.
importAssets
(
assets
);
...
@@ -142,12 +139,12 @@
...
@@ -142,12 +139,12 @@
}
}
},
},
uploadFileError
()
{
uploadFileError
()
{
console
.
log
(
'upload error'
)
console
.
log
(
'upload error'
);
},
},
...
mapMutations
([
'importView'
,
'importAssets'
,
'deleteNode'
,
'addNode'
]),
...
mapMutations
([
'importView'
,
'importAssets'
,
'deleteNode'
,
'addNode'
]),
...
mapActions
([
'exportView'
]),
...
mapActions
([
'exportView'
])
}
}
};
};
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
...
...
src/views/Editor/components/wrapper.vue
View file @
058d0999
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
mapGetters
}
from
'vuex'
;
import
{
map
State
,
map
Getters
}
from
'vuex'
;
import
{
getComposedComponents
}
from
'../../../utils/getComposedComponents'
;
import
{
getComposedComponents
}
from
'../../../utils/getComposedComponents'
;
import
{
styles
}
from
'../../../utils/common'
;
import
{
styles
}
from
'../../../utils/common'
;
import
properties
from
'../../../utils/properties'
;
import
properties
from
'../../../utils/properties'
;
...
@@ -139,6 +139,7 @@ export default {
...
@@ -139,6 +139,7 @@ export default {
}
}
},
},
computed
:
{
computed
:
{
...
mapState
([
'project'
]),
...
mapGetters
([
'activeComponentId'
]),
...
mapGetters
([
'activeComponentId'
]),
active
()
{
active
()
{
return
this
.
activeComponentId
===
(
this
.
componentData
||
{}).
uuid
;
return
this
.
activeComponentId
===
(
this
.
componentData
||
{}).
uuid
;
...
@@ -153,7 +154,7 @@ export default {
...
@@ -153,7 +154,7 @@ export default {
styleObject
()
{
styleObject
()
{
console
.
log
(
'wrapper styleObject'
);
console
.
log
(
'wrapper styleObject'
);
return
styles
.
getComponentStyle
(
this
.
componentData
);
return
styles
.
getComponentStyle
(
this
.
componentData
,
this
.
project
);
},
},
position
()
{
position
()
{
const
componentData
=
this
.
componentData
;
const
componentData
=
this
.
componentData
;
...
...
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