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