lbp-background.js
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import ImageGallery from '@/components/core/support/image-gallery/gallery.js'
export default {
name: 'lbp-background',
render () {
let style = {
width: '100%',
height: '100%'
}
if (this.imgSrc) {
style = {
...style,
'background-size': 'cover',
'background-position': '50% 50%',
'background-origin': 'content-box',
'background-image': `url(${this.imgSrc})`
}
} else {
style = {
...style,
backgroundColor: this.backgroundColor
}
}
return (
<div style="width: 100%; height: 100%; overflow: hidden; position: absolute; z-index: -1; opacity: 1;">
<div style={style}></div>
</div>
)
},
props: {
imgSrc: {
type: String,
default: ''
},
backgroundColor: {
type: String,
// TODO 为什么 transparent 无效?
default: '#ffffff'
}
},
editorConfig: {
propsConfig: {
imgSrc: {
type: 'image-gallery',
// type: 'a-input',
label: '图片url',
prop: {
type: 'textarea'
},
defaultPropValue: ''
},
backgroundColor: {
type: 'a-input', // lbs-color-picker
label: '背景颜色',
prop: {
type: 'color'
},
require: true,
defaultPropValue: '#ffffff' // TODO why logogram for color does't work?
}
},
components: {
'image-gallery': ImageGallery
}
}
}