update
1.更新im 2.修改bug
This commit is contained in:
@@ -2,19 +2,6 @@
|
||||
<Layout :class="prefixCls" v-bind="lockEvents">
|
||||
<LayoutFeatures />
|
||||
<LayoutHeader fixed v-if="getShowFullHeaderRef" />
|
||||
<div
|
||||
class="menu-list-outer"
|
||||
>
|
||||
<div class="menu-list-outer-inner">
|
||||
<template v-for="(item, index) in menuList" :key="`menu-list${index}`">
|
||||
<div @click="clickItem(item)" class="menu-list-item">
|
||||
<div class="menu-list-item-d" :class="[choosePath === item.path ? 'selected' : 'no-selected']">
|
||||
{{ item?.title || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<Layout :class="[layoutClass]">
|
||||
<LayoutSideBar v-if="getShowSidebar || getIsMobile" />
|
||||
<Layout :class="`${prefixCls}-main`">
|
||||
@@ -29,7 +16,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, unref, watch } from 'vue';
|
||||
import { computed, defineComponent, unref } from 'vue';
|
||||
import { Layout } from 'ant-design-vue';
|
||||
import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
|
||||
|
||||
@@ -45,12 +32,8 @@
|
||||
|
||||
import { useAppInject } from '/@/hooks/web/useAppInject';
|
||||
import { useUserStore, useUserStoreWithOut } from '/@/store/modules/user';
|
||||
import { findRouteMenu } from '/@/layouts/default/menu/useLayoutMenu';
|
||||
import { ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { router } from '/@/router';
|
||||
import { usePermissionStore, usePermissionStoreWithOut } from '/@/store/modules/permission';
|
||||
import { getEnvInfo, isShowNewLayout } from '/@/utils/getEnv';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { getEnvInfo } from '/@/utils/getEnv';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DefaultLayout',
|
||||
@@ -81,162 +64,6 @@
|
||||
return cls;
|
||||
});
|
||||
|
||||
const menuList = ref<any[]>([]);
|
||||
const choosePath = ref<string>('');
|
||||
|
||||
watch(
|
||||
() => route?.matched,
|
||||
(v) => {
|
||||
useUserStore().setSpecialDownPath('');
|
||||
if (v && v.length === 2) {
|
||||
let spPath = v[0]?.name ? '/' + v[0]?.name.replace('Parent', '').replace(/-/g, '/') : '';
|
||||
useUserStore().setSpecialPath(spPath);
|
||||
const p = v[1].path;
|
||||
let m = usePermissionStore().getBackMenuList;
|
||||
let f = false;
|
||||
let d = m.find((item) => {
|
||||
return item.path === spPath;
|
||||
});
|
||||
menuList.value = d?.children || [];
|
||||
menuList.value = menuList.value.filter((item) => {
|
||||
return item.hideMenu !== true;
|
||||
});
|
||||
let arr = menuList.value.map((item) => {
|
||||
return item.path;
|
||||
});
|
||||
|
||||
const pre = (list, specialDownPath) => {
|
||||
if (!list || f) return;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (arr.includes(list[i].path)) {
|
||||
specialDownPath = list[i].path;
|
||||
}
|
||||
if (list[i].path === p || (list[i]?.paramPath && list[i]?.paramPath === p)) {
|
||||
useUserStore().setSpecialDownPath(specialDownPath);
|
||||
f = true;
|
||||
break;
|
||||
} else {
|
||||
if (list[i]?.children) {
|
||||
pre(list[i].children, specialDownPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
pre(menuList.value, arr[0]);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const menuAllList = usePermissionStoreWithOut().getBackMenuList;
|
||||
const router = useRouter();
|
||||
watch(
|
||||
() => useUserStore().getSpecialPath,
|
||||
(v: string) => {
|
||||
if (isShowNewLayout(v)) {
|
||||
menuList.value = menuAllList
|
||||
? menuAllList.find((item) => {
|
||||
return item.path === v;
|
||||
})?.children || []
|
||||
: [];
|
||||
menuList.value = menuList.value.filter((item) => {
|
||||
return item.hideMenu !== true;
|
||||
});
|
||||
} else {
|
||||
menuList.value = [];
|
||||
}
|
||||
|
||||
// const toPage = (json) => {
|
||||
// if (!json?.children || json.children.length === 0) {
|
||||
// router.push(json.path);
|
||||
// } else {
|
||||
// toPage(json.children[0]);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// if (menuList.value.length > 0) {
|
||||
// toPage(menuList.value[0]);
|
||||
// }
|
||||
//
|
||||
console.log(menuList.value);
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => useUserStore().getSpecialDownPath,
|
||||
(v: string) => {
|
||||
choosePath.value = v;
|
||||
if (!v) {
|
||||
// useUserStore().setSpecialPath('');
|
||||
useUserStore().setSpecialDownPath('');
|
||||
} else {
|
||||
useUserStore().setSpecialDownPath(v);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
function clickItem(item) {
|
||||
choosePath.value = item.path;
|
||||
useUserStore().setSpecialDownPath(item.path);
|
||||
if (!item.children) {
|
||||
router.push(item.path);
|
||||
} else {
|
||||
if (
|
||||
item.children.filter((it) => {
|
||||
return !it.hideMenu;
|
||||
}).length === 0
|
||||
) {
|
||||
router.push(item.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const flag = ref<boolean>(false);
|
||||
|
||||
function preSelected(matched, list) {
|
||||
if (!list || flag.value) return;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].path === matched) {
|
||||
flag.value = true;
|
||||
break;
|
||||
} else {
|
||||
if (list[i]?.children) {
|
||||
preSelected(matched, list[i].children);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getSelected(path) {
|
||||
flag.value = false;
|
||||
let matched = route.matched;
|
||||
if (!matched || matched.length === 0 || !matched[matched.length - 1]?.path) return flag;
|
||||
for (let i = 0; i < menuList.value.length; i++) {
|
||||
if (menuList.value[i].path === path) {
|
||||
if (menuList.value[i]?.children) {
|
||||
if (flag.value) {
|
||||
break;
|
||||
}
|
||||
preSelected(matched[matched.length - 1]?.path, menuList.value[i]?.children);
|
||||
} else {
|
||||
if (matched[matched.length - 1]?.path === menuList.value[i]?.path) {
|
||||
flag.value = true;
|
||||
break;
|
||||
} else {
|
||||
flag.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag.value;
|
||||
}
|
||||
|
||||
function showNL() {
|
||||
console.log(useUserStore().getSpecialPath);
|
||||
return isShowNewLayout(useUserStore().getSpecialPath);
|
||||
}
|
||||
|
||||
console.log(showNL());
|
||||
return {
|
||||
getShowFullHeaderRef,
|
||||
getShowSidebar,
|
||||
@@ -245,13 +72,8 @@
|
||||
getIsMixSidebar,
|
||||
layoutClass,
|
||||
lockEvents,
|
||||
menuList,
|
||||
choosePath,
|
||||
clickItem,
|
||||
route,
|
||||
getSelected,
|
||||
useUserStore,
|
||||
showNL,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { useLocaleStore } from '/@/store/modules/locale';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { usePermissionStore, usePermissionStoreWithOut } from '/@/store/modules/permission';
|
||||
import { isShowNewLayout, isYT } from '/@/utils/getEnv';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -161,14 +159,16 @@
|
||||
// if (!menus || !menus.length) return null;
|
||||
return !props.isHorizontal ? (
|
||||
<SimpleMenu {...menuProps} isSplitMenu={unref(getSplit)} items={menus || []} />
|
||||
) : (<BasicMenu
|
||||
{...(menuProps as any)}
|
||||
isHorizontal={props.isHorizontal}
|
||||
type={unref(getMenuType)}
|
||||
showLogo={unref(getIsShowLogo)}
|
||||
mode={unref(getComputedMenuMode as any)}
|
||||
items={menus || []}
|
||||
/>);
|
||||
) : (
|
||||
<BasicMenu
|
||||
{...(menuProps as any)}
|
||||
isHorizontal={props.isHorizontal}
|
||||
type={unref(getMenuType)}
|
||||
showLogo={unref(getIsShowLogo)}
|
||||
mode={unref(getComputedMenuMode as any)}
|
||||
items={menus || []}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
import DragBar from './DragBar.vue';
|
||||
import { useUserStore, useUserStoreWithOut } from '/@/store/modules/user';
|
||||
import { getEnvInfo, isShowNewLayout } from '/@/utils/getEnv';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LayoutSideBar',
|
||||
@@ -180,5 +179,4 @@
|
||||
line-height: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user