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