ebike-plus-ui/src/hooks/useRoutingMethod.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-04-20 16:54:12 +08:00
import pinia from "@/store/index";
import { storeToRefs } from "pinia";
import { useRoutesListStore } from "@/store/modules/route-list";
2024-04-20 16:54:12 +08:00
/**
* hooks
* @returns
*/
export const useRoutingMethod = () => {
/**
*
* @param {string} key name
* @returns undefined则表示未找到
*/
const findLinearArray = (key: string) => {
const routerStore = useRoutesListStore(pinia);
const { routeList } = storeToRefs(routerStore);
return routeList.value.find((item: Menu.MenuOptions) => item.name == key);
};
/**
* tabs路由中查找路由
* @param {string} key name
* @returns undefined则表示未找到
*/
const findTagsList = (key: string) => {
const routerStore = useRoutesListStore(pinia);
const { tabsList } = storeToRefs(routerStore);
return tabsList.value.find((item: Menu.MenuOptions) => item.name == key);
};
return {
findLinearArray,
findTagsList
};
};