feat: fallback for back button

This commit is contained in:
Julien Calixte
2026-02-15 19:59:11 +01:00
parent 8e754021bd
commit 1d4e3e3d0a
4 changed files with 15 additions and 5 deletions

View File

@@ -1,8 +1,18 @@
<script setup lang="ts">
import { useRouter } from "vue-router"
import { useRouter, type RouteLocationRaw } from "vue-router"
const props = defineProps<{ fallback?: RouteLocationRaw }>()
const router = useRouter()
const goBack = () => router.back()
const goBack = () => {
if (window.history.state?.back) {
router.back()
} else if (props.fallback) {
router.push(props.fallback)
} else {
router.back()
}
}
</script>
<template>