feat: menu supports carrying default query (#4687)

This commit is contained in:
Vben
2024-10-19 19:50:23 +08:00
committed by GitHub
parent 0df8c5c02c
commit 477a05c26c
21 changed files with 94 additions and 29 deletions

View File

@@ -4,12 +4,24 @@ import { isHttpUrl, openWindow } from '@vben/utils';
function useNavigation() {
const router = useRouter();
const routes = router.getRoutes();
const routeMetaMap = new Map<string, any>();
routes.forEach((route) => {
routeMetaMap.set(route.path, route.meta);
});
const navigation = async (path: string) => {
if (isHttpUrl(path)) {
openWindow(path, { target: '_blank' });
} else {
await router.push(path);
const meta = routeMetaMap.get(path);
const query = meta?.query ?? {};
await router.push({
path,
query,
});
}
};