feat: support shared pet care tasks and smooth daily page return
ci-cd / verify (push) Successful in 2m18s
ci-cd / deploy (push) Skipped

This commit is contained in:
2026-10-05 20:20:05 +08:00
parent fbc1eda561
commit 3175936266
16 changed files with 196 additions and 119 deletions
+24
View File
@@ -6,6 +6,10 @@ function dateLabel() {
const now = new Date();
return `${now.getMonth() + 1}月${now.getDate()}日 周${"日一二三四五六"[now.getDay()]}`;
}
function accountKey() {
const state = getApp().globalData || {};
return (state.user && state.user.id) || state.token || "";
}
Page({
data: {
locationName: "当前位置",
@@ -23,13 +27,32 @@ Page({
phase: "auth",
error: "",
},
onLoad() {
const cached = getApp().homeSnapshot;
if (cached && cached.account === accountKey() && cached.date === localDate()) {
this.setData({ ...cached.data, ready: true, phase: "ready", loading: false });
}
},
onShow() {
this.applyEnvironment(environment.cached());
this.load();
},
onHide() {
this.rememberHome();
},
onUnload() {
this.rememberHome();
this.disposed = true;
},
rememberHome() {
if (!this.data.ready || !accountKey()) return;
const { pets, selected, tasks, undoneCount, walkCount, name } = this.data;
getApp().homeSnapshot = {
account: accountKey(),
date: localDate(),
data: { pets, selected, tasks, undoneCount, walkCount, name },
};
},
updateEnvironmentLabel() {
this.setData({
headerSubtitle:
@@ -112,6 +135,7 @@ Page({
ready: true,
phase: "ready",
});
this.rememberHome();
// Location permission and weather never hold up the first usable screen.
this.refreshEnvironment();
} catch (error) {