feat: 可配置首页菜单显示与隐藏 (#539)

* feat: 可配置首页显示与隐藏
This commit is contained in:
RealityBoy
2023-05-05 22:55:12 +08:00
committed by GitHub
parent d49b23e8f9
commit 9d0c3f305d
19 changed files with 4850 additions and 2053 deletions

View File

@@ -1,5 +1,6 @@
<script setup lang="ts">
import { isEqual } from "@pureadmin/utils";
import { routerArrays } from "@/layout/types";
import { transformI18n } from "@/plugins/i18n";
import { ref, watch, onMounted, toRaw } from "vue";
import { getParentPaths, findRouteByPath } from "@/router/utils";
@@ -10,14 +11,9 @@ const route = useRoute();
const levelList = ref([]);
const router = useRouter();
const routes: any = router.options.routes;
const { VITE_HIDE_HOME } = import.meta.env;
const multiTags: any = useMultiTagsStoreHook().multiTags;
const isDashboard = (route: RouteLocationMatched): boolean | string => {
const name = route && (route.name as string);
if (!name) return false;
return name.trim().toLocaleLowerCase() === "Welcome".toLocaleLowerCase();
};
const getBreadcrumb = (): void => {
// 当前路由信息
let currentRoute;
@@ -35,7 +31,7 @@ const getBreadcrumb = (): void => {
}
});
} else {
currentRoute = findRouteByPath(router.currentRoute.value.path, multiTags);
currentRoute = findRouteByPath(router.currentRoute.value.path, routes);
}
// 当前路由的父级路径组成的数组
const parentRoutes = getParentPaths(
@@ -53,15 +49,7 @@ const getBreadcrumb = (): void => {
if (currentRoute?.path !== "/welcome") matched.push(currentRoute);
if (!isDashboard(matched[0])) {
matched = [
{
path: "/welcome",
parentPath: "/",
meta: { title: "menus.hshome" }
} as unknown as RouteLocationMatched
].concat(matched);
}
if (VITE_HIDE_HOME === "false") matched = routerArrays.concat(matched);
matched.forEach((item, index) => {
if (currentRoute?.query || currentRoute?.params) return;