|
| 1 | +<template> |
| 2 | + <div class="template-manager"> |
| 3 | + <div class="manager-header"> |
| 4 | + <div> |
| 5 | + <tiny-icon-arrow-left |
| 6 | + v-if="!!currentPageId" |
| 7 | + class="icon-arrow-left" |
| 8 | + @click="$emit('backToDesigner', '')" |
| 9 | + ></tiny-icon-arrow-left> |
| 10 | + <svg-icon name="template-logo"></svg-icon> |
| 11 | + <span>TinyEngine</span> |
| 12 | + </div> |
| 13 | + </div> |
| 14 | + <div class="manager-index"> |
| 15 | + <div class="manager-menu"> |
| 16 | + <template v-for="item in workspaceRegistry" :key="item.value"> |
| 17 | + <div class="menu-item" :class="{ active: activeNode.id === item.id }" @click="handleMenuClick(item)"> |
| 18 | + <svg-icon :name="item.icon" /> |
| 19 | + <span>{{ item.title }}</span> |
| 20 | + </div> |
| 21 | + </template> |
| 22 | + </div> |
| 23 | + <div class="manager-container"> |
| 24 | + <component :is="activeNode.entry" /> |
| 25 | + </div> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | +</template> |
| 29 | + |
| 30 | +<script> |
| 31 | +import { ref } from 'vue' |
| 32 | +import { iconArrowLeft } from '@opentiny/vue-icon' |
| 33 | +
|
| 34 | +export default { |
| 35 | + components: { |
| 36 | + TinyIconArrowLeft: iconArrowLeft() |
| 37 | + }, |
| 38 | + props: { |
| 39 | + workspaceRegistry: { |
| 40 | + type: Array, |
| 41 | + default: () => [] |
| 42 | + }, |
| 43 | + currentPageId: { |
| 44 | + type: String, |
| 45 | + default: '' |
| 46 | + } |
| 47 | + }, |
| 48 | + emits: ['backToDesigner'], |
| 49 | + setup(props) { |
| 50 | + const activeNode = ref( |
| 51 | + props.workspaceRegistry.find((item) => item.id === props.currentPageId) || props.workspaceRegistry[0] |
| 52 | + ) |
| 53 | +
|
| 54 | + const handleMenuClick = (menu) => { |
| 55 | + activeNode.value = menu |
| 56 | + } |
| 57 | +
|
| 58 | + return { |
| 59 | + activeNode, |
| 60 | + handleMenuClick |
| 61 | + } |
| 62 | + } |
| 63 | +} |
| 64 | +</script> |
| 65 | + |
| 66 | +<style lang="less" scoped> |
| 67 | +.template-manager { |
| 68 | + width: 100%; |
| 69 | + height: 100vh; |
| 70 | + background-color: var(--te-common-bg-default); |
| 71 | + .manager-header { |
| 72 | + height: 48px; |
| 73 | + display: flex; |
| 74 | + justify-content: space-between; |
| 75 | + align-items: center; |
| 76 | + border-bottom: 1px solid var(--te-common-border-bg-divider); |
| 77 | + padding: 0 24px; |
| 78 | + .icon-arrow-left { |
| 79 | + font-size: 28px; |
| 80 | + padding-right: 10px; |
| 81 | + cursor: pointer; |
| 82 | + } |
| 83 | + .svg-icon { |
| 84 | + font-size: 28px; |
| 85 | + padding-right: 8px; |
| 86 | + } |
| 87 | +
|
| 88 | + span { |
| 89 | + font-size: 14px; |
| 90 | + font-weight: 500; |
| 91 | + } |
| 92 | + } |
| 93 | + .manager-index { |
| 94 | + display: flex; |
| 95 | + justify-content: space-between; |
| 96 | + height: calc(100vh - 49px); |
| 97 | + .manager-menu { |
| 98 | + font-size: 14px; |
| 99 | + padding-top: 24px; |
| 100 | + width: 220px; |
| 101 | + border-right: 1px solid var(--te-common-border-bg-divider); |
| 102 | + } |
| 103 | + } |
| 104 | + .menu-item { |
| 105 | + padding: 4px 16px; |
| 106 | + cursor: pointer; |
| 107 | + .svg-icon { |
| 108 | + padding-right: 4px; |
| 109 | + } |
| 110 | + &:hover { |
| 111 | + background: var(--te-common-bg-container); |
| 112 | + } |
| 113 | + } |
| 114 | + .active { |
| 115 | + background: var(--te-common-bg-container); |
| 116 | + position: relative; |
| 117 | + &::before { |
| 118 | + content: ''; |
| 119 | + position: absolute; |
| 120 | + top: 0; |
| 121 | + left: 0px; |
| 122 | + width: 2px; |
| 123 | + height: 100%; |
| 124 | + background: var(--te-common-bg-primary); |
| 125 | + } |
| 126 | + } |
| 127 | + .manager-container { |
| 128 | + padding: 20px; |
| 129 | + width: calc(100% - 220px); |
| 130 | + background: var(--te-common-bg-container); |
| 131 | + } |
| 132 | +} |
| 133 | +</style> |
0 commit comments