feat: fallback for back button
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -17,7 +17,7 @@ const author = computedAsync(async () => getUniqueAka(did.value))
|
||||
<template>
|
||||
<main class="public-note-list-view">
|
||||
<h1>{{ author?.alias ?? did }}</h1>
|
||||
<back-button class="back-button" />
|
||||
<back-button class="back-button" :fallback="{ name: 'Home' }" />
|
||||
<div v-if="isLoading"></div>
|
||||
<div v-else>
|
||||
<ul
|
||||
|
||||
@@ -10,7 +10,7 @@ const { notes, isLoading, canLoadMore, onLoadMore, getAlias } =
|
||||
<template>
|
||||
<main class="public-note-list-view">
|
||||
<h1>Remanso notes</h1>
|
||||
<back-button class="back-button" />
|
||||
<back-button class="back-button" :fallback="{ name: 'Home' }" />
|
||||
<div v-if="isLoading"></div>
|
||||
<div v-else>
|
||||
<ul
|
||||
|
||||
@@ -99,7 +99,7 @@ watch(
|
||||
</span>
|
||||
<article class="note-display" v-html="content"></article>
|
||||
|
||||
<BackButton />
|
||||
<BackButton :fallback="{ name: 'PublicNoteListByDidView', params: { did } }" />
|
||||
</div>
|
||||
<stacked-public-note
|
||||
v-for="(stackedNote, index) in stackedNotes"
|
||||
|
||||
Reference in New Issue
Block a user