Commit 1fef888ea47c13c05c1cd0c093f0c4c176869831
1 parent
47bd979e
set the background config tab as the active tab if editingElement is null
(zh)进入编辑器后,没有选择组件时,右边属性应该是默认背景的相关属性
Showing
2 changed files
with
22 additions
and
11 deletions
front-end/h5/src/components/core/editor/index.js
| ... | ... | @@ -111,7 +111,7 @@ export default { |
| 111 | 111 | data: () => ({ |
| 112 | 112 | activeMenuKey: 'pluginList', |
| 113 | 113 | isPreviewMode: false, |
| 114 | - activeTabKey: '属性', | |
| 114 | + activeTabKey: 'background', | |
| 115 | 115 | previewVisible: false, |
| 116 | 116 | scaleRate: 1 |
| 117 | 117 | }), |
| ... | ... | @@ -155,6 +155,21 @@ export default { |
| 155 | 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 | 173 | _renderMenuContent () { |
| 159 | 174 | return ( |
| 160 | 175 | <a-tabs |
| ... | ... | @@ -344,17 +359,13 @@ export default { |
| 344 | 359 | } |
| 345 | 360 | </a-button-group> |
| 346 | 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 | 363 | <a-tabs |
| 349 | 364 | style="height: 100%;" |
| 350 | 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 | 371 | #!zh tab 标题: |
| ... | ... | @@ -387,7 +398,7 @@ export default { |
| 387 | 398 | window.getEditorApp = this |
| 388 | 399 | let workId = this.$route.params.workId |
| 389 | 400 | if (workId) { |
| 390 | - this.fetchWork(workId) | |
| 401 | + this.fetchWork(workId).then(() => this.setActiveTab('background')) | |
| 391 | 402 | } else { |
| 392 | 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 | 64 | }) |
| 65 | 65 | }, |
| 66 | 66 | fetchWork ({ commit, state }, workId) { |
| 67 | - strapi.getEntry('works', workId).then(entry => { | |
| 67 | + return strapi.getEntry('works', workId).then(entry => { | |
| 68 | 68 | commit('setWork', entry) |
| 69 | 69 | commit('setEditingPage') |
| 70 | 70 | }) | ... | ... |