From b37c1e94a01c31f76b5e2b72bbad63b3d79892cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9D=92=E8=8F=9C=E7=99=BD=E7=8E=89=E6=B1=A4?=
<79054161+Azir-11@users.noreply.github.com>
Date: Thu, 7 Mar 2024 22:19:06 +0800
Subject: [PATCH 1/2] style(components): Uniform icon size for header
---
src/layouts/modules/global-search/index.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/layouts/modules/global-search/index.vue b/src/layouts/modules/global-search/index.vue
index 46d954ae..e9452d3c 100644
--- a/src/layouts/modules/global-search/index.vue
+++ b/src/layouts/modules/global-search/index.vue
@@ -13,7 +13,7 @@ function handleSearch() {
-
+
From 874aaca5bbb41607b1b8067083db38bf0f2393b4 Mon Sep 17 00:00:00 2001
From: Azir-11 <2075125282@qq.com>
Date: Sun, 10 Mar 2024 05:19:21 +0800
Subject: [PATCH 2/2] feat(projects): Add route meta parameter:fixedQuery
---
src/layouts/modules/global-menu/base-menu.vue | 7 +++++++
src/store/modules/route/index.ts | 15 +++++++++++++--
src/typings/router.d.ts | 2 ++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/layouts/modules/global-menu/base-menu.vue b/src/layouts/modules/global-menu/base-menu.vue
index 3b7fb93b..c020c73d 100644
--- a/src/layouts/modules/global-menu/base-menu.vue
+++ b/src/layouts/modules/global-menu/base-menu.vue
@@ -57,6 +57,13 @@ function updateExpandedKeys() {
}
function handleClickMenu(key: RouteKey) {
+ const meta = routeStore.getSelectedMenuMetaByKey(key);
+ if (meta?.fixedQuery) {
+ routerPushByKey(key, {
+ query: meta.fixedQuery
+ });
+ return;
+ }
routerPushByKey(key);
}
diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts
index 04e41699..c09f5099 100644
--- a/src/store/modules/route/index.ts
+++ b/src/store/modules/route/index.ts
@@ -1,5 +1,5 @@
import { computed, ref } from 'vue';
-import type { RouteRecordRaw } from 'vue-router';
+import type { RouteMeta, RouteRecordRaw } from 'vue-router';
import { defineStore } from 'pinia';
import { useBoolean } from '@sa/hooks';
import type { CustomRoute, ElegantConstRoute, LastLevelRouteKey, RouteKey, RouteMap } from '@elegant-router/types';
@@ -273,6 +273,16 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
return getSelectedMenuKeyPathByKey(selectedKey, menus.value);
}
+ /**
+ * Get selected menu meta by key
+ *
+ * @param selectedKey Selected menu key
+ */
+ function getSelectedMenuMetaByKey(selectedKey: string): RouteMeta | null {
+ // The routes in router.options.routes are static, you need to use router.getRoutes() to get all the routes.
+ return router.getRoutes().find(route => route.name === selectedKey)?.meta || null;
+ }
+
return {
resetStore,
routeHome,
@@ -287,6 +297,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
isInitAuthRoute,
setIsInitAuthRoute,
getIsAuthRouteExist,
- getSelectedMenuKeyPath
+ getSelectedMenuKeyPath,
+ getSelectedMenuMetaByKey
};
});
diff --git a/src/typings/router.d.ts b/src/typings/router.d.ts
index adcb5400..bf4c667b 100644
--- a/src/typings/router.d.ts
+++ b/src/typings/router.d.ts
@@ -59,5 +59,7 @@ declare module 'vue-router' {
multiTab?: boolean;
/** If set, the route will be fixed in tabs, and the value is the order of fixed tabs */
fixedIndexInTab?: number;
+ /** Fixed query parameters that are automatically carried when entering the route */
+ fixedQuery?: Record;
}
}