From 5c3fa9a0e50a3a021a0cee95cd42bb451987d991 Mon Sep 17 00:00:00 2001 From: SunWuyuan Date: Sun, 2 Nov 2025 11:46:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E5=B7=B2=E6=9C=89=E7=9A=84=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index.vue | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/pages/index.vue b/src/pages/index.vue index 0913050..39f26a0 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -1251,10 +1251,13 @@ export default { if (response.error.code === "NOT_FOUND") { this.state.showNoDataMessage = true; this.state.noDataMessage = response.error.message; - this.state.boardData = { - homework: {}, - attendance: { absent: [], late: [], exclude: [] }, - }; + // 只有当前没有数据时才设置为空,避免覆盖已有的本地数据 + if (!this.state.boardData || (!this.state.boardData.homework && !this.state.boardData.attendance)) { + this.state.boardData = { + homework: {}, + attendance: { absent: [], late: [], exclude: [] }, + }; + } } else { throw new Error(response.error.message); } @@ -1272,11 +1275,16 @@ export default { this.$message.success("下载成功", "数据已更新"); } } catch (error) { - this.state.boardData = { - homework: {}, - attendance: { absent: [], late: [], exclude: [] }, - }; + // 数据加载失败时不覆盖现有数据,只显示错误信息 + console.error("数据加载失败:", error); this.$message.error("下载失败", error.message); + // 如果当前没有任何数据,才初始化为空数据 + if (!this.state.boardData || (!this.state.boardData.homework && !this.state.boardData.attendance)) { + this.state.boardData = { + homework: {}, + attendance: { absent: [], late: [], exclude: [] }, + }; + } } finally { this.loading.download = false; }