fix: keep other chart profiles locally on cloud sync failure

This commit is contained in:
732642856
2026-07-20 16:56:46 +08:00
parent 94cf431b9e
commit ba7f962c71
4 changed files with 128 additions and 21 deletions
+9 -6
View File
@@ -1445,12 +1445,13 @@ export default function Home() {
profile: nextProfile,
updatedAt: timestamp(),
};
let cloudSaved = false;
try {
record = await saveCloudChartProfile(record);
} catch (caught) {
setProfileNotice("");
setAccountError(friendlyError(caught instanceof Error ? caught.message : "云端星盘保存失败,稍后重试。"));
return;
cloudSaved = true;
} catch {
setProfileNotice("已保存到本地星盘库;云端同步失败,稍后会继续使用本地记录。");
setAccountError("");
}
setChartLibrary((current) => {
const next = [...upsertSelfChart(current, profile), record];
@@ -1458,8 +1459,10 @@ export default function Home() {
return next;
});
setOtherProfileDraft(emptyProfile);
setAccountError("");
setProfileNotice("已保存到云端星盘库。");
if (cloudSaved) {
setAccountError("");
setProfileNotice("已保存到云端星盘库。");
}
}
async function deleteOtherChart(recordId: string) {