Files
screen/src/layout/components/Sidebar/index.vue

211 lines
4.8 KiB
Vue
Raw Normal View History

<template>
<div :class="['sidebar-container', { 'is-collapse': !sidebar.opened }]">
<div class="sidebar-header">
<div class="logo-wrapper">
<span class="logo-icon">📊</span>
2026-05-19 17:56:44 +08:00
<span v-show="sidebar.opened" class="logo-text">数据大屏</span>
</div>
</div>
<el-scrollbar class="sidebar-scroll">
<el-menu
:default-active="activeMenu"
:collapse="!sidebar.opened"
:collapse-transition="false"
mode="vertical"
class="sidebar-menu"
router
unique-opened
>
2026-05-19 17:56:44 +08:00
<el-menu-item v-for="item in menuItems" :key="item.path" :index="item.path">
<el-icon :size="14"><component :is="getIcon(item.meta?.icon)" /></el-icon>
<span>{{ item.meta?.title }}</span>
</el-menu-item>
</el-menu>
</el-scrollbar>
</div>
</template>
<script setup>
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useStore } from 'vuex'
2026-05-19 17:56:44 +08:00
import { Monitor, PieChart, Document, Bell } from '@element-plus/icons-vue'
const route = useRoute()
const store = useStore()
const sidebar = computed(() => store.state.app.sidebar)
const activeMenu = computed(() => route.path)
const iconMap = {
'monitor': Monitor,
'order': Document,
'cost': PieChart,
'energy': Monitor,
2026-05-19 17:56:44 +08:00
'oee': PieChart,
'output': PieChart,
2026-05-19 17:56:44 +08:00
'stop': Bell
}
const getIcon = (iconName) => {
return iconMap[iconName] || Monitor
}
const menuItems = [
2026-05-19 17:56:44 +08:00
{ path: '/dashboard/order', meta: { title: '订单大屏', icon: 'order' } },
{ path: '/dashboard/cost', meta: { title: '成本大屏', icon: 'cost' } },
{ path: '/dashboard/energy', meta: { title: '能源大屏', icon: 'energy' } },
{ path: '/dashboard/oee', meta: { title: 'OEE综合大屏', icon: 'oee' } },
{ path: '/dashboard/output', meta: { title: '产出监控大屏', icon: 'output' } },
{ path: '/dashboard/stop-analysis', meta: { title: '停机分析大屏', icon: 'stop' } },
2026-05-25 18:12:10 +08:00
{ path: '/dashboard/acid-rolling', meta: { title: '酸轧数据大屏', icon: 'example' } },
2026-05-28 14:09:08 +08:00
{ path: '/warehouse-overview', meta: { title: '库区总览大屏', icon: 'example' } }
]
</script>
<style lang="scss" scoped>
.sidebar-container {
flex-shrink: 0;
width: 200px;
height: 100vh;
2026-05-19 17:56:44 +08:00
background: linear-gradient(180deg, #0a1428 0%, #0d1b34 100%);
border-right: 1px solid rgba(0, 212, 255, 0.2);
box-shadow: 2px 2px 20px rgba(0, 0, 0, 0.3);
transition: width 0.28s ease;
overflow: hidden;
&.is-collapse {
width: 54px;
}
}
.sidebar-header {
height: 50px;
display: flex;
align-items: center;
justify-content: center;
2026-05-19 17:56:44 +08:00
background: linear-gradient(90deg, #00a8cc 0%, #00d4ff 50%, #00a8cc 100%);
border-bottom: 1px solid rgba(0, 212, 255, 0.3);
.logo-wrapper {
display: flex;
align-items: center;
gap: 8px;
.logo-icon {
font-size: 20px;
2026-05-19 17:56:44 +08:00
color: #0a1428;
}
.logo-text {
font-size: 16px;
font-weight: bold;
2026-05-19 17:56:44 +08:00
color: #0a1428;
transition: opacity 0.2s ease;
}
}
}
.sidebar-scroll {
height: calc(100% - 50px);
overflow-y: auto;
overflow-x: hidden;
&::-webkit-scrollbar {
2026-05-19 17:56:44 +08:00
width: 6px;
height: 6px;
}
&::-webkit-scrollbar-track {
2026-05-19 17:56:44 +08:00
background: rgba(0, 212, 255, 0.1);
border-radius: 3px;
}
&::-webkit-scrollbar-thumb {
2026-05-19 17:56:44 +08:00
background: rgba(0, 212, 255, 0.3);
border-radius: 3px;
transition: background 0.2s;
&:hover {
2026-05-19 17:56:44 +08:00
background: rgba(0, 212, 255, 0.5);
}
}
}
.sidebar-menu {
border-right: none;
background: transparent;
2026-05-19 17:56:44 +08:00
padding: 8px;
:deep(.el-menu) {
border-right: none;
background: transparent;
}
2026-05-19 17:56:44 +08:00
:deep(.el-menu-item) {
height: 44px;
line-height: 44px;
color: #ffffff;
margin: 6px 4px;
padding: 0 16px;
border-radius: 8px;
position: relative;
border-left: 3px solid transparent;
2026-05-19 17:56:44 +08:00
transition: all 0.25s ease;
background: rgba(0, 212, 255, 0.08);
font-size: 14px;
.el-icon {
2026-05-19 17:56:44 +08:00
color: #00d4ff;
margin-right: 12px;
font-size: 16px;
}
&:hover {
2026-05-19 17:56:44 +08:00
background: rgba(0, 212, 255, 0.25);
color: #ffffff;
transform: translateX(4px);
.el-icon {
2026-05-19 17:56:44 +08:00
color: #00d4ff;
text-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
}
}
&.is-active {
2026-05-19 17:56:44 +08:00
border-left: 3px solid #00d4ff;
background: rgba(0, 212, 255, 0.3);
color: #ffffff;
font-weight: 600;
2026-05-19 17:56:44 +08:00
box-shadow: 0 0 15px rgba(0, 212, 255, 0.25);
.el-icon {
2026-05-19 17:56:44 +08:00
color: #00d4ff;
text-shadow: 0 0 15px rgba(0, 212, 255, 0.9);
}
}
}
&.is-collapse {
2026-05-19 17:56:44 +08:00
:deep(.el-menu-item) {
padding: 0;
text-align: center;
2026-05-19 17:56:44 +08:00
border-left: none;
span {
display: none;
}
.el-icon {
margin-right: 0;
}
2026-05-19 17:56:44 +08:00
&.is-active {
border-left: none;
background: rgba(0, 212, 255, 0.2);
}
}
}
}
2026-05-19 17:56:44 +08:00
</style>