Commit 9c7836199bfdf46d0e490ee2c6d34c4a4bbadd8d
1 parent
86a331fa
feat: add page manager
Showing
2 changed files
with
36 additions
and
9 deletions
front-end/h5/src/components/core/editor/index.js
| ... | ... | @@ -47,6 +47,7 @@ export default { |
| 47 | 47 | methods: { |
| 48 | 48 | ...mapActions('editor', [ |
| 49 | 49 | 'elementManager', |
| 50 | + 'pageManager', | |
| 50 | 51 | 'saveWork', |
| 51 | 52 | 'createWork' |
| 52 | 53 | ]), |
| ... | ... | @@ -70,6 +71,32 @@ export default { |
| 70 | 71 | type: 'add', |
| 71 | 72 | value: { name, zindex, editorConfig } |
| 72 | 73 | }) |
| 74 | + }, | |
| 75 | + _renderMenuContent () { | |
| 76 | + switch (this.activeMenuKey) { | |
| 77 | + case sidebarMenus[0].value: | |
| 78 | + return <RenderShortcutsPanel groups={this.groups} handleClickShortcut={this.clone} /> | |
| 79 | + case sidebarMenus[1].value: | |
| 80 | + return ( | |
| 81 | + this.pages.map((page, index) => ( | |
| 82 | + <span style={{ display: 'flex', justifyContent: 'space-between', padding: '12px 0' }}> | |
| 83 | + <span>第{index + 1}页</span> | |
| 84 | + <a-dropdown trigger={['hover']} placement='bottomCenter'> | |
| 85 | + <a class="ant-dropdown-link" href="#"> | |
| 86 | + <a-icon type="down" /> | |
| 87 | + </a> | |
| 88 | + <a-menu slot="overlay" onClick={({ key }) => { this.pageManager({ type: key }) }}> | |
| 89 | + <a-menu-item key="add"><a-icon type="user" />新增页面</a-menu-item> | |
| 90 | + {/* <a-menu-item key="copy"><a-icon type="user" />复制页面</a-menu-item> */} | |
| 91 | + {/* <a-menu-item key="delete"><a-icon type="user" />删除页面</a-menu-item> */} | |
| 92 | + </a-menu> | |
| 93 | + </a-dropdown> | |
| 94 | + </span> | |
| 95 | + )) | |
| 96 | + ) | |
| 97 | + default: | |
| 98 | + return null | |
| 99 | + } | |
| 73 | 100 | } |
| 74 | 101 | }, |
| 75 | 102 | render (h) { |
| ... | ... | @@ -101,7 +128,7 @@ export default { |
| 101 | 128 | mode="inline" |
| 102 | 129 | defaultSelectedKeys={['pluginList']} |
| 103 | 130 | style={{ height: '100%', borderRight: 1 }} |
| 104 | - onSelect={val => { this.activeMenuKey = val }} | |
| 131 | + onSelect={({ key }) => { this.activeMenuKey = key }} | |
| 105 | 132 | > |
| 106 | 133 | { |
| 107 | 134 | sidebarMenus.map(menu => ( |
| ... | ... | @@ -113,8 +140,8 @@ export default { |
| 113 | 140 | } |
| 114 | 141 | </a-menu> |
| 115 | 142 | </a-layout-sider> |
| 116 | - <a-layout-sider width="240" theme='light' style={{ background: '#fff', padding: '0 12px' }}> | |
| 117 | - <RenderShortcutsPanel groups={this.groups} handleClickShortcut={this.clone} /> | |
| 143 | + <a-layout-sider width="240" theme='light' style={{ background: '#fff', padding: '12px' }}> | |
| 144 | + { this._renderMenuContent() } | |
| 118 | 145 | </a-layout-sider> |
| 119 | 146 | <a-layout style="padding: 0 24px 24px"> |
| 120 | 147 | <a-layout-content style={{ padding: '24px', margin: 0, minHeight: '280px' }}> | ... | ... |
front-end/h5/src/store/modules/page.js
| ... | ... | @@ -3,10 +3,10 @@ import Page from '../../components/core/models/page' |
| 3 | 3 | // actions |
| 4 | 4 | export const actions = { |
| 5 | 5 | setEditingPage ({ commit }, payload) { |
| 6 | - commit('setEditing', payload) | |
| 6 | + commit('setEditingPage', payload) | |
| 7 | 7 | }, |
| 8 | 8 | pageManager ({ commit }, payload) { |
| 9 | - commit('manager', payload) | |
| 9 | + commit('pageManager', payload) | |
| 10 | 10 | } |
| 11 | 11 | } |
| 12 | 12 | |
| ... | ... | @@ -23,13 +23,13 @@ export const mutations = { |
| 23 | 23 | state.work.pages.push(page) |
| 24 | 24 | break |
| 25 | 25 | case 'copy': |
| 26 | - state.work.pages.push(state.editing.clone()) | |
| 26 | + state.work.pages.push(state.editingPage.clone()) | |
| 27 | 27 | break |
| 28 | 28 | case 'delete': |
| 29 | - const { pagesOfCurrentWork, editing } = state | |
| 30 | - let index = pagesOfCurrentWork.findIndex(e => e.uuid === editing.uuid) | |
| 29 | + const { work, editingPage } = state | |
| 30 | + let index = work.pages.findIndex(e => e.uuid === editingPage.uuid) | |
| 31 | 31 | if (index !== -1) { |
| 32 | - let newPages = pagesOfCurrentWork.slice() | |
| 32 | + let newPages = work.slice() | |
| 33 | 33 | newPages.splice(index, 1) |
| 34 | 34 | state.work.pages = newPages |
| 35 | 35 | } | ... | ... |