2024-08-29 17:06:00 +08:00
|
|
|
<template>
|
|
|
|
<a-layout class="main-content">
|
2024-08-30 18:07:30 +08:00
|
|
|
<a-layout-sider :collapsed="collapsed" theme="light" :trigger="null" collapsible>
|
2024-08-29 17:06:00 +08:00
|
|
|
<div v-if="!collapsed" class="title flex-center">
|
|
|
|
<div>超级后台</div>
|
|
|
|
</div>
|
|
|
|
<div v-else class="logo flex-center">
|
2024-08-30 18:07:30 +08:00
|
|
|
<img src="@/assets/vue.svg" title="超级后台" alt="xx" />
|
2024-08-29 17:06:00 +08:00
|
|
|
</div>
|
2024-08-30 18:07:30 +08:00
|
|
|
<!-- -->
|
|
|
|
<a-menu v-model:selectedKeys="selectedKeys" theme="light" mode="inline">
|
|
|
|
<a-menu-item key="1">
|
|
|
|
<router-link to="/index">
|
|
|
|
<pie-chart-outlined />
|
|
|
|
<span>首页</span>
|
|
|
|
</router-link>
|
|
|
|
</a-menu-item>
|
|
|
|
<a-menu-item key="2">
|
|
|
|
<router-link to="/register/index">
|
|
|
|
<pie-chart-outlined />
|
|
|
|
<span>注册</span>
|
|
|
|
</router-link>
|
|
|
|
</a-menu-item>
|
|
|
|
</a-menu>
|
2024-08-29 17:06:00 +08:00
|
|
|
</a-layout-sider>
|
|
|
|
<a-layout>
|
2024-08-30 18:07:30 +08:00
|
|
|
<a-layout-header class="layout-header">
|
|
|
|
<layout-header v-model:collapsed="collapsed" />
|
2024-08-29 17:06:00 +08:00
|
|
|
</a-layout-header>
|
2024-08-30 18:07:30 +08:00
|
|
|
<a-layout-content class="layout-content">
|
2024-08-29 17:06:00 +08:00
|
|
|
<router-view v-slot="{ Component, route }">
|
|
|
|
<transition appear name="fade-transform" mode="out-in">
|
|
|
|
<keep-alive :include="keepAliveNames">
|
2024-08-30 18:07:30 +08:00
|
|
|
<component :is="Component" :key="route.fullPath" />
|
2024-08-29 17:06:00 +08:00
|
|
|
</keep-alive>
|
|
|
|
</transition>
|
|
|
|
</router-view>
|
|
|
|
</a-layout-content>
|
|
|
|
</a-layout>
|
|
|
|
</a-layout>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-08-30 18:07:30 +08:00
|
|
|
import LayoutHeader from '@/components/layout/header/LayoutHeader.vue'
|
|
|
|
import { computed } from 'vue'
|
|
|
|
// import Sliber from '@/components/layout/sliber/sliber.vue'
|
|
|
|
import { staticRouter } from '@/router/staticRouters'
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
const route = useRoute()
|
2024-08-29 17:06:00 +08:00
|
|
|
|
2024-08-30 18:07:30 +08:00
|
|
|
// 控制菜单折叠
|
|
|
|
// const collapsed = ref(false)
|
2024-08-29 17:06:00 +08:00
|
|
|
|
2024-08-30 18:07:30 +08:00
|
|
|
// 当前选中的菜单项
|
|
|
|
// const selectedKeys = computed(() => route.path)
|
|
|
|
const selectedKeys = computed(() => [route.path])
|
|
|
|
// 过滤出需要在菜单中显示的路由
|
|
|
|
const menuRoutes = computed(() => staticRouter.filter((route) => route.meta && route.meta.title))
|
|
|
|
|
|
|
|
// 示例:动态控制缓存页面的名称
|
|
|
|
// const keepAliveNames = ref(['index'])
|
2024-08-29 17:06:00 +08:00
|
|
|
|
2024-08-30 18:07:30 +08:00
|
|
|
import { ref } from 'vue'
|
2024-08-29 17:06:00 +08:00
|
|
|
|
2024-08-30 18:07:30 +08:00
|
|
|
const collapsed = ref<boolean>(false)
|
|
|
|
|
|
|
|
const keepAliveNames = ref<string[]>([])
|
2024-08-29 17:06:00 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.main-content {
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
|
|
|
|
.layout-header {
|
|
|
|
background: #ffffff;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.layout-content {
|
|
|
|
margin: 10px;
|
|
|
|
padding: 4px;
|
|
|
|
background: #f5f7fd;
|
|
|
|
min-height: 280px;
|
|
|
|
border-radius: 5px;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
|
|
|
height: 32px;
|
|
|
|
width: 168px;
|
|
|
|
transition: width 2ms linear 2ms;
|
|
|
|
margin: 16px;
|
|
|
|
color: black;
|
|
|
|
font-weight: bold;
|
2024-08-30 18:07:30 +08:00
|
|
|
font-size: 20px;
|
2024-08-29 17:06:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.logo {
|
|
|
|
margin: 16px;
|
|
|
|
|
|
|
|
img {
|
|
|
|
width: 50px;
|
2024-08-30 18:07:30 +08:00
|
|
|
height: 50px;
|
2024-08-29 17:06:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.site-layout .site-layout-background {
|
|
|
|
background: #ffffff;
|
|
|
|
}
|
|
|
|
</style>
|