뒤로가기 수정

This commit is contained in:
yoon 2025-03-31 18:47:26 +09:00
parent 12297153e4
commit 551569c1c6
3 changed files with 31 additions and 5 deletions

View File

@ -582,7 +582,7 @@
/* commuters */
.commuter-list {
max-height: 358px;
max-height: 450px;
overflow-y: auto;
scrollbar-width: none;
}

View File

@ -2,6 +2,7 @@
<!-- 뒤로가기 -->
<button
@click="goBack"
:disabled="!canGoBack"
:class="{ 'shifted': showButton }"
class="back-btn rounded-pill btn-icon btn-secondary position-fixed shadow z-5 border-0">
<i class='bx bx-chevron-left'></i>
@ -18,29 +19,54 @@
</template>
<script setup>
import { ref, onMounted, onUnmounted } from "vue";
import { ref, onMounted, onUnmounted, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
const showButton = ref(false);
const canGoBack = ref(false);
const route = useRoute();
const router = useRouter();
const loginPage = "/login"; //
//
const handleScroll = () => {
showButton.value = window.scrollY > 200;
};
//
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" });
};
//
const goBack = () => {
window.history.back();
if (canGoBack.value) {
router.back();
}
};
//
const updateCanGoBack = () => {
const historyBack = router.options.history.state.back;
const previousPage = document.referrer;
canGoBack.value = !!historyBack && historyBack !== loginPage && !previousPage.includes(loginPage);
};
//
onMounted(() => {
window.addEventListener("scroll", handleScroll);
updateCanGoBack();
});
// `canGoBack`
watch(route, () => {
updateCanGoBack();
});
//
onUnmounted(() => {
window.removeEventListener("scroll", handleScroll);
});
</script>
</script>

View File

@ -1,5 +1,5 @@
<template>
<div class="container-xxl flex-grow-1 container-p-y pb-0">
<div class="container-xxl flex-grow-1 container-p-y">
<div class="card app-calendar-wrapper">
<div class="row g-0">
<div class="col-3 border-end text-center" id="app-calendar-sidebar">