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