fix: prefer fallback for back button most of the time
This commit is contained in:
@@ -1,10 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter, type RouteLocationRaw } from "vue-router"
|
import { useRouter, type RouteLocationRaw } from "vue-router"
|
||||||
|
|
||||||
const props = defineProps<{ fallback?: RouteLocationRaw }>()
|
const props = withDefaults(
|
||||||
|
defineProps<{ fallback?: RouteLocationRaw; preferFallback?: boolean }>(),
|
||||||
|
{ preferFallback: true },
|
||||||
|
)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
|
if (props.preferFallback && props.fallback) {
|
||||||
|
router.push(props.fallback)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (window.history.state?.back) {
|
if (window.history.state?.back) {
|
||||||
router.back()
|
router.back()
|
||||||
} else if (props.fallback) {
|
} else if (props.fallback) {
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ watch(
|
|||||||
</span>
|
</span>
|
||||||
<article class="note-display" v-html="content"></article>
|
<article class="note-display" v-html="content"></article>
|
||||||
|
|
||||||
<BackButton :fallback="{ name: 'PublicNoteListByDidView', params: { did } }" />
|
<back-button
|
||||||
|
:fallback="{ name: 'PublicNoteListByDidView', params: { did } }"
|
||||||
|
:prefer-fallback="false"
|
||||||
|
/>
|
||||||
</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