diff --git a/src/layouts/common/GlobalHeader/index.vue b/src/layouts/common/GlobalHeader/index.vue
index 3d16a09e8..d31ddee2f 100644
--- a/src/layouts/common/GlobalHeader/index.vue
+++ b/src/layouts/common/GlobalHeader/index.vue
@@ -9,6 +9,7 @@
+
@@ -22,6 +23,7 @@ import { DarkModeContainer } from '@/components';
import { useThemeStore } from '@/store';
import type { GlobalHeaderProps } from '@/interface';
import GlobalLogo from '../GlobalLogo/index.vue';
+import GlobalSearch from '../GlobalSearch/index.vue';
import {
MenuCollapse,
GlobalBreadcrumb,
diff --git a/src/layouts/common/GlobalSearch/components/SearchFooter.vue b/src/layouts/common/GlobalSearch/components/SearchFooter.vue
new file mode 100644
index 000000000..f7a1d868d
--- /dev/null
+++ b/src/layouts/common/GlobalSearch/components/SearchFooter.vue
@@ -0,0 +1,24 @@
+
+
+
+
+ 确认
+
+
+
+
+ 切换
+
+
+
+ 关闭
+
+
+
+
+
+
diff --git a/src/layouts/common/GlobalSearch/components/SearchModal.vue b/src/layouts/common/GlobalSearch/components/SearchModal.vue
new file mode 100644
index 000000000..6657284d3
--- /dev/null
+++ b/src/layouts/common/GlobalSearch/components/SearchModal.vue
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/layouts/common/GlobalSearch/components/SearchResult.vue b/src/layouts/common/GlobalSearch/components/SearchResult.vue
new file mode 100644
index 000000000..13ff1747d
--- /dev/null
+++ b/src/layouts/common/GlobalSearch/components/SearchResult.vue
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+ {{ item.meta?.title }}
+
+
+
+
+
+
+
+
+
diff --git a/src/layouts/common/GlobalSearch/components/index.ts b/src/layouts/common/GlobalSearch/components/index.ts
new file mode 100644
index 000000000..acfa0425e
--- /dev/null
+++ b/src/layouts/common/GlobalSearch/components/index.ts
@@ -0,0 +1,3 @@
+import SearchModal from './SearchModal.vue';
+
+export { SearchModal };
diff --git a/src/layouts/common/GlobalSearch/components/types.ts b/src/layouts/common/GlobalSearch/components/types.ts
new file mode 100644
index 000000000..9319664aa
--- /dev/null
+++ b/src/layouts/common/GlobalSearch/components/types.ts
@@ -0,0 +1 @@
+export type RouteList = AuthRoute.Route;
diff --git a/src/layouts/common/GlobalSearch/index.vue b/src/layouts/common/GlobalSearch/index.vue
new file mode 100644
index 000000000..e0ae174e8
--- /dev/null
+++ b/src/layouts/common/GlobalSearch/index.vue
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts
index 1f094510d..13d2cf7a5 100644
--- a/src/store/modules/route/index.ts
+++ b/src/store/modules/route/index.ts
@@ -1,7 +1,13 @@
import type { Router } from 'vue-router';
import { defineStore } from 'pinia';
import { fetchUserRoutes } from '@/service';
-import { getUserInfo, transformAuthRouteToMenu, transformAuthRoutesToVueRoutes, getCacheRoutes } from '@/utils';
+import {
+ getUserInfo,
+ transformAuthRouteToMenu,
+ transformAuthRoutesToVueRoutes,
+ transformRouteToList,
+ getCacheRoutes
+} from '@/utils';
import type { GlobalMenuOption } from '@/interface';
import { useTabStore } from '../tab';
@@ -12,6 +18,7 @@ interface RouteState {
routeHomeName: AuthRoute.RouteKey;
/** 菜单 */
menus: GlobalMenuOption[];
+ menusList: AuthRoute.Route[];
/** 缓存的路由名称 */
cacheRoutes: string[];
}
@@ -21,6 +28,7 @@ export const useRouteStore = defineStore('route-store', {
isAddedDynamicRoute: false,
routeHomeName: 'dashboard_analysis',
menus: [],
+ menusList: [],
cacheRoutes: []
}),
actions: {
@@ -37,6 +45,7 @@ export const useRouteStore = defineStore('route-store', {
if (data) {
this.routeHomeName = data.home;
this.menus = transformAuthRouteToMenu(data.routes);
+ this.menusList = transformRouteToList(data.routes);
const vueRoutes = transformAuthRoutesToVueRoutes(data.routes);
vueRoutes.forEach(route => {
diff --git a/src/utils/router/helpers.ts b/src/utils/router/helpers.ts
index 519a4c7a3..5e8e1ae84 100644
--- a/src/utils/router/helpers.ts
+++ b/src/utils/router/helpers.ts
@@ -13,6 +13,20 @@ export function transformAuthRoutesToVueRoutes(routes: AuthRoute.Route[]) {
return routes.map(route => transformAuthRouteToVueRoute(route)).flat(1);
}
+/** 将路由转换成菜单列表 */
+export function transformRouteToList(routes: AuthRoute.Route[], treeMap: AuthRoute.Route[] = []) {
+ if (routes && routes.length === 0) return [];
+ return routes.reduce((acc, cur) => {
+ if (!cur.meta?.hide) {
+ acc.push(cur);
+ }
+ if (cur.children && cur.children.length > 0) {
+ transformRouteToList(cur.children, treeMap);
+ }
+ return acc;
+ }, treeMap);
+}
+
/**
* 将单个权限路由转换成vue路由
* @param route - 权限路由