forked from verdnatura/salix-front
feat: refs #6891 improve useRedirect
This commit is contained in:
parent
7b370e6b93
commit
80336868dc
|
@ -13,12 +13,11 @@ export default function useRedirect() {
|
|||
const { matched: matches } = router.currentRoute.value;
|
||||
const { path } = matches.at(-1);
|
||||
|
||||
if (data.length === 1)
|
||||
return router.push({
|
||||
path: path.replace(/\/(list|-list|:id)/, `/${data[0].id}`),
|
||||
});
|
||||
let to = path.replace(/:id.*/, '');
|
||||
|
||||
router.push({ path: path.replace(/:id.*/, '') });
|
||||
if (data.length === 1) to = path.replace(/\/(list|-list|:id)/, `/${data[0].id}`);
|
||||
|
||||
router.push({ path: to });
|
||||
};
|
||||
|
||||
return { navigate };
|
||||
|
|
Loading…
Reference in New Issue