Commit d34d717de4914ab40e2081b7cee6aa43f886a17a
1 parent
b220828d
feat: add component tree; !#zh: 组件树
Showing
4 changed files
with
53 additions
and
3 deletions
front-end/h5/src/components/core/editor/left-panel/index.js
| 1 | import RenderShortcutsPanel from './shortcuts-panel/index' | 1 | import RenderShortcutsPanel from './shortcuts-panel/index' |
| 2 | import RenderPageManager from './page-manager/index' | 2 | import RenderPageManager from './page-manager/index' |
| 3 | +import RenderPageTree from './page-tree/index' | ||
| 3 | 4 | ||
| 4 | export default { | 5 | export default { |
| 5 | name: 'EditorLeftPanel', | 6 | name: 'EditorLeftPanel', |
| @@ -16,6 +17,9 @@ export default { | @@ -16,6 +17,9 @@ export default { | ||
| 16 | <a-tab-pane key='page-manager' tab={this.$t('editor.sidebar.pages')}> | 17 | <a-tab-pane key='page-manager' tab={this.$t('editor.sidebar.pages')}> |
| 17 | <RenderPageManager /> | 18 | <RenderPageManager /> |
| 18 | </a-tab-pane> | 19 | </a-tab-pane> |
| 20 | + <a-tab-pane key='page-tree' tab={this.$t('editor.sidebar.tree')}> | ||
| 21 | + <RenderPageTree /> | ||
| 22 | + </a-tab-pane> | ||
| 19 | </a-tabs> | 23 | </a-tabs> |
| 20 | </a-layout-sider> | 24 | </a-layout-sider> |
| 21 | ) | 25 | ) |
front-end/h5/src/components/core/editor/left-panel/page-tree/index.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <a-tree | ||
| 3 | + class="draggable-tree" | ||
| 4 | + :default-expanded-keys="expandedKeys" | ||
| 5 | + draggable | ||
| 6 | + :tree-data="treeData" | ||
| 7 | + @dragenter="onDragEnter" | ||
| 8 | + @drop="onDrop" | ||
| 9 | + /> | ||
| 10 | +</template> | ||
| 11 | + | ||
| 12 | +<script> | ||
| 13 | +import { mapState } from 'vuex' | ||
| 14 | +function getTreeNode (ele) { | ||
| 15 | + return { | ||
| 16 | + title: ele.name, | ||
| 17 | + key: ele.uuid, | ||
| 18 | + children: (ele.children || []).map(getTreeNode) | ||
| 19 | + } | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +export default { | ||
| 23 | + computed: { | ||
| 24 | + ...mapState('editor', { | ||
| 25 | + elements: state => state.editingPage.elements | ||
| 26 | + }), | ||
| 27 | + treeData () { | ||
| 28 | + return this.elements.map(getTreeNode) | ||
| 29 | + } | ||
| 30 | + }, | ||
| 31 | + data () { | ||
| 32 | + return { | ||
| 33 | + gData: [], | ||
| 34 | + expandedKeys: [] | ||
| 35 | + } | ||
| 36 | + }, | ||
| 37 | + methods: { | ||
| 38 | + onDragEnter (info) { | ||
| 39 | + }, | ||
| 40 | + onDrop (info) { | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | +} | ||
| 44 | +</script> |
front-end/h5/src/locales/lang/en-US.js
| @@ -32,7 +32,8 @@ export default { | @@ -32,7 +32,8 @@ export default { | ||
| 32 | sidebar: { | 32 | sidebar: { |
| 33 | components: 'Components', | 33 | components: 'Components', |
| 34 | pages: 'Pages', | 34 | pages: 'Pages', |
| 35 | - templates: 'Templates' | 35 | + templates: 'Templates', |
| 36 | + tree: 'Tree' | ||
| 36 | }, | 37 | }, |
| 37 | pageManager: { | 38 | pageManager: { |
| 38 | title: 'Page {index}', | 39 | title: 'Page {index}', |
front-end/h5/src/locales/lang/zh-CN.js
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | * @Author: ly525 | 2 | * @Author: ly525 |
| 3 | * @Date: 2019-11-24 18:51:58 | 3 | * @Date: 2019-11-24 18:51:58 |
| 4 | * @LastEditors: ly525 | 4 | * @LastEditors: ly525 |
| 5 | - * @LastEditTime: 2020-10-13 00:51:57 | 5 | + * @LastEditTime: 2020-10-13 01:29:21 |
| 6 | * @FilePath: /h5/src/locales/lang/zh-CN.js | 6 | * @FilePath: /h5/src/locales/lang/zh-CN.js |
| 7 | * @Github: https://github.com/ly525/luban-h5 | 7 | * @Github: https://github.com/ly525/luban-h5 |
| 8 | * @Description: Do not edit | 8 | * @Description: Do not edit |
| @@ -42,7 +42,8 @@ export default { | @@ -42,7 +42,8 @@ export default { | ||
| 42 | sidebar: { | 42 | sidebar: { |
| 43 | components: '组件列表', | 43 | components: '组件列表', |
| 44 | pages: '页面管理', | 44 | pages: '页面管理', |
| 45 | - templates: '模板' | 45 | + templates: '模板', |
| 46 | + tree: '组件树' | ||
| 46 | }, | 47 | }, |
| 47 | pageManager: { | 48 | pageManager: { |
| 48 | title: '第{index}页面', | 49 | title: '第{index}页面', |