Skip to content

Commit e0f5359

Browse files
committed
feat(plugin): background music
1 parent 5933eed commit e0f5359

File tree

9 files changed

+155
-588
lines changed

9 files changed

+155
-588
lines changed

back-end/h5-api/extensions/documentation/documentation/1.0.0/full_documentation.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"name": "Apache 2.0",
1515
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
1616
},
17-
"x-generation-date": "12/16/2019 10:29:14 PM"
17+
"x-generation-date": "01/04/2020 12:13:39 AM"
1818
},
1919
"x-strapi-config": {
2020
"path": "/documentation",

front-end/h5/src/components/core/editor/edit-panel/props.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default {
7777
const item = obj.editor
7878
// https://vuejs.org/v2/guide/render-function.html
7979
const data = {
80-
style: { width: '100%' },
80+
// style: { width: '100%' },
8181
props: {
8282
...item.prop || {},
8383
// https://vuejs.org/v2/guide/render-function.html#v-model
@@ -86,7 +86,9 @@ export default {
8686
// 比如表单 input,如果用户手动删除了 placeholder的内容,程序会用defaultPropValue填充,
8787
// 表现在UI上就是:用户永远无法彻底删掉默认值(必须保留至少一个字符)
8888
// value: editingElement.pluginProps[propKey] || item.defaultPropValue
89-
value: editingElement.pluginProps[propKey]
89+
90+
// https://cn.vuejs.org/v2/guide/components-custom-events.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9A%84-v-model
91+
[item.type === 'a-switch' ? 'checked' : 'value']: editingElement.pluginProps[propKey]
9092
},
9193
on: {
9294
// https://vuejs.org/v2/guide/render-function.html#v-model

front-end/h5/src/components/core/editor/modals/preview.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,16 @@ export default {
101101
<a-icon type="down" class="page-controller" onClick={() => { this.postMessage2Iframe('next') }}/>
102102
*/}
103103
</div>
104-
<iframe
105-
id="iframe-for-preview"
106-
src={this.releaseUrl}
107-
frameborder="0"
108-
style="height: 100%;width: 100%;"
109-
></iframe>
104+
{
105+
// 类似 v-if="this.visible" 的目的:关闭预览弹框之后,销毁 iframe,避免继续播放音乐、视频
106+
// similar with v-if="this.visible": destory the iframe after close the preview dialog to avoid playing the music and video
107+
this.visible && <iframe
108+
id="iframe-for-preview"
109+
src={this.releaseUrl}
110+
frameborder="0"
111+
style="height: 100%;width: 100%;"
112+
></iframe>
113+
}
110114
{/** <engine :work="editingWork" :map-config="{}" /> */}
111115
</div>
112116
</div>

front-end/h5/src/components/core/styles/shortcut-btn.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
justify-content: center;
66
height: 60px !important;
77
width: 100%;
8-
margin-bottom: 15px;
8+
margin-bottom: 5px;
99

1010
border: 1px dashed #fff !important;
1111
background-color: #f5f8fb !important;

front-end/h5/src/components/plugins/bg-music.svg

+1
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* @Author: ly525
3+
* @Date: 2020-01-03 23:43:34
4+
* @LastEditors : ly525
5+
* @LastEditTime : 2020-01-04 13:27:58
6+
* @FilePath: /luban-h5/front-end/h5/src/components/plugins/lbp-bg-music.js
7+
* @Github: https://github.com/ly525/luban-h5
8+
* @Description: Do not edit
9+
* @Copyright 2018 - 2019 luban-h5. All Rights Reserved
10+
*/
11+
import './styles/bg-music.scss'
12+
13+
export default {
14+
name: 'lbp-bg-music',
15+
props: {
16+
disabled: {
17+
type: Boolean,
18+
default: true
19+
},
20+
autoplay: {
21+
type: Boolean,
22+
default: true,
23+
editor: {
24+
type: 'a-switch',
25+
label: '自动播放'
26+
}
27+
},
28+
src: {
29+
type: String,
30+
default: 'http://go.163.com/2018/0209/mengniu/audio/bgm.mp3',
31+
editor: {
32+
type: 'a-input',
33+
label: '音乐URL',
34+
prop: {
35+
type: 'textarea'
36+
}
37+
}
38+
}
39+
},
40+
data: () => ({
41+
isPlaying: true
42+
}),
43+
methods: {
44+
toggle () {
45+
let bgAudio = this.$refs.bgAudio
46+
if (!bgAudio) return
47+
48+
this.isPlaying ? bgAudio.pause() : bgAudio.play()
49+
this.isPlaying = !this.isPlaying
50+
}
51+
},
52+
render () {
53+
const btnStyle = {
54+
'animation-play-state': this.isPlaying ? 'running' : 'paused'
55+
}
56+
return (
57+
<div class="bg-music-wrapper" style="display: block;">
58+
<div class="bg-music-btn rotate" style={btnStyle} onClick={this.toggle} disabled={this.disabled}>
59+
<audio src={this.src} autoplay={this.autoplay} preload loop ref='bgAudio'></audio>
60+
</div>
61+
</div>
62+
)
63+
},
64+
created () {
65+
// 在初始化的时候,autoplay 控制是否播放
66+
// 后面是否播放,由用户的点击行为决定
67+
this.isPlaying = this.autoplay
68+
}
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@keyframes rotating {
2+
0% {
3+
transform: rotate(0deg)
4+
}
5+
6+
to {
7+
transform: rotate(1turn)
8+
}
9+
}
10+
11+
@mixin bg-music-icon {
12+
position: absolute;
13+
z-index: 200;
14+
width: 30px;
15+
height: 30px
16+
}
17+
18+
.bg-music-wrapper {
19+
right: 0;
20+
top: 0;
21+
@include bg-music-icon;
22+
23+
.bg-music-btn {
24+
@include bg-music-icon;
25+
26+
right: 0;
27+
top: 0;
28+
border-radius: 15px;
29+
background-image: url(../bg-music.svg);
30+
background-size: contain;
31+
background-repeat: no-repeat;
32+
33+
&.rotate {
34+
animation: rotating 1.2s linear infinite;
35+
}
36+
}
37+
}

front-end/h5/src/mixins/load-plugins.js

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import LbpFormRadioGroup from '../components/plugins/lbp-form-radio-group'
1010
import LbpFormCheckboxGroup from '../components/plugins/lbp-form-checkbox-group'
1111
import LbpBackground from '../components/plugins/lbp-background'
1212
import LbpSlide from '../components/plugins/lbp-slide'
13+
import LbpBgMusic from '../components/plugins/lbp-bg-music'
1314

1415
export const pluginsList = [
1516
{
@@ -134,6 +135,17 @@ export const pluginsList = [
134135
component: LbpBackground,
135136
visible: false,
136137
name: LbpBackground.name
138+
},
139+
{
140+
i18nTitle: {
141+
'en-US': 'BgMusic',
142+
'zh-CN': '背景音乐'
143+
},
144+
title: '背景音乐',
145+
icon: 'music',
146+
component: LbpBgMusic,
147+
visible: true,
148+
name: LbpBgMusic.name
137149
}
138150
]
139151

0 commit comments

Comments
 (0)