fix back button on item pages after login (#16218)

This commit is contained in:
Azri Kahar
2022-11-02 04:56:00 +08:00
committed by GitHub
parent 8c5cda446a
commit 995f92f7c2
3 changed files with 38 additions and 3 deletions

View File

@@ -42,7 +42,7 @@
icon
secondary
exact
@click="router.back()"
@click="navigateBack"
>
<v-icon name="arrow_back" />
</v-button>
@@ -365,6 +365,16 @@ const disabledOptions = computed(() => {
return [];
});
function navigateBack() {
const backState = router.options.history.state.back;
if (typeof backState !== 'string' || !backState.startsWith('/login')) {
router.back();
return;
}
router.push(`/content/${props.collection}`);
}
function useBreadcrumb() {
const breadcrumb = computed(() => [
{

View File

@@ -2,7 +2,7 @@
<files-not-found v-if="!loading && !item" />
<private-view v-else :title="loading || !item ? t('loading') : item.title">
<template #title-outer:prepend>
<v-button class="header-icon" rounded icon secondary exact @click="router.back()">
<v-button class="header-icon" rounded icon secondary exact @click="navigateBack">
<v-icon name="arrow_back" />
</v-button>
</template>
@@ -288,6 +288,20 @@ const fieldsFiltered = computed(() => {
return fields.value.filter((field: Field) => fieldsDenyList.includes(field.field) === false);
});
function navigateBack() {
const backState = router.options.history.state.back;
if (typeof backState !== 'string' || !backState.startsWith('/login')) {
router.back();
return;
}
if (item?.value?.folder) {
router.push(`/files/folders/${item.value.folder}`);
} else {
router.push('/files');
}
}
function useBreadcrumb() {
const breadcrumb = computed(() => {
if (!item?.value?.folder) {

View File

@@ -1,7 +1,7 @@
<template>
<private-view :title="title">
<template #title-outer:prepend>
<v-button class="header-icon" rounded icon secondary exact @click="router.back()">
<v-button class="header-icon" rounded icon secondary exact @click="navigateBack">
<v-icon name="arrow_back" />
</v-button>
</template>
@@ -328,6 +328,7 @@ export default defineComponent({
item,
loading,
isNew,
navigateBack,
breadcrumb,
edits,
hasEdits,
@@ -369,6 +370,16 @@ export default defineComponent({
isSavable,
};
function navigateBack() {
const backState = router.options.history.state.back;
if (typeof backState !== 'string' || !backState.startsWith('/login')) {
router.back();
return;
}
router.push('/users');
}
function useBreadcrumb() {
const breadcrumb = computed(() => [
{