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,
});
}
};

View File

@@ -95,7 +95,11 @@ onMounted(() => {
<template>
<div>
<Modal :fullscreen-button="false" class="w-[600px]" header-class="py-2">
<Modal
:fullscreen-button="false"
class="w-[600px]"
header-class="py-2 border-b"
>
<template #title>
<div class="flex items-center">
<Search class="text-muted-foreground mr-2 size-4" />