Skip to content

Commit 3e068da

Browse files
committed
fix: do not set editingElement null if change tab(not background)
1 parent 1f3ed8a commit 3e068da

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
1+
/*
2+
* @Author: ly525
3+
* @Date: 2019-12-01 18:11:49
4+
* @LastEditors : ly525
5+
* @LastEditTime : 2019-12-22 18:09:54
6+
* @FilePath: /luban-h5/front-end/h5/src/components/core/editor/edit-panel/background.js
7+
* @Github: https://github.com/ly525/luban-h5
8+
* @Description: Do not edit
9+
* @Copyright 2018 - 2019 luban-h5. All Rights Reserved
10+
*/
111
import propsEditPanel from './props.js'
12+
import { mapState, mapActions } from 'vuex'
213

314
export default {
15+
computed: {
16+
...mapState('editor', [
17+
'editingPage'
18+
])
19+
},
20+
methods: {
21+
...mapActions('editor', [
22+
'setEditingElement'
23+
])
24+
},
425
render () {
526
return <propsEditPanel layout="vertical" />
27+
},
28+
created () {
29+
const bgElement = this.editingPage.elements.find(e => e.name === 'lbp-background')
30+
this.setEditingElement(bgElement)
31+
},
32+
beforeDestroy () {
33+
this.setEditingElement()
634
}
35+
736
}

front-end/h5/src/components/core/editor/index.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default {
111111
data: () => ({
112112
activeMenuKey: 'pluginList',
113113
isPreviewMode: false,
114-
activeTabKey: 'background',
114+
activeTabKey: '属性',
115115
previewVisible: false,
116116
scaleRate: 1
117117
}),
@@ -161,14 +161,6 @@ export default {
161161
*/
162162
setActiveTab (activeTabKey) {
163163
this.activeTabKey = activeTabKey
164-
switch (activeTabKey) {
165-
case 'background':
166-
const bgElement = this.elements.find(e => e.name === 'lbp-background')
167-
this.setEditingElement(bgElement)
168-
break
169-
default:
170-
this.setEditingElement()
171-
}
172164
},
173165
_renderMenuContent () {
174166
return (
@@ -377,7 +369,7 @@ export default {
377369
<a-tab-pane label="动画" key='动画' tab={this.$t('editor.editPanel.tab.animation')}><RenderAnimationEditor /></a-tab-pane>
378370
<a-tab-pane label="动作" key='动作' tab={this.$t('editor.editPanel.tab.action')}>{ this.activeTabKey === '动作' && <RenderActoionEditor/> }</a-tab-pane>
379371
<a-tab-pane label="脚本" key='脚本' tab={this.$t('editor.editPanel.tab.script')}><RenderScriptEditor/></a-tab-pane>
380-
<a-tab-pane label="背景" key='background' tab={this.$t('editor.editPanel.tab.background')}><RenderBackgroundEditor/></a-tab-pane>
372+
<a-tab-pane label="背景" key='background' tab={this.$t('editor.editPanel.tab.background')}>{ this.activeTabKey === 'background' && <RenderBackgroundEditor/> }</a-tab-pane>
381373
</a-tabs>
382374
</a-layout-sider>
383375

0 commit comments

Comments
 (0)