Commit d1455039228ba57a0d89e8b053cefe75ef1c83d9

Authored by ly525
1 parent a073fad4

feat(plugin) support modify background image or color

front-end/h5/src/components/core/editor/edit-panel/background.js 0 → 100644
  1 +import propsEditPanel from './props.js'
  2 +
  3 +export default {
  4 + extends: propsEditPanel
  5 +}
... ...
front-end/h5/src/components/core/editor/index.js
... ... @@ -11,6 +11,7 @@ import RenderPropsEditor from './edit-panel/props'
11 11 import RenderScriptEditor from './edit-panel/script'
12 12 import RenderAnimationEditor from './edit-panel/animation'
13 13 import RenderActoionEditor from './edit-panel/action'
  14 +import RenderBackgroundEditor from './edit-panel/background'
14 15 import RenderShortcutsPanel from './shortcuts-panel/index'
15 16 import PreviewDialog from './modals/preview.vue'
16 17  
... ... @@ -297,7 +298,13 @@ export default {
297 298 <a-tabs
298 299 style="height: 100%;"
299 300 tabBarGutter={10}
300   - onChange={activeTabKey => { this.activeTabKey = activeTabKey }}
  301 + onChange={activeTabKey => {
  302 + this.activeTabKey = activeTabKey
  303 + if (activeTabKey === 'background') {
  304 + const bgElement = this.elements.find(e => e.name === 'lbp-background')
  305 + this.setEditingElement(bgElement)
  306 + }
  307 + }}
301 308 >
302 309 {/*
303 310 #!zh tab 标题:
... ... @@ -309,6 +316,7 @@ export default {
309 316 <a-tab-pane label="动画" key='动画' tab={this.$t('editor.editPanel.tab.animation')}><RenderAnimationEditor /></a-tab-pane>
310 317 <a-tab-pane label="动作" key='动作' tab={this.$t('editor.editPanel.tab.action')}>{ this.activeTabKey === '动作' && <RenderActoionEditor/> }</a-tab-pane>
311 318 <a-tab-pane label="脚本" key='脚本' tab={this.$t('editor.editPanel.tab.script')}><RenderScriptEditor/></a-tab-pane>
  319 + <a-tab-pane label="背景" key='background' tab={this.$t('editor.editPanel.tab.background')}><RenderBackgroundEditor/></a-tab-pane>
312 320 </a-tabs>
313 321 </a-layout-sider>
314 322  
... ...
front-end/h5/src/components/core/models/page.js
1 1 import Element from '../models/element'
  2 +import LbpBackground from '../../plugins/lbp-background'
2 3  
3 4 class Page {
4 5 constructor (page = {}) {
5 6 this.uuid = +new Date()
6   - this.elements = page.elements || []
  7 + this.elements = page.elements || [new Element(LbpBackground)]
7 8 }
8 9  
9 10 clone () {
... ...
front-end/h5/src/components/core/models/work.js
  1 +import Page from './page.js'
  2 +
1 3 class Work {
2 4 constructor (work = {}) {
3 5 this.title = work.title || '标题'
4 6 this.description = work.description || '描述'
5   - this.pages = work.pages || [{ elements: [] }]
  7 + this.pages = work.pages || [new Page()]
6 8  
7 9 // this.id = this.id
8 10 // TODO 用id 并不是一个好办法,有心人会得知整个系统中共有多少作品等额外信息,尽量防止信息泄漏
... ...
front-end/h5/src/components/plugins/lbp-background.js
... ... @@ -34,7 +34,8 @@ export default {
34 34 },
35 35 backgroundColor: {
36 36 type: String,
37   - default: 'transparent'
  37 + // TODO 为什么 transparent 无效?
  38 + default: '#ffffff'
38 39 }
39 40 },
40 41 editorConfig: {
... ...