|
@@ -1,86 +1,89 @@
|
|
|
<template>
|
|
|
- <div class="common-layout layouts">
|
|
|
- <el-container class="flex flex-col layouts">
|
|
|
- <!-- 头部 -->
|
|
|
- <el-header></el-header>
|
|
|
- <!-- 左侧菜单 -->
|
|
|
- <el-container class="flex-1 layouts">
|
|
|
- <el-aside class="home-el-aside" width="220px">
|
|
|
- <el-menu default-active="1" class="el-menu-vertical-demo">
|
|
|
- <el-menu-item :index="(index + 1) + ''" v-for="(item, index) in 10" :key="index">
|
|
|
- <div class="relativeElem">
|
|
|
- <el-icon>
|
|
|
- <setting />
|
|
|
- </el-icon>
|
|
|
- <span>第{{ index + 1 }}个</span>
|
|
|
- </div>
|
|
|
- </el-menu-item>
|
|
|
-
|
|
|
- <el-sub-menu index="11">
|
|
|
- <template #title>
|
|
|
- <el-icon>
|
|
|
- <location />
|
|
|
- </el-icon>
|
|
|
- <span>第十一个</span>
|
|
|
- </template>
|
|
|
- <el-menu-item :index="'11'">
|
|
|
- <div class="relativeElem">
|
|
|
- <el-icon><icon-menu /></el-icon>
|
|
|
- <span>第11-1个</span>
|
|
|
- </div>
|
|
|
- </el-menu-item>
|
|
|
- </el-sub-menu>
|
|
|
- </el-menu>
|
|
|
- </el-aside>
|
|
|
- <!-- 主体 -->
|
|
|
- <el-main>
|
|
|
- <router-view></router-view>
|
|
|
- </el-main>
|
|
|
- </el-container>
|
|
|
- </el-container>
|
|
|
- </div>
|
|
|
+ <div class="w-full h-full">
|
|
|
+ <el-container>
|
|
|
+ <el-header class="bg-sky-800 leading-10 flex flex-row justify-between">
|
|
|
+ <div class=" flex flex-row justify-start items-center text-white flex-1">
|
|
|
+ <div v-for="routerItem in routerList"
|
|
|
+ :class="`border-b-2 border-transparent hover:border-white p-2 mr-4 multipleyHeader ${activeRouter?.path === routerItem.path ? 'border-white' : ''}`"
|
|
|
+ :key="routerItem.path">
|
|
|
+ <div v-if="!routerItem.children" @click="setCurrentRouter(routerItem)">
|
|
|
+ {{ routerItem.name }}
|
|
|
+ </div>
|
|
|
+ <div v-else class="flex justify-center items-center">
|
|
|
+ <el-dropdown>
|
|
|
+ <div class="text-white w-full h-full headerText">
|
|
|
+ {{ routerItem.name }}
|
|
|
+ <el-icon class="el-icon--right">
|
|
|
+ <arrow-down />
|
|
|
+ </el-icon>
|
|
|
+ </div>
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu>
|
|
|
+ <el-dropdown-item v-for="child in routerItem.children"
|
|
|
+ :key="child.path"
|
|
|
+ @click="setCurrentRouter(child)">
|
|
|
+ {{ child.name }}
|
|
|
+ </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="flex flex-row justify-start items-center text-white">
|
|
|
+ <el-icon :size="26" class="ml-4 cursor-pointer">
|
|
|
+ <Bell />
|
|
|
+ </el-icon>
|
|
|
+ <div>
|
|
|
+ <img class="w-8 h-8 rounded-full ml-4 cursor-pointer" :src="defaultCover" alt="" @click="logout()">
|
|
|
+ </div>
|
|
|
+ <el-icon :size="26" class="ml-4 cursor-pointer">
|
|
|
+ <Grid />
|
|
|
+ </el-icon>
|
|
|
+ </div>
|
|
|
+ </el-header>
|
|
|
+ <el-main>
|
|
|
+ <router-view />
|
|
|
+ </el-main>
|
|
|
+ </el-container>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
+
|
|
|
<script lang="ts" setup>
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
+import { RouteRecordRaw, useRouter } from 'vue-router';
|
|
|
+import { useStore } from "@/store"
|
|
|
+import defaultCover from "@/assets/defaultCover.png";
|
|
|
+const { getRoutersList } = useStore()
|
|
|
+const router = useRouter();
|
|
|
+const routerList = ref<RouteRecordRaw[]>([]);
|
|
|
+const activeRouter = ref<RouteRecordRaw>();
|
|
|
+const setCurrentRouter = (item: RouteRecordRaw) => {
|
|
|
+ activeRouter.value = item;
|
|
|
+ if (item.children && item.children.length > 0) {
|
|
|
+ router.push({ path: item.children[0].path });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ router.push({ path: item.path });
|
|
|
+};
|
|
|
+const logout = () => {
|
|
|
+ router.push({ path: '/login' });
|
|
|
+};
|
|
|
+onMounted(() => {
|
|
|
+ routerList.value = getRoutersList;
|
|
|
+ activeRouter.value = routerList.value.find((item) => item.path === router.currentRoute.value.path);
|
|
|
+ console.log("routerList", routerList);
|
|
|
+})
|
|
|
|
|
|
</script>
|
|
|
-<style scoped lang="scss">
|
|
|
-.common-layout {
|
|
|
- .relativeElem {
|
|
|
- position: relative;
|
|
|
- z-index: 2;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- }
|
|
|
-
|
|
|
- .el-header {
|
|
|
- background: $darkBlue;
|
|
|
- }
|
|
|
|
|
|
- .el-menu-vertical-demo {
|
|
|
- height: 100%;
|
|
|
- background: $ashen;
|
|
|
-
|
|
|
- .is-active {
|
|
|
- position: relative;
|
|
|
- color: $modena;
|
|
|
-
|
|
|
- &:before {
|
|
|
- content: '';
|
|
|
- position: absolute;
|
|
|
- right: 0;
|
|
|
- top: 8px;
|
|
|
- width: 95%;
|
|
|
- height: 40px;
|
|
|
- background: $backColor;
|
|
|
- border-top-left-radius: 20px;
|
|
|
- border-bottom-left-radius: 20px;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .el-main {
|
|
|
- padding: 0 20px;
|
|
|
- background: $backColor;
|
|
|
- }
|
|
|
+<style scoped lang="scss">
|
|
|
+.multipleyHeader {
|
|
|
+ height: 96%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .headerText {
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|