Showing
2 changed files
with
14 additions
and
2 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-01-25 15:34:17 | 2 | * @Date: 2025-01-25 15:34:17 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-18 23:23:57 | 4 | + * @LastEditTime: 2025-12-18 23:28:38 |
| 5 | * @FilePath: /mlaj/src/components/ui/CollapsibleCalendar.vue | 5 | * @FilePath: /mlaj/src/components/ui/CollapsibleCalendar.vue |
| 6 | * @Description: 可折叠日历组件 | 6 | * @Description: 可折叠日历组件 |
| 7 | --> | 7 | --> | ... | ... |
| ... | @@ -139,7 +139,7 @@ | ... | @@ -139,7 +139,7 @@ |
| 139 | 139 | ||
| 140 | <script setup> | 140 | <script setup> |
| 141 | import { ref, onBeforeUnmount, onMounted, computed, nextTick, getCurrentInstance } from 'vue' | 141 | import { ref, onBeforeUnmount, onMounted, computed, nextTick, getCurrentInstance } from 'vue' |
| 142 | -import { useRoute, useRouter } from 'vue-router' | 142 | +import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router' |
| 143 | import { showConfirmDialog, showSuccessToast, showFailToast, showLoadingToast } from 'vant'; | 143 | import { showConfirmDialog, showSuccessToast, showFailToast, showLoadingToast } from 'vant'; |
| 144 | import AppLayout from "@/components/layout/AppLayout.vue"; | 144 | import AppLayout from "@/components/layout/AppLayout.vue"; |
| 145 | import FrostedGlass from "@/components/ui/FrostedGlass.vue"; | 145 | import FrostedGlass from "@/components/ui/FrostedGlass.vue"; |
| ... | @@ -624,6 +624,18 @@ onMounted(async () => { | ... | @@ -624,6 +624,18 @@ onMounted(async () => { |
| 624 | } | 624 | } |
| 625 | }) | 625 | }) |
| 626 | 626 | ||
| 627 | +/** | ||
| 628 | + * 路由离开守卫 | ||
| 629 | + * 只有跳转到打卡详情页(我要打卡/编辑)时保留筛选状态 | ||
| 630 | + * 其他情况离开页面都清除筛选缓存 | ||
| 631 | + */ | ||
| 632 | +onBeforeRouteLeave((to, from) => { | ||
| 633 | + // 检查目标路径是否是打卡详情页 | ||
| 634 | + if (!to.path.startsWith('/checkin/detail')) { | ||
| 635 | + sessionStorage.removeItem('collapsible_calendar_filter_state') | ||
| 636 | + } | ||
| 637 | +}) | ||
| 638 | + | ||
| 627 | const formatData = (data) => { | 639 | const formatData = (data) => { |
| 628 | let formattedData = []; | 640 | let formattedData = []; |
| 629 | formattedData = data?.checkin_list.map((item, index) => { | 641 | formattedData = data?.checkin_list.map((item, index) => { | ... | ... |
-
Please register or login to post a comment