This commit is contained in:
2026-01-05 16:47:31 +08:00
parent 1c908284e6
commit 49597a4dd2
7 changed files with 100 additions and 14 deletions
@@ -14,6 +14,7 @@
import { formatStr, sleepCharts } from '/@/components/secondaryScreen/screen-right/screenRightHooks';
import { getSleep } from '/@/components/secondaryScreen/commonApi.ts';
import { useSession, caching } from '/@/hooks/autoRefresh/caching.ts';
import { useMonitorStore } from '/@/store/modules/monitor.ts';
const { setSession, getSession } = useSession();
const { PAGE2_RIGHT1 } = caching;
@@ -40,6 +41,8 @@
avg: '',
});
const monitorStore = useMonitorStore();
async function init() {
try {
const params = {
@@ -47,13 +50,17 @@
type: props.type,
};
const { code, result } = await getSleep(params);
if (code == 200 && result.length > 0) {
setSession(PAGE2_RIGHT1, JSON.stringify(result));
setValue(result);
if (code == 200) {
if (result?.sleepInfo && result?.sleepInfo.length > 0) {
setSession(PAGE2_RIGHT1, JSON.stringify(result));
setValue(result?.sleepInfo || []);
}
monitorStore.setFourTips(result?.peopleSum || 0);
}
} catch {
const result = JSON.parse(getSession(PAGE2_RIGHT1) || '{}');
setValue(result);
setValue(result?.sleepInfo || []);
monitorStore.setFourTips(result?.peopleSum || 0);
}
}