230 lines
6.6 KiB
Vue
230 lines
6.6 KiB
Vue
<template>
|
|
<div class="flex flex-col h-screen overflow-hidden bg-gray-50">
|
|
<!-- 顶部导航栏 -->
|
|
<header class="bg-primary text-white shadow-md h-16 flex items-center justify-between px-6">
|
|
<!-- 左侧Logo和菜单按钮 -->
|
|
<div class="flex items-center">
|
|
<div class="flex">
|
|
<button @click="isCollapse = !isCollapse" class="mr-4 text-white focus:outline-none">
|
|
<el-icon><Fold /></el-icon>
|
|
</button>
|
|
<div class="flex items-center">
|
|
<el-icon><Platform /></el-icon>
|
|
<span class="ml-2 text-lg font-semibold hidden md:block">企业内网门户</span>
|
|
</div>
|
|
</div>
|
|
<div class="top-header">
|
|
<el-menu
|
|
mode="horizontal"
|
|
:ellipsis="false"
|
|
@open="handleOpen"
|
|
router
|
|
>
|
|
<el-menu-item index="/news">新闻中心</el-menu-item>
|
|
<el-menu-item index="/announcement">公告</el-menu-item>
|
|
</el-menu>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 右侧用户信息 -->
|
|
<div class="flex items-center">
|
|
<div class="relative mr-6">
|
|
<button class="relative text-white focus:outline-none">
|
|
<el-icon><Bell /></el-icon>
|
|
<span class="absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center">3</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
<img :src="userInfoData?.avatar" alt="User Avatar" class="w-8 h-8 rounded-full object-cover">
|
|
<el-dropdown trigger="click">
|
|
<span class="el-dropdown-link text-white cursor-pointer ml-2">{{ userInfoData?.nickname }}</span>
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item @click="handelLogout">退出登录</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- 主内容区 -->
|
|
<div class="flex flex-1 overflow-hidden">
|
|
<!-- 侧边栏菜单 -->
|
|
<aside class="bg-white shadow-md z-10 transition-all duration-300" :style="{ width: isCollapse ? '64px' : '200px' }">
|
|
<el-menu
|
|
default-active="/home"
|
|
:collapse="isCollapse"
|
|
@open="handleOpen"
|
|
@close="handleClose"
|
|
router
|
|
>
|
|
<el-menu-item index="/home">
|
|
<el-icon><IconMenu /></el-icon>
|
|
<template #title>首页</template>
|
|
</el-menu-item>
|
|
<el-menu-item index="/app-center">
|
|
<el-icon><Orange /></el-icon>
|
|
<template #title>应用中心</template>
|
|
</el-menu-item>
|
|
<el-menu-item index="/staff-style">
|
|
<el-icon><UserFilled /></el-icon>
|
|
<template #title>员工风采</template>
|
|
</el-menu-item>
|
|
<el-menu-item index="/app-center">
|
|
<el-icon><StarFilled /></el-icon>
|
|
<template #title>企业论坛</template>
|
|
</el-menu-item>
|
|
<el-menu-item index="/chat">
|
|
<el-icon><Comment /></el-icon>
|
|
<template #title>企业聊天</template>
|
|
</el-menu-item>
|
|
<el-menu-item index="/suggestion-box">
|
|
<el-icon><QuestionFilled /></el-icon>
|
|
<template #title>意见箱</template>
|
|
</el-menu-item>
|
|
<!-- <el-sub-menu index="2">-->
|
|
<!-- <template #title>-->
|
|
<!-- <el-icon><Location /></el-icon>-->
|
|
<!-- <span>导航一</span>-->
|
|
<!-- </template>-->
|
|
<!-- <el-menu-item-group>-->
|
|
<!-- <template #title><span>分组一</span></template>-->
|
|
<!-- <el-menu-item index="1-1">菜单项一</el-menu-item>-->
|
|
<!-- <el-menu-item index="1-2">菜单项二</el-menu-item>-->
|
|
<!-- </el-menu-item-group>-->
|
|
<!-- <el-menu-item-group title="分组二">-->
|
|
<!-- <el-menu-item index="1-3">菜单项三</el-menu-item>-->
|
|
<!-- </el-menu-item-group>-->
|
|
<!-- <el-sub-menu index="1-4">-->
|
|
<!-- <template #title><span>菜单项四</span></template>-->
|
|
<!-- <el-menu-item index="1-4-1">子菜单项一</el-menu-item>-->
|
|
<!-- </el-sub-menu>-->
|
|
<!-- </el-sub-menu>-->
|
|
<!-- <el-menu-item index="3" disabled>-->
|
|
<!-- <el-icon><Document /></el-icon>-->
|
|
<!-- <template #title>导航三</template>-->
|
|
<!-- </el-menu-item>-->
|
|
<!-- <el-menu-item index="4">-->
|
|
<!-- <el-icon><Setting /></el-icon>-->
|
|
<!-- <template #title>导航四</template>-->
|
|
<!-- </el-menu-item>-->
|
|
</el-menu>
|
|
</aside>
|
|
|
|
<!-- 内容区域 -->
|
|
<main class="flex-1 overflow-y-auto p-6 bg-gray-50">
|
|
<router-view></router-view>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {onMounted, ref} from 'vue'
|
|
import {
|
|
Document,
|
|
Menu as IconMenu,
|
|
Location,
|
|
Setting,
|
|
Switch,
|
|
StarFilled,
|
|
UserFilled,
|
|
Comment,
|
|
QuestionFilled,
|
|
Orange,
|
|
// 新增:导入需要使用的图标
|
|
Fold,
|
|
Platform,
|
|
Bell,
|
|
CaretBottom
|
|
} from '@element-plus/icons-vue'
|
|
|
|
|
|
import userInfo from '../../data/userInfo.js'
|
|
import {useRouter} from "vue-router";
|
|
import { logout } from '../../api/login';
|
|
const router=useRouter();
|
|
const userInfoData=ref(null);
|
|
|
|
const isCollapse = ref(false)
|
|
|
|
const handleOpen = (key, keyPath) => {
|
|
console.log(key, keyPath)
|
|
}
|
|
|
|
const handleClose = (key, keyPath) => {
|
|
console.log(key, keyPath)
|
|
}
|
|
|
|
onMounted(()=>{
|
|
const info=userInfo.getUserInfo()
|
|
if (!info){
|
|
router.push({path: '/login'})
|
|
}else {
|
|
userInfoData.value=info
|
|
}
|
|
})
|
|
|
|
|
|
const handelLogout = () => {
|
|
logout().then(res=>{
|
|
if (res.code===200){
|
|
userInfo.removeUserInfo()
|
|
location.reload()
|
|
}
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.el-menu-vertical-demo:not(.el-menu--collapse) {
|
|
width: 200px;
|
|
min-height: 400px;
|
|
}
|
|
|
|
|
|
|
|
.top-header{
|
|
border:none;
|
|
:deep(.el-menu-item){
|
|
background-color: #085ce6;
|
|
color: #fff !important;
|
|
border: none !important;
|
|
}
|
|
:deep(.el-menu-item):hover{
|
|
color: #ffffff !important;
|
|
background-color: #206ce8 !important;
|
|
border: none !important;
|
|
|
|
|
|
}
|
|
:deep(.el-menu-item):active{
|
|
color: #ffffff !important;
|
|
background-color: #085ce6 !important;
|
|
border: none !important;
|
|
|
|
|
|
}
|
|
|
|
:deep(.el-menu-item):focus{
|
|
color: #ffffff !important;
|
|
background-color: #206ce8 !important;
|
|
border: none !important;
|
|
}
|
|
|
|
|
|
|
|
margin-left: 20px;
|
|
}
|
|
:deep(.el-menu--horizontal.el-menu ){
|
|
border-bottom: none !important;
|
|
}
|
|
|
|
:deep(.el-menu) {
|
|
background-color: transparent !important;
|
|
}
|
|
</style> |