Commit 1fef888ea47c13c05c1cd0c093f0c4c176869831

Authored by ly525
1 parent 47bd979e

set the background config tab as the active tab if editingElement is null

(zh)进入编辑器后,没有选择组件时,右边属性应该是默认背景的相关属性
front-end/h5/src/components/core/editor/index.js
@@ -111,7 +111,7 @@ export default { @@ -111,7 +111,7 @@ export default {
111 data: () => ({ 111 data: () => ({
112 activeMenuKey: 'pluginList', 112 activeMenuKey: 'pluginList',
113 isPreviewMode: false, 113 isPreviewMode: false,
114 - activeTabKey: '属性', 114 + activeTabKey: 'background',
115 previewVisible: false, 115 previewVisible: false,
116 scaleRate: 1 116 scaleRate: 1
117 }), 117 }),
@@ -155,6 +155,21 @@ export default { @@ -155,6 +155,21 @@ export default {
155 value: { name } 155 value: { name }
156 }) 156 })
157 }, 157 },
  158 + /**
  159 + * #!zh: 设置 背景图tab 作为 active tab
  160 + * #!en: set background(bg) tab as active tab
  161 + */
  162 + setActiveTab (activeTabKey) {
  163 + 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 + }
  172 + },
158 _renderMenuContent () { 173 _renderMenuContent () {
159 return ( 174 return (
160 <a-tabs 175 <a-tabs
@@ -344,17 +359,13 @@ export default { @@ -344,17 +359,13 @@ export default {
344 } 359 }
345 </a-button-group> 360 </a-button-group>
346 </a-layout-sider> 361 </a-layout-sider>
347 - <a-layout-sider width="300" theme='light' style={{ background: '#fff', padding: '0 12px' }}> 362 + <a-layout-sider width="320" theme='light' style={{ background: '#fff', padding: '0 12px' }}>
348 <a-tabs 363 <a-tabs
349 style="height: 100%;" 364 style="height: 100%;"
350 tabBarGutter={10} 365 tabBarGutter={10}
351 - onChange={activeTabKey => {  
352 - this.activeTabKey = activeTabKey  
353 - if (activeTabKey === 'background') {  
354 - const bgElement = this.elements.find(e => e.name === 'lbp-background')  
355 - this.setEditingElement(bgElement)  
356 - }  
357 - }} 366 + defaultActiveKey={this.activeTabKey}
  367 + activeKey={this.activeTabKey}
  368 + onChange={this.setActiveTab}
358 > 369 >
359 {/* 370 {/*
360 #!zh tab 标题: 371 #!zh tab 标题:
@@ -387,7 +398,7 @@ export default { @@ -387,7 +398,7 @@ export default {
387 window.getEditorApp = this 398 window.getEditorApp = this
388 let workId = this.$route.params.workId 399 let workId = this.$route.params.workId
389 if (workId) { 400 if (workId) {
390 - this.fetchWork(workId) 401 + this.fetchWork(workId).then(() => this.setActiveTab('background'))
391 } else { 402 } else {
392 this.$message.error('no work id!') 403 this.$message.error('no work id!')
393 } 404 }
front-end/h5/src/store/modules/work.js
@@ -64,7 +64,7 @@ export const actions = { @@ -64,7 +64,7 @@ export const actions = {
64 }) 64 })
65 }, 65 },
66 fetchWork ({ commit, state }, workId) { 66 fetchWork ({ commit, state }, workId) {
67 - strapi.getEntry('works', workId).then(entry => { 67 + return strapi.getEntry('works', workId).then(entry => {
68 commit('setWork', entry) 68 commit('setWork', entry)
69 commit('setEditingPage') 69 commit('setEditingPage')
70 }) 70 })