mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 06:40:51 +08:00
feat: menu supports carrying default query (#4687)
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -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" />
|
||||
|
Reference in New Issue
Block a user