feat: 路由参数

This commit is contained in:
dap
2024-10-10 11:48:26 +08:00
parent fffe2d0db9
commit 60d513ce40
8 changed files with 124 additions and 6 deletions

View File

@@ -1,14 +1,21 @@
import { useRouter } from 'vue-router';
import { isHttpUrl, openWindow } from '@vben/utils';
import { isHttpUrl, isObject, openWindow } from '@vben/utils';
function useNavigation() {
const router = useRouter();
const allRoutes = router.getRoutes();
const navigation = async (path: string) => {
if (isHttpUrl(path)) {
openWindow(path, { target: '_blank' });
} else {
// 带路由参数
const found = allRoutes.find((item) => item.path === path);
if (found && isObject(found.meta.query)) {
await router.push({ path, query: found.meta.query });
return;
}
await router.push(path);
}
};