Files
backmanagerweb/src/components/panel.vue

117 lines
3.1 KiB
Vue
Raw Normal View History

<script setup>
import {ref} from 'vue'
import {useRoute} from 'vue-router'
import {ArrowLeft, Location, Menu as IconMenu, SwitchButton,} from '@element-plus/icons-vue'
const route = useRoute()
const isCollapse = ref(false)
const switchFold = () => {
isCollapse.value = !isCollapse.value
}
</script>
<template>
<el-container style="height: 100vh">
<el-header style="display: flex; align-items: center;">
<el-menu
:ellipsis="false"
mode="horizontal"
router
style="flex: 1;"
>
<!-- 左侧 -->
<el-menu-item index="">
<h1 style="margin: 0;">信息管理系统</h1>
</el-menu-item>
<!-- 右侧margin-left: auto 把它推到底部 -->
<el-menu-item index="/login" style="margin-left: auto">
<el-icon><SwitchButton/></el-icon>
<template #title>LogOut</template>
</el-menu-item>
</el-menu>
</el-header>
<el-container>
<el-aside style="display: flex; flex-direction: column" width="200px">
<el-menu
:collapse="isCollapse"
:default-active="route.path"
router
style="flex: 1; display: flex; flex-direction: column"
>
<el-sub-menu index="1">
<template #title>
<el-icon><IconMenu/></el-icon>
<span>一号栏</span>
</template>
<el-menu-item index="/panel/page1">
<el-icon><Location/></el-icon>
<template #title>item one</template>
</el-menu-item>
</el-sub-menu>
<el-menu-item index="/panel/page2">
<el-icon><Location/></el-icon>
<template #title>二号栏</template>
</el-menu-item>
<el-menu-item index="/panel/page3">
<el-icon><Location/></el-icon>
<template #title>三号栏</template>
</el-menu-item>
<!-- 关键margin-top: auto 把它推到最底部 -->
<el-menu-item style="margin-top: auto" @click="switchFold">
<el-icon :class="{'rotate-180-animation':!isCollapse,'rotate-180-animation-reverse':isCollapse}" ><ArrowLeft /></el-icon>
<template #title>收缩</template>
</el-menu-item>
</el-menu>
</el-aside>
<el-main>
<!-- 这个 router-view 渲染嵌套的子路由page1/page2/page3 -->
<router-view />
</el-main>
</el-container>
</el-container>
</template>
<style scoped>
.rotate-180-animation {
/* 修改为你想要的动画旋转180度执行一次持续0.5秒 */
animation: rotate-180 0.3s ease-in-out;
animation-fill-mode:forwards;
}
.rotate-180-animation-reverse {
/* 修改为你想要的动画旋转180度执行一次持续0.5秒 */
animation: rotate-180-reverse 0.3s ease-in-out;
animation-fill-mode:forwards;
}
@keyframes rotate-180 {
from {
transform: rotate(0deg);
}
to {
transform: rotate(180deg);
}
}
@keyframes rotate-180-reverse {
from {
transform: rotate(180deg);
}
to {
transform: rotate(0deg);
}
}
</style>