fix routing for query params

This commit is contained in:
Gauthier Roebroeck 2026-01-09 14:20:10 +08:00
parent 7b0c327803
commit 543b936c12
3 changed files with 11 additions and 5 deletions

View file

@ -6,17 +6,23 @@
</template>
<script lang="ts" setup>
import { watchImmediate } from '@vueuse/core'
const route = useRoute('/libraries/[id]')
const router = useRouter()
const libraryId = computed(() => route.params.id)
//TODO: for now we always redirect to 'recommended', this should be persisted per libraryId
watch(libraryId, () => {
void router.push({ name: '/libraries/[id]/recommended', params: { id: libraryId.value } })
watchImmediate(libraryId, () => {
void router.replace({
name: '/libraries/[id]/series',
params: { id: libraryId.value },
query: route.query,
})
})
</script>
<route lang="yaml">
meta:
requiresRole: ADMIN
requiresRole: USER
</route>

View file

@ -156,7 +156,7 @@ async function submitForm() {
rememberMe: appStore.rememberMe,
})
.then(() => {
if (route.query.redirect) void router.push({ path: route.query.redirect.toString() })
if (route.query.redirect) void router.push(route.query.redirect.toString())
else void router.push('/')
})
.catch((error) => {

View file

@ -38,7 +38,7 @@ async function checkAuthenticated() {
if (claimError.value) {
await router.push({ name: '/error' })
} else if (data.value) {
if (route.query.redirect) await router.push({ path: route.query.redirect.toString() })
if (route.query.redirect) await router.push(route.query.redirect.toString())
else await router.push('/')
} else if (error.value) {
if (claimData.value?.isClaimed)