update
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user