Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-12-19 01:23:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f29f1a7eaf5a11a13f2a26ed5f09319c5199f9b4
f29f1a7e
1 parent
c3bfd6cb
fix(日历组件): 修复任务切换时状态未重置的问题
重置日历组件状态时清除筛选条件和恢复标记 在任务切换时强制刷新页面数据并滚动到顶部
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
7 deletions
src/components/ui/CollapsibleCalendar.vue
src/views/checkin/IndexCheckInPage.vue
src/components/ui/CollapsibleCalendar.vue
View file @
f29f1a7
<!--
* @Date: 2025-01-25 15:34:17
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-12-1
8 23:45:18
* @LastEditTime: 2025-12-1
9 01:22:52
* @FilePath: /mlaj/src/components/ui/CollapsibleCalendar.vue
* @Description: 可折叠日历组件
-->
...
...
@@ -381,6 +381,14 @@ defineExpose({
if (calendarRef.value && calendarRef.value.reset) {
calendarRef.value.reset(date || new Date())
}
// 重置筛选状态
selectedCourseId.value = ''
selectedCourseText.value = '全部作业'
// 重置恢复状态标记,防止后续 subtaskList 监听器误判为恢复模式
isRestored.value = false
// 重置头部隐藏状态
isHeaderHidden.value = false
sessionStorage.removeItem(STORAGE_KEY)
}
})
</script>
...
...
src/views/checkin/IndexCheckInPage.vue
View file @
f29f1a7
<!--
* @Date: 2025-05-29 15:34:17
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-12-19 0
0:12:31
* @LastEditTime: 2025-12-19 0
1:21:14
* @FilePath: /mlaj/src/views/checkin/IndexCheckInPage.vue
* @Description: 文件描述
-->
...
...
@@ -616,18 +616,39 @@ const onLoad = async (date) => {
loading.value = false;
};
onMounted(async () => {
const current_date = route.query.date;
const initPage = async (date) => {
// 重置数据
checkinDataList.value = [];
page.value = 0;
finished.value = false;
loading.value = false;
taskDetail.value = {};
selectedSubtaskId.value = '';
const current_date = date || route.query.date;
if (current_date) {
selectedDate.value = new Date(current_date);
getTaskDetail(dayjs(current_date).format('YYYY-MM'));
myRefCalendar.value?.reset(new Date(current_date));
await getTaskDetail(dayjs(current_date).format('YYYY-MM'));
// 确保日历组件已挂载再调用 reset
nextTick(() => {
calendarRef.value?.reset(new Date(current_date));
})
onLoad(current_date);
} else {
selectedDate.value = new Date();
getTaskDetail(dayjs().format('YYYY-MM'));
await getTaskDetail(dayjs().format('YYYY-MM'));
// 确保日历组件已挂载再调用 reset
nextTick(() => {
calendarRef.value?.reset(new Date());
})
onLoad(dayjs().format('YYYY-MM-DD'));
}
}
onMounted(async () => {
// 记录当前的taskId
lastTaskId.value = route.query.id;
await initPage(route.query.date);
// 获取作品类型数据
try {
...
...
@@ -713,12 +734,28 @@ const formatData = (data) => {
// 保存滚动位置
const savedScrollTop = ref(0)
// 记录上次的taskId,用于判断是否切换了任务
const lastTaskId = ref('')
onDeactivated(() => {
savedScrollTop.value = window.scrollY
})
onActivated(async () => {
// 检查任务ID是否变化
// 注意:route.query.id 可能是数字或字符串,统一转为字符串比较
const currentId = String(route.query.id || '')
const lastId = String(lastTaskId.value || '')
if (currentId && currentId !== lastId) {
lastTaskId.value = currentId;
// 如果任务ID变化,强制刷新整个页面数据
await initPage(route.query.date);
// 滚动到顶部
window.scrollTo(0, 0);
return;
}
// 恢复滚动位置
if (savedScrollTop.value > 0) {
setTimeout(() => {
...
...
Please
register
or
login
to post a comment