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