mirror of
				https://github.com/soybeanjs/soybean-admin.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	Merge branch 'main' into example
This commit is contained in:
		@@ -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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ function handleSearch() {
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
  <ButtonIcon :tooltip-content="$t('common.search')" @click="handleSearch">
 | 
			
		||||
    <icon-uil-search class="text-20px" />
 | 
			
		||||
    <icon-uil-search />
 | 
			
		||||
  </ButtonIcon>
 | 
			
		||||
  <SearchModal v-model:show="show" />
 | 
			
		||||
</template>
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
  };
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								src/typings/router.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/typings/router.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -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<string, string>;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user