From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/layout/components/TabMenu/src/helper.ts | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/src/layout/components/TabMenu/src/helper.ts b/src/layout/components/TabMenu/src/helper.ts
new file mode 100644
index 0000000..cce3932
--- /dev/null
+++ b/src/layout/components/TabMenu/src/helper.ts
@@ -0,0 +1,51 @@
+import { getAllParentPath } from '@/layout/components/Menu/src/helper'
+import type { RouteMeta } from 'vue-router'
+import { isUrl } from '@/utils/is'
+import { cloneDeep } from 'lodash-es'
+
+export type TabMapTypes = {
+ [key: string]: string[]
+}
+
+export const tabPathMap = reactive<TabMapTypes>({})
+
+export const initTabMap = (routes: AppRouteRecordRaw[]) => {
+ for (const v of routes) {
+ const meta = (v.meta ?? {}) as RouteMeta
+ if (!meta?.hidden) {
+ tabPathMap[v.path] = []
+ }
+ }
+}
+
+export const filterMenusPath = (
+ routes: AppRouteRecordRaw[],
+ allRoutes: AppRouteRecordRaw[]
+): AppRouteRecordRaw[] => {
+ const res: AppRouteRecordRaw[] = []
+ for (const v of routes) {
+ let data: Nullable<AppRouteRecordRaw> = null
+ const meta = (v.meta ?? {}) as RouteMeta
+ if (!meta.hidden || meta.canTo) {
+ const allParentPath = getAllParentPath<AppRouteRecordRaw>(allRoutes, v.path)
+
+ const fullPath = isUrl(v.path) ? v.path : allParentPath.join('/')
+
+ data = cloneDeep(v)
+ data.path = fullPath
+ if (v.children && data) {
+ data.children = filterMenusPath(v.children, allRoutes)
+ }
+
+ if (data) {
+ res.push(data)
+ }
+
+ if (allParentPath.length && Reflect.has(tabPathMap, allParentPath[0])) {
+ tabPathMap[allParentPath[0]].push(fullPath)
+ }
+ }
+ }
+
+ return res
+}
--
Gitblit v1.8.0