From 0af2c4cc6330c4f18ff93996f7a4662907880a6f Mon Sep 17 00:00:00 2001 From: Sunwuyuan Date: Sun, 9 Nov 2025 16:15:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E6=B8=85=E7=A9=BA=E6=95=B0=E6=8D=AE=E4=BB=A5?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E8=A6=86=E7=9B=96=E7=8E=B0=E6=9C=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/index.vue b/src/pages/index.vue index 9f4cb37..e189c42 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -1283,7 +1283,7 @@ export default { await Promise.all([this.downloadData(), this.loadConfig()]); }, - async downloadData() { + async downloadData(forceClear = false) { if (this.loading.download) return; try { @@ -1296,8 +1296,8 @@ export default { if (response.error.code === "NOT_FOUND") { this.state.showNoDataMessage = true; this.state.noDataMessage = response.error.message; - // 只有当前没有数据时才设置为空,避免覆盖已有的本地数据 - if (!this.state.boardData || (!this.state.boardData.homework && !this.state.boardData.attendance)) { + // 如果强制清空或当前没有数据时才设置为空 + if (forceClear || !this.state.boardData || (!this.state.boardData.homework && !this.state.boardData.attendance)) { this.state.boardData = { homework: {}, attendance: { absent: [], late: [], exclude: [] }, @@ -1320,11 +1320,11 @@ export default { this.$message.success("下载成功", "数据已更新"); } } catch (error) { - // 数据加载失败时不覆盖现有数据,只显示错误信息 + // 数据加载失败时的处理 console.error("数据加载失败:", error); this.$message.error("下载失败", error.message); - // 如果当前没有任何数据,才初始化为空数据 - if (!this.state.boardData || (!this.state.boardData.homework && !this.state.boardData.attendance)) { + // 如果强制清空或当前没有任何数据,才初始化为空数据 + if (forceClear || !this.state.boardData || (!this.state.boardData.homework && !this.state.boardData.attendance)) { this.state.boardData = { homework: {}, attendance: { absent: [], late: [], exclude: [] }, @@ -1615,8 +1615,8 @@ export default { }) .catch(() => {}); - // Load both data and subjects in parallel - await Promise.all([this.downloadData(), this.loadSubjects()]); + // Load both data and subjects in parallel, force clear data when switching dates + await Promise.all([this.downloadData(true), this.loadSubjects()]); } } catch (error) { console.error("Date processing error:", error);