|
@@ -1,15 +1,15 @@
|
|
|
<template>
|
|
|
<a-row class="grid-demo">
|
|
|
- <a-col :span="menuSecondData && menuSecondData.children && menuSecondData.children.length!==0?12:24" style="height: 100vh;background-color: #232324;">
|
|
|
+ <a-col :span="menuSecondData && menuSecondData && menuSecondData.length !== 0 ? 12 : 24"
|
|
|
+ style="height: 100vh;background-color: #232324;">
|
|
|
<div class="logo-layout" v-if="LayoutStore.setting.SidebarLogo">
|
|
|
<div class="logo">
|
|
|
<img src="@/assets/images/logo.png" />
|
|
|
</div>
|
|
|
<h3>Easy life</h3>
|
|
|
</div>
|
|
|
- <a-menu v-model:selectedKeys="menuTabSate" theme="dark" mode="inline" @mouseleave="evMouseleaveMenu">
|
|
|
- <a-menu-item v-for="routeItem in routesData" :key="routeItem.name"
|
|
|
- @mouseenter="evMenuGetFn(routeItem, 'mouseenter')" @click="changeRoutesItems(routeItem)">
|
|
|
+ <a-menu v-model:selectedKeys="menuTabSate" theme="dark" mode="inline">
|
|
|
+ <a-menu-item v-for="routeItem in routesData" :key="routeItem.name" @click="changeRoutesItems(routeItem)">
|
|
|
<template #icon>
|
|
|
<svg-icon :icon="routeItem.meta.icon"></svg-icon>
|
|
|
</template>
|
|
@@ -17,13 +17,13 @@
|
|
|
</a-menu-item>
|
|
|
</a-menu>
|
|
|
</a-col>
|
|
|
- <a-col :span="12" v-if="menuSecondData && menuSecondData.children && menuSecondData.children.length!==0">
|
|
|
+ <a-col :span="12" v-if="menuSecondData && menuSecondData && menuSecondData.length !== 0">
|
|
|
<a-menu :selectedKeys="routeItemSelectedKeys" id="layout-sider" theme="light" mode="vertical" :collapsed="false"
|
|
|
:auto-open="true" style="height: 100vh;color: #fff;">
|
|
|
- <template v-for="routeItem in menuSecondData?.children || []">
|
|
|
+ <template v-for="routeItem in menuSecondData">
|
|
|
<a-menu-item v-if="!routeItem.children || routeItem.children.length === 0" :key="routeItem.name?.toString()"
|
|
|
@click="evGoPage(routeItem)">
|
|
|
- <span class="menu-level-font">{{ routeItem.meta.title }}</span>
|
|
|
+ <span class="menu-level-font">{{ routeItem.meta?.title }}</span>
|
|
|
</a-menu-item>
|
|
|
<template v-else-if="routeItem.children && routeItem.children.length > 0">
|
|
|
<sub-menu :key="routeItem.name" :menu-info="routeItem" @go="evGoPage" />
|
|
@@ -37,7 +37,6 @@
|
|
|
import { ref, computed, h, reactive, onMounted, watch, nextTick } from "vue";
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
import { useSystemStore } from "@/store/modules/systemStore";
|
|
|
-import LayoutHeader from "@/components/Layout/components/layoutHeader/index.vue";
|
|
|
import subMenu from "@/components/Layout/components/subMenu/index.vue";
|
|
|
import { RouterTagData } from '@/store/modules/routerTag.js'
|
|
|
import { layoutSetting } from '@/store/modules/layoutSetting'
|
|
@@ -50,41 +49,16 @@ const systemStore = useSystemStore();
|
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
|
|
|
|
-const menuSecondLongShow = ref(systemStore.menuSecondLongShow);
|
|
|
// 主菜单
|
|
|
const routesData = router.options.routes[0]?.children || [];
|
|
|
|
|
|
-const menuTabSate = ref([systemStore.getMenuTabSate || routesData[0].name]);
|
|
|
+const menuTabSate = ref([routerTagData.getDefault]);
|
|
|
//子菜单
|
|
|
-const menuSecondData = ref(systemStore.getRouteItem);
|
|
|
+const menuSecondData = ref([]);
|
|
|
// 选中的状态路由列表
|
|
|
-const menuSecondSelectedStatusData = ref(systemStore.getRouteItem);
|
|
|
+
|
|
|
const routeItemSelectedKeys = ref();
|
|
|
|
|
|
-const evMenuSecondLongShow = () => {
|
|
|
- systemStore.setStateValue({
|
|
|
- key: "menuSecondLongShow",
|
|
|
- value: menuSecondLongShow.value ? 1 : 0,
|
|
|
- localStorage: true,
|
|
|
- });
|
|
|
-};
|
|
|
-const evMouseleaveMenu = (e) => {
|
|
|
- if (
|
|
|
- e.relatedTarget?.offsetParent?.id &&
|
|
|
- e.relatedTarget?.offsetParent?.id == "layout-sider"
|
|
|
- )
|
|
|
- return;
|
|
|
- menuSecondData.value = menuSecondSelectedStatusData.value;
|
|
|
-};
|
|
|
-// 子菜单
|
|
|
-const evMouseLeavesSubMenu = () => {
|
|
|
- menuSecondData.value = menuSecondSelectedStatusData.value;
|
|
|
-};
|
|
|
-// 鼠标滑动上去更新菜单栏 目前先屏蔽
|
|
|
-const evMenuGetFn = (routeItem, type) => {
|
|
|
- // menuSecondData.value = routeItem;
|
|
|
- // console.log(routeItem);
|
|
|
-};
|
|
|
|
|
|
// 查找最下级
|
|
|
const findPath = (data) => {
|
|
@@ -97,6 +71,13 @@ const findPath = (data) => {
|
|
|
|
|
|
// 主路由 状态
|
|
|
const changeRoutesItems = (e) => {
|
|
|
+ // 储存当前路由
|
|
|
+ systemStore.setStateValue({
|
|
|
+ key: "routeItem",
|
|
|
+ value: JSON.stringify(e),
|
|
|
+ localStorage: true,
|
|
|
+ });
|
|
|
+ menuSecondData.value = e.children
|
|
|
const item = findPath(e);
|
|
|
evGoPage(item);
|
|
|
};
|
|
@@ -106,53 +87,41 @@ const evGoPage = async (routeItem) => {
|
|
|
await router.push({
|
|
|
name: routeItem.name,
|
|
|
});
|
|
|
-
|
|
|
if (LayoutStore.setting.HeadNavigationBar) {
|
|
|
routerTagData.tagsPushData(routeItem)
|
|
|
routerTagData.getDefault(routeItem.name)
|
|
|
}
|
|
|
- menuTabSate.value = [route.matched[1].name];
|
|
|
systemStore.setStateValue({
|
|
|
key: "menuTabSate",
|
|
|
value: routeItem.name || "",
|
|
|
localStorage: true,
|
|
|
});
|
|
|
-
|
|
|
- menuSecondSelectedStatusData.value = routesData.find(
|
|
|
- (item) => item.name == menuTabSate.value
|
|
|
- );
|
|
|
- menuSecondData.value = menuSecondSelectedStatusData.value;
|
|
|
- systemStore.setStateValue({
|
|
|
- key: "routeItem",
|
|
|
- value: JSON.stringify(menuSecondData.value),
|
|
|
- localStorage: true,
|
|
|
- });
|
|
|
};
|
|
|
|
|
|
watch(
|
|
|
route,
|
|
|
(val) => {
|
|
|
- if (val.name) {
|
|
|
- routeItemSelectedKeys.value = [val.name];
|
|
|
- }
|
|
|
+ routesData.forEach(res => {
|
|
|
+ if (res.children && res.children.length > 0) {
|
|
|
+ res.children.forEach(item => {
|
|
|
+ if (item.name == val.name) {
|
|
|
+ menuTabSate.value = [res.name]
|
|
|
+ routeItemSelectedKeys.value = [item.name]
|
|
|
+ menuSecondData.value = res.children
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (res.name == val.name) {
|
|
|
+ menuTabSate.value = [res.name]
|
|
|
+ menuSecondData.value = []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
{ immediate: true }
|
|
|
);
|
|
|
|
|
|
-watch(() => routerTagData.getMenuTabSate, val => {
|
|
|
- routesData.forEach(res => {
|
|
|
- if (res.children && res.children.length > 0) {
|
|
|
- res.children.forEach(item => {
|
|
|
- if (item.name == val) {
|
|
|
- menuTabSate.value = [res.name]
|
|
|
- routeItemSelectedKeys.value = [item.name]
|
|
|
- const items = findPath(res);
|
|
|
- evGoPage(items);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-}, { immediate: true })
|
|
|
+
|
|
|
</script>
|
|
|
<style scoped lang="less">
|
|
|
.grid-demo {
|