Commit a6920bbdcbb1f6a2d939d10e32014dbe6ab73c39
1 parent
ab5940ed
fix: redirect to work list page when click my-work
Showing
3 changed files
with
32 additions
and
29 deletions
front-end/h5/src/engine-entry.js
| 1 | 1 | /** |
| 2 | - * #!zh: | |
| 2 | + * #!zh: | |
| 3 | 3 | * engine 页面是 webpack 构建多页面中的其中的一个页面 |
| 4 | 4 | * entry-entry 是 构建 engine 页面的入口,类似于 src/main.js 的作用 |
| 5 | 5 | * 作用:作品预览的渲染引擎,其实就是简单遍历 work(作品) 的 pages 以及 elements,显示即可 |
| 6 | 6 | * 主要在预览弹窗中预览 和 用户在手机上查看作品使用 |
| 7 | - * | |
| 7 | + * | |
| 8 | 8 | */ |
| 9 | 9 | import Vue from 'vue' |
| 10 | 10 | import Antd from 'ant-design-vue' | ... | ... |
front-end/h5/src/views/work-manager/index.vue
| ... | ... | @@ -8,7 +8,8 @@ const sidebarMenus = [ |
| 8 | 8 | label: '我的作品', |
| 9 | 9 | value: 'workManager', |
| 10 | 10 | antIcon: 'bars', |
| 11 | - key: '1' | |
| 11 | + key: '1', | |
| 12 | + routerName: 'work-manager-list' | |
| 12 | 13 | }, |
| 13 | 14 | { |
| 14 | 15 | label: '数据中心', |
| ... | ... | @@ -22,12 +23,6 @@ const sidebarMenus = [ |
| 22 | 23 | antIcon: 'snippets', |
| 23 | 24 | key: '2-1', |
| 24 | 25 | routerName: 'form-stat' |
| 25 | - }, | |
| 26 | - { | |
| 27 | - label: '表单统计', | |
| 28 | - value: 'formData', | |
| 29 | - antIcon: 'snippets', | |
| 30 | - key: '2-2' | |
| 31 | 26 | } |
| 32 | 27 | ] |
| 33 | 28 | }, |
| ... | ... | @@ -58,6 +53,32 @@ export default { |
| 58 | 53 | // PreView, |
| 59 | 54 | // Sidebar |
| 60 | 55 | }, |
| 56 | + methods: { | |
| 57 | + renderSidebar (menus) { | |
| 58 | + const renderLabel = menu => menu.routerName ? <router-link to={{ name: menu.routerName }} >{menu.label}</router-link> : menu.label | |
| 59 | + | |
| 60 | + return menus.map(menu => ( | |
| 61 | + menu.children | |
| 62 | + ? ( | |
| 63 | + <a-sub-menu key={menu.key}> | |
| 64 | + <span slot="title"><a-icon type={menu.antIcon} />{menu.label}</span> | |
| 65 | + { | |
| 66 | + (menu.children).map(submenu => ( | |
| 67 | + <a-menu-item key={submenu.key}>{renderLabel(submenu)}</a-menu-item> | |
| 68 | + )) | |
| 69 | + } | |
| 70 | + </a-sub-menu> | |
| 71 | + ) | |
| 72 | + : ( | |
| 73 | + <a-menu-item key={menu.key}> | |
| 74 | + <a-icon type={menu.antIcon}></a-icon> | |
| 75 | + {/** 这边有个疑惑,不知是否为 antd-vue 的 bug,需要用 span 包裹,否则不会显示 label */} | |
| 76 | + <span>{renderLabel(menu)}</span> | |
| 77 | + </a-menu-item> | |
| 78 | + ) | |
| 79 | + )) | |
| 80 | + } | |
| 81 | + }, | |
| 61 | 82 | render (h) { |
| 62 | 83 | return ( |
| 63 | 84 | <a-layout id="luban-work-manager-layout" style={{ height: '100vh' }}> |
| ... | ... | @@ -84,25 +105,7 @@ export default { |
| 84 | 105 | defaultOpenKeys={['1', '2', '3']} |
| 85 | 106 | style="height: 100%" |
| 86 | 107 | > |
| 87 | - { | |
| 88 | - sidebarMenus.map(menu => ( | |
| 89 | - menu.children | |
| 90 | - ? <a-sub-menu key={menu.key}> | |
| 91 | - <span slot="title"><a-icon type={menu.antIcon} />{menu.label}</span> | |
| 92 | - { | |
| 93 | - (menu.children).map(submenu => ( | |
| 94 | - <a-menu-item key={submenu.key}> | |
| 95 | - { submenu.routerName ? <router-link to={{ name: submenu.routerName }}>{submenu.label}</router-link> : submenu.label } | |
| 96 | - </a-menu-item> | |
| 97 | - )) | |
| 98 | - } | |
| 99 | - </a-sub-menu> | |
| 100 | - : <a-menu-item key={menu.key}> | |
| 101 | - <a-icon type={menu.antIcon} /> | |
| 102 | - <span>{menu.label}</span> | |
| 103 | - </a-menu-item> | |
| 104 | - )) | |
| 105 | - } | |
| 108 | + {this.renderSidebar(sidebarMenus)} | |
| 106 | 109 | </a-menu> |
| 107 | 110 | </a-layout-sider> |
| 108 | 111 | <a-layout style="padding: 0 24px 24px"> | ... | ... |
front-end/h5/src/views/work-manager/list.vue
| ... | ... | @@ -46,7 +46,7 @@ const ListItemCard = { |
| 46 | 46 | </div> |
| 47 | 47 | <template class="ant-card-actions" slot="actions"> |
| 48 | 48 | <a-tooltip effect="dark" placement="bottom" title="编辑"> |
| 49 | - <router-link to={{ name: 'editor', params: { workId: this.work.id }}} target="_blank"> | |
| 49 | + <router-link to={{ name: 'editor', params: { workId: this.work.id } }} target="_blank"> | |
| 50 | 50 | <a-icon type="edit" title="编辑"/> |
| 51 | 51 | </router-link> |
| 52 | 52 | </a-tooltip> | ... | ... |