1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-12-07 13:03:59 +00:00

fix: 优化数据加载逻辑,避免覆盖已有的本地数据

This commit is contained in:
SunWuyuan 2025-11-02 11:46:24 +08:00
parent a7ff0e5714
commit 5c3fa9a0e5
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64

View File

@ -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;
}