| 1 | <template> |
| 2 | <div id="app"> |
| 3 | <el-container> |
| 4 | <el-aside :width="isCollapse ? '64px' : '200px'"> |
| 5 | <div class="sidebar"> |
| 6 | <div class="logo"> |
| 7 | <img v-show="isCollapse" src="/vite.svg" alt="Logo" class="logo-img"> |
| 8 | <h2 v-show="!isCollapse">自媒体自动化运营系统</h2> |
| 9 | </div> |
| 10 | <el-menu |
| 11 | :router="true" |
| 12 | :default-active="activeMenu" |
| 13 | :collapse="isCollapse" |
| 14 | class="sidebar-menu" |
| 15 | background-color="#001529" |
| 16 | text-color="#fff" |
| 17 | active-text-color="#409EFF" |
| 18 | > |
| 19 | <el-menu-item index="/"> |
| 20 | <el-icon><HomeFilled /></el-icon> |
| 21 | <span>首页</span> |
| 22 | </el-menu-item> |
| 23 | <el-menu-item index="/account-management"> |
| 24 | <el-icon><User /></el-icon> |
| 25 | <span>账号管理</span> |
| 26 | </el-menu-item> |
| 27 | <el-menu-item index="/material-management"> |
| 28 | <el-icon><Picture /></el-icon> |
| 29 | <span>素材管理</span> |
| 30 | </el-menu-item> |
| 31 | <el-menu-item index="/publish-center"> |
| 32 | <el-icon><Upload /></el-icon> |
| 33 | <span>发布中心</span> |
| 34 | </el-menu-item> |
| 35 | <el-menu-item index="/about"> |
| 36 | <el-icon><DataAnalysis /></el-icon> |
| 37 | <span>关于</span> |
| 38 | </el-menu-item> |
| 39 | </el-menu> |
| 40 | </div> |
| 41 | </el-aside> |
| 42 | <el-container> |
| 43 | <el-header> |
| 44 | <div class="header-content"> |
| 45 | <div class="header-left"> |
| 46 | <el-icon class="toggle-sidebar" @click="toggleSidebar"><Fold /></el-icon> |
| 47 | </div> |
| 48 | <div class="header-right"> |
| 49 | <!-- 账号信息已移除 --> |
| 50 | </div> |
| 51 | </div> |
| 52 | </el-header> |
| 53 | <el-main> |
| 54 | <router-view /> |
| 55 | </el-main> |
| 56 | </el-container> |
| 57 | </el-container> |
| 58 | </div> |
| 59 | </template> |
| 60 | |
| 61 | <script setup> |
| 62 | import { ref, computed } from 'vue' |
| 63 | import { useRoute } from 'vue-router' |
| 64 | import { |
| 65 | HomeFilled, User, DataAnalysis, |
| 66 | Fold, Picture, Upload |
| 67 | } from '@element-plus/icons-vue' |
| 68 | |
| 69 | const route = useRoute() |
| 70 | |
| 71 | // 当前激活的菜单项 |
| 72 | const activeMenu = computed(() => { |
| 73 | return route.path |
| 74 | }) |
| 75 | |
| 76 | // 侧边栏折叠状态 |
| 77 | const isCollapse = ref(false) |
| 78 | |
| 79 | // 切换侧边栏折叠状态 |
| 80 | const toggleSidebar = () => { |
| 81 | isCollapse.value = !isCollapse.value |
| 82 | } |
| 83 | </script> |
| 84 | |
| 85 | <style lang="scss" scoped> |
| 86 | @use '@/styles/variables.scss' as *; |
| 87 | |
| 88 | #app { |
| 89 | min-height: 100vh; |
| 90 | } |
| 91 | |
| 92 | .el-container { |
| 93 | height: 100vh; |
| 94 | } |
| 95 | |
| 96 | .el-aside { |
| 97 | background-color: #001529; |
| 98 | color: #fff; |
| 99 | height: 100vh; |
| 100 | overflow: hidden; |
| 101 | transition: width 0.3s; |
| 102 | |
| 103 | .sidebar { |
| 104 | display: flex; |
| 105 | flex-direction: column; |
| 106 | height: 100%; |
| 107 | |
| 108 | .logo { |
| 109 | height: 60px; |
| 110 | padding: 0 16px; |
| 111 | display: flex; |
| 112 | align-items: center; |
| 113 | background-color: #002140; |
| 114 | overflow: hidden; |
| 115 | |
| 116 | .logo-img { |
| 117 | width: 32px; |
| 118 | height: 32px; |
| 119 | margin-right: 12px; |
| 120 | } |
| 121 | |
| 122 | h2 { |
| 123 | color: #fff; |
| 124 | font-size: 16px; |
| 125 | font-weight: 600; |
| 126 | white-space: nowrap; |
| 127 | margin: 0; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | .sidebar-menu { |
| 132 | border-right: none; |
| 133 | flex: 1; |
| 134 | |
| 135 | .el-menu-item { |
| 136 | display: flex; |
| 137 | align-items: center; |
| 138 | |
| 139 | .el-icon { |
| 140 | margin-right: 10px; |
| 141 | font-size: 18px; |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | .el-header { |
| 149 | background-color: #fff; |
| 150 | box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); |
| 151 | padding: 0; |
| 152 | height: 60px; |
| 153 | |
| 154 | .header-content { |
| 155 | display: flex; |
| 156 | justify-content: space-between; |
| 157 | align-items: center; |
| 158 | height: 100%; |
| 159 | padding: 0 16px; |
| 160 | |
| 161 | .header-left { |
| 162 | .toggle-sidebar { |
| 163 | font-size: 20px; |
| 164 | cursor: pointer; |
| 165 | color: $text-regular; |
| 166 | |
| 167 | &:hover { |
| 168 | color: $primary-color; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | .header-right { |
| 174 | .user-dropdown { |
| 175 | display: flex; |
| 176 | align-items: center; |
| 177 | cursor: pointer; |
| 178 | |
| 179 | .username { |
| 180 | margin: 0 8px; |
| 181 | color: $text-regular; |
| 182 | } |
| 183 | |
| 184 | .el-icon { |
| 185 | font-size: 12px; |
| 186 | color: $text-secondary; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | .el-main { |
| 194 | background-color: $bg-color-page; |
| 195 | padding: 20px; |
| 196 | overflow-y: auto; |
| 197 | } |
| 198 | </style> |
| 199 |