Skip to content

Commit aa288eb

Browse files
committed
close button on advancedcardviewpage now only router.backs if there is something to go back otherwise it goes to main page
1 parent 89217eb commit aa288eb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/views/AdvancedCardViewPage.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<div class="h-screen bg-black text-white flex lg:h-[80vh] p-16 lg:p-8"/>
33
<CardviewModal
44
:id="state.id"
5-
@close="$router.back()"
5+
@close="onClose"
66
/>
77
</template>
88

99
<script setup lang="ts">
1010
import CardviewModal from "@/components/modals/CardviewModal.vue";
1111
import { onMounted, reactive } from "vue";
12-
import { useRoute } from "vue-router";
12+
import { useRoute, useRouter } from "vue-router";
1313
1414
const initialState: {
1515
id: number;
@@ -18,6 +18,7 @@ const initialState: {
1818
};
1919
2020
const route = useRoute();
21+
const router = useRouter();
2122
const state = reactive(initialState);
2223
2324
onMounted(() => {
@@ -26,4 +27,12 @@ onMounted(() => {
2627
state.id = id;
2728
}
2829
});
30+
31+
const onClose = () => {
32+
if (router.options.history.state.back) {
33+
router.back();
34+
} else {
35+
router.push('/');
36+
}
37+
}
2938
</script>

0 commit comments

Comments
 (0)