|
@@ -43,6 +43,12 @@
|
|
|
return div.innerHTML;
|
|
return div.innerHTML;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 日期加减(YYYYMMDD),用于默认「最近 N 天」 */
|
|
|
|
|
+ function shiftYmd(ymd, days) {
|
|
|
|
|
+ const d = new Date(Date.UTC(Number(ymd.slice(0, 4)), Number(ymd.slice(4, 6)) - 1, Number(ymd.slice(6, 8)) + days));
|
|
|
|
|
+ return `${d.getUTCFullYear()}${String(d.getUTCMonth() + 1).padStart(2, '0')}${String(d.getUTCDate()).padStart(2, '0')}`;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function ymdToInput(ymd) {
|
|
function ymdToInput(ymd) {
|
|
|
const s = String(ymd || '');
|
|
const s = String(ymd || '');
|
|
|
return /^\d{8}$/.test(s) ? `${s.slice(0, 4)}-${s.slice(4, 6)}-${s.slice(6, 8)}` : '';
|
|
return /^\d{8}$/.test(s) ? `${s.slice(0, 4)}-${s.slice(4, 6)}-${s.slice(6, 8)}` : '';
|
|
@@ -87,8 +93,12 @@
|
|
|
const { body } = await api('/api/ops/summary');
|
|
const { body } = await api('/api/ops/summary');
|
|
|
state.summary = body || { enabled: false, reason: 'storage-unreachable' };
|
|
state.summary = body || { enabled: false, reason: 'storage-unreachable' };
|
|
|
if (state.summary.enabled && state.summary.coverage) {
|
|
if (state.summary.enabled && state.summary.coverage) {
|
|
|
- if (!state.from) state.from = state.summary.coverage.from;
|
|
|
|
|
|
|
+ // 默认只看最近 2 天;数据不足 2 天时从最早一天开始
|
|
|
if (!state.to) state.to = state.summary.coverage.to;
|
|
if (!state.to) state.to = state.summary.coverage.to;
|
|
|
|
|
+ if (!state.from) {
|
|
|
|
|
+ const recent = shiftYmd(state.to, -1);
|
|
|
|
|
+ state.from = recent < state.summary.coverage.from ? state.summary.coverage.from : recent;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return state.summary;
|
|
return state.summary;
|
|
|
}
|
|
}
|