<template>
|
<el-container class="layout-container">
|
<!-- 侧边栏 -->
|
<el-aside width="200px" class="sidebar">
|
<div class="logo">
|
<h2>蓉易创</h2>
|
</div>
|
<el-menu
|
:default-active="$route.path"
|
class="sidebar-menu"
|
router
|
unique-opened
|
>
|
<el-menu-item
|
v-for="item in menuItems"
|
:key="item.path"
|
:index="item.path"
|
>
|
<el-icon><component :is="item.icon" /></el-icon>
|
<span>{{ item.title }}</span>
|
</el-menu-item>
|
</el-menu>
|
</el-aside>
|
|
<!-- 主内容区 -->
|
<el-container>
|
<!-- 顶部导航 -->
|
<el-header class="header">
|
<div class="header-left">
|
<h3>{{ currentPageTitle }}</h3>
|
</div>
|
<div class="header-right">
|
<el-dropdown @command="handleCommand">
|
<span class="user-info">
|
<el-icon><User /></el-icon>
|
<span>管理员</span>
|
<el-icon><ArrowDown /></el-icon>
|
</span>
|
<template #dropdown>
|
<el-dropdown-menu>
|
<el-dropdown-item command="profile">个人信息</el-dropdown-item>
|
<el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
|
</el-dropdown-menu>
|
</template>
|
</el-dropdown>
|
</div>
|
</el-header>
|
|
<!-- 主内容 -->
|
<el-main class="main-content">
|
<router-view />
|
</el-main>
|
</el-container>
|
</el-container>
|
</template>
|
|
<script setup lang="ts">
|
import { computed } from 'vue'
|
import { useRoute, useRouter } from 'vue-router'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
const route = useRoute()
|
const router = useRouter()
|
|
// 菜单项
|
const menuItems = [
|
{ path: '/dashboard', title: '工作台', icon: 'House' },
|
{ path: '/activity', title: '比赛管理', icon: 'Trophy' },
|
{ path: '/judge', title: '评委管理', icon: 'User' },
|
{ path: '/rating-scheme', title: '评分模板', icon: 'Document' },
|
{ path: '/player', title: '比赛报名', icon: 'UserFilled' },
|
{ path: '/carousel', title: '新闻与推广', icon: 'Picture' },
|
{ path: '/region', title: '区域管理', icon: 'Location' },
|
{ path: '/employee', title: '员工管理', icon: 'Avatar' }
|
]
|
|
// 当前页面标题
|
const currentPageTitle = computed(() => {
|
const currentItem = menuItems.find(item => item.path === route.path)
|
return currentItem?.title || '蓉易创管理系统'
|
})
|
|
// 处理用户操作
|
const handleCommand = async (command: string) => {
|
if (command === 'logout') {
|
try {
|
await ElMessageBox.confirm('确定要退出登录吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
|
localStorage.removeItem('token')
|
ElMessage.success('退出登录成功')
|
router.push('/login')
|
} catch {
|
// 用户取消
|
}
|
} else if (command === 'profile') {
|
ElMessage.info('个人信息功能待开发')
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.layout-container {
|
height: 100vh;
|
}
|
|
.sidebar {
|
background-color: #304156;
|
color: white;
|
|
.logo {
|
height: 60px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
border-bottom: 1px solid #434a50;
|
|
h2 {
|
color: white;
|
font-size: 18px;
|
font-weight: bold;
|
}
|
}
|
|
.sidebar-menu {
|
background-color: #304156;
|
border-right: none;
|
|
:deep(.el-menu-item) {
|
color: #bfcbd9;
|
|
&:hover {
|
background-color: #434a50;
|
color: white;
|
}
|
|
&.is-active {
|
background-color: #409eff;
|
color: white;
|
}
|
}
|
}
|
}
|
|
.header {
|
background-color: white;
|
border-bottom: 1px solid #e4e7ed;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
padding: 0 20px;
|
|
.header-left {
|
h3 {
|
color: #303133;
|
font-size: 16px;
|
font-weight: 500;
|
}
|
}
|
|
.header-right {
|
.user-info {
|
display: flex;
|
align-items: center;
|
cursor: pointer;
|
color: #606266;
|
|
.el-icon {
|
margin: 0 4px;
|
}
|
|
&:hover {
|
color: #409eff;
|
}
|
}
|
}
|
}
|
|
.main-content {
|
background-color: #f5f5f5;
|
min-height: calc(100vh - 60px);
|
}
|
</style>
|