feat: 路由参数
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user